Update README.md

This commit is contained in:
Felix Roos 2023-02-28 23:25:40 +01:00 committed by GitHub
parent df35a5c9b1
commit 4463d4a417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,24 +13,43 @@ npm i @strudel.cycles/react
Here is a minimal example of how to set up a MiniRepl: Here is a minimal example of how to set up a MiniRepl:
```jsx ```jsx
import { evalScope, controls } from '@strudel.cycles/core'; import * as React from 'react';
import '@strudel.cycles/react/dist/style.css';
import { MiniRepl } from '@strudel.cycles/react'; import { MiniRepl } from '@strudel.cycles/react';
import { prebake } from '../repl/src/prebake.mjs'; import { evalScope, controls } from '@strudel.cycles/core';
import { samples, initAudioOnFirstClick } from '@strudel.cycles/webaudio';
evalScope( async function prebake() {
controls, await samples(
import('@strudel.cycles/core'), 'https://strudel.tidalcycles.org/tidal-drum-machines.json',
import('@strudel.cycles/tonal'), 'github:ritchse/tidal-drum-machines/main/machines/'
import('@strudel.cycles/mini'), );
import('@strudel.cycles/webaudio'), await samples(
/* probably import other strudel packages */ 'https://strudel.tidalcycles.org/EmuSP12.json',
); 'https://strudel.tidalcycles.org/EmuSP12/'
);
}
prebake(); async function init() {
await evalScope(
controls,
import('@strudel.cycles/core'),
import('@strudel.cycles/mini'),
import('@strudel.cycles/webaudio'),
import('@strudel.cycles/tonal')
);
await prebake();
initAudioOnFirstClick();
}
export function Repl({ tune }) { if (typeof window !== 'undefined') {
return <MiniRepl tune={tune} hideOutsideView={true} />; init();
}
export default function App() {
return <MiniRepl tune={`s("bd sd,hh*4")`} />;
} }
``` ```
For a more sophisticated example, check out the [nano-repl](./examples/nano-repl/)! - Open [example on stackblitz](https://stackblitz.com/edit/react-ts-saaair?file=tune.tsx,App.tsx)
- Also check out the [nano-repl](./examples/nano-repl/) for a more sophisticated example