memory leaking

This commit is contained in:
Jade (Rose) Rowland 2024-05-05 23:54:30 -04:00
parent 3159f66560
commit 7df663e87d
3 changed files with 37 additions and 14 deletions

View file

@ -324,7 +324,7 @@ export const superdough = async (value, t, hapDuration, cps, cycle) => {
phasercenter,
//
coarse,
gainmod,
am,
crush,
shape,
@ -474,11 +474,12 @@ export const superdough = async (value, t, hapDuration, cps, cycle) => {
crush !== undefined && chain.push(getWorklet(ac, 'crush-processor', { crush }));
shape !== undefined && chain.push(getWorklet(ac, 'shape-processor', { shape, postgain: shapevol }));
distort !== undefined && chain.push(getWorklet(ac, 'distort-processor', { distort, postgain: distortvol }));
gainmod !== undefined &&
am !== undefined &&
chain.push(
getWorklet(ac, 'gainmod-processor', {
speed: gainmod,
// depth: amdepth, shape: amshape,
getWorklet(ac, 'am-processor', {
speed: am,
depth: amdepth,
// shape: amshape,
cps,
cycle,

View file

@ -128,14 +128,14 @@ class CrushProcessor extends AudioWorkletProcessor {
}
registerProcessor('crush-processor', CrushProcessor);
class GainModProcessor extends AudioWorkletProcessor {
class AMProcessor extends AudioWorkletProcessor {
static get parameterDescriptors() {
return [
{ name: 'cps', defaultValue: 0.5 },
{ name: 'speed', defaultValue: 0.5 },
{ name: 'cycle', defaultValue: 0 },
// { name: 'shape', defaultValue: 'tri' },
// { name: 'depth', defaultValue: 1 },
{ name: 'depth', defaultValue: 1 },
];
}
@ -155,6 +155,7 @@ class GainModProcessor extends AudioWorkletProcessor {
const speed = parameters['speed'][0];
const cps = parameters['cps'][0];
const cycle = parameters['cycle'][0];
const depth = clamp(parameters['depth'][0], 0, 1);
const blockSize = 128;
const frequency = speed * cps;
@ -169,7 +170,7 @@ class GainModProcessor extends AudioWorkletProcessor {
const dt = frequency / sampleRate;
for (let n = 0; n < blockSize; n++) {
for (let i = 0; i < input.length; i++) {
const modval = waveshapes.tri(this.phase, 0.99);
const modval = waveshapes.tri(this.phase, 0.99) * depth + (1 - depth);
output[i][n] = input[i][n] * modval;
}
@ -178,7 +179,7 @@ class GainModProcessor extends AudioWorkletProcessor {
return true;
}
}
registerProcessor('gainmod-processor', GainModProcessor);
registerProcessor('am-processor', AMProcessor);
class ShapeProcessor extends AudioWorkletProcessor {
static get parameterDescriptors() {