Skip to content

Commit

Permalink
gswaFxReverb: use gswaReverbIR
Browse files Browse the repository at this point in the history
  • Loading branch information
mr21 committed Dec 7, 2024
1 parent 6a83fb7 commit 88a5a57
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions gswaFxReverb/gswaFxReverb.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class gswaFxReverb {
#convolver = null;
#wetConstant = null; // needed for Chrome (the delayNode seems to stop sending when it stop receiving).
#enable = false;
#updateBufferDeb = GSUdebounce( this.#updateBuffer.bind( this ), 100 );
#data = DAWCoreJSON_effects_reverb();

constructor() {
Expand All @@ -27,6 +28,7 @@ class gswaFxReverb {
$setBPM( bpm ) {
this.#bps = bpm / 60;
this.#changeProp( "delay", this.#data.delay );
this.#updateBufferDeb();
}
$setContext( ctx ) {
if ( this.#ctx ) {
Expand All @@ -47,14 +49,6 @@ class gswaFxReverb {
this.#wetConstant = ctx.createConstantSource();
this.$toggle( this.#enable );
this.$change( this.#data );

fetch( "ir-reverb0_1-1_5-15000-1000.wav" )
.then( res => res.arrayBuffer() )
.then( arr => ctx.decodeAudioData( arr ) )
.then( buf => {
lg( "reverb IR loaded" );
this.#convolver.buffer = buf;
} );
}
$toggle( b ) {
this.#enable = b;
Expand Down Expand Up @@ -99,8 +93,13 @@ class gswaFxReverb {
case "dry": this.#dryGain.gain.setValueAtTime( val, now ); break;
case "wet": this.#wetGain.gain.setValueAtTime( val, now ); break;
case "delay": this.#wetDelay.delayTime.setValueAtTime( val / this.#bps, now ); break;
case "fadein":
case "decay": this.#updateBufferDeb(); break;
}
}
#updateBuffer() {
this.#convolver.buffer = gswaReverbIR.$createIR( this.#ctx, this.#data.fadein / this.#bps, this.#data.decay / this.#bps );
}
}

Object.freeze( gswaFxReverb );

0 comments on commit 88a5a57

Please sign in to comment.