synth-kit
Synthesizers construction kit for Web Audio API
Work in progress. Experimental API
synth-kit
is a small (8Kb minified, 3Kb minified and gzipped) collection of ready-to-use Web Audio instruments:
const ac = // create a Kick instrument and connect it to the audio context destinationconst kick = // trigger the kickkick
Features
- Sound reasonably good
- No setup: nice defaults, no config
- Easy and simple API
- Extensible and flexible
SynthKit
Percussion instruments
Melodic instruments
- MonoSynth: One oscillator subtractive synth
Effects
Components
Usage
synth-kit
is designed to be very easy to use: install the library, create an instrument and trigger it.
Installation
Node
With npm: npm i --save synth-kit
or with yarn: yarn add --save synth-kit
ES6:
const ac = const clave = clave
ES5:
const SynthKit = const ac = const clave = acclave
Browser
Create instruments
Call the function with an audio context. The connect
function is chainable and accepts true
to connect to the AudioContext's destination:
const mono = // trigger signature for melodic instruments: (midi, time, duration)monomono
Trigger
Trigger the attack/release envelope of an instrument with the trigger
function:
const snare = snare
Perussion instruments accept time
as trigger
arguments:
snare
Melodic instruments accept frequency, time, duration
as trigger
arguments:
const mono = mono
Re-triggerable
You can trigger an instrument any number of times:
monomono
You can use Sample
to get a re-triggerable buffer source:
Attack/release
Using a melodic instrument, you can trigger the attack and release phases at different moments:
const triggerRelease = mono
Polyphony
All instruments are monophonic by default. You can create a polyphonic instrument with polyphonc
function:
const synth = const freqs = 400 500 600 700freqs
Update parameters
All instruments have an update
function:
const duo = duoduo
And an inspect
function:
console// console.log output: osc1: frequency: 440 ... osc2: frequency: 880 ... filter: ... amp: gain: 06
For fine-grained control, use the audio nodes directly:
const duo = duofilterfrequency
References
- Of course, the synth secrets tutorial was the beginning of all: https://github.com/micjamking/synth-secrets (that's a easy to read version). Thanks Gordon Reid (here it is an awesome PDF version)
- Vincent made some nice 808 drum synsthesis: https://github.com/vincentriemer/io-808
- Percussion synthesis tutorial: http://www.cim.mcgill.ca/~clark/nordmodularbook/nm_percussion.html
- Sound Design in Web Audio its an awesome two part blog post: http://nickwritesablog.com/sound-design-in-web-audio-neurofunk-bass-part-1/ and http://nickwritesablog.com/sound-design-in-web-audio-neurofunk-bass-part-2/
- There are a lot of resources about synthesis, here is a nice one: https://www.gearslutz.com/board/electronic-music-instruments-electronic-music-production/460283-how-do-you-synthesize-808-ish-drums.html
License
MIT License