# new MMSynth(voices, nodes, buffersizeopt)
This is a software synthesizer based on https://github.com/simap/MicroModSynth.
Note: MMSynth module must be loaded by calling LoadLibrary("mmsynth") before using!
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
voices |
string
|
number of voices to allocate. |
|
nodes |
number
|
number of nodes to allocate per voice. |
|
buffersize |
number
|
<optional> |
playback buffer size, default is 4KiB. |
- See:
-
- LoadLibrary()
Members
Methods
# EnvelopeNode(voice, node, gain, attack, decay, sustain, release)
create an envelope node.
Parameters:
| Name | Type | Description |
|---|---|---|
voice |
number
|
The voice where the node shall be created (0..v). |
node |
number
|
The node to create (0..n). |
gain |
number
|
<0 to select another nodes output as gain (node #0 is -1, node #1 is -2, etc), >=0 to use a numeric value as gain or null for no gain. |
attack |
number
|
attack value. |
decay |
number
|
decay value. |
sustain |
number
|
sustain value. |
release |
number
|
release value. |
# FilterHpNode(voice, node, gain, input, factor)
create a HP filter node.
Parameters:
| Name | Type | Description |
|---|---|---|
voice |
number
|
The voice where the node shall be created (0..v). |
node |
number
|
The node to create (0..n). |
gain |
number
|
<0 to select another nodes output as gain (node #0 is -1, node #1 is -2, etc), >=0 to use a numeric value as gain or null for no gain. |
input |
number
|
<0 to select another nodes output as input (node #0 is -1, node #1 is -2, etc), >=0 to use a numeric value as input or null for no input. |
factor |
number
|
filter value. |
# FilterLpNode(voice, node, gain, input, factor)
create a LP filter node.
Parameters:
| Name | Type | Description |
|---|---|---|
voice |
number
|
The voice where the node shall be created (0..v). |
node |
number
|
The node to create (0..n). |
gain |
number
|
<0 to select another nodes output as gain (node #0 is -1, node #1 is -2, etc), >=0 to use a numeric value as gain or null for no gain. |
input |
number
|
<0 to select another nodes output as input (node #0 is -1, node #1 is -2, etc), >=0 to use a numeric value as input or null for no input. |
factor |
number
|
filter value. |
# GetNode(voice, node) → {*}
return node as JS object.
Parameters:
| Name | Type | Description |
|---|---|---|
voice |
number
|
the voice to get |
node |
number
|
the noce to get |
returns an object representing the node. Will contain "type"=[null,"Oscillator","Envelope","FilterLp","FilterHp","Mixer"]. Will also contain properties matching the parameters when creating the node.
*
# HzToPhase(value) → {number}
convert Hz to Phase.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
number
|
in Hz. |
the value converted to phase.
number
# IsNodeDefined(voice, node) → {bool}
check if the given node for given voice is defined.
Parameters:
| Name | Type | Description |
|---|---|---|
voice |
number
|
the voice to check. |
node |
number
|
the node to check. |
true if the node is defined, else false.
bool
# MixerNode(voice, node, gain, input1, input2, input3)
create a mixer node.
Parameters:
| Name | Type | Description |
|---|---|---|
voice |
number
|
The voice where the node shall be created (0..v). |
node |
number
|
The node to create (0..n). |
gain |
number
|
<0 to select another nodes output as gain (node #0 is -1, node #1 is -2, etc), >=0 to use a numeric value as gain or null for no gain. |
input1 |
number
|
<0 to select another nodes output as input (node #0 is -1, node #1 is -2, etc), >=0 to use a numeric value as input or null for no input. |
input2 |
number
|
<0 to select another nodes output as input (node #0 is -1, node #1 is -2, etc), >=0 to use a numeric value as input or null for no input. |
input3 |
number
|
<0 to select another nodes output as input (node #0 is -1, node #1 is -2, etc), >=0 to use a numeric value as input or null for no input. |
# NoteOff(voice)
silence voice.
Parameters:
| Name | Type | Description |
|---|---|---|
voice |
number
|
the voice to turn off |
# NoteOn(voice, note)
play a note on a voice.
Parameters:
| Name | Type | Description |
|---|---|---|
voice |
number
|
the voice to play. |
note |
number
|
the note in play (midi note number). |
# OscillatorNode(voice, node, gain, phaseIncrement, detune, wavegen)
create an oscillator node.
Parameters:
| Name | Type | Description |
|---|---|---|
voice |
number
|
The voice where the node shall be created (0..v). |
node |
number
|
The node to create (0..n). |
gain |
number
|
<0 to select another nodes output as gain (node #0 is -1, node #1 is -2, etc), >=0 to use a numeric value as gain or null for no gain. |
phaseIncrement |
number
|
<0 to select another nodes output as phaseIncrement (node #0 is -1, node #1 is -2, etc), >=0 to use a numeric value as phaseIncrement or null to get the value from the notes value. |
detune |
number
|
<0 to select another nodes output as detune (node #0 is -1, node #1 is -2, etc), >=0 to use a numeric value as detune. |
wavegen |
number
|
One of MMSynth.SAWTOOTH, MMSynth.SINE, MMSynth.SQUARE, MMSynth.TRIANGLE, MMSynth.FALLING, MMSynth.EXP_DECAY. |