Channel¶
An object that represents a single channel of audio.
Detailed Description¶
The Channel class is a lightweight reference to a ChannelInternalState object which is managed internally by the Engine. Multiple channels may point to the same underlying data while maintaining different states.
Public Functions¶
| Type | Name |
|---|---|
| ChannelInstance | AddInstance (const AmVector3 & location) const Adds a new instance at the specified world position. |
| Channel () Construct an uninitialized channel. | |
| Channel (ChannelInternalState * state) Creates a wrapper instance over the provided state. | |
| void | Clear () Uninitializes this channel. |
| void | ClearInstances () const Removes all instances. |
| void | DisableInstancing () const Disables multi-position mode, reverting to single-position behavior. |
| void | EnableInstancing (eChannelInstanceMode mode) const Enables multi-position mode for this channel. |
| Entity | GetEntity () const Returns the Entity associated with this channel. |
| AmReal32 | GetGain () const Returns the gain on this channel. |
| AmChannelID | GetId () const Gets the ID of this channel. |
| ChannelInstance | GetInstance (AmChannelInstanceID instanceId) const Gets an instance by ID. |
| AmSize | GetInstanceCount () const Gets the number of active instances. |
| eChannelInstanceMode | GetInstancingMode () const Gets the instancing mode. |
| Listener | GetListener () const Returns the Listener associated with this channel. |
| const AmVector3 & | GetLocation () const Gets the location of this channel in the game environment. |
| eChannelPlaybackState | GetPlaybackState () const Returns the playback state of this channel. |
| Room | GetRoom () const Returns the Room associated with this channel. |
| ChannelInternalState * | GetState () const Returns the internal state of this channel. |
| bool | IsInstancingEnabled () const Checks if multi-position instancing is enabled. |
| void | On (eChannelEvent event, ChannelEventCallback callback, void * userData=nullptr) const Registers a callback for a channel event. |
| void | Pause (AmTime duration=kMinFadeDuration) const Pauses the channel. |
| bool | Playing () const Checks if the sound associated with this channel is playing. |
| void | RemoveInstance (AmChannelInstanceID instanceId) const Removes an instance by ID. |
| void | Resume (AmTime duration=kMinFadeDuration) const Resumes the channel. |
| void | SetGain (AmReal32 gain) const Sets the gain on this channel. |
| void | SetLocation (const AmVector3 & location) const Sets the location of this channel in the game environment. |
| void | Stop (AmTime duration=kMinFadeDuration) const Stops the channel. |
| bool | Valid () const Checks whether this channel has been initialized. |
Public Functions Documentation¶
AddInstance
Adds a new instance at the specified world position.
Creates a new position instance for this channel. In Blended mode, all instances share the same playback cursor. In Separate mode, each instance has an independent cursor starting from the current playback position.
Parameters:
-
locationThe world position for the new instance.
Returns:
The created ChannelInstance handle.
Note:
Instancing must be enabled before adding instances.
See also: EnableInstancing
See also: ChannelInstance
Channel[1/3]
Construct an uninitialized channel.
Note:
An uninitialized channel cannot have its data set or queried.
Channel[2/3]
Creates a wrapper instance over the provided state.
Parameters:
-
stateThe internal state to wrap.
Warning:
This constructor is for internal usage only.
Clear
Uninitializes this channel.
Note:
This does not stop the audio or destroy the internal state it references, it just removes this reference to it.
ClearInstances
Removes all instances.
After calling this, the channel will have no position instances. Instancing will still be enabled with the same mode.
DisableInstancing
Disables multi-position mode, reverting to single-position behavior.
All existing instances will be removed when instancing is disabled.
EnableInstancing
Enables multi-position mode for this channel.
When enabled, this channel can have multiple position instances, allowing the same sound to be perceived from multiple locations simultaneously.
Parameters:
-
modeThe instance mode.
Note:
Must be called before adding instances. The mode cannot be changed while instancing is already enabled.
See also: eChannelInstanceMode
See also: AddInstance
GetEntity
Returns the Entity associated with this channel.
Note:
If no Entity is associated with this channel, this method will return an uninitialized Entity object. You should check if the entity is valid before using it.
Returns:
The entity associated with this channel.
See also: Entity
GetGain
Returns the gain on this channel.
Returns:
The channel's gain.
GetId
Gets the ID of this channel.
Returns:
The ID of this channel.
GetInstance
Gets an instance by ID.
Parameters:
-
instanceIdThe ID of the instance to retrieve.
Returns:
The ChannelInstance handle, or an invalid instance if not found.
See also: ChannelInstance::Valid
GetInstanceCount
Gets the number of active instances.
Returns:
The number of position instances.
GetInstancingMode
Gets the instancing mode.
Returns:
The current instancing mode.
See also: eChannelInstanceMode
GetListener
Returns the Listener associated with this channel.
Note:
If no Listener is associated with this channel, this method will return an uninitialized Listener object. You should check if the listener is valid before using it.
Returns:
The listener associated with this channel.
See also: Listener
GetLocation
Gets the location of this channel in the game environment.
If the audio on this channel doesn't support positional data, this method will return an invalid location.
Returns:
The location of this channel.
GetPlaybackState
Returns the playback state of this channel.
Returns:
An eChannelPlaybackState enumeration value representing the current state of the channel.
GetRoom
Returns the Room associated with this channel.
Note:
If no Room is associated with this channel, this method will return an uninitialized Room object. You should check if the room is valid before using it.
Returns:
The room associated with this channel.
GetState
Returns the internal state of this channel.
Returns:
The internal state of this channel.
Warning:
This method is for internal usage only.
IsInstancingEnabled
Checks if multi-position instancing is enabled.
Returns:
true if instancing is enabled, false otherwise.
On
Registers a callback for a channel event.
void Amplitude::Channel::On (
eChannelEvent event,
ChannelEventCallback callback,
void * userData=nullptr
) const
Parameters:
-
eventThe channel event. -
callbackThe callback function. -
userDataThe user data to pass to the callback.
See also: eChannelEvent
See also: ChannelEventCallback
Pause
Pauses the channel.
Note:
A paused channel may be resumed where it left off.
Parameters:
-
durationThe fade out duration before to pause the channel.
See also: Resume
Playing
Checks if the sound associated with this channel is playing.
Returns:
true if the channel is currently playing, false otherwise.
RemoveInstance
Removes an instance by ID.
Parameters:
-
instanceIdThe ID of the instance to remove.
See also: ChannelInstance::GetId
Resume
Resumes the channel.
If this channel is paused, it will continue where it left off.
Parameters:
-
durationThe fade-in duration after resuming the channel.
See also: Pause
SetGain
Sets the gain on this channel.
Parameters:
-
gainThe new gain value.
SetLocation
Sets the location of this channel in the game environment.
If the audio on this channel doesn't support positional data, this method does nothing.
Parameters:
-
locationThe new location of the channel.
Stop
Stops the channel.
Note:
A sound will stop on its own if it's not set to loop. Looped audio must be explicitly stopped.
Parameters:
-
durationThe fade out duration before to stop the channel.
Valid
Checks whether this channel has been initialized.
Returns:
true if this channel has been initialized, false otherwise.
The documentation for this class was generated from the following file: include/SparkyStudios/Audio/Amplitude/Core/Playback/Channel.h