use new getTime callback in repl + mini repl

This commit is contained in:
Felix Roos 2022-08-23 21:23:28 +02:00
parent 7b0c80c8be
commit ec4cfe6f86
2 changed files with 13 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import 'tailwindcss/tailwind.css';
import './style.css';
import styles from './MiniRepl.module.css';
import { Icon } from './Icon';
import { Tone } from '@strudel.cycles/tone';
export function MiniRepl({ tune, defaultSynth, hideOutsideView = false, theme, init, onEvent, enableKeyboard }) {
const { code, setCode, pattern, activeCode, activateCode, evaluateOnly, error, cycle, dirty, togglePlay, stop } =
@ -31,7 +32,12 @@ export function MiniRepl({ tune, defaultSynth, hideOutsideView = false, theme, i
}
return isVisible || wasVisible.current;
}, [isVisible, hideOutsideView]);
useHighlighting({ view, pattern, active: cycle.started && !activeCode?.includes('strudel disable-highlighting') });
useHighlighting({
view,
pattern,
active: cycle.started && !activeCode?.includes('strudel disable-highlighting'),
getTime: () => Tone.getTransport().seconds,
});
// set active pattern on ctrl+enter
useLayoutEffect(() => {

View File

@ -144,7 +144,12 @@ function App() {
return () => window.removeEventListener('keydown', handleKeyPress, true);
}, [pattern, code, activateCode, cycle, view]);
useHighlighting({ view, pattern, active: cycle.started && !activeCode?.includes('strudel disable-highlighting') });
useHighlighting({
view,
pattern,
active: cycle.started && !activeCode?.includes('strudel disable-highlighting'),
getTime: () => Tone.getTransport().seconds,
});
useWebMidi({
ready: useCallback(