strudel/packages/webaudio
2022-12-12 20:53:11 +01:00
..
feedbackdelay.mjs
index.mjs
package-lock.json
package.json
README.md
reverb.mjs
sampler.mjs
vite.config.js
vowel.mjs
webaudio.mjs
worklets.mjs

@strudel.cycles/webaudio

This package contains a scheduler + a clockworker and synths based on the Web Audio API. It's an alternative to @strudel.cycles/tone, with better performance, but less features.

Install

npm i @strudel.cycles/webaudio --save

Example

import { Scheduler, getAudioContext } from '@strudel.cycles/webaudio';

const scheduler = new Scheduler({
  audioContext: getAudioContext(),
  interval: 0.1,
  onEvent: (e) => e.context?.createAudioNode?.(e),
});
const pattern = sequence([55, 99], 110).osc('sawtooth');
scheduler.setPattern(pattern);
scheduler.start();
//scheduler.stop()

A more sophisticated example can be found in examples/repl.html. You can run it by opening the html file with your browser, or by clicking this link