function AudioEngine () { // soundfont setup Soundfont.instrument(Tone.context, 'acoustic_grand_piano').then(function (piano) { this.instrument = piano; }.bind(this)); // tone setup this.tone = new Tone(); // effects setup this.delay = new Tone.FeedbackDelay(0.25, 0.5); this.delay.wet.value = 0; this.pitchShift = new Tone.PitchShift(); this.panner = new Tone.Panner(); this.reverb = new Tone.Freeverb(); this.reverb.wet.value = 0; Tone.Master.chain(this.delay, this.pitchShift, this.panner, this.reverb); // synth setup for play note block this.synth = new Tone.PolySynth(6, Tone.Synth).toMaster(); // drum sounds var drumFileNames = ['high_conga', 'small_cowbell', 'snare_drum', 'splash cymbal']; this.drumSamplers = this._loadSoundFiles(drumFileNames); // sound files var soundFileNames = ['meow','boing','cave','drip_drop','drum_machine','eggs','zoop']; this.soundSamplers = this._loadSoundFiles(soundFileNames); } AudioEngine.prototype.playSound = function (soundNum) { this.soundSamplers[soundNum].triggerAttack(); }; AudioEngine.prototype.getSoundDuration = function (soundNum) { return this.soundSamplers[soundNum].player.buffer.duration; }; AudioEngine.prototype.playNoteForBeats = function(note, beats) { this.instrument.play(note, this.tone.now(), beats); }; AudioEngine.prototype.playDrumForBeats = function(drumNum, beats) { this.drumSamplers[drumNum].triggerAttack(); }; AudioEngine.prototype.stopAllSounds = function() { // stop synth notes this.synth.releaseAll(); // stop drum notes for (var i=0; i