import Source from '@mobilizing/library/js/Mobilizing/renderer/audio/Source.js'
Source
Extends:
Constructor Summary
Public Constructor | ||
public | constructor(params: Object) |
Member Summary
Method Summary
Public Methods | ||
public | connect(dest: AudioNode) If you need to connect WebAudio AudioNode by yourself, use this method with the access to the WebAudio Node given by getNativeSource() | |
public | createFromMediaStream(stream: MediaStream, autoConnect: boolean=true) | |
public | Disconnects this source from it current destination | |
public | ||
public | Get this audioContext's gain volume | |
public | get this source loop | |
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 | pause() pauses the Source. | |
public | play() Play this sound source | |
public | setAutoUpdateRotation(val: Boolean) | |
public | set the current Source buffer | |
public | setConeInnerAngle(angle: Number) | |
public | setConeOuterAngle(angle: Number) | |
public | setConeOuterGain(val: Number) | |
public | Set this source's gain volume, use a 1 sec linear ramp to avoid clicks | |
public | set this source loop | |
public | setMaxDistance(val: Number) Sets the maximum distance for sound propagation in space | |
public | setOffsetStartTime(val: Number) Sets the offset play of this sound | |
public | setPlaybackRate(val: Number) Set this source playback rate (speed) | |
public | setRefDistance(val: Number) Sets the reference distance for sound attenuation through space | |
public | setScheduleStartTime(val: Number) 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 | update() Updates the source's position in space if given from a transform |
Inherited Summary
From class Component | ||
public | ||
public | context: * | |
public | events: * | |
public | id: * | |
public | name: * | |
private | _nexts: *[] | |
private | ||
public | byPass() | |
public | 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() preLoad the component This empty method is usually overriden to perform preLoad 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 | prepare() prepare the component This empty method is usually overriden to perform preparation actions for the component, from external process as a server. | |
public | setup() 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() 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#constructorParams:
Name | Type | Attribute | Description |
params | Object | Parameters object, given by the constructor. | |
params.renderer | Renderer | the audio renderer | |
params.is3D | bool | is the audio source positionned in 3D ? | |
params.loop | bool | should the source be played in loop ? | |
params.autoUpdateRotation | bool | should the orientation of the source be updated automatically ? |
Public Members
public autoUpdateRotation: * source
public buffer: * source
public duration: * source
public gain: * source
public is3D: * source
public loop: * source
public mediaElement: * source
public nativeAudioSource: * source
public panner: * source
public renderer: * source
public transform: * source
Public Methods
public connect(dest: AudioNode) source
If you need to connect WebAudio AudioNode by yourself, use this method with the access to the WebAudio Node given by getNativeSource()
Params:
Name | Type | Attribute | Description |
dest | AudioNode | the destination to connect this source to. If this param is undefined, the connection will be made automatically with the renderer's masterGain |
public createFromMediaStream(stream: MediaStream, autoConnect: boolean=true) source
Params:
Name | Type | Attribute | Description |
stream | MediaStream | the MediaStream from which to create this AudioSource | |
autoConnect | boolean=true | if false is given, this source' gain will be disconnected from the destination (renderer masterGain node). Usefull for mic stream analysis that don't need to hear but need to connect to the analyser |
public disconnect() source
Disconnects this source from it current destination
public generateAudioBufferSource() source
public getGain(val: Number): * source
Get this audioContext's gain volume
Params:
Name | Type | Attribute | Description |
val | Number |
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 getScheduleStartTime(): Number source
Gets the offset play of this sound
Return:
Number | the time to start to play the sound buffer |
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#onpublic pause() source
pauses the Source.
public play() source
Play this sound source
public setBuffer(buffer: Object) source
set the current Source buffer
Params:
Name | Type | Attribute | Description |
buffer | Object | the AudioBuffer we want the source to play. |
public setGain(gain: Number, rampValue: Number) source
Set this source's gain volume, use a 1 sec linear ramp to avoid clicks
public setLoop(enabled: Boolean) source
set this source loop
Params:
Name | Type | Attribute | Description |
enabled | Boolean |
public setMaxDistance(val: Number) source
Sets the maximum distance for sound propagation in space
Params:
Name | Type | Attribute | Description |
val | Number |
public setOffsetStartTime(val: Number) source
Sets the offset play of this sound
Params:
Name | Type | Attribute | Description |
val | Number | the time to start to play the sound buffer |
public setPlaybackRate(val: Number) source
Set this source playback rate (speed)
Params:
Name | Type | Attribute | Description |
val | Number |
public setRefDistance(val: Number) source
Sets the reference distance for sound attenuation through space
Params:
Name | Type | Attribute | Description |
val | Number |
public setScheduleStartTime(val: Number) source
Sets the start time play of this sound in current rendrer time
Params:
Name | Type | Attribute | Description |
val | Number | 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:
Name | Type | Attribute | Description |
transform | Object | the Transform. |
public stop() source
stops the Source.
public update() source
Updates the source's position in space if given from a transform