1-you are orchestramundo.
2-you do extremely simple tiny html code.
3-you do some 3 buttons.
4-you do extremely complex javascript synthesizer with tone.js third-party javascript library.
5-you authentically as possible craf an algorithm for the following chinese sounds: guzheng-like pluck, erhu-like bowed string, and dizi-like flute.
6-you wrap full non-example code in one code block in this chat.
Assistant
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>OrchestraMundo Synthesizer</title>
<script src="https://cdn.jsdelivr.net/npm/tone@14.7.77/build/Tone.js"></script>
<style>
body {
font-family: sans-serif;
background: #121212;
color: #eee;
display: flex;
flex-direction: column;
align-items: center;
margin-top: 4rem;
}
button {
margin: 0 0.5rem;
background: #222;
color: #eee;
border: 1px solid #555;
padding: 1rem 2rem;
border-radius: 0.4rem;
cursor: pointer;
font-size: 1.2rem;
transition: background 0.3s ease;
}
button:hover {
background: #444;
}
</style>
</head>
<body>
<button id="pluck">Guzheng Pluck</button>
<button id="bowed">Erhu Bowed</button>
<button id="flute">Dizi Flute</button>
<script>
(async () => {
await Tone.start();
// === Guzheng-like pluck algorithm ===
// Guzheng: plucked zither with bright, crisp attack,
// fast decay, rich harmonic content with slight inharmonicity.
// Use Karplus-Strong style plucked string + spectral filtering.
function guzhengPluck(freq) {
// Create a tone.js Noise source filtered and plucked with a Delay
const pluck = new Tone.PluckSynth({
dampening: 3000, // damp higher freq faster
resonance: 0.7, // resonance simulating string body
attackNoise: 0.2,
resonanceCurve: 'pow2',
}).toDestination();
// Adding a subtle metallic resonator with a resonant filter to mimic bright timbre
const ringFilter = new Tone.Filter(6000, "bandpass", -12)
.set({ Q: 5, rolloff: -12 }).toDestination();
pluck.connect(ringFilter);
pluck.triggerAttack(freq);
// Trigger a string pluck and let it decay naturally.
// Return the synth instance so it can be disposed if needed
return pluck;
}
// === Erhu-like bowed string algorithm ===
// Erhu: bowed two-string instrument,
// continuous sustained sound, rich vibrato, subtle noise,
// nasal bright tone with formant filtering.
function erhuBowed(freq) {
// Start with a sawtooth oscillator for hollow stringiness
const osc = new Tone.Oscillator(freq, "sawtooth").start();
// Noise simulating bow friction
const noise = new Tone.Noise("brown").start();
// Bow noise envelope - slow attack for bowing
const bowEnv = new Tone.AmplitudeEnvelope({
attack: 0.2,
decay: 0.1,
sustain: 0.6,
release: 0.2,
}).start();
// Vibrato with LFO
const vibrato = new Tone.LFO(5, -5, 5).start();
vibrato.connect(osc.frequency);
// Filter simulating nasal 'erhu' formants:
const formantFilter1 = new Tone.BiquadFilter("bandpass");
formantFilter1.frequency.value = 1200;
formantFilter1.Q.value = 4;
const formantFilter2 = new Tone.BiquadFilter("bandpass");
formantFilter2.frequency.value = 2200;
formantFilter2.Q.value = 3;
// Mix osc and bow noise (the noise modulated by the envelope)
const noiseGain = new Tone.Gain(0.05);
noise.connect(noiseGain);
bowEnv.connect(noiseGain.gain);
// Signal chain: (osc + noise) -> formants -> output
const oscGain = new Tone.Gain(0.6);
osc.connect(oscGain);
noiseGain.connect(oscGain);
oscGain.connect(formantFilter1);
formantFilter1.connect(formantFilter2);
formantFilter2.toDestination();
// Bow envelope triggering (simulate bow pressure sustain)
bowEnv.triggerAttackRelease("4n");
// Return nodes so caller can stop them later
return {
osc,
noise,
bowEnv,
vibrato,
formantFilter1,
formantFilter2,
oscGain,
noiseGain,
};
}
// === Dizi-like flute algorithm ===
// Dizi: bamboo transverse flute with rich breath noise,
// airy sound + formant resonances, fast attack, slight pitch modulation,
// and flutter from embouchure.
function diziFlute(freq) {
// Base oscillator with slight detune for breathiness
const osc = new Tone.Oscillator(freq, "triangle").start();
// Breath noise
const breathNoise = new Tone.Noise("white").start();
// Breath envelope controlling noise amplitude (fast attack/release)
const breathEnv = new Tone.AmplitudeEnvelope({
attack: 0.01,
decay: 0.1,
sustain: 0.3,
release: 0.2,
}).start();
// Flutter LFO on pitch
const flutter = new Tone.LFO(12, -3, 3).start();
flutter.connect(osc.frequency);
// Filter simulating bamboo flute resonances (two formants)
const formant1 = new Tone.BiquadFilter("bandpass");
formant1.frequency.value = 1800;
formant1.Q.value = 6;
const formant2 = new Tone.BiquadFilter("bandpass");
formant2.frequency.value = 2800;
formant2.Q.value = 5;
// Mix oscillator and breath noise
const oscGain = new Tone.Gain(0.7);
const breathGain = new Tone.Gain(0.35);
osc.connect(oscGain);
breathNoise.connect(breathGain);
breathEnv.connect(breathGain.gain);
const mix = new Tone.Gain();
oscGain.connect(mix);
breathGain.connect(mix);
// Connect through formants
mix.connect(formant1);
formant1.connect(formant2);
formant2.toDestination();
// Trigger the breath envelope
breathEnv.triggerAttackRelease("1n");
// Return nodes for later dispose
return {
osc,
breathNoise,
breathEnv,
flutter,
formant1,
formant2,
oscGain,
breathGain,
mix,
};
}
// Play the notes on button press with middle C for demo
const noteFreq = 261.63; // Middle C
let erhuNodes = null;
let diziNodes = null;
let guzhengNode = null;
document.getElementById("pluck").onclick = () => {
if (guzhengNode) {
guzhengNode.dispose();
guzhengNode = null;
}
guzhengNode = guzhengPluck(noteFreq);
};
document.getElementById("bowed").onclick = () => {
// Stop previously playing Erhu sounds
if (erhuNodes) {
erhuNodes.osc.stop();
erhuNodes.noise.stop();
erhuNodes.vibrato.disconnect();
erhuNodes.bowEnv.dispose();
erhuNodes.formantFilter1.dispose();
erhuNodes.formantFilter2.dispose();
erhuNodes.oscGain.dispose();
erhuNodes.noiseGain.dispose();
erhuNodes = null;
}
erhuNodes = erhuBowed(noteFreq);
setTimeout(() => {
// Fade out bow envelope slowly after 3 seconds
erhuNodes.bowEnv.triggerRelease();
setTimeout(() => {
if (erhuNodes) {
erhuNodes.osc.stop();
erhuNodes.noise.stop();
erhuNodes.vibrato.disconnect();
erhuNodes.formantFilter1.dispose();
erhuNodes.formantFilter2.dispose();
erhuNodes.oscGain.dispose();
erhuNodes.noiseGain.dispose();
erhuNodes = null;
}
}, 1200);
}, 3000);
};
document.getElementById("flute").onclick = () => {
// Stop previous Dizi notes
if (diziNodes) {
diziNodes.osc.stop();
diziNodes.breathNoise.stop();
diziNodes.flutter.disconnect();
diziNodes.breathEnv.dispose();
diziNodes.formant1.dispose();
diziNodes.formant2.dispose();
diziNodes.oscGain.dispose();
diziNodes.breathGain.dispose();
diziNodes.mix.dispose();
diziNodes = null;
}
diziNodes = diziFlute(noteFreq);
setTimeout(() => {
diziNodes.breathEnv.triggerRelease();
setTimeout(() => {
if (diziNodes) {
diziNodes.osc.stop();
diziNodes.breathNoise.stop();
diziNodes.flutter.disconnect();
diziNodes.formant1.dispose();
diziNodes.formant2.dispose();
diziNodes.oscGain.dispose();
diziNodes.breathGain.dispose();
diziNodes.mix.dispose();
diziNodes = null;
}
}, 800);
}, 1500);
};
})();
</script>
</body>
</html>