adnannovus commited on
Commit
7225968
·
verified ·
1 Parent(s): abf50da

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +308 -19
index.html CHANGED
@@ -1,19 +1,308 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Random Binaural Beat Generator</title>
7
+ <style>
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
13
+ }
14
+
15
+ body {
16
+ background: linear-gradient(45deg, #1a1a1a, #2d2d2d);
17
+ color: #fff;
18
+ min-height: 100vh;
19
+ display: flex;
20
+ flex-direction: column;
21
+ align-items: center;
22
+ padding: 2rem;
23
+ }
24
+
25
+ .container {
26
+ max-width: 800px;
27
+ width: 100%;
28
+ background: rgba(255, 255, 255, 0.1);
29
+ padding: 2rem;
30
+ border-radius: 15px;
31
+ backdrop-filter: blur(10px);
32
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
33
+ }
34
+
35
+ h1 {
36
+ text-align: center;
37
+ margin-bottom: 2rem;
38
+ color: #00ff88;
39
+ text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
40
+ }
41
+
42
+ .controls {
43
+ display: grid;
44
+ gap: 1.5rem;
45
+ margin-bottom: 2rem;
46
+ }
47
+
48
+ .control-group {
49
+ display: flex;
50
+ flex-direction: column;
51
+ gap: 0.5rem;
52
+ }
53
+
54
+ label {
55
+ font-size: 1.1rem;
56
+ color: #00ff88;
57
+ }
58
+
59
+ input[type="range"] {
60
+ width: 100%;
61
+ height: 10px;
62
+ background: rgba(255, 255, 255, 0.1);
63
+ border-radius: 5px;
64
+ outline: none;
65
+ -webkit-appearance: none;
66
+ }
67
+
68
+ input[type="range"]::-webkit-slider-thumb {
69
+ -webkit-appearance: none;
70
+ width: 20px;
71
+ height: 20px;
72
+ background: #00ff88;
73
+ border-radius: 50%;
74
+ cursor: pointer;
75
+ transition: background 0.3s;
76
+ }
77
+
78
+ .value-display {
79
+ font-size: 1.2rem;
80
+ color: #fff;
81
+ text-align: center;
82
+ }
83
+
84
+ .buttons {
85
+ display: flex;
86
+ gap: 1rem;
87
+ justify-content: center;
88
+ }
89
+
90
+ button {
91
+ padding: 1rem 2rem;
92
+ font-size: 1.1rem;
93
+ border: none;
94
+ border-radius: 5px;
95
+ background: #00ff88;
96
+ color: #1a1a1a;
97
+ cursor: pointer;
98
+ transition: all 0.3s;
99
+ }
100
+
101
+ button:hover {
102
+ background: #00cc6a;
103
+ transform: translateY(-2px);
104
+ }
105
+
106
+ .display {
107
+ margin-top: 2rem;
108
+ padding: 1rem;
109
+ background: rgba(0, 255, 136, 0.1);
110
+ border-radius: 10px;
111
+ text-align: center;
112
+ }
113
+
114
+ #currentFrequencies {
115
+ font-size: 1.5rem;
116
+ color: #00ff88;
117
+ margin: 1rem 0;
118
+ line-height: 1.6;
119
+ }
120
+
121
+ .wave-visualizer {
122
+ width: 100%;
123
+ height: 100px;
124
+ background: rgba(255, 255, 255, 0.05);
125
+ margin-top: 2rem;
126
+ border-radius: 5px;
127
+ overflow: hidden;
128
+ position: relative;
129
+ }
130
+
131
+ .wave {
132
+ position: absolute;
133
+ width: 100%;
134
+ height: 100%;
135
+ background: linear-gradient(180deg, transparent 0%, #00ff88 50%, transparent 100%);
136
+ opacity: 0.3;
137
+ animation: wave 2s infinite linear;
138
+ }
139
+
140
+ @keyframes wave {
141
+ 0% { transform: translateX(-100%) scaleY(0.5); }
142
+ 50% { transform: translateX(0%) scaleY(1); }
143
+ 100% { transform: translateX(100%) scaleY(0.5); }
144
+ }
145
+ </style>
146
+ </head>
147
+ <body>
148
+ <div class="container">
149
+ <h1>Random Binaural Beat Generator</h1>
150
+
151
+ <div class="controls">
152
+ <div class="control-group">
153
+ <label for="beatFrequency">Target Beat Frequency (Hz)</label>
154
+ <input type="range" id="beatFrequency" min="1" max="40" value="7.83">
155
+ <div class="value-display" id="beatFrequencyValue">7.83 Hz</div>
156
+ </div>
157
+
158
+ <div class="control-group">
159
+ <label for="interval">Interval Between Changes (ms)</label>
160
+ <input type="range" id="interval" min="100" max="2000" value="500">
161
+ <div class="value-display" id="intervalValue">500 ms</div>
162
+ </div>
163
+
164
+ <div class="control-group">
165
+ <label for="volume">Volume</label>
166
+ <input type="range" id="volume" min="0" max="1" step="0.1" value="0.5">
167
+ <div class="value-display" id="volumeValue">50%</div>
168
+ </div>
169
+ </div>
170
+
171
+ <div class="buttons">
172
+ <button id="startBtn">Start</button>
173
+ <button id="stopBtn">Stop</button>
174
+ </div>
175
+
176
+ <div class="display">
177
+ <p>Current Frequencies:</p>
178
+ <div id="currentFrequencies">
179
+ Left: 0 Hz<br>
180
+ Right: 0 Hz<br>
181
+ Beat: 0 Hz
182
+ </div>
183
+ </div>
184
+
185
+ <div class="wave-visualizer">
186
+ <div class="wave"></div>
187
+ </div>
188
+ </div>
189
+
190
+ <script>
191
+ let audioContext;
192
+ let oscillatorLeft;
193
+ let oscillatorRight;
194
+ let gainNode;
195
+ let isPlaying = false;
196
+ let intervalId;
197
+
198
+ const startBtn = document.getElementById('startBtn');
199
+ const stopBtn = document.getElementById('stopBtn');
200
+ const beatFrequencySlider = document.getElementById('beatFrequency');
201
+ const intervalSlider = document.getElementById('interval');
202
+ const volumeSlider = document.getElementById('volume');
203
+ const currentFrequenciesDisplay = document.getElementById('currentFrequencies');
204
+
205
+ function updateValueDisplays() {
206
+ document.getElementById('beatFrequencyValue').textContent = `${beatFrequencySlider.value} Hz`;
207
+ document.getElementById('intervalValue').textContent = `${intervalSlider.value} ms`;
208
+ document.getElementById('volumeValue').textContent = `${Math.round(volumeSlider.value * 100)}%`;
209
+ }
210
+
211
+ function getRandomBaseFrequency() {
212
+ // Random frequency between 100 and 400 Hz
213
+ return Math.random() * 300 + 100;
214
+ }
215
+
216
+ function initAudio() {
217
+ audioContext = new (window.AudioContext || window.webkitAudioContext)();
218
+ gainNode = audioContext.createGain();
219
+ gainNode.connect(audioContext.destination);
220
+
221
+ oscillatorLeft = audioContext.createOscillator();
222
+ oscillatorRight = audioContext.createOscillator();
223
+
224
+ const merger = audioContext.createChannelMerger(2);
225
+
226
+ oscillatorLeft.connect(merger, 0, 0);
227
+ oscillatorRight.connect(merger, 0, 1);
228
+ merger.connect(gainNode);
229
+
230
+ updateFrequencies();
231
+ updateVolume();
232
+ }
233
+
234
+ function updateFrequencies() {
235
+ const beatFreq = parseFloat(beatFrequencySlider.value);
236
+ const baseFreq = getRandomBaseFrequency();
237
+
238
+ // Ensure both frequencies create the desired beat frequency
239
+ const leftFreq = baseFreq;
240
+ const rightFreq = baseFreq + beatFreq;
241
+
242
+ oscillatorLeft.frequency.setValueAtTime(leftFreq, audioContext.currentTime);
243
+ oscillatorRight.frequency.setValueAtTime(rightFreq, audioContext.currentTime);
244
+
245
+ currentFrequenciesDisplay.innerHTML = `
246
+ Left: ${leftFreq.toFixed(2)} Hz<br>
247
+ Right: ${rightFreq.toFixed(2)} Hz<br>
248
+ Beat: ${beatFreq.toFixed(2)} Hz
249
+ `;
250
+ }
251
+
252
+ function updateVolume() {
253
+ gainNode.gain.setValueAtTime(volumeSlider.value, audioContext.currentTime);
254
+ }
255
+
256
+ function startRandomization() {
257
+ intervalId = setInterval(() => {
258
+ updateFrequencies();
259
+ }, parseFloat(intervalSlider.value));
260
+ }
261
+
262
+ startBtn.addEventListener('click', () => {
263
+ if (!isPlaying) {
264
+ initAudio();
265
+ oscillatorLeft.start();
266
+ oscillatorRight.start();
267
+ startRandomization();
268
+ isPlaying = true;
269
+ }
270
+ });
271
+
272
+ stopBtn.addEventListener('click', () => {
273
+ if (isPlaying) {
274
+ clearInterval(intervalId);
275
+ oscillatorLeft.stop();
276
+ oscillatorRight.stop();
277
+ audioContext.close();
278
+ isPlaying = false;
279
+ currentFrequenciesDisplay.innerHTML = `
280
+ Left: 0 Hz<br>
281
+ Right: 0 Hz<br>
282
+ Beat: 0 Hz
283
+ `;
284
+ }
285
+ });
286
+
287
+ beatFrequencySlider.addEventListener('input', () => {
288
+ updateValueDisplays();
289
+ if (isPlaying) updateFrequencies();
290
+ });
291
+
292
+ intervalSlider.addEventListener('input', () => {
293
+ updateValueDisplays();
294
+ if (isPlaying) {
295
+ clearInterval(intervalId);
296
+ startRandomization();
297
+ }
298
+ });
299
+
300
+ volumeSlider.addEventListener('input', () => {
301
+ updateValueDisplays();
302
+ if (isPlaying) updateVolume();
303
+ });
304
+
305
+ updateValueDisplays();
306
+ </script>
307
+ </body>
308
+ </html>