nCine::IAudioPlayer class

Interface for an audio player.

Common base for AudioBufferPlayer and AudioStreamPlayer, wraps a single source of the device.

Base classes

class Object
Base class of all nCine objects.

Derived classes

class AudioBufferPlayer
Plays back a fully decoded AudioBuffer.
class AudioStreamPlayer
Plays back an AudioStream decoded on the fly.

Public types

enum class PlayerState { Initial = 0, Playing, Paused, Stopped }
Playback state.

Constructors, destructors, conversion operators

IAudioPlayer(ObjectType type)
~IAudioPlayer() override
IAudioPlayer(IAudioPlayer&&) defaulted

Public functions

auto operator=(IAudioPlayer&&) -> IAudioPlayer& defaulted
auto GetSourceId() const -> std::uint32_t
Returns the backend id of the source.
auto GetBufferId() const -> std::uint32_t pure virtual
Returns the backend id of the currently playing buffer.
auto GetBytesPerSample() const -> std::int32_t pure virtual
Returns the number of bytes per sample.
auto GetChannelCount() const -> std::int32_t pure virtual
Returns the number of audio channels of the currently playing buffer.
auto GetFrequency() const -> std::int32_t pure virtual
Returns the sample frequency of the currently playing buffer.
auto GetSampleCount() const -> std::int32_t pure virtual
Returns the total number of samples.
auto GetDuration() const -> float pure virtual
Returns the duration in seconds.
auto GetBufferSize() const -> std::int32_t pure virtual
Returns the size of the currently playing buffer in bytes.
auto GetSampleOffset() const -> std::int32_t virtual
Returns the current playback position in samples.
void SetSampleOffset(std::int32_t offset) virtual
Sets the current playback position in samples.
void Play() pure virtual
Starts or resumes playback.
void Pause() pure virtual
Pauses playback at the current position.
void Stop() pure virtual
Stops playback and rewinds to the beginning.
auto GetState() const -> PlayerState
Returns the current playback state.
auto IsSilent() const -> bool
Returns true if the player is currently playing.
auto IsPlaying() const -> bool
auto IsPaused() const -> bool
Returns true if the player is paused.
auto IsStopped() const -> bool
Returns true if the player is stopped.
auto IsLooping() const -> bool
Returns true if the player is looping.
void SetLooping(bool value) virtual
Sets whether the player should loop.
auto IsSourceRelative() const -> bool
Returns true if the position is relative to the listener.
void SetSourceRelative(bool value) virtual
Sets whether the position is relative to the listener.
auto IsAs2D() const -> bool
Returns true if the player is forced to behave as a 2D source.
void SetAs2D(bool value) virtual
Sets whether the player should behave as a 2D source.
auto GetGain() const -> float
Returns the player gain.
void SetGain(float gain) virtual
Sets the player gain.
auto GetPitch() const -> float
Returns the player pitch.
void SetPitch(float pitch) virtual
Sets the player pitch.
auto GetLowPass() const -> float
Returns the player low-pass amount.
void SetLowPass(float value) virtual
Sets the player low-pass amount.
auto GetPosition() const -> Vector3f
Returns the player position.
void SetPosition(const Vector3f& position) virtual
Sets the player position.

Protected functions

void UpdateState() pure virtual
Updates the player state once the source has finished playing.
void UpdateFilters() virtual
auto GetAdjustedPosition(IAudioDevice& device, const Vector3f& pos, bool isSourceRelative, bool isAs2D) -> Vector3f virtual
void SetPositionInternal(const Vector3f& position)

Enum documentation

enum class nCine::IAudioPlayer::PlayerState

Playback state.

Enumerators
Initial

Created but never played

Playing

Currently playing

Paused

Paused, can be resumed from the current position

Stopped

Stopped and rewound to the beginning

Function documentation

bool nCine::IAudioPlayer::IsSilent() const

Returns true if the player is currently playing.

Returns true if the player is configured so that nothing could be heard from it

All user volumes are folded into the gain, so zero gain means muted.

void nCine::IAudioPlayer::UpdateState() pure virtual protected

Updates the player state once the source has finished playing.

Called every frame by IAudioDevice. In stream players it is also responsible for queueing and unqueueing buffers.