Merge pull request #189 from tidalcycles/fix-188

wait for prebake to finish before evaluating
This commit is contained in:
Felix Roos 2022-08-14 15:45:53 +02:00 committed by GitHub
commit 745c37f2d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -219,12 +219,12 @@ function App() {
className="hover:bg-gray-300 p-2" className="hover:bg-gray-300 p-2"
onClick={async () => { onClick={async () => {
const _code = getRandomTune(); const _code = getRandomTune();
console.log('tune', _code); // uncomment this to debug when random code fails // console.log('tune', _code); // uncomment this to debug when random code fails
setCode(_code); setCode(_code);
cleanupDraw(); cleanupDraw();
cleanupUi(); cleanupUi();
resetLoadedSamples(); resetLoadedSamples();
prebake(); await prebake(); // declare default samples
const parsed = await evaluate(_code); const parsed = await evaluate(_code);
setPattern(parsed.pattern); setPattern(parsed.pattern);
setActiveCode(_code); setActiveCode(_code);

View File

@ -1,7 +1,7 @@
import { Pattern, toMidi } from '@strudel.cycles/core'; import { Pattern, toMidi } from '@strudel.cycles/core';
import { samples } from '@strudel.cycles/webaudio'; import { samples } from '@strudel.cycles/webaudio';
export function prebake(isMock = false) { export async function prebake(isMock = false) {
samples( samples(
{ {
piano: { piano: {
@ -42,7 +42,7 @@ export function prebake(isMock = false) {
'./piano/', './piano/',
); );
if (!isMock) { if (!isMock) {
fetch('EmuSP12.json') await fetch('EmuSP12.json')
.then((res) => res.json()) .then((res) => res.json())
.then((json) => samples(json, './EmuSP12/')); .then((json) => samples(json, './EmuSP12/'));
} }