Home Manual Reference Source
import AudioContext from 'itslanguage/WebAudio/AudioContext.js'
public class | source

AudioContext

Direct Subclass:

Player, Recorder

Recorder Simple Audio Recorder based on WebAudio technology

Constructor Summary

Public Constructor
public

constructor(audioContext: Object, debugNameSpace: string)

Construct the Player.

Member Summary

Public Members
public

Private object to hold AudioContext node.

public

This will be the error function.

public

This will be the log function.

Private Members
private

Keep a list of all registered event listeners.

Method Summary

Public Methods
public

addEventListener(args: ...*)

Wraps the addEventListener which is available on the AudioContext node.

public

Get the audio context or create one.

public

fireEvent(eventName: string, data: Object)

Use this method to conveniently fire an event.

public
public

removeEventListener(args: ...*)

Wraps the removeEventListener which is available on the AudioContext node.

public

Resume a suspended AudioContext.

public

Suspend the AudioContext to preserve power and such.

Public Constructors

public constructor(audioContext: Object, debugNameSpace: string) source

Construct the Player.

Params:

NameTypeAttributeDescription
audioContext Object

Allow to provide custom/own audioContext object.

debugNameSpace string

Name to be used for debugging.

Public Members

public audioContext: AudioContext source

Private object to hold AudioContext node.

public error: Function source

This will be the error function. Will output to stderr.

public log: Function source

This will be the log function. Will output to stdout.

Private Members

private eventListeners: Array source

Keep a list of all registered event listeners. This way, we could conveniently remove all the listeners at once.

Public Methods

public addEventListener(args: ...*) source

Wraps the addEventListener which is available on the AudioContext node. Note that it is requierd to pass a named function to actually be able to remove an event listeners. This is just how the EventTarget.removeEventListener works. There are no extra checks for.

Params:

NameTypeAttributeDescription
args ...*

Array with passed arguments.

See:

public createAudioContext(): AudioContext source

Get the audio context or create one.

Return:

AudioContext

The AudioContext created will be returned

public fireEvent(eventName: string, data: Object) source

Use this method to conveniently fire an event. We could, if we wanted, add some data.

Params:

NameTypeAttributeDescription
eventName string

Event to fire.

data Object

Data to pass as detail.

public removeAllEventListeners() source

public removeEventListener(args: ...*) source

Wraps the removeEventListener which is available on the AudioContext node. Make sure to call with the same arguments as the addEventListner.

If you didn't call the addEventListener with a named function, please note that you won't be able to remove the eventListener.

Params:

NameTypeAttributeDescription
args ...*

Array with passed arguments.

See:

public resumeAudioContext() source

Resume a suspended AudioContext.

public suspendAudioContext() source

Suspend the AudioContext to preserve power and such.