import * as THREE from 'three';
// === REAL-TIME AUDIO ENGINE ===
let audioCtx = null;
// Continuous oscillators for real-time spring sound
let springOsc1 = null;
let springOsc2 = null;
let springGain = null;
let springFilter = null;
let isAudioRunning = false;
// Sound toggle
let soundEnabled = false;
// Additional audio nodes for richer sound
let springOsc3 = null;
let springLowpass = null;
let springHighpass = null;
let reverbGain = null;
let reverbConvolver = null;
async function initAudio() {
if (!audioCtx) {
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
// === SPRING OSCILLATORS ===
// Main tone - soft sine for warmth
springOsc1 = audioCtx.createOscillator();
springOsc1.type = 'sine';
springOsc1.frequency.value = 180;
// Harmonic - adds metallic shimmer
springOsc2 = audioCtx.createOscillator();
springOsc2.type = 'sine';
springOsc2.frequency.value = 360; // Octave up
// Sub harmonic - body/weight
springOsc3 = audioCtx.createOscillator();
springOsc3.type = 'sine';
springOsc3.frequency.value = 90; // Octave down
// === FILTERS ===
// Bandpass for resonant metallic character
springFilter = audioCtx.createBiquadFilter();