Compare commits

...

1 Commits

Author SHA1 Message Date
Felix Roos 297ade42fc add gainpre + gainpost for effect sends 2023-02-23 21:11:33 +01:00
2 changed files with 12 additions and 5 deletions
+2
View File
@@ -78,6 +78,8 @@ const generic_params = [
'gain', 'gain',
'a pattern of numbers that specify volume. Values less than 1 make the sound quieter. Values greater than 1 make the sound louder. For the linear equivalent, see @amp@.', 'a pattern of numbers that specify volume. Values less than 1 make the sound quieter. Values greater than 1 make the sound louder. For the linear equivalent, see @amp@.',
], ],
['f', 'gainpre'],
['f', 'gainpost'],
/** /**
* Like {@link gain}, but linear. * Like {@link gain}, but linear.
* *
+10 -5
View File
@@ -219,6 +219,8 @@ export const webaudioOutput = async (hap, deadline, hapDuration) => {
n = 0, n = 0,
note, note,
gain = 0.8, gain = 0.8,
gainpost = 1,
gainpre = 1,
// low pass // low pass
lpf, lpf,
cutoff = lpf, cutoff = lpf,
@@ -373,23 +375,26 @@ export const webaudioOutput = async (hap, deadline, hapDuration) => {
} }
// last gain // last gain
const post = gainNode(1); const pre = gainNode(gainpre);
chain.push(post); chain.push(pre);
post.connect(getDestination());
// delay // delay
let delaySend; let delaySend;
if (delay > 0 && delaytime > 0 && delayfeedback > 0) { if (delay > 0 && delaytime > 0 && delayfeedback > 0) {
const delyNode = getDelay(orbit, delaytime, delayfeedback, t); const delyNode = getDelay(orbit, delaytime, delayfeedback, t);
delaySend = effectSend(post, delyNode, delay); delaySend = effectSend(pre, delyNode, delay);
} }
// reverb // reverb
let reverbSend; let reverbSend;
if (room > 0 && roomsize > 0) { if (room > 0 && roomsize > 0) {
const reverbNode = getReverb(orbit, roomsize); const reverbNode = getReverb(orbit, roomsize);
reverbSend = effectSend(post, reverbNode, room); reverbSend = effectSend(pre, reverbNode, room);
} }
const post = gainNode(gainpost);
chain.push(post);
post.connect(getDestination());
// connect chain elements together // connect chain elements together
chain.slice(1).reduce((last, current) => last.connect(current), chain[0]); chain.slice(1).reduce((last, current) => last.connect(current), chain[0]);