fix: mini repl could eval before modules are ready
This commit is contained in:
parent
49bcb5e19f
commit
a2d7d6e81f
2 changed files with 6 additions and 5 deletions
|
|
@ -3,8 +3,9 @@ import { initAudioOnFirstClick } from '@strudel.cycles/webaudio';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { prebake } from '../repl/prebake';
|
import { prebake } from '../repl/prebake';
|
||||||
|
|
||||||
|
let modules;
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
evalScope(
|
modules = evalScope(
|
||||||
controls,
|
controls,
|
||||||
import('@strudel.cycles/core'),
|
import('@strudel.cycles/core'),
|
||||||
// import('@strudel.cycles/tone'),
|
// import('@strudel.cycles/tone'),
|
||||||
|
|
@ -27,9 +28,9 @@ export function MiniRepl({ tune, drawTime, punchcard, canvasHeight = 100 }) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// we have to load this package on the client
|
// we have to load this package on the client
|
||||||
// because codemirror throws an error on the server
|
// because codemirror throws an error on the server
|
||||||
import('@strudel.cycles/react').then((res) => {
|
Promise.all([import('@strudel.cycles/react'), modules])
|
||||||
setRepl(() => res.MiniRepl);
|
.then(([res]) => setRepl(() => res.MiniRepl))
|
||||||
});
|
.catch((err) => console.error(err));
|
||||||
}, []);
|
}, []);
|
||||||
return Repl ? (
|
return Repl ? (
|
||||||
<div className="mb-4">
|
<div className="mb-4">
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ Alternatively, you can get a taste of what Strudel can do by clicking play on th
|
||||||
hh: ['hh27/000_hh27closedhh.wav','hh/000_hh3closedhh.wav'],
|
hh: ['hh27/000_hh27closedhh.wav','hh/000_hh3closedhh.wav'],
|
||||||
}, 'github:tidalcycles/Dirt-Samples/master/');
|
}, 'github:tidalcycles/Dirt-Samples/master/');
|
||||||
stack(
|
stack(
|
||||||
s("bd,[~ <sd!3 sd(3,4,2)>],hh(3,4)") // drums
|
s("bd,[~ <sd!3 sd(3,4,2)>],hh*8") // drums
|
||||||
.speed(perlin.range(.7,.9)) // random sample speed variation
|
.speed(perlin.range(.7,.9)) // random sample speed variation
|
||||||
,"<a1 b1\*2 a1(3,8) e2>" // bassline
|
,"<a1 b1\*2 a1(3,8) e2>" // bassline
|
||||||
.off(1/8,x=>x.add(12).degradeBy(.5)) // random octave jumps
|
.off(1/8,x=>x.add(12).degradeBy(.5)) // random octave jumps
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue