Make kabelsalat stereo out
This commit is contained in:
parent
bbe95b3995
commit
7bc8576a68
2 changed files with 13 additions and 5 deletions
|
|
@ -613,7 +613,7 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
|
||||||
|
|
||||||
// Kabelsalat
|
// Kabelsalat
|
||||||
if (fx.workletSrc !== undefined) {
|
if (fx.workletSrc !== undefined) {
|
||||||
const workletNode = getWorklet(ac, 'generic-processor', {});
|
const workletNode = getWorklet(ac, 'generic-processor', {}, { outputChannelCount: [2] });
|
||||||
chain.connect(workletNode);
|
chain.connect(workletNode);
|
||||||
const workletSrc = fx.workletSrc
|
const workletSrc = fx.workletSrc
|
||||||
.replace(/\bpat\[(\d+)\]/g, (_, i) => fx.workletInputs[i])
|
.replace(/\bpat\[(\d+)\]/g, (_, i) => fx.workletInputs[i])
|
||||||
|
|
|
||||||
|
|
@ -1540,12 +1540,20 @@ class GenericProcessor extends AudioWorkletProcessor {
|
||||||
this.gateNode?.setValue(0);
|
this.gateNode?.setValue(0);
|
||||||
this.gateEnded = true;
|
this.gateEnded = true;
|
||||||
}
|
}
|
||||||
const outL = outputs[0][0];
|
const output = outputs[0];
|
||||||
const outR = outputs[0][1] ?? outputs[0][0];
|
const outL = output[0];
|
||||||
|
const outR = output[1];
|
||||||
for (let n = 0; n < blockSize; n++) {
|
for (let n = 0; n < blockSize; n++) {
|
||||||
this.genSample(this.playPos, this.nodes, input ? input[n] : 0, this.registers, this.outputs, this.sources);
|
this.genSample(this.playPos, this.nodes, input ? input[n] : 0, this.registers, this.outputs, this.sources);
|
||||||
outL[n] = this.outputs[0];
|
const left = this.outputs[0];
|
||||||
outR[n] = this.outputs[1];
|
const right = this.outputs[1];
|
||||||
|
// Spread to stereo if possible; else mixdown to mono
|
||||||
|
if (outR) {
|
||||||
|
outL[n] = left;
|
||||||
|
outR[n] = right;
|
||||||
|
} else {
|
||||||
|
outL[n] = 0.5 * (left + right);
|
||||||
|
}
|
||||||
this.playPos += 1 / sampleRate;
|
this.playPos += 1 / sampleRate;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue