A Web Audio subtractive, polyphonic synthesizer. Just need one voice? Check out submono!
var audioCtx = new AudioContext();
var synth = new Polysynth(audioCtx);
Your new synth
has an array of submono voices
attached.
synth.voices[i].start();
synth.voices[i].stop();
synth.start();
synth.stop();
synth.voices[i].pitch(440); // in hertz
console.log(synth.voices[i].waveform()); // 'sawtooth'
synth.voices[i].maxGain = 0.5; // out of 1
synth.voices[i].attack = 1.0; // in seconds
synth.maxGain(0.5); // out of 1
synth.attack(1.0); // in seconds
synth.pitch(440); // in hertz
synth.waveform('sawtooth'); // or sine, triangle, square
synth.width(1.0); // out of 1
var config = {
waveform: 'sawtooth', // or sine, triangle, square
pitch: 440, // in hertz
maxGain: 0.5, // out of 1
attack: 0.1, // in seconds
decay: 0.0, // in seconds
sustain: 1.0, // out of 1
release: 0.8, // in seconds
stereoWidth: 0.5, // out of 1
numVoices: 5, // unlimited
cutoff: {
maxFrequency: 7500, // in hertz
attack: 0.1, // in seconds
decay: 2.5, // in seconds
sustain: 0.2 // 0-5; maxFrequency multiplied by this
}
};
var synth = new Polysynth(audioCtx, config);