Skip to content
Snippets Groups Projects
Commit a3a6c725 authored by Paul Kaplan's avatar Paul Kaplan
Browse files

Adjust sound effects to playtest levels

parent e356c173
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,7 @@ class AudioEffects { ...@@ -19,6 +19,7 @@ class AudioEffects {
constructor (buffer, name) { constructor (buffer, name) {
// Some effects will modify the playback rate and/or number of samples. // Some effects will modify the playback rate and/or number of samples.
// Need to precompute those values to create the offline audio context. // Need to precompute those values to create the offline audio context.
const pitchRatio = Math.pow(2, 4 / 12); // A major third
let sampleCount = buffer.length; let sampleCount = buffer.length;
let playbackRate = 1; let playbackRate = 1;
switch (name) { switch (name) {
...@@ -26,11 +27,11 @@ class AudioEffects { ...@@ -26,11 +27,11 @@ class AudioEffects {
sampleCount = buffer.length + 0.25 * 3 * buffer.sampleRate; sampleCount = buffer.length + 0.25 * 3 * buffer.sampleRate;
break; break;
case effectTypes.FASTER: case effectTypes.FASTER:
playbackRate = 1.5; playbackRate = pitchRatio;
sampleCount = Math.floor(buffer.length / playbackRate); sampleCount = Math.floor(buffer.length / playbackRate);
break; break;
case effectTypes.SLOWER: case effectTypes.SLOWER:
playbackRate = 0.5; playbackRate = 1 / pitchRatio;
sampleCount = Math.floor(buffer.length / playbackRate); sampleCount = Math.floor(buffer.length / playbackRate);
break; break;
case effectTypes.REVERSE: case effectTypes.REVERSE:
...@@ -51,10 +52,10 @@ class AudioEffects { ...@@ -51,10 +52,10 @@ class AudioEffects {
let output; let output;
switch (this.name) { switch (this.name) {
case effectTypes.LOUDER: case effectTypes.LOUDER:
({input, output} = new VolumeEffect(this.audioContext, 1.5)); ({input, output} = new VolumeEffect(this.audioContext, 1.25));
break; break;
case effectTypes.SOFTER: case effectTypes.SOFTER:
({input, output} = new VolumeEffect(this.audioContext, 0.5)); ({input, output} = new VolumeEffect(this.audioContext, 0.75));
break; break;
case effectTypes.ECHO: case effectTypes.ECHO:
({input, output} = new EchoEffect(this.audioContext, 0.25)); ({input, output} = new EchoEffect(this.audioContext, 0.25));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment