mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 13:48:34 +00:00
- @strudel.cycles/core@0.7.2 - @strudel.cycles/csound@0.7.1 - @strudel.cycles/eval@0.7.1 - @strudel.cycles/midi@0.7.1 - @strudel.cycles/mini@0.7.2 - @strudel.cycles/osc@0.7.1 - @strudel.cycles/react@0.7.1 - @strudel.cycles/serial@0.7.1 - @strudel.cycles/soundfonts@0.7.1 - @strudel.cycles/tonal@0.7.1 - @strudel.cycles/tone@0.7.1 - @strudel.cycles/transpiler@0.7.1 - @strudel.cycles/webaudio@0.7.1 - @strudel.cycles/webdirt@0.7.1 - @strudel.cycles/xen@0.7.1
@strudel.cycles/webaudio
This package contains helpers to make music with strudel and the Web Audio API.
Install
npm i @strudel.cycles/webaudio --save
Example
import { repl, controls } from "@strudel.cycles/core";
import { initAudioOnFirstClick, getAudioContext, webaudioOutput } from "@strudel.cycles/webaudio";
const { note } = controls;
initAudioOnFirstClick();
const ctx = getAudioContext();
const { scheduler } = repl({
defaultOutput: webaudioOutput,
getTime: () => ctx.currentTime
});
const pattern = note("c3", ["eb3", "g3"]).s("sawtooth");
scheduler.setPattern(pattern);
document.getElementById("start").addEventListener("click", () => scheduler.start());
document.getElementById("stop").addEventListener("click", () => scheduler.stop());