strudel/packages/webaudio
Alex McLean 2d5064bd5b
Reinstate slice and splice (#500)
Reinstate slice/splice, fixing up "unit" param using new global cps
2023-03-02 14:44:41 +00:00
..
feedbackdelay.mjs delay as global send via orbit 2022-09-24 21:45:23 +02:00
index.mjs move scheduler to core + move audioctx to userland 2022-08-17 21:26:00 +02:00
package.json bump webaudio 2023-02-01 22:45:53 +01:00
README.md overhaul the remaining readmes 2023-02-01 16:29:18 +01:00
reverb.mjs fix: reverb mono 2022-10-31 20:34:07 +01:00
sampler.mjs use jsdoc in autocomplete, still not context aware 2023-02-09 12:19:38 +01:00
vite.config.js webaudio build 2023-01-28 23:14:56 +01:00
vowel.mjs make vowel work with node 2022-09-15 20:11:10 +02:00
webaudio.mjs Reinstate slice and splice (#500) 2023-03-02 14:44:41 +00:00
worklets.mjs fix: multichannel worklets 2022-10-31 20:33:42 +01:00

@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());

Play with the example codesandbox.

Read more in the docs about samples, synths and effects.