-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMischiefMaker.html
451 lines (396 loc) · 16 KB
/
MischiefMaker.html
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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stop It Please Disorientation Generator</title>
<style>
body {
font-family: 'Arial', sans-serif;
background-color: #1a1a2e;
color: #e0e0e0;
margin: 0;
padding: 20px;
line-height: 1.3;
}
.container {
max-width: 600px;
margin: 0 auto;
background-color: #16213e;
padding: 10px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
h1 {
text-align: center;
color: #0f3460;
background-color: #e94560;
padding: 5px;
border-radius: 5px;
margin-bottom: 10px;
}
.control-group {
background-color: #0f3460;
border-radius: 8px;
padding: 15px;
margin-bottom: 20px;
}
.slider-container {
display: flex;
align-items: center;
margin-bottom: 15px;
}
.slider-container label {
flex: 1;
margin-right: 15px;
color: #e94560;
}
.slider-container input[type="range"] {
flex: 2;
accent-color: #e94560;
}
.slider-container span {
flex: 0.5;
color: #e0e0e0;
margin-left: 10px;
}
button {
background-color: #e94560;
color: white;
border: none;
padding: 10px 15px;
margin: 5px;
border-radius: 5px;
cursor: pointer;
transition: all 0.3s ease;
}
button:hover {
background-color: #ff6b81;
transform: scale(1.05);
}
button:active {
transform: scale(0.95);
}
#visualizer {
width: 100%;
height: 150px;
background-color: #0f3460;
margin-top: 20px;
border-radius: 8px;
}
.button-group {
display: flex;
flex-wrap: wrap;
gap: 5px;
justify-content: center;
}
</style>
</head>
<body>
<div class="container">
<h1>Advanced Ear Wrestler And Disorientation Generator</h1>
<div class="control-group button-group">
<button id="playButton">Start Tone</button>
<button id="stopButton">Stop Tone</button>
<button id="autoToggleButton">Auto Morph</button>
</div>
<div class="control-group">
<h2>Sine Wave Controls</h2>
<div class="slider-container">
<label for="frequencySlider">Frequency (Hz)</label>
<input type="range" id="frequencySlider" min="-4000" max="20000" step="1" value="12000">
<span id="frequencyValue">12000</span> Hz
</div>
<div class="slider-container">
<label for="detuneSlider">Detune (Cents)</label>
<input type="range" id="detuneSlider" min="-100" max="1000" step="1" value="0">
<span id="detuneValue">0</span> cents
</div>
<div class="slider-container">
<label for="modulationFreqSlider">Modulation Frequency (Hz)</label>
<input type="range" id="modulationFreqSlider" min="-2000" max="20000" step="0.1" value="20">
<span id="modulationFreqValue">20</span> Hz
</div>
<div class="slider-container">
<label for="modulationDepthSlider">Modulation Depth</label>
<input type="range" id="modulationDepthSlider" min="0" max="500" step="0.01" value="0.75">
<span id="modulationDepthValue">0.75</span>
</div>
</div>
<div class="control-group">
<h2>Annoyance Intensity</h2>
<div class="slider-container">
<label for="volumeSlider">Volume</label>
<input type="range" id="volumeSlider" min="0" max="1" step="0.01" value="0.75">
<span id="volumeValue">0.75</span>
</div>
<div class="slider-container">
<label for="gainSlider">Gain Intensity</label>
<input type="range" id="gainSlider" min="-2" max="50" step="0.01" value="1">
<span id="gainValue">1</span>
</div>
</div>
<div class="control-group">
<h2>Preset Annoying Tones</h2>
<div class="button-group">
<button id="annoyingTone1">Disorienting Low</button>
<button id="annoyingTone2">Piercing High</button>
<button id="annoyingTone3">Aggressive Mid</button>
<button id="annoyingTone4">Ultrasonic Edge</button>
<button id="highPitchTone1">Extreme High 1</button>
<button id="highPitchTone2">Extreme High 2</button>
<button id="dogTone">Dog Goes Mad</button>
<button id="detuneRandomButton">Random Detune</button>
<button id="startButton">Evasive Sound Mode</button>
<button id="evasiveBtn">Evasive Mode</button>
</div>
</div>
<canvas id="visualizer"></canvas>
</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
// Audio context setup
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
// DOM Element Selections
const elements = {
frequencySlider: document.getElementById('frequencySlider'),
detuneSlider: document.getElementById('detuneSlider'),
modulationFreqSlider: document.getElementById('modulationFreqSlider'),
modulationDepthSlider: document.getElementById('modulationDepthSlider'),
volumeSlider: document.getElementById('volumeSlider'),
gainSlider: document.getElementById('gainSlider'),
frequencyValue: document.getElementById('frequencyValue'),
detuneValue: document.getElementById('detuneValue'),
modulationFreqValue: document.getElementById('modulationFreqValue'),
modulationDepthValue: document.getElementById('modulationDepthValue'),
volumeValue: document.getElementById('volumeValue'),
gainValue: document.getElementById('gainValue'),
playButton: document.getElementById('playButton'),
stopButton: document.getElementById('stopButton'),
autoToggleButton: document.getElementById('autoToggleButton'),
evasiveBtn: document.getElementById('evasiveBtn'),
canvas: document.getElementById('visualizer'),
annoyingTones: {
tone1: document.getElementById('annoyingTone1'),
tone2: document.getElementById('annoyingTone2'),
tone3: document.getElementById('annoyingTone3'),
tone4: document.getElementById('annoyingTone4'),
highPitch1: document.getElementById('highPitchTone1'),
highPitch2: document.getElementById('highPitchTone2'),
dogTone: document.getElementById('dogTone'),
detuneRandom: document.getElementById('detuneRandomButton')
}
};
// Audio Nodes
let audioNodes = {
oscillator: null,
gainNode: null,
modulationOscillator: null,
modulationGainNode: null,
analyser: null
};
// Visualization Context
const ctx = elements.canvas.getContext('2d');
ctx.canvas.width = elements.canvas.offsetWidth;
ctx.canvas.height = elements.canvas.offsetHeight;
// Audio State
let state = {
isPlaying: false,
isAutoToggle: false,
autoToggleInterval: null,
evasiveInterval: null
};
function setupAudioNodes() {
// Safely stop and disconnect existing nodes
if (audioNodes.oscillator) {
audioNodes.oscillator.stop();
audioNodes.oscillator.disconnect();
}
if (audioNodes.modulationOscillator) {
audioNodes.modulationOscillator.stop();
audioNodes.modulationOscillator.disconnect();
}
// Create new audio nodes
audioNodes.oscillator = audioContext.createOscillator();
audioNodes.gainNode = audioContext.createGain();
audioNodes.modulationOscillator = audioContext.createOscillator();
audioNodes.modulationGainNode = audioContext.createGain();
audioNodes.analyser = audioContext.createAnalyser();
// Node connections
audioNodes.oscillator.connect(audioNodes.gainNode);
audioNodes.gainNode.connect(audioNodes.analyser);
audioNodes.analyser.connect(audioContext.destination);
audioNodes.modulationOscillator.connect(audioNodes.modulationGainNode);
audioNodes.modulationGainNode.connect(audioNodes.gainNode.gain);
// Start oscillators
audioNodes.oscillator.start();
audioNodes.modulationOscillator.start();
state.isPlaying = true;
}
function updateSound() {
if (!state.isPlaying) return;
const frequency = parseFloat(elements.frequencySlider.value);
const detune = parseFloat(elements.detuneSlider.value);
const modulationFreq = parseFloat(elements.modulationFreqSlider.value);
const modulationDepth = parseFloat(elements.modulationDepthSlider.value);
const volume = parseFloat(elements.volumeSlider.value);
const gain = parseFloat(elements.gainSlider.value);
// Update oscillator parameters
audioNodes.oscillator.frequency.setValueAtTime(frequency, audioContext.currentTime);
audioNodes.oscillator.detune.setValueAtTime(detune, audioContext.currentTime);
audioNodes.modulationOscillator.frequency.setValueAtTime(modulationFreq, audioContext.currentTime);
audioNodes.modulationGainNode.gain.setValueAtTime(modulationDepth, audioContext.currentTime);
audioNodes.gainNode.gain.setValueAtTime(volume * gain, audioContext.currentTime);
// Update UI values
elements.frequencyValue.textContent = frequency;
elements.detuneValue.textContent = detune;
elements.modulationFreqValue.textContent = modulationFreq;
elements.modulationDepthValue.textContent = modulationDepth.toFixed(2);
elements.volumeValue.textContent = volume.toFixed(2);
elements.gainValue.textContent = gain.toFixed(2);
visualizeSound();
}
function visualizeSound() {
const analyser = audioNodes.analyser;
analyser.fftSize = 256;
const bufferLength = analyser.frequencyBinCount;
const dataArray = new Uint8Array(bufferLength);
requestAnimationFrame(visualizeSound);
analyser.getByteFrequencyData(dataArray);
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
const barWidth = (ctx.canvas.width / bufferLength) * 2.5;
let x = 0;
for(let i = 0; i < bufferLength; i++) {
const barHeight = dataArray[i] / 2;
ctx.fillStyle = `hsl(${i * 360 / bufferLength}, 70%, 50%)`;
ctx.fillRect(x, ctx.canvas.height - barHeight, barWidth, barHeight);
x += barWidth + 1;
}
}
// Event Listeners
function addSliderListeners() {
[
'frequencySlider',
'detuneSlider',
'modulationFreqSlider',
'modulationDepthSlider',
'volumeSlider',
'gainSlider'
].forEach(sliderId => {
elements[sliderId].addEventListener('input', updateSound);
});
}
addSliderListeners();
elements.playButton.addEventListener('click', () => {
if (!state.isPlaying) {
setupAudioNodes();
updateSound();
}
});
elements.stopButton.addEventListener('click', () => {
if (state.isPlaying) {
state.isPlaying = false;
audioNodes.oscillator.stop();
audioNodes.modulationOscillator.stop();
audioNodes.gainNode.disconnect();
audioNodes.analyser.disconnect();
}
});
// Auto Toggle (Morphing Tone)
elements.autoToggleButton.addEventListener('click', () => {
state.isAutoToggle = !state.isAutoToggle;
if (state.isAutoToggle) {
elements.autoToggleButton.textContent = 'Stop Auto Morph';
state.autoToggleInterval = setInterval(() => {
elements.frequencySlider.value = Math.random() * (10000 - 10) + 10;
elements.detuneSlider.value = Math.random() * (2000 - (-2000)) + (-2000);
updateSound();
}, 100);
} else {
elements.autoToggleButton.textContent = 'Start Auto Morph';
clearInterval(state.autoToggleInterval);
}
});
// Preset Annoying Tones
function setPresetTone(freq, detune, modFreq, modDepth, volume, gain) {
elements.frequencySlider.value = freq;
elements.detuneSlider.value = detune;
elements.modulationFreqSlider.value = modFreq;
elements.modulationDepthSlider.value = modDepth;
elements.volumeSlider.value = volume;
elements.gainSlider.value = gain;
updateSound();
}
elements.annoyingTones.tone1.addEventListener('click', () => {
setPresetTone(200, 500, 50, 0.8, 0.7, 1.5);
});
elements.annoyingTones.tone2.addEventListener('click', () => {
setPresetTone(10000, -2000, 100, 1, 0.8, 1);
});
elements.annoyingTones.tone3.addEventListener('click', () => {
setPresetTone(1000, 0, 20, 0.5, 0.8, 1);
});
elements.annoyingTones.tone4.addEventListener('click', () => {
setPresetTone(15000, 0, 25, 1.0, 0.5, 1);
});
elements.annoyingTones.highPitch1.addEventListener('click', () => {
setPresetTone(15000, 0, 30, 1.5, 0.8, 2);
});
elements.annoyingTones.highPitch2.addEventListener('click', () => {
setPresetTone(13000, 0, 30, 1.5, 0.9, 2);
});
elements.annoyingTones.dogTone.addEventListener('click', () => {
setPresetTone(12000, 0, 50, 0.6, 0.7, 1.4);
});
elements.annoyingTones.detuneRandom.addEventListener('click', () => {
elements.detuneSlider.value = Math.random() * (2000 - (-2000)) + (-2000);
updateSound();
});
// Evasive Mode Button
elements.evasiveBtn.addEventListener('click', () => {
evasiveMode();
});
// Evasive Mode Logic
function evasiveMode() {
stopOscillator();
initializeContext();
audioNodes.oscillator = audioContext.createOscillator();
audioNodes.gainNode = audioContext.createGain();
audioNodes.oscillator.connect(audioNodes.gainNode);
audioNodes.gainNode.connect(audioContext.destination);
audioNodes.oscillator.start();
const fade = (gainNode, target, duration) => {
const now = audioContext.currentTime;
gainNode.gain.cancelScheduledValues(now);
gainNode.gain.setValueAtTime(gainNode.gain.value, now);
gainNode.gain.linearRampToValueAtTime(target, now + duration);
};
const playBurst = () => {
const randomFrequency = Math.random() * 5000 + 8000;
audioNodes.oscillator.frequency.setValueAtTime(randomFrequency, audioContext.currentTime);
fade(audioNodes.gainNode, 0.5, 2);
setTimeout(() => fade(audioNodes.gainNode, 0, 2), 3000);
const randomDelay = Math.random() * (15 - 5) + 5;
state.evasiveInterval = setTimeout(playBurst, (7 + randomDelay) * 1000);
};
playBurst();
}
function stopOscillator() {
if (audioNodes.oscillator) {
audioNodes.oscillator.stop();
audioNodes.oscillator.disconnect();
}
}
function initializeContext() {
audioNodes = {
oscillator: null,
gainNode: null,
modulationOscillator: null,
modulationGainNode: null,
analyser: null
};
}
});
</script>
</body>
</html>