Namespace: synth

syngen.audio.synth

Provides factories for building simple prefabricated synthesizers. Importantly, these are not the only way to generate audio with syngen. Implementations can build their own synthesizers or use any external library that supports connecting to its audio graph.

Source:

Methods

(static) createAdditive(optionsopt) → {syngen.audio.synth~Synth}

Creates an additive synthesizer which wraps configurable harmonics into a unified synth. Each harmonic is calculated from an individual frequency coefficient, gain multiplier, and detune modifier. With ConstantSourceNodes their values are controllable in unison such that they maintain their relationships.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}
Properties
Name Type Attributes Default Description
detune Number <optional>
0
frequency Number <optional>
440
gain Number <optional>
syngen.const.zeroGain
harmonic Array.<Object> <optional>
[]

Each harmonic is an object with these fields:

Properties
Name Type Attributes Default Description
coefficient Number <optional>
1
detune Number <optional>
0
gain Number <optional>
1
type String <optional>
sine
when Number <optional>
syngen.audio.time()
Source:
Returns:
Type
syngen.audio.synth~Synth

(static) createAm(optionsopt) → {syngen.audio.synth~Synth}

Creates a synthesizer with amplitude modulation.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}
Properties
Name Type Attributes Default Description
carrierDetune Number <optional>
0
carrierFrequency Number <optional>
440
carrierGain Number <optional>
1
carrierType Number <optional>
sine
gain Number <optional>
syngen.const.zeroGain
modDepth Number <optional>
syngen.const.zeroGain
modDetune Number <optional>
0
modFrequency Number <optional>
440
modType Number <optional>
sine
modWhen Number <optional>
when Number <optional>
syngen.audio.time()
Source:
To Do:
Returns:
Type
syngen.audio.synth~Synth

(static) createAmBuffer(optionsopt) → {syngen.audio.synth~Synth}

Creates a synthesizer which applies amplitude modulation to an AudioBufferSourceNode.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}
Properties
Name Type Attributes Default Description
buffer AudioBuffer
carrierGain Number <optional>
1
detune Number <optional>
0
gain Number <optional>
syngen.const.zeroGain
loop Boolean <optional>
true
loopEnd Number <optional>
loopStart Number <optional>
modDepth Number <optional>
syngen.const.zeroGain
modDetune Number <optional>
0
modFrequency Number <optional>
440
modType String <optional>
sine
modWhen String <optional>
playbackRate String <optional>
1
when Number <optional>
syngen.audio.time()
Source:
To Do:
Returns:
Type
syngen.audio.synth~Synth

(static) createBuffer(optionsopt) → {syngen.audio.synth~Synth}

Creates a synthesizer which uses an AudioBufferSourceNode.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}
Properties
Name Type Attributes Default Description
buffer AudioBuffer
detune Number <optional>
0
gain Number <optional>
syngen.const.zeroGain
loop Boolean <optional>
true
loopEnd Number <optional>
loopStart Number <optional>
playbackRate String <optional>
1
when Number <optional>
syngen.audio.time()
Source:
Returns:
Type
syngen.audio.synth~Synth

(static) createFm(optionsopt) → {syngen.audio.synth~Synth}

Creates a synthesizer with frequency modulation.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}
Properties
Name Type Attributes Default Description
carrierDetune Number <optional>
0
carrierFrequency Number <optional>
440
carrierGain Number <optional>
1
carrierType Number <optional>
sine
gain Number <optional>
syngen.const.zeroGain
modDepth Number <optional>
syngen.const.zeroGain
modDetune Number <optional>
0
modFrequency Number <optional>
440
modType Number <optional>
sine
modWhen Number <optional>
when Number <optional>
syngen.audio.time()
Source:
To Do:
Returns:
Type
syngen.audio.synth~Synth

(static) createLfo(optionsopt) → {syngen.audio.synth~Synth}

Creates a simple low-frequency oscillator intended for modulation. This is identical to createSimple() except with different terminology.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}
Properties
Name Type Attributes Default Description
depth Number <optional>
syngen.const.zeroGain
detune Number <optional>
0
frequency Number <optional>
0
type String <optional>
sine
when Number <optional>
syngen.audio.time()
Source:
Returns:
Type
syngen.audio.synth~Synth

(static) createMod(optionsopt) → {syngen.audio.synth~Synth}

Creates a synthesizer with both amplitude and frequency modulation.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}
Properties
Name Type Attributes Default Description
amodDepth Number <optional>
syngen.const.zeroGain
amodDetune Number <optional>
0
amodFrequency Number <optional>
440
amodType Number <optional>
sine
amodWhen Number <optional>
carrierDetune Number <optional>
0
carrierFrequency Number <optional>
440
carrierGain Number <optional>
1
carrierType Number <optional>
sine
fmodDepth Number <optional>
syngen.const.zeroGain
fmodDetune Number <optional>
0
fmodFrequency Number <optional>
440
fmodType Number <optional>
sine
fmodWhen Number <optional>
gain Number <optional>
syngen.const.zeroGain
when Number <optional>
syngen.audio.time()
Source:
To Do:
Returns:
Type
syngen.audio.synth~Synth

(static) createPwm(optionsopt) → {syngen.audio.synth~Synth}

Creates a simple synthesizer with configurable pulse-width modulation.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}
Properties
Name Type Attributes Default Description
detune Number <optional>
0
frequency Number <optional>
440
gain Number <optional>
syngen.const.zeroGain
type String <optional>
sine
when Number <optional>
syngen.audio.time()
width Number <optional>
0
Source:
Returns:
Type
syngen.audio.synth~Synth

(static) createSimple(optionsopt) → {syngen.audio.synth~Synth}

Creates a simple synthesizer with a single oscillator.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}
Properties
Name Type Attributes Default Description
detune Number <optional>
0
frequency Number <optional>
440
gain Number <optional>
syngen.const.zeroGain
type String <optional>
sine
when Number <optional>
syngen.audio.time()
Source:
Returns:
Type
syngen.audio.synth~Synth

Type Definitions

Plugin

A plugin compatible with synth chaining. Typically returned from a syngen.audio.effect or syngen.audio.formant factory method. Implementations can create their own plugins for synths as long as they have an input and output.

Type:
  • Object
Properties:
Name Type Attributes Description
input AudioNode

The plugin output.

output AudioNode

The plugin output.

param Object <optional>

Hash of all AudioParams.

stop function <optional>

Stops the plugins.

Source:
To Do:
  • Improve documentation as an interface

Synth

A prefabricated synth returned from a syngen.audio.synth factory method. They wrap their AudioNodes with an interface that exposes their AudioParams and provides methods to build more sophisticated circuits. Internally they maintain a pointer to the last node before output so they can unlink them and dynamically add plugins to the output chain.

Type:
  • Object
Properties:
Name Type Description
assign function

Assigns plugin to key and merges its parameters.

chain function

Adds plugin to the output chain and ensures they stop together.

chainAssign function

Assigns and chains plugin to key. This is shorthand for calling both chain() and assign().

chainStop function

Ensures plugin stops when the synth is stopped. This is called internally by chain(). Implementations should only call this manually if plugin is not part of its output chain.

connect function

Connects synth output to node with optional ...args.

disconnect function

Disconnects synth output from node with optional ...args.

filtered function

Adds a BiquadFilterNode to the output chain with options.

output GainNode

The final output after all chained plugins.

param Object

Hash of all AudioParams.

shaped function

Adds a WaveShaperNode to the output chain with curve.

stop function

Stops the synth and all chained plugins.

Source:
To Do:
  • Improve documentation as an interface