Skip to content

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.

ChannelInstance Amplitude::Channel::AddInstance (
    const AmVector3 & location
) const

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:

  • location The 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.

Amplitude::Channel::Channel () 

Note:

An uninitialized channel cannot have its data set or queried.

Channel[2/3]

Creates a wrapper instance over the provided state.

explicit Amplitude::Channel::Channel (
    ChannelInternalState * state
) 

Parameters:

  • state The internal state to wrap.

Warning:

This constructor is for internal usage only.

Clear

Uninitializes this channel.

void Amplitude::Channel::Clear () 

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.

void Amplitude::Channel::ClearInstances () const

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.

void Amplitude::Channel::DisableInstancing () const

All existing instances will be removed when instancing is disabled.

EnableInstancing

Enables multi-position mode for this channel.

void Amplitude::Channel::EnableInstancing (
    eChannelInstanceMode mode
) const

When enabled, this channel can have multiple position instances, allowing the same sound to be perceived from multiple locations simultaneously.

Parameters:

  • mode The 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.

Entity Amplitude::Channel::GetEntity () const

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.

AmReal32 Amplitude::Channel::GetGain () const

Returns:

The channel's gain.

GetId

Gets the ID of this channel.

AmChannelID Amplitude::Channel::GetId () const

Returns:

The ID of this channel.

GetInstance

Gets an instance by ID.

ChannelInstance Amplitude::Channel::GetInstance (
    AmChannelInstanceID instanceId
) const

Parameters:

  • instanceId The 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.

AmSize Amplitude::Channel::GetInstanceCount () const

Returns:

The number of position instances.

GetInstancingMode

Gets the instancing mode.

eChannelInstanceMode Amplitude::Channel::GetInstancingMode () const

Returns:

The current instancing mode.

See also: eChannelInstanceMode

GetListener

Returns the Listener associated with this channel.

Listener Amplitude::Channel::GetListener () const

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.

const AmVector3 & Amplitude::Channel::GetLocation () const

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.

eChannelPlaybackState Amplitude::Channel::GetPlaybackState () const

Returns:

An eChannelPlaybackState enumeration value representing the current state of the channel.

GetRoom

Returns the Room associated with this channel.

Room Amplitude::Channel::GetRoom () const

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.

ChannelInternalState * Amplitude::Channel::GetState () const

Returns:

The internal state of this channel.

Warning:

This method is for internal usage only.

IsInstancingEnabled

Checks if multi-position instancing is enabled.

bool Amplitude::Channel::IsInstancingEnabled () const

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:

  • event The channel event.
  • callback The callback function.
  • userData The user data to pass to the callback.

See also: eChannelEvent

See also: ChannelEventCallback

Pause

Pauses the channel.

void Amplitude::Channel::Pause (
    AmTime duration=kMinFadeDuration
) const

Note:

A paused channel may be resumed where it left off.

Parameters:

  • duration The fade out duration before to pause the channel.

See also: Resume

Playing

Checks if the sound associated with this channel is playing.

bool Amplitude::Channel::Playing () const

Returns:

true if the channel is currently playing, false otherwise.

RemoveInstance

Removes an instance by ID.

void Amplitude::Channel::RemoveInstance (
    AmChannelInstanceID instanceId
) const

Parameters:

  • instanceId The ID of the instance to remove.

See also: ChannelInstance::GetId

Resume

Resumes the channel.

void Amplitude::Channel::Resume (
    AmTime duration=kMinFadeDuration
) const

If this channel is paused, it will continue where it left off.

Parameters:

  • duration The fade-in duration after resuming the channel.

See also: Pause

SetGain

Sets the gain on this channel.

void Amplitude::Channel::SetGain (
    AmReal32 gain
) const

Parameters:

  • gain The new gain value.
SetLocation

Sets the location of this channel in the game environment.

void Amplitude::Channel::SetLocation (
    const AmVector3 & location
) const

If the audio on this channel doesn't support positional data, this method does nothing.

Parameters:

  • location The new location of the channel.
Stop

Stops the channel.

void Amplitude::Channel::Stop (
    AmTime duration=kMinFadeDuration
) const

Note:

A sound will stop on its own if it's not set to loop. Looped audio must be explicitly stopped.

Parameters:

  • duration The fade out duration before to stop the channel.
Valid

Checks whether this channel has been initialized.

bool Amplitude::Channel::Valid () const

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