Working version

This commit is contained in:
Aria
2025-12-04 22:12:54 -06:00
parent 5738020ac2
commit 099288545e
4 changed files with 17 additions and 10 deletions
+3 -2
View File
@@ -566,8 +566,9 @@ export const getDistortionAlgorithm = (algo) => {
return distortionAlgorithms[name];
};
export const getDistortion = (distort, postgain, algorithm) => {
return getWorklet(getAudioContext(), 'distort-processor', { distort, postgain }, { processorOptions: { algorithm } });
export const getDistortion = (fullParams) => {
const { algorithm, ...params } = fullParams;
return getPooledWorklet(getAudioContext(), 'distort-processor', params, {}, { algorithm });
};
export const getFrequencyFromValue = (value, defaultNote = 36) => {
+11 -5
View File
@@ -539,7 +539,10 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
}
const chain = []; // audio nodes that will be connected to each other sequentially
chain.push(sourceNode);
stretch !== undefined && chain.push(getPooledWorklet(ac, 'phase-vocoder-processor', { pitchFactor: stretch }));
stretch !== undefined &&
chain.push(
getPooledWorklet(ac, 'phase-vocoder-processor', { pitchFactor: stretch, begin: t, end: endWithRelease }),
);
// gain stage
chain.push(gainNode(gain));
@@ -652,10 +655,13 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
}
// effects
coarse !== undefined && chain.push(getPooledWorklet(ac, 'coarse-processor', { coarse }));
crush !== undefined && chain.push(getPooledWorklet(ac, 'crush-processor', { crush }));
shape !== undefined && chain.push(getPooledWorklet(ac, 'shape-processor', { shape, postgain: shapevol }));
distort !== undefined && chain.push(getDistortion(distort, distortvol, distorttype));
coarse !== undefined &&
chain.push(getPooledWorklet(ac, 'coarse-processor', { coarse, begin: t, end: endWithRelease }));
crush !== undefined && chain.push(getPooledWorklet(ac, 'crush-processor', { crush, begin: t, end: endWithRelease }));
shape !== undefined &&
chain.push(getPooledWorklet(ac, 'shape-processor', { shape, postgain: shapevol, begin: t, end: endWithRelease }));
distort !== undefined &&
chain.push(getDistortion({ distort, postgain: distortvol, algorithm: distorttype, begin: t, end: endWithRelease }));
if (tremolosync != null) {
tremolo = cps * tremolosync;
-1
View File
@@ -41,7 +41,6 @@ export const makeReusable = (Base) =>
this.handlePortMessage(type, payload, e);
}
};
this.initialize();
}
initialize(_options) {
+3 -2
View File
@@ -476,7 +476,7 @@ function genHannWindow(length) {
class PhaseVocoderProcessor extends OLAProcessor {
static get parameterDescriptors() {
return [{ name: 'pitchFactor', defaultValue: 1.0 }];
return [...super.parameterDescriptors, { name: 'pitchFactor', defaultValue: 1.0 }];
}
constructor(options) {
@@ -488,7 +488,8 @@ class PhaseVocoderProcessor extends OLAProcessor {
this.invfftSize = 1 / this.fftSize;
}
initialize(_options) {
initialize(options) {
super.initialize(options);
this.timeCursor = 0;
this.hannWindow = genHannWindow(this.fftSize);
// prepare FFT and pre-allocate buffers