new Synth( dhc )

Description

The Synth class
A tool for listen the tones computed by the DHC.

Provide a simple basic synth useful as reference sound.

Parameters
Name Type Description
dhc HUM.DHC

The DHC instance to which it belongs

Details

Classes


new SynthVoice( synth, freq, velocity, type )

Members


<static> defaultReverb :Object

Description

IR file from the Voxengo Free Reverb Impulse Responses library by Aleksey Vaneev (The Musikvereinssaal, Vienna).
NB: The audio file is encoded in Base64 so that it can be auto-loaded under the local file:// protocol.

Properties
Name Type Description
name string

Filename

data string

The WAV audio file encoded in Base64

Examples

To make a Base64 file with OpenSSL

#openssl base64 -in /path/ir.wav -out /path/ir.base64 
Details
Object

id :string

Description

The id of this Synth instance (same as the DHC id)

Details
string

dhc :HUM.DHC

Description

The DHC instance

Details

status :boolean

Description

The state of the Synth (Power ON/OFF); if false, it is turned off.

Details
boolean

voices :Object

Description

Namespace for FT and HT voices slots

Properties
Name Type Description
ft HUM.Synth#SynthVoice

FT slot for a SynthVoice object

ht Object.<xtnum, HUM.Synth#SynthVoice>

HT slot for a register of SynthVoice objects

Details
Object

volume :Object

Description

Namespace for Gain nodes

Properties
Name Type Description
master GainNode

Final gain out node

mix GainNode

FT+HT mixer gain

ft GainNode

FT gain

ht GainNode

HT gain

defaultValue number

The default volume value for FT and HT

Details
Object

waveform :Object

Description

Namespace for FT and HT waveform

Properties
Name Type Description
ft 'sine' | 'square' | 'sawtooth' | 'triangle'

FTs waveform

ht 'sine' | 'square' | 'sawtooth' | 'triangle'

HTs waveform

Details
Object

envelope :Object

Description

Namespace for the ADSR envelope parameters

Properties
Name Type Description
attack number

Attack time (seconds)

decay number

Decay time (time-constant)

sustain number

Sustain gain value (amount from 0.0 to 1.0)

release number

Release time (seconds)

Details
Object

portamento :Object

Description

Portamento/Glide parameters for monophonic FT and FT/HT osc frequency updates.

Properties
Name Type Description
amount number

Portamento time (time-constant)

lastFreqFT number

Last FT frequency expressed in hertz (Hz); init value should be null

Details
Object

reverb :Object

Description

Namespace for convolver Reverb and wet/dry mixer gains

Properties
Name Type Description
convolver ConvolverNode

Slot for convolver reverb node

wet GainNode

Reverberated gain bus/carrier node

dry GainNode

Dry gain bus/carrier node

amount GainNode

Reverb wey/dry mixing amount (for cross-fade)

defaultValue number

Default value for the wet/dry mixer gain

Details
Object

compressor :DynamicsCompressorNode

Description

The compressor node


vumeter :ScriptProcessorNode

Description

The vumeter from "webAudioPeakMeter" lib
NB: the ScriptProcessorNode is deprecated but still working.

Details

uiElements :Object

Description

UI HTML elements

Properties
Name Type Description
fn Object.<string, HTMLElement>

Functional UI elements

in Object.<string, HTMLElement>

Input UI elements

out Object.<string, HTMLElement>

Output UI elements

Details
Object

Methods


_init()

Description

Initialize the new instance of Synth

Details

updatesFromDHC( msg )

Description

Manage and route an incoming message

Parameters
Name Type Description
msg HUM.DHCmsg

The incoming message

Details

voiceON( type, toneID, velocity )

Description

Create a new voice of the synth

Parameters
Name Type Description
type tonetype

If the voice will be a FTs or HTs

toneID xtnum

The ID of the new voice; the FT/HT tone number

velocity velocity

MIDI Velocity amount (from 0 to 127) of the MIDI-IN message from the controller

Details

voiceOFF( type, toneID, panic )

Description

Destroy a voice of the synth

Parameters
Name Type Default Description
type tonetype

If you need to destroy a FT or HT voice

toneID xtnum

The ID of the voice to be destroy; the FT/HT tone number

panic boolean false

If true tells that the message has been generated by a "hard" All-Notes-Off request.

Details

allNotesOff()

Description

Turns off all the active voices

Details

updateFTfrequency()

Description

Update the frequency of the current playing FT oscillator
(on UI setting changes)

Details

updateHTfrequency()

Description

Update the frequencies of the current playing HT oscillators
(when the FT is changing or on other UI setting changes)

Details

updateWaveform( type )

Description

Update the current FT or HT waveform

Parameters
Name Type Description
type 'sine' | 'square' | 'sawtooth' | 'triangle'

Waveform type

Details

updateReverb( value )

Description

Update the Reverb amount mixing the wet and dry lines with an equal-power cross-fade

Parameters
Name Type Description
value number

Reverb (wet) amount (normalized to 0.0 > 1.0)

Details

updatePitchBend()

Description

Apply the current Pitch Bend amount (from the controller) to every already active synth voices

Details

tryCreateConvolver() → {ConvolverNode}

Description

Try to create a convolver node

Returns
  • The new instance of a ConvolverNode (from Web Audio API)
Throws

Open an alert warning that the browser does not support convolution reverberation

Details

handleIrFile( changeEvent )

Description

Manage the event when the user is trying to load a IR Reverb file

Parameters
Name Type Description
changeEvent Event

DOM change event on 'input' element (reverb file uploader)

Details

readIrFile( file )

Description

Initialize the reading process of the IR Reverb file

Parameters
Name Type Description
file File

The file to be read

Details

loadIrFile( data, fileName )

Description

Load the IR Reverb wav file on the convolver

Parameters
Name Type Description
data ArrayBuffer

The raw binary data of the file

fileName string

The filename

Details

<static> base64ToBlob( file ) → {Blob}

Description

Convert Base64 data held in a string into raw binary blob

Parameters
Name Type Description
file Object

A File-like object

Name Type Description
name Object

Filename

data Object

Data content in Base64

Returns
  • The decoded file in a Blob object

synthState( clickEvent )

Description

Manage the event when the user clicks on the the status of the synth Power ON/OFF checkbox.

Can be used as a sort of PANIC button for stuck synth Voices by the user.

Parameters
Name Type Description
clickEvent Event

Click HTML event on 'input' element (synth checkbox)

Details

_initUI()

Description

Initialize the Synth UI controllers

Details