Skip to content

Commit

Permalink
add pregain + move postgain after sends
Browse files Browse the repository at this point in the history
  • Loading branch information
felixroos committed Jan 12, 2024
1 parent a053f40 commit 751c4b7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
7 changes: 6 additions & 1 deletion packages/core/controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ const generic_params = [
*/
['gain'],
/**
* Gain applied after all effects have been processed.
* Gain applied before effect sends (delay, reverb ...)
*
*/
['pregain'],
/**
* Gain applied after effect sends (delay, reverb ...)
*
* @name postgain
* @example
Expand Down
21 changes: 14 additions & 7 deletions packages/superdough/superdough.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ export const superdough = async (value, deadline, hapDuration) => {
bank,
source,
gain = 0.8,
postgain = 1,
pregain = 1,
postgain,
density = 0.03,
// filters
ftype = '12db',
Expand Down Expand Up @@ -470,16 +471,15 @@ export const superdough = async (value, deadline, hapDuration) => {
chain.push(phaserFX);
}

// last gain
const post = new GainNode(ac, { gain: postgain });
chain.push(post);
connectToDestination(post, channels);
// pre fx gain
const pre = new GainNode(ac, { gain: pregain });
chain.push(pre);

// delay
let delaySend;
if (delay > 0 && delaytime > 0 && delayfeedback > 0) {
const delyNode = getDelay(orbit, delaytime, delayfeedback, t);
delaySend = effectSend(post, delyNode, delay);
delaySend = effectSend(pre, delyNode, delay);
}
// reverb
let reverbSend;
Expand All @@ -496,9 +496,16 @@ export const superdough = async (value, deadline, hapDuration) => {
roomIR = await loadBuffer(url, ac, ir, 0);
}
const reverbNode = getReverb(orbit, roomsize, roomfade, roomlp, roomdim, roomIR);
reverbSend = effectSend(post, reverbNode, room);
reverbSend = effectSend(pre, reverbNode, room);
}

let post = pre;
if (postgain !== undefined) {
// post fx gain
post = new GainNode(ac, { gain: postgain });
chain.push(post);
}
connectToDestination(post, channels);
// analyser
let analyserSend;
if (analyze) {
Expand Down

0 comments on commit 751c4b7

Please sign in to comment.