memory leaking
This commit is contained in:
parent
3159f66560
commit
7df663e87d
3 changed files with 37 additions and 14 deletions
|
|
@ -431,16 +431,37 @@ export const { crush } = registerControl('crush');
|
||||||
export const { coarse } = registerControl('coarse');
|
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
|
* @name am
|
||||||
* @param {number | Pattern} factor 1 for original 2 for half, 3 for a third and so on.
|
* @param {number | Pattern} speed modulation speed in cycles
|
||||||
* @example
|
* @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
|
* Allows you to set the output channels on the interface
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ export const superdough = async (value, t, hapDuration, cps, cycle) => {
|
||||||
phasercenter,
|
phasercenter,
|
||||||
//
|
//
|
||||||
coarse,
|
coarse,
|
||||||
gainmod,
|
am,
|
||||||
crush,
|
crush,
|
||||||
shape,
|
shape,
|
||||||
|
|
||||||
|
|
@ -474,11 +474,12 @@ export const superdough = async (value, t, hapDuration, cps, cycle) => {
|
||||||
crush !== undefined && chain.push(getWorklet(ac, 'crush-processor', { crush }));
|
crush !== undefined && chain.push(getWorklet(ac, 'crush-processor', { crush }));
|
||||||
shape !== undefined && chain.push(getWorklet(ac, 'shape-processor', { shape, postgain: shapevol }));
|
shape !== undefined && chain.push(getWorklet(ac, 'shape-processor', { shape, postgain: shapevol }));
|
||||||
distort !== undefined && chain.push(getWorklet(ac, 'distort-processor', { distort, postgain: distortvol }));
|
distort !== undefined && chain.push(getWorklet(ac, 'distort-processor', { distort, postgain: distortvol }));
|
||||||
gainmod !== undefined &&
|
am !== undefined &&
|
||||||
chain.push(
|
chain.push(
|
||||||
getWorklet(ac, 'gainmod-processor', {
|
getWorklet(ac, 'am-processor', {
|
||||||
speed: gainmod,
|
speed: am,
|
||||||
// depth: amdepth, shape: amshape,
|
depth: amdepth,
|
||||||
|
// shape: amshape,
|
||||||
|
|
||||||
cps,
|
cps,
|
||||||
cycle,
|
cycle,
|
||||||
|
|
|
||||||
|
|
@ -128,14 +128,14 @@ class CrushProcessor extends AudioWorkletProcessor {
|
||||||
}
|
}
|
||||||
registerProcessor('crush-processor', CrushProcessor);
|
registerProcessor('crush-processor', CrushProcessor);
|
||||||
|
|
||||||
class GainModProcessor extends AudioWorkletProcessor {
|
class AMProcessor extends AudioWorkletProcessor {
|
||||||
static get parameterDescriptors() {
|
static get parameterDescriptors() {
|
||||||
return [
|
return [
|
||||||
{ name: 'cps', defaultValue: 0.5 },
|
{ name: 'cps', defaultValue: 0.5 },
|
||||||
{ name: 'speed', defaultValue: 0.5 },
|
{ name: 'speed', defaultValue: 0.5 },
|
||||||
{ name: 'cycle', defaultValue: 0 },
|
{ name: 'cycle', defaultValue: 0 },
|
||||||
// { name: 'shape', defaultValue: 'tri' },
|
// { 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 speed = parameters['speed'][0];
|
||||||
const cps = parameters['cps'][0];
|
const cps = parameters['cps'][0];
|
||||||
const cycle = parameters['cycle'][0];
|
const cycle = parameters['cycle'][0];
|
||||||
|
const depth = clamp(parameters['depth'][0], 0, 1);
|
||||||
|
|
||||||
const blockSize = 128;
|
const blockSize = 128;
|
||||||
const frequency = speed * cps;
|
const frequency = speed * cps;
|
||||||
|
|
@ -169,7 +170,7 @@ class GainModProcessor extends AudioWorkletProcessor {
|
||||||
const dt = frequency / sampleRate;
|
const dt = frequency / sampleRate;
|
||||||
for (let n = 0; n < blockSize; n++) {
|
for (let n = 0; n < blockSize; n++) {
|
||||||
for (let i = 0; i < input.length; i++) {
|
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;
|
output[i][n] = input[i][n] * modval;
|
||||||
}
|
}
|
||||||
|
|
@ -178,7 +179,7 @@ class GainModProcessor extends AudioWorkletProcessor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
registerProcessor('gainmod-processor', GainModProcessor);
|
registerProcessor('am-processor', AMProcessor);
|
||||||
|
|
||||||
class ShapeProcessor extends AudioWorkletProcessor {
|
class ShapeProcessor extends AudioWorkletProcessor {
|
||||||
static get parameterDescriptors() {
|
static get parameterDescriptors() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue