mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-25 20:48:27 +00:00
Merge pull request #189 from tidalcycles/fix-188
wait for prebake to finish before evaluating
This commit is contained in:
commit
745c37f2d1
@ -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);
|
||||||
|
|||||||
@ -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/'));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user