This commit is contained in:
Eric Rosenbaum 2016-10-12 17:22:50 -04:00
parent 7b179546ed
commit 80764f053d

View file

@ -5,7 +5,7 @@ function AudioEngine () {
// tone setup // tone setup
this.tone = new Tone(); this.tone = new Tone();
// effects setup // effects setup
@ -19,7 +19,8 @@ function AudioEngine () {
// drum sounds // drum sounds
// var drumFileNames = ['high_conga', 'small_cowbell', 'snare_drum', 'splash cymbal']; // var drumFileNames = ['high_conga', 'small_cowbell',
// 'snare_drum', 'splash cymbal'];
// this.drumSamplers = this._loadSoundFiles(drumFileNames); // this.drumSamplers = this._loadSoundFiles(drumFileNames);
// sound urls - map each url to its tone.sampler // sound urls - map each url to its tone.sampler
@ -27,14 +28,18 @@ function AudioEngine () {
// soundfont setup // soundfont setup
// instrument names used by Musyng Kite soundfont, in order to match scratch instruments // instrument names used by Musyng Kite soundfont, in order to
this.instrumentNames = ['acoustic_grand_piano', 'electric_piano_1', 'drawbar_organ', 'acoustic_guitar_nylon', // match scratch instruments
'electric_guitar_clean', 'acoustic_bass', 'pizzicato_strings', 'cello', 'trombone', 'clarinet']; this.instrumentNames = ['acoustic_grand_piano', 'electric_piano_1',
'drawbar_organ', 'acoustic_guitar_nylon', 'electric_guitar_clean',
'acoustic_bass', 'pizzicato_strings', 'cello', 'trombone', 'clarinet'];
Soundfont.instrument(Tone.context, this.instrumentNames[0]).then(function (inst) { Soundfont.instrument(Tone.context, this.instrumentNames[0]).then(
this.instrument = inst; function (inst) {
this.instrument.connect(Tone.Master); this.instrument = inst;
}.bind(this)); this.instrument.connect(Tone.Master);
}.bind(this)
);
} }
AudioEngine.prototype.playSound = function (soundNum) { AudioEngine.prototype.playSound = function (soundNum) {
@ -63,7 +68,9 @@ AudioEngine.prototype.getSoundDuration = function (url) {
}; };
AudioEngine.prototype.playNoteForBeats = function(note, beats) { AudioEngine.prototype.playNoteForBeats = function(note, beats) {
this.instrument.play(note, Tone.context.currentTime, {duration : Number(beats)}); this.instrument.play(
note, Tone.context.currentTime, {duration : Number(beats)}
);
}; };
AudioEngine.prototype.playDrumForBeats = function(drumNum, beats) { AudioEngine.prototype.playDrumForBeats = function(drumNum, beats) {