Repository

Source

Extends:

Component → Source

Source Class. Encapsulates the concept of Audio source, a sound-emitting entity with a given position in space. requires the Web Audio API.

The webAudio graph used here is : AudioBufferSourceNode -> GainNode -> MasterGainNode (a GainNode inside the renderer).

if the property "is3D" is set to "true" then it is : AudioBufferSourceNode -> GainNode -> PannerNode -> MasterGainNode (a GainNode inside the renderer).

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public

buffer: *

public
public
public

gain: *

public

is3D: *

public

loop: *

public
public
public
public

panner: *

public
public
public
public
public
public

Method Summary

Public Methods
public
public

getGain(val: Number): *

Get this audioContext's gain volume

public

getNativeSource(): AudioBufferSourceNode

Return the underlying WebAudio audio source

public

Gets the offset play of this sound

public

Get this source playback rate (speed)

public

Gets the offset play of this sound

public

off()

public
public

on()

public

pauses the Source.

public

play(time: Number)

Play this sound source

public
public

setBuffer(buffer: Object)

set the current Source buffer

public
public
public
public

Set this source's gain volume, use a 1 sec linear ramp to avoid clicks

public

setLoop(enabled: Boolean)

set this source loop

public

Sets the maximum distance for sound propagation in space

public

Sets the offset play of this sound

public

Set this source playback rate (speed)

public

Sets the reference distance for sound attenuation through space

public

Sets the start time play of this sound in current rendrer time

public

setTransform(transform: Object)

set the current Transform that represents the Source position in space.

public

stop()

stops the Source.

public

Updates the source's position in space if given from a transform

Inherited Summary

From class Component
public
public
public

events: *

public

id: *

public

name: *

private

_nexts: *[]

private
public
public

chain(component: Component)

Adds a component to this chained component array

public

Returns the array of attached children components

public

off()

Deactivate the component

public

on()

Activate the component A call to this method calls the setup method if it has not been run yet

public

Run code after the update of all components is run This empty method is usually overriden to perform post-update actions for the component It is called periodically by an internal Mobilizing mechanism

public

preLoad the component This empty method is usually overriden to perform setup actions for the component.

public

Run code before the update of all components is run This empty method is usually overriden to perform pre-update actions for the component It is called once per component by an internal Mobilizing mechanism

public

Set's up the component This empty method is usually overriden to perform setup actions for the component This is where all the initialization (such as adding event listeners)should be done It is called automatically by an internal Mobilizing mechanism and should thus not be called directly

public

Update the component This empty method is usually overriden to perform update actions for the component It is called periodically by an internal Mobilizing mechanism

Public Constructors

public constructor(params: Object) source

Override:

Component#constructor

Params:

NameTypeAttributeDescription
paramsObject

Parameters object, given by the constructor.

params.rendererRenderer

the audio renderer

params.is3Dbool

is the audio source positionned in 3D ?

params.loopbool

should the source be played in loop ?

params.autoUpdateRotationbool

should the orientation of the source be updated automatically ?

Public Members

public autoUpdateRotation: * source

public buffer: * source

public currentTime: number source

public duration: * source

public gain: * source

public is3D: * source

public loop: * source

public mediaElement: * source

public nativeAudioSource: * source

public offsetStartTime: number source

public panner: * source

public playbackRate: number source

public playing: boolean source

public renderer: * source

public scheduleStartTime: number source

public startedTime: number source

public transform: * source

Public Methods

public generateAudioBufferSource() source

public getGain(val: Number): * source

Get this audioContext's gain volume

Params:

NameTypeAttributeDescription
valNumber

Return:

*

public getNativeSource(): AudioBufferSourceNode source

Return the underlying WebAudio audio source

Return:

AudioBufferSourceNode

webAudio source

public getOffsetStartTime(): Number source

Gets the offset play of this sound

Return:

Number

the time to start to play the sound buffer

public getPlaybackRate(): Number source

Get this source playback rate (speed)

Return:

Number

public getScheduleStartTime(): Number source

Gets the offset play of this sound

Return:

Number

the time to start to play the sound buffer

public off() source

Deactivate the component

Override:

Component#off

public offlinePlay() source

public on() source

Activate the component A call to this method calls the setup method if it has not been run yet

Override:

Component#on

public pause() source

pauses the Source.

public play(time: Number) source

Play this sound source

Params:

NameTypeAttributeDescription
timeNumber

the time to start the sound from

public setAutoUpdateRotation(val: Boolean) source

Params:

NameTypeAttributeDescription
valBoolean

public setBuffer(buffer: Object) source

set the current Source buffer

Params:

NameTypeAttributeDescription
bufferObject

the AudioBuffer we want the source to play.

public setConeInnerAngle(angle: Number) source

Params:

NameTypeAttributeDescription
angleNumber

public setConeOuterAngle(angle: Number) source

Params:

NameTypeAttributeDescription
angleNumber

public setConeOuterGain(val: Number) source

Params:

NameTypeAttributeDescription
valNumber

public setGain(val: Number) source

Set this source's gain volume, use a 1 sec linear ramp to avoid clicks

Params:

NameTypeAttributeDescription
valNumber

public setLoop(enabled: Boolean) source

set this source loop

Params:

NameTypeAttributeDescription
enabledBoolean

public setMaxDistance(val: Number) source

Sets the maximum distance for sound propagation in space

Params:

NameTypeAttributeDescription
valNumber

public setOffsetStartTime(val: Number) source

Sets the offset play of this sound

Params:

NameTypeAttributeDescription
valNumber

the time to start to play the sound buffer

public setPlaybackRate(val: Number) source

Set this source playback rate (speed)

Params:

NameTypeAttributeDescription
valNumber

public setRefDistance(val: Number) source

Sets the reference distance for sound attenuation through space

Params:

NameTypeAttributeDescription
valNumber

public setScheduleStartTime(val: Number) source

Sets the start time play of this sound in current rendrer time

Params:

NameTypeAttributeDescription
valNumber

the time to start to play the sound buffer

public setTransform(transform: Object) source

set the current Transform that represents the Source position in space.

Params:

NameTypeAttributeDescription
transformObject

the Transform.

public stop() source

stops the Source.

public update() source

Updates the source's position in space if given from a transform

Override:

Component#update