-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstrudel.js
More file actions
78 lines (64 loc) · 1.64 KB
/
Copy pathstrudel.js
File metadata and controls
78 lines (64 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { initStrudel, hush } from './strudelWeb';
import { aliasBank, registerSynthSounds, registerZZFXSounds, samples } from "@strudel/webaudio"
import { registerSoundfonts } from '@strudel/soundfonts';
import { flash, flashField } from "@strudel/codemirror";
import { initHydra, clearHydra } from "@strudel/hydra";
let initDone = null;
export class StrudelClient {
async init(options = {}) {
if (initDone) {
console.warn('Strudel already initialized, skipping init.');
return;
}
initDone = true
options = {
prebake: prebake,
...options,
}
console.log('Initializing Strudel...');
await initStrudel(options);
}
async evaluate(code) {
return evaluate(code);
}
async stop() {
console.log('Stopping strudel');
initDone = null;
hush();
clearHydra();
}
async startHydra() {
console.log('Starting hydra...');
initHydra();
}
async stopHydra() {
console.log('Stopping hydra...');
clearHydra();
}
flashCode(editorView) {
flash(editorView);
}
extensions() {
return [
flashField,
];
}
}
async function prebake() {
// see @strudel/repl prebake script
const ds = 'https://raw.githubusercontent.com/felixroos/dough-samples/main/';
const ts = 'https://raw.githubusercontent.com/todepond/samples/main/';
await Promise.all([
registerSoundfonts(),
registerSynthSounds(),
registerZZFXSounds(),
samples('github:tidalcycles/dirt-samples'),
samples(`${ds}/tidal-drum-machines.json`),
samples(`${ds}/piano.json`),
samples(`${ds}/Dirt-Samples.json`),
samples(`${ds}/EmuSP12.json`),
samples(`${ds}/vcsl.json`),
samples(`${ds}/mridangam.json`),
]);
aliasBank(`${ts}/tidal-drum-machines-alias.json`);
}