-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqhtml.html
100 lines (94 loc) · 3.65 KB
/
qhtml.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Virtual Quantum Flute</title>
<style>
body {
font-family: 'Times New Roman', serif;
background-color: #ffffff;
color: #000000;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
padding: 10px;
}
#quantum-output {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(20px, auto));
gap: 2px;
font-family: monospace;
font-size: 14px;
margin-top: 20px;
max-width: 90%;
padding: 10px;
border: 1px solid #000000;
overflow: auto;
max-height: 80vh;
}
.state-0 { color: blue; }
.state-1 { color: green; }
.state-2 { color: red; }
#controls input[type="range"] {
width: 50%;
}
</style>
</head>
<body>
<div id="controls">
<button onclick="startQuantumFlute()">Play Quantum Flute</button>
<input type="range" min="0.5" max="1.5" step="0.01" value="1" oninput="updateModulation(this.value)" role="slider" aria-label="Modulation Factor" />
</div>
<div id="quantum-output"></div>
<script>
(function() {
if (!window.AudioContext && !window.webkitAudioContext) {
alert('Your browser does not support the Web Audio API');
return;
}
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
const gainNode = audioContext.createGain();
let quantumLoop;
let modulationFactor = 1;
let quantumStates = [];
window.startQuantumFlute = function() {
gainNode.connect(audioContext.destination);
clearInterval(quantumLoop);
quantumLoop = setInterval(runQuantumEmulation, 200);
}
function runQuantumEmulation() {
if (quantumStates.length >= 4000) {
quantumStates.shift(); // Remove the oldest state
}
quantumStates.push(Math.floor(Math.random() * 3));
displayQuantumOutput();
playQuantumSound(quantumStates[quantumStates.length - 1]);
}
function displayQuantumOutput() {
const outputElement = document.getElementById('quantum-output');
outputElement.innerHTML = quantumStates.map(state => {
const className = `state-${state}`;
return `<span class="${className}">${state === 0 ? '1' : state === 1 ? '2' : '0'}</span>`;
}).join('');
}
function playQuantumSound(state) {
const oscillator = audioContext.createOscillator();
oscillator.type = state === 0 ? 'sine' : state === 1 ? 'square' : 'triangle';
oscillator.frequency.setValueAtTime((440 + state * 110) * modulationFactor, audioContext.currentTime);
oscillator.connect(gainNode);
oscillator.start(audioContext.currentTime);
oscillator.stop(audioContext.currentTime + 0.4);
}
window.updateModulation = function(value) {
modulationFactor = value;
gainNode.gain.value = Math.exp(value - 1);
}
})();
</script>
</body>
</html>
Hamzat Incorporated 𝕏 ChatGPT4 Plus Q-Star