mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
lint
This commit is contained in:
parent
7b179546ed
commit
80764f053d
1 changed files with 22 additions and 15 deletions
|
@ -5,11 +5,11 @@ function AudioEngine () {
|
||||||
|
|
||||||
// tone setup
|
// tone setup
|
||||||
|
|
||||||
this.tone = new Tone();
|
this.tone = new Tone();
|
||||||
|
|
||||||
// effects setup
|
// effects setup
|
||||||
|
|
||||||
this.delay = new Tone.FeedbackDelay(0.25, 0.5);
|
this.delay = new Tone.FeedbackDelay(0.25, 0.5);
|
||||||
this.panner = new Tone.Panner();
|
this.panner = new Tone.Panner();
|
||||||
this.reverb = new Tone.Freeverb();
|
this.reverb = new Tone.Freeverb();
|
||||||
|
|
||||||
|
@ -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) {
|
||||||
|
@ -48,7 +53,7 @@ AudioEngine.prototype.playSoundFromUrl = function (url) {
|
||||||
// this.soundSamplers[url].triggerAttack();
|
// this.soundSamplers[url].triggerAttack();
|
||||||
this.soundSamplers[url].player.start();
|
this.soundSamplers[url].player.start();
|
||||||
} else {
|
} else {
|
||||||
// else load, play, and store it
|
// else load, play, and store it
|
||||||
// this results in a delay the first time you play the sound
|
// this results in a delay the first time you play the sound
|
||||||
var sampler = new Tone.Sampler(url, function() {
|
var sampler = new Tone.Sampler(url, function() {
|
||||||
sampler.triggerAttack();
|
sampler.triggerAttack();
|
||||||
|
@ -63,11 +68,13 @@ 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) {
|
||||||
this.drumSamplers[drumNum].triggerAttack();
|
this.drumSamplers[drumNum].triggerAttack();
|
||||||
};
|
};
|
||||||
|
|
||||||
AudioEngine.prototype.stopAllSounds = function() {
|
AudioEngine.prototype.stopAllSounds = function() {
|
||||||
|
@ -119,7 +126,7 @@ AudioEngine.prototype.changeEffect = function(effect, value) {
|
||||||
// this.pitchShift.pitch += value / 20;
|
// this.pitchShift.pitch += value / 20;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioEngine.prototype._setPitchShift = function(value) {
|
AudioEngine.prototype._setPitchShift = function(value) {
|
||||||
for (var i in this.soundSamplers) {
|
for (var i in this.soundSamplers) {
|
||||||
|
@ -141,7 +148,7 @@ AudioEngine.prototype.loadSoundFromUrl = function(url) {
|
||||||
|
|
||||||
AudioEngine.prototype._loadSoundFiles = function(filenames) {
|
AudioEngine.prototype._loadSoundFiles = function(filenames) {
|
||||||
var samplers = [];
|
var samplers = [];
|
||||||
|
|
||||||
for (name in filenames) {
|
for (name in filenames) {
|
||||||
var sampler = new Tone.Sampler('sounds/' + name + '.mp3').toMaster();
|
var sampler = new Tone.Sampler('sounds/' + name + '.mp3').toMaster();
|
||||||
samplers.push(sampler);
|
samplers.push(sampler);
|
||||||
|
|
Loading…
Reference in a new issue