This commit is contained in:
Eric Rosenbaum 2016-10-13 11:48:31 -04:00
parent e084a76485
commit d808a83f79

View file

@ -73,18 +73,18 @@ AudioEngine.prototype.playNoteForBeats = function(note, beats) {
); );
}; };
AudioEngine.prototype.playDrumForBeats = function(drumNum, beats) { AudioEngine.prototype.playDrumForBeats = function(drumNum) {
this.drumSamplers[drumNum].triggerAttack(); this.drumSamplers[drumNum].triggerAttack();
}; };
AudioEngine.prototype.stopAllSounds = function() { AudioEngine.prototype.stopAllSounds = function() {
// stop drum notes // stop drum notes
for (var i=0; i<this.drumSamplers.length; i++) { // for (var i = 0; i<this.drumSamplers.length; i++) {
this.drumSamplers[i].triggerRelease(); // this.drumSamplers[i].triggerRelease();
} // }
// stop sounds triggered with playSound (indexed by their urls) // stop sounds triggered with playSound (indexed by their urls)
for (var i in this.soundSamplers) { for (var key in this.soundSamplers) {
this.soundSamplers[i].triggerRelease(); this.soundSamplers[key].triggerRelease();
} }
// stop soundfont notes // stop soundfont notes
this.instrument.stop(); this.instrument.stop();
@ -93,7 +93,7 @@ AudioEngine.prototype.stopAllSounds = function() {
AudioEngine.prototype.setEffect = function(effect, value) { AudioEngine.prototype.setEffect = function(effect, value) {
switch (effect) { switch (effect) {
case 'ECHO': case 'ECHO':
this.delay.wet.value = (value / 100) / 2; // max 50% wet (need dry signal too) this.delay.wet.value = (value / 100) / 2; // max 50% wet
break; break;
case 'PAN': case 'PAN':
this.panner.pan.value = value / 100; this.panner.pan.value = value / 100;
@ -102,16 +102,15 @@ AudioEngine.prototype.setEffect = function(effect, value) {
this.reverb.wet.value = value / 100; this.reverb.wet.value = value / 100;
break; break;
case 'PITCH': case 'PITCH':
// this.pitchShift.pitch = value / 20; // arbitrary scaling of 20 per semitone, for now... default 100 is a perfect fourth
this._setPitchShift(value / 20); this._setPitchShift(value / 20);
break; break;
} }
} };
AudioEngine.prototype.changeEffect = function(effect, value) { AudioEngine.prototype.changeEffect = function(effect, value) {
switch (effect) { switch (effect) {
case 'ECHO': case 'ECHO':
this.delay.wet.value += (value / 100) / 2; // max 50% wet (need dry signal too) this.delay.wet.value += (value / 100) / 2; // max 50% wet
this.delay.wet.value = this._clamp(this.delay.wet.value, 0, 0.5); this.delay.wet.value = this._clamp(this.delay.wet.value, 0, 0.5);
break; break;
case 'PAN': case 'PAN':
@ -126,7 +125,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) {
@ -142,9 +141,9 @@ AudioEngine.prototype.clearEffects = function() {
this.reverb.wet.value = 0; this.reverb.wet.value = 0;
}; };
AudioEngine.prototype.loadSoundFromUrl = function(url) { // AudioEngine.prototype.loadSoundFromUrl = function(url) {
}; // };
AudioEngine.prototype._loadSoundFiles = function(filenames) { AudioEngine.prototype._loadSoundFiles = function(filenames) {
var samplers = []; var samplers = [];
@ -157,11 +156,6 @@ AudioEngine.prototype._loadSoundFiles = function(filenames) {
return samplers; return samplers;
}; };
AudioEngine.prototype._midiToFreq = function(midiNote) {
var freq = this.tone.intervalToFrequencyRatio(midiNote - 60) * 261.63; // 60 is C4
return freq;
};
AudioEngine.prototype._clamp = function(input, min, max) { AudioEngine.prototype._clamp = function(input, min, max) {
return Math.min(Math.max(input, min), max); return Math.min(Math.max(input, min), max);
}; };