nCine::AudioStreamPlayer class

Plays back an AudioStream decoded on the fly.

Suitable for long sounds such as music. Owns the AudioStream it plays and forwards most queries to it.

Base classes

class IAudioPlayer
Interface for an audio player.

Public static functions

static auto sType() -> ObjectType
Returns the static object type of this class.

Constructors, destructors, conversion operators

AudioStreamPlayer()
AudioStreamPlayer(StringView filename) explicit
Creates a player and loads the stream from the specified file.
~AudioStreamPlayer() override
AudioStreamPlayer(const AudioStreamPlayer&) deleted
AudioStreamPlayer(AudioStreamPlayer&&) defaulted

Public functions

auto operator=(const AudioStreamPlayer&) -> AudioStreamPlayer& deleted
auto operator=(AudioStreamPlayer&&) -> AudioStreamPlayer& defaulted
auto LoadFromFile(const char* filename) -> bool
Loads the stream from the specified file.
auto GetBufferId() const -> std::uint32_t override
Returns the backend id of the currently playing buffer.
auto GetBytesPerSample() const -> std::int32_t override
Returns the number of bytes per sample.
auto GetChannelCount() const -> std::int32_t override
Returns the number of audio channels of the currently playing buffer.
auto GetFrequency() const -> std::int32_t override
Returns the sample frequency of the currently playing buffer.
auto GetSampleCount() const -> std::int32_t override
Returns the total number of samples.
auto GetDuration() const -> float override
Returns the duration in seconds.
auto GetBufferSize() const -> std::int32_t override
Returns the size of the currently playing buffer in bytes.
auto GetStreamSampleCount() const -> std::int32_t
Returns the number of samples held by a single streaming buffer.
auto GetStreamBufferSize() const -> std::int32_t
Returns the size of a single streaming buffer in bytes.
void Play() override
Starts or resumes playback.
void Pause() override
Pauses playback at the current position.
void Stop() override
Stops playback and rewinds to the beginning.
void SetLooping(bool value) override
Sets whether the player should loop.
void UpdateState() override
Updates the player state once the source has finished playing.
auto GetModuleState(AudioModuleState& state) const -> bool partially supported
Returns the state of a tracker module at the position being heard, false if the stream isn't a module.
auto SetModulePosition(std::int32_t order, std::int32_t row) -> bool partially supported
Jumps to a row of a position in the order list of a tracker module.
auto SetModuleSpeed(std::int32_t speed) -> bool partially supported
Sets the ticks per row of a tracker module until the module changes them.
auto SetModuleTempo(std::int32_t tempo) -> bool partially supported
Sets the tempo of a tracker module until the module changes it.
auto SlideModuleChannelVolume(std::int32_t channel, float volume, std::int32_t milliseconds) -> bool partially supported
Changes the volume of a channel of a tracker module gradually, volume is in 0.0 to 1.0.

Function documentation

void nCine::AudioStreamPlayer::UpdateState() override

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.

bool nCine::AudioStreamPlayer::GetModuleState(AudioModuleState& state) const

Returns the state of a tracker module at the position being heard, false if the stream isn't a module.

bool nCine::AudioStreamPlayer::SetModulePosition(std::int32_t order, std::int32_t row)

Jumps to a row of a position in the order list of a tracker module.

While playing, the jump is heard at once. Otherwise the module continues from there once it plays.

bool nCine::AudioStreamPlayer::SetModuleSpeed(std::int32_t speed)

Sets the ticks per row of a tracker module until the module changes them.

bool nCine::AudioStreamPlayer::SetModuleTempo(std::int32_t tempo)

Sets the tempo of a tracker module until the module changes it.

bool nCine::AudioStreamPlayer::SlideModuleChannelVolume(std::int32_t channel, float volume, std::int32_t milliseconds)

Changes the volume of a channel of a tracker module gradually, volume is in 0.0 to 1.0.