File size: 7,863 Bytes
c875695
 
 
 
 
 
 
 
42a06f9
 
 
 
 
 
 
ee2b289
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b003de
ee2b289
 
 
 
 
 
 
 
 
2b003de
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ee2b289
 
 
 
 
 
 
 
 
 
 
 
 
2b003de
 
ee2b289
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b003de
 
 
ee2b289
 
2b003de
 
ee2b289
2b003de
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ee2b289
2b003de
 
ee2b289
 
2b003de
 
ee2b289
 
 
 
2b003de
ee2b289
 
 
 
2b003de
 
ee2b289
2b003de
 
 
ee2b289
2b003de
ee2b289
2b003de
 
 
 
ee2b289
 
2b003de
 
 
 
ee2b289
 
2b003de
 
 
 
 
 
 
 
 
 
ee2b289
 
 
 
2b003de
 
ee2b289
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b003de
 
 
ee2b289
 
 
42a06f9
ee2b289
 
 
2b003de
 
 
 
ee2b289
 
 
 
2b003de
 
 
ee2b289
 
2b003de
 
 
 
ee2b289
 
2b003de
 
 
ee2b289
 
 
 
2b003de
42a06f9
 
 
 
f6902d8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
import subprocess
import sys

try:
    from flask import Flask, render_template_string
except ImportError:
    subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'flask'])
    from flask import Flask, render_template_string

app = Flask(__name__)

@app.route('/')
def home():
    html_content = '''
    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Binaural Beats and Bindu Tratak</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background: black;
            color: white;
            font-family: Arial, sans-serif;
            overflow: hidden;
        }

        .container {
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
        }

        .dot {
            width: 20px;
            height: 20px;
            background-color: #ff0000;
            border-radius: 50%;
            margin: 20px 0;
        }

        .instructions {
            position: absolute;
            top: 10%;
            color: white;
            font-size: 1.2rem;
            background: rgba(0, 0, 0, 0.7);
            padding: 10px 15px;
            border-radius: 5px;
            text-align: center;
        }

        .instructions.hidden {
            display: none;
        }

        .controls-panel {
            position: absolute;
            right: 20px;
            top: 20px;
            background: rgba(0, 0, 0, 0.7);
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
            backdrop-filter: blur(10px);
            display: none;
            flex-direction: column;
            max-height: 80vh;
            overflow-y: auto;
        }

        .controls-panel.visible {
            display: flex;
        }

        .controls-panel input, .controls-panel button, .controls-panel select {
            margin: 10px 0;
            padding: 10px;
            border: none;
            border-radius: 5px;
        }

        .controls-panel label {
            margin-top: 10px;
        }

        .toggle-controls {
            position: absolute;
            top: 20px;
            left: 20px;
            background: #ffffff30;
            color: white;
            border: none;
            padding: 10px 15px;
            border-radius: 5px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="instructions" id="instructions">
            Focus on the bindu (dot) for meditation and relaxation.  
            Adjust frequencies and bindu settings using the controls.
        </div>

        <div class="dot" id="bindu"></div>
    </div>

    <div class="controls-panel" id="controls-panel">
        <label for="left-frequency">Left Ear Frequency:</label>
        <input type="range" id="left-frequency" min="20" max="2000" value="440">

        <label for="right-frequency">Right Ear Frequency:</label>
        <input type="range" id="right-frequency" min="20" max="2000" value="446">

        <label for="dot-size">Bindu Size:</label>
        <input type="range" id="dot-size" min="10" max="100" value="20">

        <label for="presets">Quick Presets:</label>
        <select id="presets">
            <option value="440-446">Focus (440Hz - 446Hz)</option>
            <option value="100-106">Relaxation (100Hz - 106Hz)</option>
            <option value="20-26">Deep Sleep (20Hz - 26Hz)</option>
            <option value="528-534">Healing (528Hz - 534Hz)</option>
        </select>

        <button id="apply-preset">Apply Preset</button>
        <button id="play-music">Play Music</button>
    </div>

    <button class="toggle-controls" id="toggle-controls">Show Controls</button>

    <script>
        const playMusicButton = document.getElementById('play-music');
        const leftFrequencyInput = document.getElementById('left-frequency');
        const rightFrequencyInput = document.getElementById('right-frequency');
        const dotSizeInput = document.getElementById('dot-size');
        const presets = document.getElementById('presets');
        const applyPresetButton = document.getElementById('apply-preset');
        const controlsPanel = document.getElementById('controls-panel');
        const toggleControlsButton = document.getElementById('toggle-controls');
        const instructions = document.getElementById('instructions');
        const bindu = document.getElementById('bindu');

        let audioContext = null;
        let leftOscillator = null;
        let rightOscillator = null;
        let isPlaying = false;
        let instructionsTimeout;

        function hideInstructions() {
            instructionsTimeout = setTimeout(() => {
                instructions.classList.add('hidden');
            }, 5000);
        }

        function showInstructions() {
            clearTimeout(instructionsTimeout);
            instructions.classList.remove('hidden');
            hideInstructions();
        }

        function stopMusic() {
            if (audioContext) {
                audioContext.close();
                audioContext = null;
                leftOscillator = null;
                rightOscillator = null;
                isPlaying = false;
                playMusicButton.textContent = 'Play Music';
            }
        }

        function setupBinauralBeats(leftFreq, rightFreq) {
            audioContext = new (window.AudioContext || window.webkitAudioContext)();

            leftOscillator = audioContext.createOscillator();
            rightOscillator = audioContext.createOscillator();
            const leftGain = audioContext.createGain();
            const rightGain = audioContext.createGain();

            leftOscillator.frequency.value = leftFreq;
            rightOscillator.frequency.value = rightFreq;

            leftGain.gain.value = 0.5;
            rightGain.gain.value = 0.5;

            leftOscillator.connect(leftGain).connect(audioContext.destination);
            rightOscillator.connect(rightGain).connect(audioContext.destination);

            leftOscillator.start();
            rightOscillator.start();
        }

        playMusicButton.addEventListener('click', () => {
            if (isPlaying) {
                stopMusic();
            } else {
                setupBinauralBeats(leftFrequencyInput.value, rightFrequencyInput.value);
                playMusicButton.textContent = 'Stop Music';
                isPlaying = true;
            }
        });

        applyPresetButton.addEventListener('click', () => {
            const [left, right] = presets.value.split('-').map(Number);
            leftFrequencyInput.value = left;
            rightFrequencyInput.value = right;
            stopMusic(); // Stop music when a new preset is applied
        });

        toggleControlsButton.addEventListener('click', () => {
            controlsPanel.classList.toggle('visible');
            toggleControlsButton.textContent = controlsPanel.classList.contains('visible')
                ? 'Hide Controls'
                : 'Show Controls';
        });

        dotSizeInput.addEventListener('input', (e) => {
            const newSize = e.target.value + 'px';
            bindu.style.width = newSize;
            bindu.style.height = newSize;
        });

        document.addEventListener('mousemove', showInstructions);

        hideInstructions(); // Initial call to hide instructions after delay
    </script>
</body>
</html>


    '''
    return render_template_string(html_content)

if __name__ == '__main__':
    app.run(debug=True,host='0.0.0.0', port=7860)