Basic Usage — Single Notes & Chords

Click any button below to hear ChiptuneSynth in action. Each example demonstrates a core API feature.

Waveform
1. Single Notes — Different Waveforms
const synth = new ChiptuneSynth();
await synth.init();

// Square wave on Lead (track 0)
synth.playNote(440, 0, 0.5);

// Triangle on Bass (track 1)
synth.playNoteByName('C', 3, 1, 0.5);

// Sawtooth on FX (track 3)
synth.tracks[3].type = 'sawtooth';
synth.playNote(330, 3, 0.5);
2. Chords — Play Multiple Tracks
// C major across 3 tracks simultaneously
synth.playNoteByName('C', 4, 0, 1.0);  // Root
synth.playNoteByName('E', 4, 1, 1.0);  // Third
synth.playNoteByName('G', 4, 3, 1.0);  // Fifth
3. Unison — Thick Detuned Voices
// 8-voice super-saw with stereo spread
synth.tracks[0].type = 'sawtooth';
synth.tracks[0].unisonVoices = 8;
synth.tracks[0].unisonDetune = 25;
synth.tracks[0].unisonSpread = 80;
synth.envelopes[0] = { attack: 0.2, decay: 0.3, sustain: 0.7, release: 1.0 };

synth.playNoteByName('E', 4, 0, 2.0);
4. LFOs — Vibrato & Tremolo
// LFO1: Vibrato (pitch modulation)
synth.vibrato[0] = { rate: 5, depth: 12 };

// LFO2: Filter modulation
synth.tracks[0].filterEnabled = true;
synth.tracks[0].filterCutoff = 1000;
synth.tracks[0].lfoFilterRate = 3;
synth.tracks[0].lfoFilterDepth = 2000;

// LFO3: Tremolo (amplitude modulation)
synth.tracks[0].tremoloRate = 6;
synth.tracks[0].tremoloDepth = 50;
Powered by 8Binami