Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions packages/superdough/superdough.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ const defaultDefaultValues = {
density: '.03',
ftype: '12db',
fanchor: 0,
resonance: 1,
hresonance: 1,
bandq: 1,
resonance: 0.183,
hresonance: 0.183,
bandq: 0.183,
channels: [1, 2],
phaserdepth: 0.75,
shapevol: 1,
Expand Down Expand Up @@ -182,6 +182,9 @@ export const getAudioContext = () => {
export function getAudioContextCurrentTime() {
return getAudioContext().currentTime;
}
function applyResonanceCurve(res) {
return Math.min(30.03, Math.pow(res * 5.48, 2));
}

let workletsLoading;
function loadWorklets() {
Expand Down Expand Up @@ -526,6 +529,10 @@ export const superdough = async (value, t, hapDuration) => {
compressorRelease,
} = value;

resonance = applyResonanceCurve(resonance);
hresonance = applyResonanceCurve(hresonance);
bandq = applyResonanceCurve(bandq);

gain = applyGainCurve(nanFallback(gain, 1));
postgain = applyGainCurve(postgain);
shapevol = applyGainCurve(shapevol);
Expand Down
2 changes: 1 addition & 1 deletion packages/superdough/worklets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ class LadderProcessor extends AudioWorkletProcessor {
cutoff = (cutoff * 2 * _PI) / sampleRate;
cutoff = cutoff > 1 ? 1 : cutoff;

const k = Math.min(8, resonance * 0.4);
const k = Math.min(8, resonance * 0.13);
// drive makeup * resonance volume loss makeup
let makeupgain = (1 / drive) * Math.min(1.75, 1 + k);

Expand Down