diff --git a/csound-live-code b/csound-live-code new file mode 160000 index 0000000..71b9973 --- /dev/null +++ b/csound-live-code @@ -0,0 +1 @@ +Subproject commit 71b9973520f6491bc8773418360e1e3b479f7cff diff --git a/src/App.svelte b/src/App.svelte index 17acd60..3ea49b8 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -31,6 +31,7 @@ FileStack, PanelLeftOpen, PanelRightOpen, + CircleStop, } from "lucide-svelte"; const appContext = createAppContext(); @@ -44,7 +45,7 @@ uiState, executionContext, } = appContext; - const csoundDerived = createCsoundDerivedStores(csound); + const { logs: csoundLogs, initialized, compiled, running } = createCsoundDerivedStores(csound); let analyserNode = $state(null); let interpreterLogs = $state([]); @@ -91,9 +92,27 @@ projectEditor.loadProject(projectToLoad); } - logsUnsubscribe = csoundDerived.logs.subscribe((logs) => { + logsUnsubscribe = csoundLogs.subscribe((logs) => { interpreterLogs = logs; }); + + const handleKeyDown = (e: KeyboardEvent) => { + if ((e.ctrlKey || e.metaKey) && e.key === '.') { + e.preventDefault(); + handleStop(); + } + + if ((e.ctrlKey || e.metaKey) && e.key === 's') { + e.preventDefault(); + handleSave(); + } + }; + + window.addEventListener('keydown', handleKeyDown); + + return () => { + window.removeEventListener('keydown', handleKeyDown); + }; }); onDestroy(async () => { @@ -220,6 +239,14 @@ } } + async function handleStop() { + try { + await csound.stop(); + } catch (error) { + console.error("Failed to stop:", error); + } + } + $effect(() => { if (uiState.scopePopupVisible || uiState.spectrogramPopupVisible) { analyserNode = csound.getAnalyserNode(); @@ -281,6 +308,14 @@
{#snippet leftActions()} +