A Web Audio subtractive, monophonic synthesizer. Looking for polyphony? Check out subpoly!
var audioCtx = new AudioContext();
var synth = new Monosynth(audioCtx);
synth.start();
synth.stop();
synth.pitch(440); // in hertz
console.log(synth.waveform()); // 'sawtooth' (or sine, triangle, square)
synth.maxGain = 0.5; // out of 1
synth.attack = 1.0; // in seconds
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
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 Monosynth(audioCtx, config);