diff --git a/packages/tone/tone.mjs b/packages/tone/tone.mjs index 34d19dc4..5ad55edc 100644 --- a/packages/tone/tone.mjs +++ b/packages/tone/tone.mjs @@ -30,13 +30,16 @@ import { getPlayableNoteValue } from '@strudel.cycles/core/util.mjs'; // "balanced" | "interactive" | "playback"; // Tone.setContext(new Tone.Context({ latencyHint: 'playback', lookAhead: 1 })); -export const defaultSynth = new PolySynth().chain(new Gain(0.5), getDestination()); -defaultSynth.set({ - oscillator: { type: 'triangle' }, - envelope: { - release: 0.01, - }, -}); +export const getDefaultSynth = () => { + const s = new PolySynth().chain(new Gain(0.5), getDestination()); + s.set({ + oscillator: { type: 'triangle' }, + envelope: { + release: 0.01, + }, + }); + return s; +}; // what about // https://www.charlie-roberts.com/gibberish/playground/ diff --git a/repl/src/App.js b/repl/src/App.js index 4b5ffc83..71307f55 100644 --- a/repl/src/App.js +++ b/repl/src/App.js @@ -3,7 +3,7 @@ import CodeMirror, { markEvent, markParens } from './CodeMirror'; import cx from './cx'; import logo from './logo.svg'; import playStatic from './static.mjs'; -import { defaultSynth } from '@strudel.cycles/tone'; +import { getDefaultSynth } from '@strudel.cycles/tone'; import * as tunes from './tunes.mjs'; import useRepl from './useRepl.mjs'; import { useWebMidi } from './useWebMidi'; @@ -52,6 +52,7 @@ function getRandomTune() { } const randomTune = getRandomTune(); +const defaultSynth = getDefaultSynth(); function App() { const [editor, setEditor] = useState(); diff --git a/repl/src/static.mjs b/repl/src/static.mjs index dc0d76e2..0fc70537 100644 --- a/repl/src/static.mjs +++ b/repl/src/static.mjs @@ -2,7 +2,9 @@ import { Tone } from '@strudel.cycles/tone'; import { State, TimeSpan } from '@strudel.cycles/core'; import { getPlayableNoteValue } from '@strudel.cycles/core/util.mjs'; import { evaluate } from '@strudel.cycles/eval'; -import { defaultSynth } from '@strudel.cycles/tone'; +import { getDefaultSynth } from '@strudel.cycles/tone'; + +const defaultSynth = getDefaultSynth(); // this is a test to play back events with as less runtime code as possible.. // the code asks for the number of seconds to prequery