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;
|
| 10 |
+
padding: 0;
|
| 11 |
+
box-sizing: border-box;
|
| 12 |
+
font-family: Arial, sans-serif;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
body {
|
| 16 |
+
background: #1a1a1a;
|
| 17 |
+
color: #fff;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
.container {
|
| 21 |
+
max-width: 1200px;
|
| 22 |
+
margin: 0 auto;
|
| 23 |
+
padding: 20px;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
.header {
|
| 27 |
+
text-align: center;
|
| 28 |
+
padding: 20px 0;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
.controls {
|
| 32 |
+
display: grid;
|
| 33 |
+
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
| 34 |
+
gap: 20px;
|
| 35 |
+
margin: 20px 0;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.control-panel {
|
| 39 |
+
background: #2a2a2a;
|
| 40 |
+
padding: 20px;
|
| 41 |
+
border-radius: 8px;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.visualization {
|
| 45 |
+
display: grid;
|
| 46 |
+
grid-template-columns: 2fr 1fr;
|
| 47 |
+
gap: 20px;
|
| 48 |
+
margin: 20px 0;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
canvas {
|
| 52 |
+
width: 100%;
|
| 53 |
+
height: 400px;
|
| 54 |
+
background: #2a2a2a;
|
| 55 |
+
border-radius: 8px;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
button {
|
| 59 |
+
background: #4CAF50;
|
| 60 |
+
color: white;
|
| 61 |
+
padding: 10px 20px;
|
| 62 |
+
border: none;
|
| 63 |
+
border-radius: 4px;
|
| 64 |
+
cursor: pointer;
|
| 65 |
+
margin: 5px;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
button:hover {
|
| 69 |
+
background: #45a049;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
input[type="number"] {
|
| 73 |
+
width: 100%;
|
| 74 |
+
padding: 8px;
|
| 75 |
+
margin: 5px 0;
|
| 76 |
+
border-radius: 4px;
|
| 77 |
+
border: 1px solid #444;
|
| 78 |
+
background: #333;
|
| 79 |
+
color: white;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
.device-status {
|
| 83 |
+
background: #2a2a2a;
|
| 84 |
+
padding: 20px;
|
| 85 |
+
border-radius: 8px;
|
| 86 |
+
margin-top: 20px;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
.preset-container {
|
| 90 |
+
display: grid;
|
| 91 |
+
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
| 92 |
+
gap: 10px;
|
| 93 |
+
margin: 20px 0;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
.preset {
|
| 97 |
+
background: #333;
|
| 98 |
+
padding: 10px;
|
| 99 |
+
border-radius: 4px;
|
| 100 |
+
cursor: pointer;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
.preset:hover {
|
| 104 |
+
background: #444;
|
| 105 |
+
}
|
| 106 |
+
</style>
|
| 107 |
+
</head>
|
| 108 |
+
<body>
|
| 109 |
+
<div class="container">
|
| 110 |
+
<div class="header">
|
| 111 |
+
<h1>3D Audio Spectrum Analyzer</h1>
|
| 112 |
+
</div>
|
| 113 |
+
|
| 114 |
+
<div class="controls">
|
| 115 |
+
<div class="control-panel">
|
| 116 |
+
<h3>Device Configuration</h3>
|
| 117 |
+
<button id="startAnalysis">Start Analysis</button>
|
| 118 |
+
<button id="stopAnalysis">Stop Analysis</button>
|
| 119 |
+
<button id="calibrate">Calibrate Devices</button>
|
| 120 |
+
<div>
|
| 121 |
+
<label>Device Role:</label>
|
| 122 |
+
<select id="deviceRole">
|
| 123 |
+
<option value="left">Left Channel</option>
|
| 124 |
+
<option value="right">Right Channel</option>
|
| 125 |
+
<option value="center">Center Channel</option>
|
| 126 |
+
</select>
|
| 127 |
+
</div>
|
| 128 |
+
</div>
|
| 129 |
+
|
| 130 |
+
<div class="control-panel">
|
| 131 |
+
<h3>Binaural Beat Generator</h3>
|
| 132 |
+
<div>
|
| 133 |
+
<label>Base Frequency (Hz):</label>
|
| 134 |
+
<input type="number" id="baseFreq" value="432" min="20" max="1000">
|
| 135 |
+
</div>
|
| 136 |
+
<div>
|
| 137 |
+
<label>Beat Frequency (Hz):</label>
|
| 138 |
+
<input type="number" id="beatFreq" value="7" min="1" max="40">
|
| 139 |
+
</div>
|
| 140 |
+
<button id="startBinaural">Generate Binaural Beat</button>
|
| 141 |
+
<button id="stopBinaural">Stop</button>
|
| 142 |
+
</div>
|
| 143 |
+
</div>
|
| 144 |
+
|
| 145 |
+
<div class="visualization">
|
| 146 |
+
<canvas id="spectrumCanvas"></canvas>
|
| 147 |
+
<canvas id="3dRoomCanvas"></canvas>
|
| 148 |
+
</div>
|
| 149 |
+
|
| 150 |
+
<div class="preset-container">
|
| 151 |
+
<div class="preset">
|
| 152 |
+
<h4>Alpha Wave</h4>
|
| 153 |
+
<p>8-12 Hz</p>
|
| 154 |
+
</div>
|
| 155 |
+
<div class="preset">
|
| 156 |
+
<h4>Theta Wave</h4>
|
| 157 |
+
<p>4-7 Hz</p>
|
| 158 |
+
</div>
|
| 159 |
+
<div class="preset">
|
| 160 |
+
<h4>Delta Wave</h4>
|
| 161 |
+
<p>0.5-4 Hz</p>
|
| 162 |
+
</div>
|
| 163 |
+
</div>
|
| 164 |
+
|
| 165 |
+
<div class="device-status">
|
| 166 |
+
<h3>Connected Devices</h3>
|
| 167 |
+
<div id="deviceList"></div>
|
| 168 |
+
</div>
|
| 169 |
+
</div>
|
| 170 |
+
|
| 171 |
+
<script>
|
| 172 |
+
class AudioAnalyzer {
|
| 173 |
+
constructor() {
|
| 174 |
+
this.audioContext = null;
|
| 175 |
+
this.analyser = null;
|
| 176 |
+
this.oscillator = null;
|
| 177 |
+
this.isPlaying = false;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
async initialize() {
|
| 181 |
+
try {
|
| 182 |
+
this.audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
| 183 |
+
this.analyser = this.audioContext.createAnalyser();
|
| 184 |
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
| 185 |
+
const source = this.audioContext.createMediaStreamSource(stream);
|
| 186 |
+
source.connect(this.analyser);
|
| 187 |
+
this.setupVisualization();
|
| 188 |
+
} catch (error) {
|
| 189 |
+
console.error('Error initializing audio:', error);
|
| 190 |
+
}
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
generateBinauralBeat(baseFreq, beatFreq) {
|
| 194 |
+
if (this.isPlaying) this.stopBinauralBeat();
|
| 195 |
+
|
| 196 |
+
const leftOsc = this.audioContext.createOscillator();
|
| 197 |
+
const rightOsc = this.audioContext.createOscillator();
|
| 198 |
+
const leftGain = this.audioContext.createGain();
|
| 199 |
+
const rightGain = this.audioContext.createGain();
|
| 200 |
+
const merger = this.audioContext.createChannelMerger(2);
|
| 201 |
+
|
| 202 |
+
leftOsc.frequency.value = baseFreq;
|
| 203 |
+
rightOsc.frequency.value = baseFreq + beatFreq;
|
| 204 |
+
|
| 205 |
+
leftOsc.connect(leftGain);
|
| 206 |
+
rightOsc.connect(rightGain);
|
| 207 |
+
leftGain.connect(merger, 0, 0);
|
| 208 |
+
rightGain.connect(merger, 0, 1);
|
| 209 |
+
merger.connect(this.audioContext.destination);
|
| 210 |
+
|
| 211 |
+
leftOsc.start();
|
| 212 |
+
rightOsc.start();
|
| 213 |
+
this.oscillator = { left: leftOsc, right: rightOsc };
|
| 214 |
+
this.isPlaying = true;
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
stopBinauralBeat() {
|
| 218 |
+
if (this.oscillator) {
|
| 219 |
+
this.oscillator.left.stop();
|
| 220 |
+
this.oscillator.right.stop();
|
| 221 |
+
this.isPlaying = false;
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
setupVisualization() {
|
| 226 |
+
const canvas = document.getElementById('spectrumCanvas');
|
| 227 |
+
const ctx = canvas.getContext('2d');
|
| 228 |
+
const width = canvas.width;
|
| 229 |
+
const height = canvas.height;
|
| 230 |
+
|
| 231 |
+
const draw = () => {
|
| 232 |
+
requestAnimationFrame(draw);
|
| 233 |
+
const dataArray = new Uint8Array(this.analyser.frequencyBinCount);
|
| 234 |
+
this.analyser.getByteFrequencyData(dataArray);
|
| 235 |
+
|
| 236 |
+
ctx.fillStyle = '#2a2a2a';
|
| 237 |
+
ctx.fillRect(0, 0, width, height);
|
| 238 |
+
|
| 239 |
+
const barWidth = width / dataArray.length;
|
| 240 |
+
let x = 0;
|
| 241 |
+
|
| 242 |
+
dataArray.forEach(value => {
|
| 243 |
+
const barHeight = value * height / 255;
|
| 244 |
+
ctx.fillStyle = `hsl(${value}, 100%, 50%)`;
|
| 245 |
+
ctx.fillRect(x, height - barHeight, barWidth, barHeight);
|
| 246 |
+
x += barWidth;
|
| 247 |
+
});
|
| 248 |
+
};
|
| 249 |
+
|
| 250 |
+
draw();
|
| 251 |
+
}
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
// Initialize application
|
| 255 |
+
const analyzer = new AudioAnalyzer();
|
| 256 |
+
|
| 257 |
+
document.getElementById('startAnalysis').addEventListener('click', () => analyzer.initialize());
|
| 258 |
+
document.getElementById('startBinaural').addEventListener('click', () => {
|
| 259 |
+
const baseFreq = parseFloat(document.getElementById('baseFreq').value);
|
| 260 |
+
const beatFreq = parseFloat(document.getElementById('beatFreq').value);
|
| 261 |
+
analyzer.generateBinauralBeat(baseFreq, beatFreq);
|
| 262 |
+
});
|
| 263 |
+
document.getElementById('stopBinaural').addEventListener('click', () => analyzer.stopBinauralBeat());
|
| 264 |
+
|
| 265 |
+
// Setup room visualization
|
| 266 |
+
const room3d = document.getElementById('3dRoomCanvas');
|
| 267 |
+
const ctx3d = room3d.getContext('2d');
|
| 268 |
+
|
| 269 |
+
function draw3dRoom() {
|
| 270 |
+
// Basic 3D room visualization implementation would go here
|
| 271 |
+
// This would require a more complex 3D rendering library for proper implementation
|
| 272 |
+
ctx3d.fillStyle = '#2a2a2a';
|
| 273 |
+
ctx3d.fillRect(0, 0, room3d.width, room3d.height);
|
| 274 |
+
ctx3d.strokeStyle = '#4CAF50';
|
| 275 |
+
ctx3d.beginPath();
|
| 276 |
+
ctx3d.moveTo(50, 50);
|
| 277 |
+
ctx3d.lineTo(room3d.width - 50, 50);
|
| 278 |
+
ctx3d.lineTo(room3d.width - 50, room3d.height - 50);
|
| 279 |
+
ctx3d.lineTo(50, room3d.height - 50);
|
| 280 |
+
ctx3d.closePath();
|
| 281 |
+
ctx3d.stroke();
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
draw3dRoom();
|
| 285 |
+
</script>
|
| 286 |
+
</body>
|
| 287 |
+
</html><script async data-explicit-opt-in="true" data-cookie-opt-in="true" src="https://vercel.live/_next-live/feedback/feedback.js"></script>
|