// Create Oscillators
var carrierOsc = audioContext.createOscillator();
var modOsc = audioContext.createOscillator();
var amOsc = audioContext.createOscillator();
var modOscGain = audioContext.createGain();
var amOscGain = audioContext.createGain();
// Create the AM/FM structures
var fm = new fmSynth(audioContext, carrierOsc, modOscGain);
var am = new amSynth(audioContext, fm, amOscGain);
// Create control envelopes
this.mainEnvelope = new paramEAD(audioContext, mainGain.gain);
this.fmFrequencyEnvelope = new paramEAD(audioContext, modOsc.frequency);
this.amFrequencyEnvelope = new paramEAD(audioContext, amOsc.frequency);
this.fmGainEnvelope = new paramEAD(audioContext, modOscGain.gain);
this.amGainEnvelope = new paramEAD(audioContext, amOscGain.gain);
// Connect the AM output to destination
am.connect(mainGain);
mainGain.connect(panner);
panner.connect(audioContext.destination);