mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-22 11:08:35 +00:00
Merge remote-tracking branch 'origin/main' into setcps-reset-only-on-shuffle
This commit is contained in:
commit
6a201be1fd
@ -41,7 +41,7 @@ export function repl({
|
|||||||
throw new Error('no code to evaluate');
|
throw new Error('no code to evaluate');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
beforeEval?.({ code });
|
await beforeEval?.({ code });
|
||||||
let { pattern } = await _evaluate(code, transpiler);
|
let { pattern } = await _evaluate(code, transpiler);
|
||||||
|
|
||||||
logger(`[eval] code updated`);
|
logger(`[eval] code updated`);
|
||||||
|
|||||||
@ -46,9 +46,9 @@ function useStrudel({
|
|||||||
drawContext,
|
drawContext,
|
||||||
transpiler,
|
transpiler,
|
||||||
editPattern,
|
editPattern,
|
||||||
beforeEval: ({ code }) => {
|
beforeEval: async ({ code }) => {
|
||||||
setCode(code);
|
setCode(code);
|
||||||
beforeEval?.();
|
await beforeEval?.();
|
||||||
},
|
},
|
||||||
afterEval: (res) => {
|
afterEval: (res) => {
|
||||||
const { pattern: _pattern, code } = res;
|
const { pattern: _pattern, code } = res;
|
||||||
|
|||||||
@ -42,7 +42,7 @@ const modules = [
|
|||||||
import('@strudel.cycles/csound'),
|
import('@strudel.cycles/csound'),
|
||||||
];
|
];
|
||||||
|
|
||||||
evalScope(
|
const modulesLoading = evalScope(
|
||||||
controls, // sadly, this cannot be exported from core direclty
|
controls, // sadly, this cannot be exported from core direclty
|
||||||
...modules,
|
...modules,
|
||||||
);
|
);
|
||||||
@ -102,7 +102,7 @@ export function Repl({ embedded = false }) {
|
|||||||
const isEmbedded = embedded || window.location !== window.parent.location;
|
const isEmbedded = embedded || window.location !== window.parent.location;
|
||||||
const [view, setView] = useState(); // codemirror view
|
const [view, setView] = useState(); // codemirror view
|
||||||
const [lastShared, setLastShared] = useState();
|
const [lastShared, setLastShared] = useState();
|
||||||
const [pending, setPending] = useState(false);
|
const [pending, setPending] = useState(true);
|
||||||
|
|
||||||
const { theme, keybindings, fontSize, fontFamily } = useSettings();
|
const { theme, keybindings, fontSize, fontFamily } = useSettings();
|
||||||
|
|
||||||
@ -111,10 +111,11 @@ export function Repl({ embedded = false }) {
|
|||||||
initialCode: '// LOADING',
|
initialCode: '// LOADING',
|
||||||
defaultOutput: webaudioOutput,
|
defaultOutput: webaudioOutput,
|
||||||
getTime,
|
getTime,
|
||||||
beforeEval: () => {
|
beforeEval: async () => {
|
||||||
|
setPending(true);
|
||||||
|
await modulesLoading;
|
||||||
cleanupUi();
|
cleanupUi();
|
||||||
cleanupDraw();
|
cleanupDraw();
|
||||||
setPending(true);
|
|
||||||
},
|
},
|
||||||
afterEval: ({ code }) => {
|
afterEval: ({ code }) => {
|
||||||
setPending(false);
|
setPending(false);
|
||||||
@ -135,6 +136,7 @@ export function Repl({ embedded = false }) {
|
|||||||
'highlight',
|
'highlight',
|
||||||
);
|
);
|
||||||
setCode(decoded || latestCode || randomTune);
|
setCode(decoded || latestCode || randomTune);
|
||||||
|
setPending(false);
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@ -144,6 +146,10 @@ export function Repl({ embedded = false }) {
|
|||||||
async (e) => {
|
async (e) => {
|
||||||
if (e.ctrlKey || e.altKey) {
|
if (e.ctrlKey || e.altKey) {
|
||||||
if (e.code === 'Enter') {
|
if (e.code === 'Enter') {
|
||||||
|
if (getAudioContext().state !== 'running') {
|
||||||
|
alert('please click play to initialize the audio. you can use shortcuts after that!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
flash(view);
|
flash(view);
|
||||||
await activateCode();
|
await activateCode();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user