mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-27 05:28:41 +00:00
fix: sometimes wouldnt start the first time
This commit is contained in:
parent
2efbb68627
commit
72b963fb21
@ -68,12 +68,20 @@ function useCycle(props: UseCycleProps) {
|
|||||||
Tone.getTransport().start('+0.1');
|
Tone.getTransport().start('+0.1');
|
||||||
};
|
};
|
||||||
const stop = () => {
|
const stop = () => {
|
||||||
console.log('stop');
|
|
||||||
setStarted(false);
|
|
||||||
Tone.getTransport().pause();
|
Tone.getTransport().pause();
|
||||||
|
setStarted(false);
|
||||||
};
|
};
|
||||||
const toggle = () => (started ? stop() : start());
|
const toggle = () => (started ? stop() : start());
|
||||||
return { start, stop, setStarted, onEvent, started, toggle, query, activeCycle };
|
return {
|
||||||
|
start,
|
||||||
|
stop,
|
||||||
|
onEvent,
|
||||||
|
started,
|
||||||
|
setStarted,
|
||||||
|
toggle,
|
||||||
|
query,
|
||||||
|
activeCycle,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default useCycle;
|
export default useCycle;
|
||||||
|
|||||||
@ -25,13 +25,13 @@ function useRepl({ tune, defaultSynth, autolink = true, onEvent, onDraw }: any)
|
|||||||
const activateCode = async (_code = code) => {
|
const activateCode = async (_code = code) => {
|
||||||
if (activeCode && !dirty) {
|
if (activeCode && !dirty) {
|
||||||
setError(undefined);
|
setError(undefined);
|
||||||
!cycle.started && cycle.start();
|
cycle.start();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
setPending(true);
|
setPending(true);
|
||||||
const parsed = await evaluate(_code);
|
const parsed = await evaluate(_code);
|
||||||
!cycle.started && cycle.start();
|
cycle.start();
|
||||||
broadcast({ type: 'start', from: id });
|
broadcast({ type: 'start', from: id });
|
||||||
setPattern(() => parsed.pattern);
|
setPattern(() => parsed.pattern);
|
||||||
if (autolink) {
|
if (autolink) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user