-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
405 lines (369 loc) · 17.4 KB
/
index.html
File metadata and controls
405 lines (369 loc) · 17.4 KB
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced Audio-Visual Stimulation Tool</title>
<style>
body { font-family: Arial, sans-serif; margin: 0; padding: 20px; background-color: #f0f0f0; }
#intro, #warning { background-color: #ffcccc; border: 2px solid #ff0000; padding: 20px; margin-bottom: 20px; }
#mainContent { max-width: 800px; margin: 0 auto; }
#controls { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 20px; }
#stimulationArea { width: 100%; height: 400px; position: relative; overflow: hidden; margin-bottom: 20px; }
#flashArea, #ballArea { width: 100%; height: 100%; position: absolute; }
#ball { width: 20px; height: 20px; border-radius: 50%; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
#status, #ballFreqIndicator, #audioSpeedIndicator, #timer { margin-bottom: 10px; font-weight: bold; }
button { padding: 10px; margin: 5px; cursor: pointer; }
input, select { margin-top: 5px; }
@media (max-width: 600px) { #controls { grid-template-columns: 1fr; } }
</style>
</head>
<body>
<div id="intro">
<h2>Benefits of 34-38 Hz Stimulation</h2>
<p>Recent research suggests that 34-38 Hz stimulation may be more effective than 40 Hz for entraining gamma waves, potentially benefiting cognitive function and Alzheimer's treatment. This frequency range has shown promise in enhancing neural synchronization, information routing, and cortical communication.
Clinical Applications
Research has demonstrated promising results for several applications:
Alzheimer's Disease (AD):
Cognitive improvement in patients with mild AD.
Reduced brain atrophy in AD patients.
Improved functional connectivity in the brains of AD patients.
General Cognitive Benefits:
Potential improvements in sleep quality.
Possible positive effects on mood.
Indications of enhanced memory function.
Gamma wave states, particularly around 40 Hz, are associated with expert-level meditation and may assist in reshaping brain structures.
</p>
</div>
<div id="warning">
<h2>Warning: Non-Medical Use Only</h2>
<p>This tool is for experimental and recreational purposes only. It is not a medical device and should not be used to diagnose, treat, cure, or prevent any disease. If you have a history of epilepsy or seizures, do not use this tool. Consult a healthcare professional before use. Gamma stimulation has been shown to be generally safe and well-tolerated:
Clinical trials have reported no severe adverse effects.
The stimulation does not trigger epileptiform activity, even in epilepsy patients.
However, it's important to note that more research is needed to fully establish long-term safety profiles.</p>
<p>For a better experience, please use headphones. Bilateral stimulation is particularly beneficial for trauma recovery.</p>
<p>Based on the provided research, we recommend using heterochromatic red and blue light at 400 cd/m² intensity, a flickering frequency of 34-38 Hz, and a stimulation period of 1 hour daily for a week. </br> </br>
Research: </br>https://doi.org/10.1038/s41598-024-52679-z
</br>
https://doi.org/10.1038/s41598-021-95550-1
</p>
<button id="acceptWarning">I Understand</button>
</div>
<div id="mainContent" style="display:none;">
<h1>Advanced Audio-Visual Stimulation Tool</h1>
<div id="stimulationArea">
<div id="flashArea" style="background-color: #0000FF;"></div>
<div id="ballArea">
<div id="ball" style="background-color: black;"></div>
</div>
</div>
<div id="status">Status: Stopped</div>
<div id="timer">Time Remaining: 0:00</div>
<div id="ballFreqIndicator">Ball Frequency: 0 Hz</div>
<div id="audioSpeedIndicator">Audio Movement Speed: 0 Hz</div>
<div id="controls">
<button id="switch" style="display: flex; justify-content: center; align-items: center;">Start/Stop</button>
<button id="fullscreenBtn">Fullscreen</button>
<div>
<label for="visualType">Visual Stimulation:</label>
<select id="visualType">
<option value="flashing">Flashing</option>
<option value="bilateral">Bilateral</option>
<option value="combined">Combined</option>
</select>
</div>
<div>
<label for="audioType">Audio Stimulation:</label>
<select id="audioType">
<option value="pureTone">Pure Tone</option>
<option value="bilateral">Bilateral</option>
<option value="binaural">Binaural Beats</option>
<option value="combined">Combined</option>
</select>
</div>
<div>
<label for="visualFreq">Visual Frequency (Hz):</label>
<input type="number" id="visualFreq" min="1" max="100" step="0.1" value="36">
</div>
<div>
<label for="audioFreq">Audio Frequency (Hz):</label>
<input type="number" id="audioFreq" min="20" max="20000" step="1" value="36">
</div>
<div>
<label for="leftFreq">Left Frequency (Hz):</label>
<input type="number" id="leftFreq" min="20" max="20000" step="1" value="240">
</div>
<div>
<label for="rightFreq">Right Frequency (Hz):</label>
<input type="number" id="rightFreq" min="20" max="20000" step="1" value="200">
</div>
<div>
<label for="duration">Duration (minutes):</label>
<input type="number" id="duration" min="1" max="120" value="60">
</div>
<div>
<label for="audioSpeed">Audio Movement Speed (Hz):</label>
<input type="number" id="audioSpeed" min="0.1" max="10" step="0.1" value="0.5">
</div>
<div>
<label for="ballSpeed">Ball Movement Speed (Hz):</label>
<input type="range" id="ballSpeed" min="0.1" max="10" step="0.1" value="0.5">
</div>
<div>
<label for="bgColor">Background Color:</label>
<input type="color" id="bgColor" value="#0000FF">
</div>
<div>
<label for="flashColor">Flash Color:</label>
<input type="color" id="flashColor" value="#FF0000">
</div>
<div>
<label for="ballColor">Ball Color:</label>
<input type="color" id="ballColor" value="black">
</div>
<div>
</div>
</div>
</div>
<script> </script>
</body>
</html>
<script>
let audioContext, leftOscillator, rightOscillator, leftGain, rightGain, stereoPanner;
let isRunning = false, ballPosition = 0, ballDirection = 1;
let animationFrameId, audioIntervalId, flashIntervalId, timerIntervalId;
let remainingTime = 0;
document.getElementById('acceptWarning').addEventListener('click', () => {
document.getElementById('intro').style.display = 'none';
document.getElementById('warning').style.display = 'none';
document.getElementById('mainContent').style.display = 'block';
});
document.getElementById('switch').addEventListener('click', () => {
if (isRunning) {
stopStimulation();
} else {
startStimulation();
}
});
document.addEventListener('keydown', (e) => {
if (e.key === ' ') {
if (isRunning) {
stopStimulation();
} else {
startStimulation();
}
}
});
document.addEventListener('fullscreenchange', () => {
if (!document.fullscreenElement) {
document.getElementById('stimulationArea').style.width = '';
document.getElementById('stimulationArea').style.height = '';
}
});
document.getElementById('fullscreenBtn').addEventListener('click', function() {
const stimulationArea = document.getElementById('stimulationArea');
if (stimulationArea.requestFullscreen) {
stimulationArea.requestFullscreen();
} else if (stimulationArea.mozRequestFullScreen) {
stimulationArea.mozRequestFullScreen();
} else if (stimulationArea.webkitRequestFullscreen) {
stimulationArea.webkitRequestFullscreen();
} else if (stimulationArea.msRequestFullscreen) {
stimulationArea.msRequestFullscreen();
} else if (stimulationArea.webkitEnterFullscreen) { // For iOS Safari
stimulationArea.webkitEnterFullscreen();
}
document.addEventListener('keydown', (e) => {
if (e.key === ' ') {
if (isRunning) {
stopStimulation();
} else {
startStimulation();
}
}
});
});
['visualFreq', 'audioFreq', 'leftFreq', 'rightFreq', 'audioSpeed'].forEach(id => {
document.getElementById(id).addEventListener('input', updateStimulation);
});
function startStimulation() {
if (isRunning) return;
isRunning = true;
if (!audioContext) audioContext = new (window.AudioContext || window.webkitAudioContext)();
remainingTime = document.getElementById('duration').value * 60;
updateTimer();
timerIntervalId = setInterval(updateTimer, 1000);
initializeAudio();
updateStimulation();
document.getElementById('status').textContent = 'Status: Running';
}
function initializeAudio() {
leftOscillator = audioContext.createOscillator();
rightOscillator = audioContext.createOscillator();
leftGain = audioContext.createGain();
rightGain = audioContext.createGain();
stereoPanner = audioContext.createStereoPanner();
leftOscillator.connect(leftGain);
rightOscillator.connect(rightGain);
leftGain.connect(stereoPanner);
rightGain.connect(stereoPanner);
stereoPanner.connect(audioContext.destination);
leftOscillator.start();
rightOscillator.start();
}
function updateStimulation() {
if (!isRunning) return;
const visualType = document.getElementById('visualType').value;
const audioType = document.getElementById('audioType').value;
const visualFreq = clamp(parseFloat(document.getElementById('visualFreq').value), 1, 100);
const audioFreq = clamp(parseFloat(document.getElementById('audioFreq').value), 20, 20000);
const leftFreq = clamp(parseFloat(document.getElementById('leftFreq').value), 20, 20000);
const rightFreq = clamp(parseFloat(document.getElementById('rightFreq').value), 20, 20000);
const audioSpeed = clamp(parseFloat(document.getElementById('audioSpeed').value), 0.1, 10);
const ballSpeed = clamp(parseFloat(document.getElementById('ballSpeed').value), 0.1, 10);
const bgColor = document.getElementById('bgColor').value;
const flashColor = document.getElementById('flashColor').value;
const ballColor = document.getElementById('ballColor').value;
document.getElementById('stimulationArea').style.backgroundColor = bgColor;
document.getElementById('ball').style.backgroundColor = ballColor;
if (visualType === 'flashing' || visualType === 'combined') {
updateFlashing(visualFreq, flashColor, 50);
}
if (visualType === 'bilateral' || visualType === 'combined') {
updateBilateralVisual(ballSpeed);
}
updateAudio(audioType, audioFreq, audioSpeed, leftFreq, rightFreq);
}
function clamp(value, min, max) {
return Math.min(Math.max(value, min), max);
}
function hexToRGBA(hex, opacity) {
const r = parseInt(hex.slice(1, 3), 16);
const g = parseInt(hex.slice(3, 5), 16);
const b = parseInt(hex.slice(5, 7), 16);
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
}
function updateFlashing(frequency, color, dutyDivision) {
clearInterval(flashIntervalId);
const flashArea = document.getElementById('flashArea');
flashArea.style.backgroundColor = color;
const cycleDuration = 1000 / frequency;
const onDuration = cycleDuration * (dutyDivision / 100);
const offDuration = cycleDuration - onDuration;
flashIntervalId = setInterval(() => {
flashArea.style.backgroundColor = 'transparent';
setTimeout(() => {
flashArea.style.backgroundColor = color;
}, onDuration);
}, cycleDuration);
}
function updateBilateralVisual(speed) {
cancelAnimationFrame(animationFrameId);
const ball = document.getElementById('ball');
const ballArea = document.getElementById('ballArea');
function animateBall() {
if (!isRunning) return;
const maxX = ballArea.clientWidth - ball.clientWidth;
ballPosition += speed * ballDirection * 5;
if (ballPosition > maxX) {
ballPosition = maxX;
ballDirection = -1;
} else if (ballPosition < 0) {
ballPosition = 0;
ballDirection = 1;
}
ball.style.left = `${ballPosition}px`;
document.getElementById('ballFreqIndicator').textContent = `Ball Frequency: ${speed.toFixed(2)} Hz`;
animationFrameId = requestAnimationFrame(animateBall);
}
animateBall();
}
function updateAudio(type, frequency, speed, leftFreq, rightFreq) {
if (!isRunning) return;
if (type === 'bilateral' || type === 'combined') {
// Bilateral or combined stimulation, set the same frequency in both ears
leftOscillator.frequency.setValueAtTime(leftFreq, audioContext.currentTime);
rightOscillator.frequency.setValueAtTime(rightFreq, audioContext.currentTime);
} else if (type === 'binaural') {
// Calculate the binaural beat as the difference between the left and right frequencies
const binauralBeat = Math.abs(leftFreq - rightFreq);
const baseFrequency = Math.min(leftFreq, rightFreq);
// Set one oscillator at the base frequency, and the other one offset by the binaural beat difference
leftOscillator.frequency.setValueAtTime(baseFrequency, audioContext.currentTime);
rightOscillator.frequency.setValueAtTime(baseFrequency + binauralBeat, audioContext.currentTime);
console.log(`Binaural Beat: ${binauralBeat} Hz | Left Frequency: ${baseFrequency} Hz | Right Frequency: ${baseFrequency + binauralBeat} Hz`);
} else {
// For pure tone or other modes, set the same frequency in both ears
leftOscillator.frequency.setValueAtTime(frequency, audioContext.currentTime);
rightOscillator.frequency.setValueAtTime(frequency, audioContext.currentTime);
}
// For bilateral and combined modes, implement panning for spatial audio movement
if (type === 'bilateral' || type === 'combined') {
let panPosition = -1;
audioIntervalId = setInterval(() => {
panPosition *= -1;
stereoPanner.pan.setValueAtTime(panPosition, audioContext.currentTime);
if (type === 'combined') {
const leftVolume = (panPosition + 1) / 2;
const rightVolume = 1 - leftVolume;
leftGain.gain.setValueAtTime(leftVolume, audioContext.currentTime);
rightGain.gain.setValueAtTime(rightVolume, audioContext.currentTime);
// Adjust oscillator frequencies to match panning volumes
leftOscillator.frequency.setValueAtTime(baseFrequency * leftVolume, audioContext.currentTime);
rightOscillator.frequency.setValueAtTime(baseFrequency * rightVolume, audioContext.currentTime);
}
}, 1000 / (2 * speed));
}
document.getElementById('audioSpeedIndicator').textContent = `Audio Movement Speed: ${speed.toFixed(2)} Hz`;
}
function fadeOutAudio() {
if (leftOscillator) {
leftOscillator.stop();
rightOscillator.stop();
}
clearInterval(audioIntervalId);
const fadeOutDuration = 1000;
const fadeOutIntervalId = setInterval(() => {
const fadeOutValue = Math.max(0, 1 - (audioContext.currentTime / fadeOutDuration));
leftGain.gain.setValueAtTime(fadeOutValue, audioContext.currentTime);
rightGain.gain.setValueAtTime(fadeOutValue, audioContext.currentTime);
if (fadeOutValue === 0) {
clearInterval(fadeOutIntervalId);
}
}, 16);
}
function updateAudioInternal(type, frequency, speed, leftFreq, rightFreq) {
fadeOutAudio();
setTimeout(() => {
updateAudio(type, frequency, speed, leftFreq, rightFreq);
}, 1000);
}
function stopStimulation(updateStatus = true) {
isRunning = false;
cancelAnimationFrame(animationFrameId);
clearInterval(audioIntervalId);
clearInterval(flashIntervalId);
clearInterval(timerIntervalId);
document.getElementById('flashArea').style.backgroundColor = 'transparent';
if (leftOscillator) {
leftOscillator.stop();
rightOscillator.stop();
}
if (updateStatus) {
document.getElementById('status').textContent = 'Status: Stopped';
}
}
function updateTimer() {
if (remainingTime <= 0) {
stopStimulation();
return;
}
const minutes = Math.floor(remainingTime / 60);
const seconds = remainingTime % 60;
document.getElementById('timer').textContent = `Time Remaining: ${minutes}:${seconds.toString().padStart(2, '0')}`;
remainingTime--;
}
if (!(window.AudioContext || window.webkitAudioContext)) {
alert("Web Audio API is not supported in this browser. The audio features may not work.");
}
</script>