This module provides some typical syntetizers components, like vca, vcf and some syntetizers
Example
// a dual osc synth sound
synth(
frequency: 440,
oscillators: { ratios: [1, 5/7, 9/8], types: 'saw' },
attack: 0.1, release: 0.1,
filter: { frequency: 'follow' }
).connect(dest()).start()
Methods
(static) bank(frequencies, options) → {AudioNode}
Create a bank of oscillators.
Parameters:
Name | Type | Description |
---|---|---|
frequencies |
Array.<Float> | an array with the frequencies |
options |
Object | (Optional) options can include:
|
Returns:
- Type
- AudioNode
Example
// create three sines with unrelated frequencies:
bank({ frequencies: [1345.387, 435.392, 899.432] })
// create three sawtooth with relative frequencies:
bank({ frequency: 440, ratios: [1, 2, 2.4] , types: 'sawtooth' })
// create two squares of 400 and 800 and two sawtooths of 600 and 1200
// (the types are cyclic)
bank({ frequencies: [400, 600, 800, 1200], types: ['square', 'sawtooth'] })
// specify gains
bank({ frequencies: [440, 660], gains: [0.6, 0.2] })
(static) subtractive(source, options)
A subtractive synthetizer (oscillator bank -> VCF -> VCA)
Parameters:
Name | Type | Description |
---|---|---|
source |
AudioNode | Number | String | The subtractive synth source |
options |
Object | (Optional) the configuration may include:
|
Example
// a 300Hz sawtooth with adsr and lowass filter at 600
subtractive({ frequency: 300, type: 'sawtooth', adsr: [0.01, 0.1, 0.8, 1], filter: { type: 'lowpass', frequency: 600 } })
// a custom source node
substractive({ source: add(white(), square(500)), attack: 0.1, duration: 1 })
// connected in a chain
connect(sample('snare.wav', subtractive({ attack: 0.1 }))
(static) vca(options) → {AudioNode}
Create a VCA: an amplifier controlled by an ADSR envelope
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | may include: |
Returns:
a GainNode
- db: the gain in decibels
- gain: the gain (will override dB param)
- attack, decay, sustain, release: the ADSR envelope parameters
- context: the audio context
- Type
- AudioNode
(static) vcf(config) → {AudioNode}
Create a VCF: a filter controlled by an ADSR envelope
Parameters:
Name | Type | Description |
---|---|---|
config |
Object | may include: |
Returns:
the BiquadFilterNode
- type: filter type
- frequency: filter frequency (can be a signal)
- octaves: amplitude of the modulation in octaves (defaults to 2)
- attack, decay, sustain, release: the adsr parameters
- context: the audio context
- Type
- AudioNode
Example
conn(square({ frequency: 800 }), vcf({ frequency: 400, attack: 0.1 }))
(static) withDefaults()
Decorate a function to have default configuration