Some cleanup

This commit is contained in:
Aria 2025-09-24 22:17:30 -07:00
parent f0669ce3ba
commit b3537a9acb
2 changed files with 3 additions and 10 deletions

View file

@ -398,16 +398,9 @@ export const getDistortionAlgorithm = (algo) => {
} }
} }
const name = _algoNames[index % _algoNames.length]; // allow for wrapping if algo was a number const name = _algoNames[index % _algoNames.length]; // allow for wrapping if algo was a number
const algorithm = distortionAlgorithms[name]; return distortionAlgorithms[name];
return { algorithm, index };
}; };
export const getDistortion = (distort, postgain, algorithm) => { export const getDistortion = (distort, postgain, algorithm) => {
const { index } = getDistortionAlgorithm(algorithm); return getWorklet(getAudioContext(), 'distort-processor', { distort, postgain }, { processorOptions: { algorithm } });
return getWorklet(
getAudioContext(),
'distort-processor',
{ distort, postgain },
{ processorOptions: { algorithm: index } },
);
}; };

View file

@ -354,7 +354,7 @@ class DistortProcessor extends AudioWorkletProcessor {
constructor({ processorOptions }) { constructor({ processorOptions }) {
super(); super();
this.started = false; this.started = false;
this.algorithm = getDistortionAlgorithm(processorOptions.algorithm).algorithm; this.algorithm = getDistortionAlgorithm(processorOptions.algorithm);
} }
process(inputs, outputs, parameters) { process(inputs, outputs, parameters) {