<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>OrchestraMundo Chinese Synth Hold Play Erhu Fix</title>
<style>
button{margin:6px; padding:6px 12px; user-select:none;}
</style>
</head>
<body>
<button id="guzheng">Guzheng Pluck</button>
<button id="erhu">Erhu Bow</button>
<button id="dizi">Dizi Flute</button>
<script src="https://cdn.jsdelivr.net/npm/tone@14.7.77/build/Tone.min.js"></script>
<script>
(() => {
const startTone = async () => {
if (Tone.context.state !== 'running') await Tone.start();
};
function GuzhengPluck(freq) {
const osc = new Tone.Oscillator(freq, "triangle");
const ampEnv = new Tone.AmplitudeEnvelope({
attack: 0.01,
decay: 0.1,
sustain: 0.7,
release: 0.3
});
const filter = new Tone.Filter({
type: "lowpass",
frequency: freq * 3,
Q: 4,
rolloff: -12,
});
const gain = new Tone.Gain(1).toDestination();
osc.connect(filter);
filter.connect(ampEnv);
ampEnv.connect(gain);
const loop = new Tone.Loop(time => {
ampEnv.triggerAttack(time);
ampEnv.triggerRelease(time + 0.15);
}, 0.35);
return {
triggerAttack: () => {
if (osc.state !== "started") osc.start();
loop.start(0);
Tone.Transport.start();
},
triggerRelease: () => {
loop.stop();
ampEnv.triggerRelease();
setTimeout(() => {
if (osc.state !== "stopped") osc.stop();
if (!window.anySynthPlaying) Tone.Transport.stop();
}, 500);
},
loop
};
}
// THE PROBLEM with Erhu: By connecting the amp envelope only to the Gain node,
// but NOT ensuring Oscillators and Vibrato are started properly before triggerAttack,
// plus Vibrato not started before oscillator start can cause inaudibility.
// Also, assigning vibrato to osc.freq directly can produce near-zero frequency during modulation.
// To fix:
// 1. Start vibrato *before* oscillators.
// 2. Use vibrato start time synchronized with oscillators start.
// 3. Slightly reduce vibrato depth, or shift freq base to avoid zero or negative freq.
// 4. Ensure amplitude envelope controls the gain, not just filter output.
// 5. Use a separate gain node after ampEnv to set louder volume.
function ErhuBow(freq) {
const oscA = new Tone.Oscillator(freq, "sawtooth");
const oscB = new Tone.Oscillator(freq * 1.995, "sawtooth");
const vibrato = new Tone.LFO(5, -3, 3);
// Start vibrato *before* connection so LFO signal is ready
vibrato.start(Tone.now());
// Connect vibrato to detune instead of freq to avoid going to zero or negative freq
// Detune is in cents, so ±3 cents is subtle vibrato
vibrato.connect(oscA.detune);
vibrato.connect(oscB.detune);
// Bandpass filter with Q 7 for body resonance and brighter sound
const filter = new Tone.Filter(freq * 2.5, "bandpass");
filter.Q.value = 7;
// Gain node for volume control
const gain = new Tone.Gain(1.6).toDestination();
const ampEnv = new Tone.AmplitudeEnvelope({
attack: 0.5,
decay: 0.3,
sustain: 0.7,
release: 1.2,
});
oscA.connect(filter);
oscB.connect(filter);
filter.connect(ampEnv);
ampEnv.connect(gain);
return {
triggerAttack: () => {
const now = Tone.now();
if (oscA.state !== "started") oscA.start(now);
if (oscB.state !== "started") oscB.start(now);
// vibrato already started
ampEnv.triggerAttack(now);
},
triggerRelease: () => {
const now = Tone.now();
ampEnv.triggerRelease(now);
setTimeout(() => {
if (oscA.state !== "stopped") oscA.stop();
if (oscB.state !== "stopped") oscB.stop();
vibrato.stop();
if (!window.anySynthPlaying) Tone.Transport.stop();
}, 1600);
}
};
}
function DiziFlute(freq) {
const osc = new Tone.Oscillator(freq, "sawtooth");
const noise = new Tone.Noise("brown");
const noiseFilter = new Tone.Filter(1500, "highpass");
noise.connect(noiseFilter);
const noiseGain = new Tone.Gain(0.01);
noiseFilter.connect(noiseGain);
const masterGain = new Tone.Gain(1).toDestination();
const ampEnv = new Tone.AmplitudeEnvelope({
attack: 0.03,
decay: 0.12,
sustain: 0.8,
release: 0.1,
});
const breathEnv = new Tone.AmplitudeEnvelope({
attack: 0.03,
decay: 0.12,
sustain: 0.8,
release: 0.1,
});
osc.connect(ampEnv);
noiseGain.connect(breathEnv);
breathEnv.connect(ampEnv);
ampEnv.connect(masterGain);
return {
triggerAttack: () => {
if (osc.state !== "started") osc.start();
if (noise.state !== "started") noise.start();
ampEnv.triggerAttack();
breathEnv.triggerAttack();
},
triggerRelease: () => {
ampEnv.triggerRelease();
breathEnv.triggerRelease();
setTimeout(() => {
if (osc.state !== "stopped") osc.stop();
if (noise.state !== "stopped") noise.stop();
if (!window.anySynthPlaying) Tone.Transport.stop();
}, 300);
}
};
}
let activeSynths = {
guzheng: null,
erhu: null,
dizi: null
};
window.anySynthPlaying = false;
const onPress = async (id, freq) => {
await startTone();
if (activeSynths[id]) return;
if (!window.anySynthPlaying) {
Tone.Transport.start();
window.anySynthPlaying = true;
}
let synth;
if (id === "guzheng") synth = GuzhengPluck(freq);
else if (id === "erhu") synth = ErhuBow(freq);
else if (id === "dizi") synth = DiziFlute(freq);
activeSynths[id] = synth;
synth.triggerAttack();
};
const onRelease = (id) => {
const synth = activeSynths[id];
if (!synth) return;
synth.triggerRelease();
activeSynths[id] = null;
if (!Object.values(activeSynths).some(s => s !== null)) {
window.anySynthPlaying = false;
}
};
const setupButton = (id, freq) => {
const btn = document.getElementById(id);
btn.addEventListener("pointerdown", e => {
e.preventDefault();
onPress(id, freq);
});
btn.addEventListener("pointerup", e => {
e.preventDefault();
onRelease(id);
});
btn.addEventListener("pointerleave", e => {
e.preventDefault();
onRelease(id);
});
btn.addEventListener("pointercancel", e => {
e.preventDefault();
onRelease(id);
});
btn.addEventListener("keydown", e => {
if (e.key === " " || e.key === "Enter") {
e.preventDefault();
onPress(id, freq);
}
});
btn.addEventListener("keyup", e => {
if (e.key === " " || e.key === "Enter") {
e.preventDefault();
onRelease(id);
}
});
};
setupButton("guzheng", 220);
setupButton("erhu", 220);
setupButton("dizi", 440);
})();
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>OrchestraMundo Chinese Synth</title>
<style>
button{margin:5px; padding:5px 10px; user-select:none;}
</style>
</head>
<body>
<button id="guzheng">Guzheng Pluck</button>
<button id="erhu">Erhu Bow</button>
<button id="dizi">Dizi Flute</button>
<script src="https://cdn.jsdelivr.net/npm/tone@14.7.77/build/Tone.min.js"></script>
<script>
(() => {
// Ensure audio context is resumed on first user interaction
const ensureAudio = async () => {
if (Tone.context.state !== "running") await Tone.start();
};
// Guzheng pluck synthesis: Plucked string with triangle osc, short fast envelope, strong resonant lowpass filter
function GuzhengPluck(freq) {
// Oscillator: triangle wave for soft pluck timbre
const osc = new Tone.Oscillator({
frequency: freq,
type: "triangle"
});
// Pluck envelope (Amplitude Envelope)
const ampEnv = new Tone.AmplitudeEnvelope({
attack: 0.005,
decay: 0.15,
sustain: 0,
release: 0.2
});
// Lowpass filter to simulate string harmonic rolloff with slight resonance
const filter = new Tone.Filter({
frequency: freq * 3.5,
type: "lowpass",
Q: 5,
rolloff: -24
});
// Output gain node boosted to full audible range (1.0)
const gain = new Tone.Gain(1).toDestination();
// Chain: osc → filter → ampEnv → gain → destination
osc.connect(filter);
filter.connect(ampEnv);
ampEnv.connect(gain);
return {
triggerAttack: () => {
const now = Tone.now();
if (osc.state !== "started") osc.start(now);
ampEnv.triggerAttack(now);
},
triggerRelease: () => {
const now = Tone.now();
ampEnv.triggerRelease(now);
setTimeout(() => {
if (osc.state !== "stopped") osc.stop();
}, 300);
}
};
}
// Erhu bowed string synthesis: two sawtooths slightly detuned + vibrato on detune, bandpass resonance,
// slow amplitude envelope with a soft bowing attack and sustained tone.
function ErhuBow(freq) {
// Two sawtooth oscs detuned just under a semitone for a beating, string-like richness
const oscA = new Tone.Oscillator(freq, "sawtooth");
const oscB = new Tone.Oscillator(freq * 1.994, "sawtooth");
// Vibrato: fast LFO modulating detune in cents ±4 for lively pitch oscillation
const vibrato = new Tone.LFO({
frequency: 5.5,
min: -4,
max: 4
});
vibrato.start();
// Connect vibrato to detune param (in cents) to avoid zero or negative freq
vibrato.connect(oscA.detune);
vibrato.connect(oscB.detune);
// Bandpass filter (center freq ~2.5x fundamental) with medium Q for brighter bow timbre
const filter = new Tone.Filter({
frequency: freq * 2.45,
type: "bandpass",
Q: 6
});
// Soft amplitude envelope with slow attack and long release to simulate bowing
const ampEnv = new Tone.AmplitudeEnvelope({
attack: 0.6,
decay: 0.2,
sustain: 0.8,
release: 1.0
});
// Gain node for loudness boost to full 100%
const gain = new Tone.Gain(1.5).toDestination();
// Chain: (oscA + oscB) → filter → ampEnv → gain → dest
oscA.connect(filter);
oscB.connect(filter);
filter.connect(ampEnv);
ampEnv.connect(gain);
return {
triggerAttack: () => {
const now = Tone.now();
if (oscA.state !== "started") oscA.start(now);
if (oscB.state !== "started") oscB.start(now);
ampEnv.triggerAttack(now);
},
triggerRelease: () => {
const now = Tone.now();
ampEnv.triggerRelease(now);
setTimeout(() => {
if (oscA.state !== "stopped") oscA.stop();
if (oscB.state !== "stopped") oscB.stop();
vibrato.stop();
}, 1200);
}
};
}
// Dizi flute synthesis aims to capture breathy, slightly buzzy, airy tone with subtle dimo membrane effect
function DiziFlute(freq) {
// Oscillator basic tone: triangle for softness, fundamental freq
const osc = new Tone.Oscillator(freq, "triangle");
// Noise source for breath + membrane buzz (brown noise for smoother noise)
const noise = new Tone.Noise("brown");
// A fast, subtle amplitude envelope for noise simulating breath attack
const noiseEnv = new Tone.AmplitudeEnvelope({
attack: 0.01,
decay: 0.15,
sustain: 0.2,
release: 0.2
});
// Noise tone shaping: highpass filter to remove low rumble + bandpass for membrane buzz
const noiseHPF = new Tone.Filter(700, "highpass");
const noiseBPF = new Tone.Filter(2400, "bandpass");
// Gain for noise level
const noiseGain = new Tone.Gain(0.12);
noise.connect(noiseHPF);
noiseHPF.connect(noiseBPF);
noiseBPF.connect(noiseGain);
noiseGain.connect(noiseEnv);
// Vibrato on oscillator detune for natural slight pitch fluctuations
const vibrato = new Tone.LFO(6, -5, 5);
vibrato.start();
vibrato.connect(osc.detune);
// Amplitude envelope for main tone; slower attack & release for smooth breathy note
const toneEnv = new Tone.AmplitudeEnvelope({
attack: 0.08,
decay: 0.1,
sustain: 0.75,
release: 0.25
});
// Gain for main oscillator output
const toneGain = new Tone.Gain(1.25);
osc.connect(toneEnv);
toneEnv.connect(toneGain);
// Add subtle chorus effect for shimmer / spatial feel (not heavy)
const chorus = new Tone.Chorus(1.5, 2.5, 0.3);
chorus.start();
toneGain.connect(chorus);
chorus.toDestination();
// Noise envelope connects directly to destination for breathiness awith volume control
noiseEnv.toDestination();
return {
triggerAttack: () => {
const now = Tone.now();
if (osc.state !== "started") osc.start(now);
if (noise.state !== "started") noise.start(now);
toneEnv.triggerAttack(now);
noiseEnv.triggerAttack(now);
},
triggerRelease: () => {
const now = Tone.now();
toneEnv.triggerRelease(now);
noiseEnv.triggerRelease(now);
setTimeout(() => {
if (osc.state !== "stopped") osc.stop();
if (noise.state !== "stopped") noise.stop();
vibrato.stop();
chorus.stop();
}, 400);
}
};
}
const freqMap = {
guzheng: 220, // A3
erhu: 220,
dizi: 440 // A4 to make flute brighter
};
const synths = {
guzheng: null,
erhu: null,
dizi: null
};
window.anySynthPlaying = false;
// On press handler: instantiate synth, start Tone context, trigger attack
const onPress = async (id) => {
await ensureAudio();
if (synths[id]) return;
if (!window.anySynthPlaying) {
window.anySynthPlaying = true;
}
let synth;
if (id === "guzheng") synth = GuzhengPluck(freqMap.guzheng);
else if (id === "erhu") synth = ErhuBow(freqMap.erhu);
else if (id === "dizi") synth = DiziFlute(freqMap.dizi);
synths[id] = synth;
synth.triggerAttack();
};
// On release handler: trigger release envelope and schedule oscillator stop
const onRelease = (id) => {
if (!synths[id]) return;
synths[id].triggerRelease();
synths[id] = null;
if (!Object.values(synths).some(s => s !== null)) {
window.anySynthPlaying = false;
}
};
// Setup button interaction
const setupButton = (id) => {
const btn = document.getElementById(id);
btn.addEventListener("pointerdown", e => {
e.preventDefault();
onPress(id);
});
btn.addEventListener("pointerup", e => {
e.preventDefault();
onRelease(id);
});
btn.addEventListener("pointerleave", e => {
e.preventDefault();
onRelease(id);
});
btn.addEventListener("pointercancel", e => {
e.preventDefault();
onRelease(id);
});
// Keyboard support for space and enter keys
btn.addEventListener("keydown", e => {
if (e.key === " " || e.key === "Enter") {
e.preventDefault();
onPress(id);
}
});
btn.addEventListener("keyup", e => {
if (e.key === " " || e.key === "Enter") {
e.preventDefault();
onRelease(id);
}
});
};
setupButton("guzheng");
setupButton("erhu");
setupButton("dizi");
})();
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>OrchestraMundo Chinese Synth</title>
<style>
button{margin:5px; padding:5px 10px; user-select:none;}
</style>
</head>
<body>
<button id="guzheng">Guzheng Pluck</button>
<button id="erhu">Erhu Bow</button>
<button id="dizi">Dizi Flute</button>
<script src="https://cdn.jsdelivr.net/npm/tone@14.7.77/build/Tone.min.js"></script>
<script>
(() => {
const ensureAudio = async () => {
if (Tone.context.state !== "running") await Tone.start();
};
function GuzhengPluck(freq) {
const osc = new Tone.Oscillator({
frequency: freq,
type: "triangle"
});
const ampEnv = new Tone.AmplitudeEnvelope({
attack: 0.005,
decay: 0.15,
sustain: 0,
release: 0.2
});
const filter = new Tone.Filter({
frequency: freq * 3.5,
type: "lowpass",
Q: 5,
rolloff: -24
});
const gain = new Tone.Gain(1).toDestination();
osc.connect(filter);
filter.connect(ampEnv);
ampEnv.connect(gain);
return {
triggerAttack: () => {
const now = Tone.now();
if (osc.state !== "started") osc.start(now);
ampEnv.triggerAttack(now);
},
triggerRelease: () => {
const now = Tone.now();
ampEnv.triggerRelease(now);
setTimeout(() => {
if (osc.state !== "stopped") osc.stop();
}, 300);
}
};
}
function ErhuBow(freq) {
const oscA = new Tone.Oscillator(freq, "sawtooth");
const oscB = new Tone.Oscillator(freq * 1.994, "sawtooth");
const vibrato = new Tone.LFO({
frequency: 5.5,
min: -4,
max: 4
});
vibrato.start();
vibrato.connect(oscA.detune);
vibrato.connect(oscB.detune);
const filter = new Tone.Filter({
frequency: freq * 2.45,
type: "bandpass",
Q: 6
});
const ampEnv = new Tone.AmplitudeEnvelope({
attack: 0.6,
decay: 0.2,
sustain: 0.8,
release: 1.0
});
const gain = new Tone.Gain(1.5).toDestination();
oscA.connect(filter);
oscB.connect(filter);
filter.connect(ampEnv);
ampEnv.connect(gain);
return {
triggerAttack: () => {
const now = Tone.now();
if (oscA.state !== "started") oscA.start(now);
if (oscB.state !== "started") oscB.start(now);
ampEnv.triggerAttack(now);
},
triggerRelease: () => {
const now = Tone.now();
ampEnv.triggerRelease(now);
setTimeout(() => {
if (oscA.state !== "stopped") oscA.stop();
if (oscB.state !== "stopped") oscB.stop();
vibrato.stop();
}, 1200);
}
};
}
function DiziFlute(freq) {
const osc = new Tone.Oscillator(freq, "triangle");
const noise = new Tone.Noise("brown");
const noiseEnv = new Tone.AmplitudeEnvelope({
attack: 0.01,
decay: 0.15,
sustain: 0.2,
release: 0.2
});
const noiseHPF = new Tone.Filter(700, "highpass");
const noiseBPF = new Tone.Filter(2400, "bandpass");
const noiseGain = new Tone.Gain(0.12);
noise.connect(noiseHPF);
noiseHPF.connect(noiseBPF);
noiseBPF.connect(noiseGain);
noiseGain.connect(noiseEnv);
const vibrato = new Tone.LFO(6, -5, 5);
vibrato.start();
vibrato.connect(osc.detune);
const toneEnv = new Tone.AmplitudeEnvelope({
attack: 0.08,
decay: 0.1,
sustain: 0.75,
release: 0.25
});
const toneGain = new Tone.Gain(1.25);
osc.connect(toneEnv);
toneEnv.connect(toneGain);
const chorus = new Tone.Chorus(1.5, 2.5, 0.3);
chorus.start();
toneGain.connect(chorus);
chorus.toDestination();
noiseEnv.toDestination();
return {
triggerAttack: () => {
const now = Tone.now();
if (osc.state !== "started") osc.start(now);
if (noise.state !== "started") noise.start(now);
toneEnv.triggerAttack(now);
noiseEnv.triggerAttack(now);
},
triggerRelease: () => {
const now = Tone.now();
toneEnv.triggerRelease(now);
noiseEnv.triggerRelease(now);
setTimeout(() => {
if (osc.state !== "stopped") osc.stop();
if (noise.state !== "stopped") noise.stop();
vibrato.stop();
chorus.stop();
}, 400);
}
};
}
const freqMap = {
guzheng: 220,
erhu: 220,
dizi: 440
};
const synths = {
guzheng: null,
erhu: null,
dizi: null
};
window.anySynthPlaying = false;
const onPress = async (id) => {
await ensureAudio();
if (synths[id]) return;
window.anySynthPlaying = true;
let synth;
if (id === "guzheng") synth = GuzhengPluck(freqMap.guzheng);
else if (id === "erhu") synth = ErhuBow(freqMap.erhu);
else if (id === "dizi") synth = DiziFlute(freqMap.dizi);
synths[id] = synth;
synth.triggerAttack();
};
const onRelease = (id) => {
if (!synths[id]) return;
synths[id].triggerRelease();
synths[id] = null;
if (!Object.values(synths).some(s => s !== null)) {
window.anySynthPlaying = false;
}
};
const setupButton = (id) => {
const btn = document.getElementById(id);
btn.addEventListener("pointerdown", e => {
e.preventDefault();
onPress(id);
});
btn.addEventListener("pointerup", e => {
e.preventDefault();
onRelease(id);
});
btn.addEventListener("pointerleave", e => {
e.preventDefault();
onRelease(id);
});
btn.addEventListener("pointercancel", e => {
e.preventDefault();
onRelease(id);
});
};
setupButton("guzheng");
setupButton("erhu");
setupButton("dizi");
})();
</script>
</body>
</html>
OrchestraMundo Chinese Synth Sound Algorithms - Detailed Schematics
1) Guzheng-like Pluck
----------------------
Goal: Emulate the bright, crisp plucking sound with a fast transient and natural harmonic decay.
- Oscillator: Single "triangle" wave oscillator at fundamental freq.
* Triangle chosen for soft, natural pluck timbre (no harsh rich harmonics like saw)
- Filter: Lowpass filter tuned ~3.5× fundamental freq with moderate Q (5)
* Simulates string harmonic content rolloff, smooths timbre, adds slight resonance/glow.
- Amplitude Envelope: Fast attack (~5ms), short decay (~150ms), no sustain, moderate release (200ms)
* Models the quick pluck transient and rapid decay of vibration.
- Gain: Unity gain to ensure audible volume.
- Signal Chain: Oscillator → Filter → Amplitude Envelope → Gain → Destination
Behavior:
- On Press: Oscillator starts, envelope triggers attack -> decay quickly.
- On Release: Envelope triggers release, oscillator stops shortly after envelope finishes.
Tone.js Extensions:
- Use Oscillator with "triangle" waveform.
- Tone.Filter with lowpass mode and Q for resonance.
- Tone.AmplitudeEnvelope controlling gain dynamically.
2) Erhu-like Bowed String
--------------------------
Goal: Simulate smooth sustained bowed string sound with subtle vibrato and dual-oscillator richness.
- Oscillators: Two detuned "sawtooth" oscillators (~0 and +3 cents detuning)
* Sawtooth to capture rich upper harmonics of bowed strings.
* Slight detuning to create chorus-like beating for natural richness.
- Vibrato: A slow (~5.5 Hz) LFO modulating oscillator detune ±4 cents (not frequency)
* Detune modulation avoids negative frequencies and keeps vibrato natural and subtle.
- Filter: Bandpass filter centered about 2.45× fundamental freq with moderate Q (6)
* Emphasizes the body resonance, mimics the filtering effect of instrument body and bow.
- Amplitude Envelope: Slow attack (600ms), moderate decay (200ms), sustain (80%), long release (1s)
* Models bowing onset and steady sustain with a smooth release at note end.
- Gain: Boost gain (~1.5) to ensure clear presence.
- Signal Chain: (Osc A + Osc B) → Bandpass Filter → Amplitude Envelope → Gain → Destination
Behavior:
- On Press: Start oscillators simultaneously, start vibrato LFO, trigger envelope attack.
- On Release: Trigger envelope release, stop oscillators and vibrato after release phase.
Tone.js Extensions:
- Use two Oscillators with sawtooth wave.
- LFO connected to detune param of both oscillators.
- Bandpass Filter with adjustable Q.
- AmplitudeEnvelope for smooth bowing dynamics.
3) Dizi-like Flute
-------------------
Goal: Capture the airy, breathy, slightly buzzy tone of bamboo flute with "dimo" membrane effect.
- Oscillator: Single "triangle" wave at fundamental freq for soft flute tone.
- Noise Source: Brown noise filtered and shaped into a subtle breathy and membrane buzz.
* Noise path: Brown noise → Highpass filter (~700 Hz) to remove low rumble → Bandpass filter (~2400 Hz) to emphasize dimo buzz frequency region.
- Noise Envelope: Fast attack (10 ms), decay (150 ms), low sustain (20%), release (200 ms)
* Models the transient breathiness and sustaining buzz.
- Vibrato: Moderate LFO (~6 Hz) modulating oscillator detune ±5 cents for natural pitch modulation.
- Amplitude Envelope: Moderate attack (80 ms), quick decay (100 ms), high sustain (75%), medium release (250 ms)
* Smooth flute note onset with controlled sustain and release.
- Chorus Effect: Subtle chorus (rate ~1.5 Hz, depth 0.3) on tone path to simulate slight spatial movement and shimmer.
- Gain: Main tone gain (~1.25), noise gain (~0.12) — noise low volume to avoid harshness.
- Signal Chain:
- Tone path: Oscillator → Amplitude Envelope → Gain → Chorus → Destination
- Noise path: Noise → HPF → BPF → Gain → Noise Envelope → Destination
Behavior:
- On Press: Start oscillator and noise sources, trigger both envelopes, start chorus and vibrato.
- On Release: Trigger envelopes release, stop oscillator, noise, vibrato, chorus shortly after.
Tone.js Extensions:
- Oscillator with triangle waveform.
- Noise generator (brown noise).
- Multiple filter stages to shape noise spectra.
- Separate amplitude envelopes for tone and noise.
- LFO modulating detune parameter.
- Chorus for spatial shimmer.
-----------------------------------------------------------------------------------
Summary:
- Guzheng uses a pluck-style fast envelope with filtered triangle osc to mimic string pluck.
- Erhu uses dual sawtooths with vibrato on detune, bandpass filtering and slow bowing envelope.
- Dizi uses triangle + filtered brown noise with separate envelopes and vibrato + chorus for breathy flute with membrane buzz effect.
Implementation Notes:
- LFO vibratos always modulate detune to prevent zero or negative frequencies.
- Oscillators and LFOs are started before envelopes to ensure immediate modulation.
- Explicit gain nodes used for clear volume control at 100% or above audible level.
- Amplitude envelopes shaped carefully to mimic attack, sustain, and release characteristics of each instrument.
- Noise component added only for Dizi to simulate breath and membrane buzz.