This is a very basic modular synth I made that's configured with yaml files. You can call it via:
npm start path/to/file.yml
There's some examples in the examples
folder, which you can try out via:
npm start examples/chords.yml
Moreover, there's a way to draw the node graph, if you'd like:
npm test examples/chords.yml
This can be helpful for building your own things and testing them out.
The synth is configured with a YAML file, that is passed as the first argument to the script.
It consists of three sections: nodes
, values
, and connections
.
nodes
allows you declare nodes and assign them names for later use.
An example section might look something like this
nodes:
osc1: Oscillator
osc2: Oscillator
chord: Sequencer
lfo: Oscillator
You can then reference those nodes by name in later sections
The values
section allows you to assign constant values to properties of a node.
For instance, an oscillator can be created to have a constant frequency
values:
osc1.carrier: 220
osc2.carrier: 440
The connections
section allows you to provide the dynamic portions of the synthesizer and connect nodes you've previously declared.
For instance, you can connect the above sequencer to the first oscillator, then connect that oscillator to the speaker
connections:
chord: osc1.carrier
os1: speaker.input
The examples folder also provides some sample configuration files for creating various sounds.
There are multiple node types available, and all of them have a predefined set of inputs and a single output.
The Oscillator node provides a simple sine or square oscillator. Setting carrier
defines it's frequency, and amplitude
the amplitude.
waveform
is a string value set to either "sine"
or "square"
which will change the waveform.
The LowPassFilter implements a basic low pass filter. It has two parameters: filterWidth
a number which, when higher, lowers the cutoff frequency and input
, the input to filter.
The noise node implements random noise, with no inputs.
The sequencer node will loop over an array of values periodically and emit those as values.
Its first input parameter is sequence
, an array of values to emit.
Its second is length
which denotes how long to stay on a given value before moving to the next one.
The adder node adds its two inputs input1
and input2
and provides the sum as it's output
The multiplier node multiplies its two inputs input1
and input2
and provides the sum as it's output
The envelope node provides an ADSR Envelope. You can set a couple of inputs:
attack
the attack time of the envelopedecay
the decay time of the envelopesustain
the sustain level of the enveloperelease
the release time of the envelopetrigger
should be a1
or a0
triggering the envelope to start. For instance, if the envelope is silenced, settingtrigger
to 1 will start the envelope. It will attack, then decay, and wait at sustain until atrigger
of 0 is encountered, upon which it will because the release process.
npm install
may fail on your machine, due to sound library configuration required by the speaker
module.
In short, you may have to change you npm install to something like npm install --mpg123-backend=openal
or npm install --mpg123-backend=coreaudio
depending or your system.