{
+ let { freq } = value; // destructure control params
+ const ctx = getAudioContext();
+ // create oscillator
+ const o = new OscillatorNode(ctx, { type: 'sawtooth', frequency: Number(freq) });
+ o.start(time);
+ // add gain node to level down osc
+ const g = new GainNode(ctx, { gain: 0.3 });
+ // connect osc to gain
+ const node = o.connect(g);
+ // this function can be called from outside to stop the sound
+ const stop = (time) => o.stop(time);
+ // ended will be fired when stop has been fired
+ o.addEventListener('ended', () => {
+ o.disconnect();
+ g.disconnect();
+ onended();
+ });
+ return { node, stop };
+ },
+ { type: 'synth' },
+ );
+ // use the sound
+ freq("220 440 330").s('mysaw');`}
+/>
You can actually use this code in the [REPL](https://strudel.cc/) and it'll work.
After evaluating the code, you should see `mysaw` in listed in the sounds tab.
diff --git a/website/src/repl/components/panel/ExportTab.jsx b/website/src/repl/components/panel/ExportTab.jsx
index 9671ff1a3..cbb132e44 100644
--- a/website/src/repl/components/panel/ExportTab.jsx
+++ b/website/src/repl/components/panel/ExportTab.jsx
@@ -66,7 +66,7 @@ export default function ExportTab(Props) {
{
let v = parseInt(e.target.value);
diff --git a/website/src/repl/components/panel/SoundsTab.jsx b/website/src/repl/components/panel/SoundsTab.jsx
index 52fbf928c..5a7df5ba9 100644
--- a/website/src/repl/components/panel/SoundsTab.jsx
+++ b/website/src/repl/components/panel/SoundsTab.jsx
@@ -210,7 +210,11 @@ export function SoundsTab() {
) : (
''
)}
- {!soundEntries.length && soundsFilter !== 'importSounds' ? 'No sounds loaded' : ''}
+ {!soundEntries.length && soundsFilter !== 'importSounds'
+ ? search == ''
+ ? 'No sounds loaded'
+ : 'No sounds found'
+ : ''}
);