diff --git a/doc.json b/doc.json
index e8a5beba..9f5f2f29 100644
--- a/doc.json
+++ b/doc.json
@@ -3740,15 +3740,15 @@
"___s": true
},
{
- "comment": "/**\n *\n * Uses [webdirt](https://github.com/dktr0/WebDirt) as output.\n *\n * \n * show supported Webdirt controls
\n *\n * - s :: String, -- name of sample bank\n * - n :: Int, -- number of sample within a bank\n * - {@link gain} :: Number, -- clamped from 0 to 2; 1 is default and full-scale\n * - {@link overgain} :: Number, -- additional gain added to gain to go past clamp at 2\n * - {@link pan} :: Number, -- range: 0 to 1\n * - {@link nudge} :: Number, -- nudge the time of the sample forwards/backwards in seconds\n * - {@link speed} :: Number, -- speed / pitch of the sample\n * - {@link unit} :: String\n * - {@link note} :: Number, -- pitch offset in semitones\n * - {@link begin} :: Number, -- cut from sample start, normalized\n * - {@link end} :: Number, -- cut from sample end, normalized\n * - {@link cut} :: Int, -- samples with same cut number will interupt each other\n * - {@link shape} :: Number,\n * - {@link cutoff} :: Number, -- lowpass filter frequency\n * - {@link resonance} :: Number, -- lowpass filter resonance\n * - {@link hcutoff} :: Number, -- highpass filter frequency\n * - {@link hresonance} :: Number, -- highpass filter resonance\n * - {@link bandf} :: Number, -- bandpass filter frequency\n * - {@link bandq} :: Number, -- bandpass filter resonance\n * - {@link vowel} :: String, -- name of vowel ('a' | 'e' | 'i' | 'o' | 'u')\n * - {@link delay} :: Number, -- delay wet/dry mix\n * - {@link delaytime} :: Number, -- delay time in seconds\n * - {@link delayfeedback} :: Number, -- delay feedback\n * - {@link loop} :: Number, -- loop sample n times (relative to sample length)\n * - {@link crush} :: Number, -- bitcrusher (currently not working)\n * - {@link coarse} :: Number, -- coarse effect (currently not working)\n\n *\n * \n *\n * @name webdirt\n * @memberof Pattern\n * @returns Pattern\n * @example\n * s(\"bd*2 hh sd hh\").n(\"<0 1>\").webdirt()\n */",
+ "comment": "/**\n *\n * Uses [webdirt](https://github.com/dktr0/WebDirt) as output.\n *\n * \n * show supported Webdirt controls
\n *\n * - s :: String, -- name of sample bank\n * - n :: Int, -- number of sample within a bank\n * - {@link gain} :: Number, -- clamped from 0 to 2; 1 is default and full-scale\n * - overgain :: Number, -- additional gain added to gain to go past clamp at 2\n * - {@link pan} :: Number, -- range: 0 to 1\n * - nudge :: Number, -- nudge the time of the sample forwards/backwards in seconds\n * - {@link speed} :: Number, -- speed / pitch of the sample\n * - {@link unit} :: String\n * - note :: Number, -- pitch offset in semitones\n * - {@link begin} :: Number, -- cut from sample start, normalized\n * - {@link end} :: Number, -- cut from sample end, normalized\n * - {@link cut} :: Int, -- samples with same cut number will interupt each other\n * - {@link cutoff} :: Number, -- lowpass filter frequency\n * - {@link resonance} :: Number, -- lowpass filter resonance\n * - {@link hcutoff} :: Number, -- highpass filter frequency\n * - {@link hresonance} :: Number, -- highpass filter resonance\n * - {@link bandf} :: Number, -- bandpass filter frequency\n * - {@link bandq} :: Number, -- bandpass filter resonance\n * - {@link vowel} :: String, -- name of vowel ('a' | 'e' | 'i' | 'o' | 'u')\n * - delay :: Number, -- delay wet/dry mix\n * - delaytime :: Number, -- delay time in seconds\n * - delayfeedback :: Number, -- delay feedback\n * - {@link loop} :: Number, -- loop sample n times (relative to sample length)\n * - {@link crush} :: Number, -- bitcrusher (currently not working)\n * - {@link coarse} :: Number, -- coarse effect (currently not working)\n * - {@link shape} :: Number, -- (currently not working)\n\n *\n * \n *\n * @name webdirt\n * @memberof Pattern\n * @returns Pattern\n * @example\n * s(\"bd*2 hh sd hh\").n(\"<0 1>\").webdirt()\n */",
"meta": {
"filename": "webdirt.mjs",
- "lineno": 19,
+ "lineno": 20,
"columnno": 0,
"path": "/home/felix/projects/strudel/packages/webdirt",
"code": {}
},
- "description": "
Uses webdirt as output.
\n\nshow supported Webdirt controls
\n\n- s :: String, -- name of sample bank
\n- n :: Int, -- number of sample within a bank
\n- {@link gain} :: Number, -- clamped from 0 to 2; 1 is default and full-scale
\n- {@link overgain} :: Number, -- additional gain added to gain to go past clamp at 2
\n- {@link pan} :: Number, -- range: 0 to 1
\n- {@link nudge} :: Number, -- nudge the time of the sample forwards/backwards in seconds
\n- {@link speed} :: Number, -- speed / pitch of the sample
\n- {@link unit} :: String
\n- {@link note} :: Number, -- pitch offset in semitones
\n- {@link begin} :: Number, -- cut from sample start, normalized
\n- {@link end} :: Number, -- cut from sample end, normalized
\n- {@link cut} :: Int, -- samples with same cut number will interupt each other
\n- {@link shape} :: Number,
\n- {@link cutoff} :: Number, -- lowpass filter frequency
\n- {@link resonance} :: Number, -- lowpass filter resonance
\n- {@link hcutoff} :: Number, -- highpass filter frequency
\n- {@link hresonance} :: Number, -- highpass filter resonance
\n- {@link bandf} :: Number, -- bandpass filter frequency
\n- {@link bandq} :: Number, -- bandpass filter resonance
\n- {@link vowel} :: String, -- name of vowel ('a' | 'e' | 'i' | 'o' | 'u')
\n- {@link delay} :: Number, -- delay wet/dry mix
\n- {@link delaytime} :: Number, -- delay time in seconds
\n- {@link delayfeedback} :: Number, -- delay feedback
\n- {@link loop} :: Number, -- loop sample n times (relative to sample length)
\n- {@link crush} :: Number, -- bitcrusher (currently not working)
\n- {@link coarse} :: Number, -- coarse effect (currently not working)
\n
\n ",
+ "description": "Uses webdirt as output.
\n\nshow supported Webdirt controls
\n\n- s :: String, -- name of sample bank
\n- n :: Int, -- number of sample within a bank
\n- {@link gain} :: Number, -- clamped from 0 to 2; 1 is default and full-scale
\n- overgain :: Number, -- additional gain added to gain to go past clamp at 2
\n- {@link pan} :: Number, -- range: 0 to 1
\n- nudge :: Number, -- nudge the time of the sample forwards/backwards in seconds
\n- {@link speed} :: Number, -- speed / pitch of the sample
\n- {@link unit} :: String
\n- note :: Number, -- pitch offset in semitones
\n- {@link begin} :: Number, -- cut from sample start, normalized
\n- {@link end} :: Number, -- cut from sample end, normalized
\n- {@link cut} :: Int, -- samples with same cut number will interupt each other
\n- {@link cutoff} :: Number, -- lowpass filter frequency
\n- {@link resonance} :: Number, -- lowpass filter resonance
\n- {@link hcutoff} :: Number, -- highpass filter frequency
\n- {@link hresonance} :: Number, -- highpass filter resonance
\n- {@link bandf} :: Number, -- bandpass filter frequency
\n- {@link bandq} :: Number, -- bandpass filter resonance
\n- {@link vowel} :: String, -- name of vowel ('a' | 'e' | 'i' | 'o' | 'u')
\n- delay :: Number, -- delay wet/dry mix
\n- delaytime :: Number, -- delay time in seconds
\n- delayfeedback :: Number, -- delay feedback
\n- {@link loop} :: Number, -- loop sample n times (relative to sample length)
\n- {@link crush} :: Number, -- bitcrusher (currently not working)
\n- {@link coarse} :: Number, -- coarse effect (currently not working)
\n- {@link shape} :: Number, -- (currently not working)
\n
\n ",
"name": "webdirt",
"memberof": "Pattern",
"returns": [
@@ -3762,7 +3762,7 @@
"scope": "static",
"longname": "Pattern.webdirt",
"kind": "member",
- "___id": "T000002R004015",
+ "___id": "T000002R004040",
"___s": true
},
{
@@ -3839,6 +3839,7 @@
"/home/felix/projects/strudel/packages/webaudio/scheduler.mjs",
"/home/felix/projects/strudel/packages/webaudio/webaudio.mjs",
"/home/felix/projects/strudel/packages/webdirt/index.mjs",
+ "/home/felix/projects/strudel/packages/webdirt/sampler.mjs",
"/home/felix/projects/strudel/packages/webdirt/webdirt.mjs",
"/home/felix/projects/strudel/packages/xen/index.mjs",
"/home/felix/projects/strudel/packages/xen/test/xen.test.mjs",
@@ -3846,7 +3847,7 @@
"/home/felix/projects/strudel/packages/xen/tunejs.js",
"/home/felix/projects/strudel/packages/xen/xen.mjs"
],
- "___id": "T000002R014031",
+ "___id": "T000002R014063",
"___s": true
}
]
diff --git a/packages/webdirt/sampler.mjs b/packages/webdirt/sampler.mjs
index 7dbc52b6..b50b134e 100644
--- a/packages/webdirt/sampler.mjs
+++ b/packages/webdirt/sampler.mjs
@@ -22,14 +22,16 @@ export const playSample = async (url) => playBuffer(await loadBuffer(url)); */
// Array<{ "url":string, "bank": string, "n": number}>
// ritchse/tidal-drum-machines/tree/main/machines/AkaiLinn
const githubCache = {};
-let loaded;
+let sampleCache = { current: undefined };
export const loadGithubSamples = async (path, nameFn) => {
const storageKey = 'loadGithubSamples ' + path;
const stored = localStorage.getItem(storageKey);
if (stored) {
- return JSON.parse(stored);
+ console.log('[sampler]: loaded sample list from localstorage', path);
+ githubCache[path] = JSON.parse(stored);
}
if (githubCache[path]) {
+ sampleCache.current = githubCache[path];
return githubCache[path];
}
console.log('[sampler]: fetching sample list from github', path);
@@ -62,10 +64,14 @@ export const loadGithubSamples = async (path, nameFn) => {
console.error('[sampler]: failed to fetch sample list from github', err);
return;
}
- loaded = githubCache[path];
- localStorage.setItem(storageKey, JSON.stringify(loaded));
- console.log('[sampler]: loaded samples:', loaded);
+ sampleCache.current = githubCache[path];
+ localStorage.setItem(storageKey, JSON.stringify(sampleCache.current));
+ console.log('[sampler]: loaded samples:', sampleCache.current);
return githubCache[path];
};
-export const getLoadedSamples = () => loaded;
+export const resetLoadedSamples = () => {
+ sampleCache.current = undefined;
+};
+
+export const getLoadedSamples = () => sampleCache.current;
diff --git a/repl/src/App.jsx b/repl/src/App.jsx
index ac49578e..6d132577 100644
--- a/repl/src/App.jsx
+++ b/repl/src/App.jsx
@@ -13,7 +13,7 @@ import './App.css';
import logo from './logo.svg';
import * as tunes from './tunes.mjs';
import * as WebDirt from 'WebDirt';
-import { loadWebDirt } from '@strudel.cycles/webdirt';
+import { loadWebDirt, resetLoadedSamples } from '@strudel.cycles/webdirt';
evalScope(
Tone,
@@ -173,6 +173,7 @@ function App() {
setCode(_code);
cleanupDraw();
cleanupUi();
+ resetLoadedSamples();
const parsed = await evaluate(_code);
setPattern(parsed.pattern);
setActiveCode(_code);