Use static getters for echo params

This commit is contained in:
Eric Rosenbaum committed 2019-07-22 15:07:34 -04:00
1 parent 3823dd0629
commit e74255cf10
2 files changed
+10 -5

No files matched your search

+2 -2
View File
@@ -38,7 +38,7 @@ class AudioEffects {
this.playbackRate = 1;
switch (name) {
case effectTypes.ECHO:
sampleCount = Math.max(sampleCount, Math.floor((this.trimEndSeconds + 0.75) * buffer.sampleRate));
sampleCount = Math.max(sampleCount, Math.floor((this.trimEndSeconds + EchoEffect.TAIL_SECONDS) * buffer.sampleRate));
break;
case effectTypes.FASTER:
this.playbackRate = pitchRatio;
@@ -115,7 +115,7 @@ class AudioEffects {
this.adjustedTrimStartSeconds, this.adjustedTrimEndSeconds));
break;
case effectTypes.ECHO:
({input, output} = new EchoEffect(this.audioContext, 0.25,
({input, output} = new EchoEffect(this.audioContext,
this.adjustedTrimStartSeconds, this.adjustedTrimEndSeconds));
break;
case effectTypes.ROBOT:
+8 -3
View File
@@ -1,7 +1,12 @@
class EchoEffect {
constructor (audioContext, delayTime, startTime, endTime) {
static get DELAY_TIME () {
return 0.25;
}
static get TAIL_SECONDS () {
return 0.75;
}
constructor (audioContext, startTime, endTime) {
this.audioContext = audioContext;
this.delayTime = delayTime;
this.input = this.audioContext.createGain();
this.output = this.audioContext.createGain();
@@ -12,7 +17,7 @@ class EchoEffect {
this.effectInput.gain.setValueAtTime(0, endTime);
this.delay = this.audioContext.createDelay(1);
this.delay.delayTime.value = delayTime;
this.delay.delayTime.value = EchoEffect.DELAY_TIME;
this.decay = this.audioContext.createGain();
this.decay.gain.value = 0.3;