From 88a5a57b4aa55cc21baf6eb194042fe8ac235aaf Mon Sep 17 00:00:00 2001 From: mr21 Date: Sat, 7 Dec 2024 06:43:11 +0100 Subject: [PATCH] gswaFxReverb: use gswaReverbIR --- gswaFxReverb/gswaFxReverb.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/gswaFxReverb/gswaFxReverb.js b/gswaFxReverb/gswaFxReverb.js index ffa9424..88bb107 100644 --- a/gswaFxReverb/gswaFxReverb.js +++ b/gswaFxReverb/gswaFxReverb.js @@ -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() { @@ -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 ) { @@ -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; @@ -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 );