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"
onClick={async () => {
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);
cleanupDraw();
cleanupUi();
resetLoadedSamples();
prebake();
await prebake(); // declare default samples
const parsed = await evaluate(_code);
setPattern(parsed.pattern);
setActiveCode(_code);

View File

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