From 5ed28d6168b8d323ed64efa049c0feb285d73678 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Mon, 31 Mar 2025 00:17:26 -0400 Subject: [PATCH 01/59] gain curve func --- packages/superdough/helpers.mjs | 4 ++-- packages/superdough/superdough.mjs | 24 ++++++++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/packages/superdough/helpers.mjs b/packages/superdough/helpers.mjs index e51156fec..2ad1567c5 100644 --- a/packages/superdough/helpers.mjs +++ b/packages/superdough/helpers.mjs @@ -1,9 +1,9 @@ -import { getAudioContext } from './superdough.mjs'; +import { getAudioContext } from './superdough.mjs'; import { clamp, nanFallback } from './util.mjs'; export function gainNode(value) { const node = getAudioContext().createGain(); - node.gain.value = value; + node.gain.value = value return node; } diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index fc81f565e..a9372ca1d 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -20,6 +20,16 @@ export function registerSound(key, onTrigger, data = {}) { soundMap.setKey(key.toLowerCase(), { onTrigger, data }); } +let gainCurveFunc = (val) => Math.pow(val,2) + +export function applyGainCurve(val) { + return gainCurveFunc(val) +} + +export function setGainCurve(newGainCurveFunc) { + gainCurveFunc = newGainCurveFunc +} + function aliasBankMap(aliasMap) { // Make all bank keys lower case for case insensitivity for (const key in aliasMap) { @@ -87,7 +97,7 @@ export function getSound(s) { const defaultDefaultValues = { s: 'triangle', - gain: 0.8, + gain: 1, postgain: 1, density: '.03', ftype: '12db', @@ -471,12 +481,17 @@ export const superdough = async (value, t, hapDuration) => { compressorRelease, } = value; - gain = nanFallback(gain, 1); + gain = applyGainCurve(nanFallback(gain, 1)); + postgain = applyGainCurve(postgain) + shapevol = applyGainCurve(shapevol) + distortvol = applyGainCurve(distortvol) + delay = applyGainCurve(delay) + velocity = applyGainCurve(velocity) + //music programs/audio gear usually increments inputs/outputs from 1, so imitate that behavior channels = (Array.isArray(channels) ? channels : [channels]).map((ch) => ch - 1); - gain *= velocity; // velocity currently only multiplies with gain. it might do other things in the future let toDisconnect = []; // audio nodes that will be disconnected when the source has ended const onended = () => { toDisconnect.forEach((n) => n?.disconnect()); @@ -516,6 +531,7 @@ export const superdough = async (value, t, hapDuration) => { // gain stage chain.push(gainNode(gain)); + chain.push(gainNode(.8 * velocity)) //filter const ftype = getFilterType(value.ftype); @@ -616,7 +632,7 @@ export const superdough = async (value, t, hapDuration) => { } // last gain - const post = new GainNode(ac, { gain: postgain }); + const post = new GainNode(ac, { gain:postgain }); chain.push(post); connectToDestination(post, channels); From 999c0b23495583a96c89cea6d787390a8d40ad0b Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Mon, 31 Mar 2025 00:21:01 -0400 Subject: [PATCH 02/59] lint --- packages/superdough/helpers.mjs | 4 ++-- packages/superdough/superdough.mjs | 21 ++++++++++----------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/superdough/helpers.mjs b/packages/superdough/helpers.mjs index 2ad1567c5..e51156fec 100644 --- a/packages/superdough/helpers.mjs +++ b/packages/superdough/helpers.mjs @@ -1,9 +1,9 @@ -import { getAudioContext } from './superdough.mjs'; +import { getAudioContext } from './superdough.mjs'; import { clamp, nanFallback } from './util.mjs'; export function gainNode(value) { const node = getAudioContext().createGain(); - node.gain.value = value + node.gain.value = value; return node; } diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index a9372ca1d..d2c825ab7 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -20,14 +20,14 @@ export function registerSound(key, onTrigger, data = {}) { soundMap.setKey(key.toLowerCase(), { onTrigger, data }); } -let gainCurveFunc = (val) => Math.pow(val,2) +let gainCurveFunc = (val) => Math.pow(val, 2); export function applyGainCurve(val) { - return gainCurveFunc(val) + return gainCurveFunc(val); } export function setGainCurve(newGainCurveFunc) { - gainCurveFunc = newGainCurveFunc + gainCurveFunc = newGainCurveFunc; } function aliasBankMap(aliasMap) { @@ -482,12 +482,11 @@ export const superdough = async (value, t, hapDuration) => { } = value; gain = applyGainCurve(nanFallback(gain, 1)); - postgain = applyGainCurve(postgain) - shapevol = applyGainCurve(shapevol) - distortvol = applyGainCurve(distortvol) - delay = applyGainCurve(delay) - velocity = applyGainCurve(velocity) - + postgain = applyGainCurve(postgain); + shapevol = applyGainCurve(shapevol); + distortvol = applyGainCurve(distortvol); + delay = applyGainCurve(delay); + velocity = applyGainCurve(velocity); //music programs/audio gear usually increments inputs/outputs from 1, so imitate that behavior channels = (Array.isArray(channels) ? channels : [channels]).map((ch) => ch - 1); @@ -531,7 +530,7 @@ export const superdough = async (value, t, hapDuration) => { // gain stage chain.push(gainNode(gain)); - chain.push(gainNode(.8 * velocity)) + chain.push(gainNode(0.8 * velocity)); //filter const ftype = getFilterType(value.ftype); @@ -632,7 +631,7 @@ export const superdough = async (value, t, hapDuration) => { } // last gain - const post = new GainNode(ac, { gain:postgain }); + const post = new GainNode(ac, { gain: postgain }); chain.push(post); connectToDestination(post, channels); From 3dae2a80ab113b484664abdced52beeef2e55937 Mon Sep 17 00:00:00 2001 From: hpunq <128979576+hpunq@users.noreply.github.com> Date: Thu, 24 Apr 2025 13:51:44 +0100 Subject: [PATCH 03/59] change import sounds label to import sounds folder --- website/src/repl/components/panel/ImportSoundsButton.jsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/website/src/repl/components/panel/ImportSoundsButton.jsx b/website/src/repl/components/panel/ImportSoundsButton.jsx index 7862b7669..b668cba61 100644 --- a/website/src/repl/components/panel/ImportSoundsButton.jsx +++ b/website/src/repl/components/panel/ImportSoundsButton.jsx @@ -21,8 +21,9 @@ export default function ImportSoundsButton({ onComplete }) { return ( ); } From 759cdb627673f6883150b108fc3733e677bf624b Mon Sep 17 00:00:00 2001 From: hpunq <128979576+hpunq@users.noreply.github.com> Date: Thu, 24 Apr 2025 13:53:42 +0100 Subject: [PATCH 04/59] add new import sounds tab with explanation and hyperlinks --- .../src/repl/components/panel/SoundsTab.jsx | 58 ++++++++++++++++++- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/website/src/repl/components/panel/SoundsTab.jsx b/website/src/repl/components/panel/SoundsTab.jsx index c91721e00..4c88e8ae0 100644 --- a/website/src/repl/components/panel/SoundsTab.jsx +++ b/website/src/repl/components/panel/SoundsTab.jsx @@ -14,6 +14,8 @@ export function SoundsTab() { const sounds = useStore(soundMap); const { soundsFilter } = useSettings(); const [search, setSearch] = useState(''); + const { BASE_URL } = import.meta.env; + const baseNoTrailing = BASE_URL.endsWith('/') ? BASE_URL.slice(0, -1) : BASE_URL; const soundEntries = useMemo(() => { if (!sounds) { @@ -37,6 +39,9 @@ export function SoundsTab() { if (soundsFilter === 'synths') { return filtered.filter(([_, { data }]) => ['synth', 'soundfont'].includes(data.type)); } + if (soundsFilter === 'importSounds') { + return []; + } return filtered; }, [sounds, soundsFilter, search]); @@ -51,7 +56,6 @@ export function SoundsTab() { ref?.stop(getAudioContext().currentTime + 0.01); }); }); - return (
setSearch(v)} /> @@ -65,9 +69,9 @@ export function SoundsTab() { drums: 'drum-machines', synths: 'Synths', user: 'User', + importSounds: 'import-sounds', }} > - settingsMap.setKey('soundsFilter', 'user')} />
@@ -101,7 +105,55 @@ export function SoundsTab() { ); })} - {!soundEntries.length ? 'No custom sounds loaded in this pattern (yet).' : ''} + {!soundEntries.length && soundsFilter === 'importSounds' ? ( +
+ settingsMap.setKey('soundsFilter', 'user')} /> +

+ To import sounds into strudel, they must be contained{' '} + + within a folder or subfolder + + . The best way to do this is to upload a “samples” folder containing subfolders of individual sounds or + soundbanks (see diagram below).{' '} +

+
+              {`└─ samples <-- import this folder
+   ├─ swoop
+   │  ├─ swoopshort.wav
+   │  ├─ swooplong.wav
+   │  └─ swooptight.wav
+   └─ smash
+      ├─ smashhigh.wav
+      ├─ smashlow.wav
+      └─ smashmiddle.wav`}
+            
+

+ The name of a subfolder corresponds to the sound name under the “user” tab. Multiple samples within a + subfolder are all labelled with the same name, but can be accessed using “.n( )” - remember sounds are + zero-indexed and in alphabetical order! +

+

+ For more information, and other ways to use your own sounds in strudel,{' '} + + check out the docs + + ! +

+

Preview Sounds

+
+              n("0 1 2 3 4 5").s("sample-name")
+            
+

+ Paste the line above into the main editor to hear the uploaded folder. Remember to use the name of your + sample as it appears under the "user" tab. +

+
+ ) : ( + '' + )} + {!soundEntries.length && soundsFilter !== 'importSounds' + ? 'No custom sounds loaded in this pattern (yet).' + : ''}
); From f539930509ec7c108f346c66534b54c0f2bc611b Mon Sep 17 00:00:00 2001 From: hpunq <128979576+hpunq@users.noreply.github.com> Date: Sat, 26 Apr 2025 01:04:11 +0100 Subject: [PATCH 05/59] formatted code with prettier --- website/src/repl/components/panel/ImportSoundsButton.jsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/website/src/repl/components/panel/ImportSoundsButton.jsx b/website/src/repl/components/panel/ImportSoundsButton.jsx index b668cba61..999bbf69c 100644 --- a/website/src/repl/components/panel/ImportSoundsButton.jsx +++ b/website/src/repl/components/panel/ImportSoundsButton.jsx @@ -21,8 +21,7 @@ export default function ImportSoundsButton({ onComplete }) { return (