mirror of
https://codeberg.org/uzu/strudel
synced 2026-08-08 07:38:13 -04:00
memory leaking
This commit is contained in:
@@ -431,16 +431,37 @@ export const { crush } = registerControl('crush');
|
||||
export const { coarse } = registerControl('coarse');
|
||||
|
||||
/**
|
||||
* modulate the output gain of a sound with a continuous wave
|
||||
* modulate the amplitude of a sound with a continuous waveform
|
||||
*
|
||||
* @name gainmod
|
||||
* @param {number | Pattern} factor 1 for original 2 for half, 3 for a third and so on.
|
||||
* @name am
|
||||
* @param {number | Pattern} speed modulation speed in cycles
|
||||
* @example
|
||||
* s("triangle").gainmod("2:1:0")
|
||||
* s("triangle").am("2").amshape("<tri saw ramp square>").amdepth(.5)
|
||||
*
|
||||
*/
|
||||
export const { gainmod } = registerControl('gainmod');
|
||||
export const { am } = registerControl(['am', 'amdepth', 'amshape']);
|
||||
|
||||
/**
|
||||
* depth of amplitude modulation
|
||||
*
|
||||
* @name amdepth
|
||||
* @param {number | Pattern} depth
|
||||
* @example
|
||||
* s("triangle").am(1).amdepth("1")
|
||||
*
|
||||
*/
|
||||
export const { amdepth } = registerControl('amdepth');
|
||||
|
||||
/**
|
||||
* shape of amplitude modulation
|
||||
*
|
||||
* @name amshape
|
||||
* @param {number | Pattern} shape tri | square | sine | saw | ramp
|
||||
* @example
|
||||
* note("{f g c d}%16").am(4).amshape("ramp").s("sawtooth")
|
||||
*
|
||||
*/
|
||||
export const { amshape } = registerControl('amshape');
|
||||
/**
|
||||
* Allows you to set the output channels on the interface
|
||||
*
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user