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

View file

@ -19,7 +19,8 @@ function AudioEngine () {
// 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);
// sound urls - map each url to its tone.sampler
@ -27,14 +28,18 @@ function AudioEngine () {
// soundfont setup
// instrument names used by Musyng Kite soundfont, in order to match scratch instruments
this.instrumentNames = ['acoustic_grand_piano', 'electric_piano_1', 'drawbar_organ', 'acoustic_guitar_nylon',
'electric_guitar_clean', 'acoustic_bass', 'pizzicato_strings', 'cello', 'trombone', 'clarinet'];
// instrument names used by Musyng Kite soundfont, in order to
// match scratch instruments
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(
function (inst) {
this.instrument = inst;
this.instrument.connect(Tone.Master);
}.bind(this));
}.bind(this)
);
}
AudioEngine.prototype.playSound = function (soundNum) {
@ -63,7 +68,9 @@ AudioEngine.prototype.getSoundDuration = function (url) {
};
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) {