Guide
How to use Synthlet modules
This guide will show you how to use the Synthlet modules.
Create
To create a module, you need to call the Module
function that will return an instance of an AudioWorkletNode.
The create function will take two arguments, the audioContext
and an object with optional configuration and initial values of each parameter:
Connect modules to the audio graph
Since returning nodes are normal AudioWorkletNodes , you can connect them to the audio graph as you would with any other node:
Parameters
Each module has a set of parameters exposed as AudioParam that you can control using the value
property the same way as you would with any other Web Audio API node:
Connect parameters on constructor
Unlike WebAudioAPI, Synthlet create functions accepts other modules as parameters. This is useful to connect modules on creation:
The lfo is now connected and modulating the gain of the amp node.
Start and stop
There are no start
and stop
methods in Synthlet modules, sources are started by default.
No start/stop
Unlike the standard WebAudio API, Synthlet modules starts automatically.
The modules that needs some kind of start/stop (envelopes, sequencers, etc...) the control is managed with parameters too. For example, start
and stop
methods are normally replaced by a gate
parameter that you can control using the setValueAtTime
method:
The advantage is that you can use a module to start/stop other modules. Evertying can be connected.
Connect and disconnect
Synthlet modules isses the same connect and disconnect methods as any other AudioNode:
Disconnect is not enough
Audio worklets still running even if you disconnect them from the audio graph.
If you want to fully stop them you have to dispose
.
Dispose
Dispose is a handy function that funlly disconnects and stop the module:
It also disconnects all dependencies:
Unlike the connect
in standard WebAudio API, dispose
can be called more than once (but only the first call will have effect) and once called, the module is not usable anymore.
Installing individual modules
If you want to optimize for bundle size, you can use the individual module packages and register each module individually.
Install:
And use: