Home Reference Source Test Repository
import ElectroPhone from 'electrophone/lib/ElectroPhone.js'
public class | source

ElectroPhone

ElectroPhone Library.

Example:

const AudioCtx = window.AudioContext || window.webkitAudioContext;
const synth = new ElectroPhone(new AudioCtx(), { spectrum: false });

Test:

Static Method Summary

Static Public Methods
public static

Describe all ElectroPhone modules with parameters configuration.

public static

getFrequency(note: String, octave: Number): Number

Get frequency float value calculated from given note and octave.

public static

Get module properties by type.

public static

Get complete notes list.

Constructor Summary

Public Constructor
public

constructor(audioContext: AudioContext, properties: ElectroPhoneProperties)

Create a playable web synthesizer instance.

Member Summary

Public Members
public

Method Summary

Public Methods
public

adsr(properties: Object): ElectroPhone

Update the ADSR module.

public

create(id: String, type: String, properties: Object): ElectroPhone

Create a new synth module.

public

Destroy the synth module by id.

public

Returns current synth modules configuration object.

public

link(source: String, target: String): ElectroPhone

Link two modules, connect source module to target module.

public

master(properties: Object): ElectroPhone

Update the master module.

public

play(frequency: Number): ElectroPhone

Start playing the input frequency.

public

stop(frequency: Number): ElectroPhone

Stop playing the input frequency.

public

update(id: String, properties: Object): ElectroPhone

Update the synth module by id.

Static Public Methods

public static describeModules(): Array source

Describe all ElectroPhone modules with parameters configuration.

Return:

Array

public static getFrequency(note: String, octave: Number): Number source

Get frequency float value calculated from given note and octave.

Params:

NameTypeAttributeDescription
note String

note char indicator. sharp char for semi-tones.

octave Number

octave number.

Return:

Number

public static getModuleProperties(moduleType: String): Array source

Get module properties by type.

Params:

NameTypeAttributeDescription
moduleType String

module='' type, taken from ElectroPhone.TYPES.

Return:

Array

public static getNotes(): Array source

Get complete notes list.

Return:

Array

Public Constructors

public constructor(audioContext: AudioContext, properties: ElectroPhoneProperties) source

Create a playable web synthesizer instance.

Params:

NameTypeAttributeDescription
audioContext AudioContext

Web Audio Context instance.

properties ElectroPhoneProperties
  • optional

synth properties.

Test:

Public Members

Public Methods

public adsr(properties: Object): ElectroPhone source

Update the ADSR module.

Params:

NameTypeAttributeDescription
properties Object

ADSR (Envelope) properties

Return:

ElectroPhone

Test:

public create(id: String, type: String, properties: Object): ElectroPhone source

Create a new synth module.

Params:

NameTypeAttributeDescription
id String

the module identifier.

type String

the type of module.

properties Object

module properties.

Return:

ElectroPhone

Throw:

Error

throw error when module with id is already created.

Test:

public destroy(id: String): ElectroPhone source

Destroy the synth module by id.

Params:

NameTypeAttributeDescription
id String

the module identifier.

Return:

ElectroPhone

Throw:

Error

throw error when module with id is not found.

Test:

public getModules(): Object source

Returns current synth modules configuration object.

Return:

Object

current synth modules configuration.

Return Properties:

NameTypeAttributeDescription
master Object

the master ModuleProperties.

adsr Object

the adsr ModuleProperties.

<module_id> ModuleProperties

one ModuleProperties for each created module.

Test:

Link two modules, connect source module to target module.

Params:

NameTypeAttributeDescription
source String

the source module id.

target String

the target module id.

Return:

ElectroPhone

Throw:

Error

throw error when source is master.

Error

throw error when source module is not found.

Error

throw error when target module is not found.

Test:

public master(properties: Object): ElectroPhone source

Update the master module.

Params:

NameTypeAttributeDescription
properties Object

master properties.

Return:

ElectroPhone

Test:

public play(frequency: Number): ElectroPhone source

Start playing the input frequency.

Params:

NameTypeAttributeDescription
frequency Number

the frequency value.

Return:

ElectroPhone

Test:

public stop(frequency: Number): ElectroPhone source

Stop playing the input frequency.

Params:

NameTypeAttributeDescription
frequency Number

the frequency value.

Return:

ElectroPhone

Test:

public update(id: String, properties: Object): ElectroPhone source

Update the synth module by id.

Params:

NameTypeAttributeDescription
id String

the module identifier.

properties Object

module properties.

Return:

ElectroPhone

Throw:

Error

throw error when module with id is not found.

Test: