nCine::IAudioPlayer class

Audio player interface.

Base classes

class Object
Base class of nCine objects.

Derived classes

class AudioBufferPlayer
Audio buffer player.
class AudioStreamPlayer
Audio stream player.

Public types

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

Constructors, destructors, conversion operators

IAudioPlayer(ObjectType type)
~IAudioPlayer() override
IAudioPlayer(IAudioPlayer&&) defaulted
Default move constructor.

Public functions

auto operator=(IAudioPlayer&&) -> IAudioPlayer& defaulted
Default move assignment operator.
auto sourceId() const -> unsigned int
Returns the OpenAL id of the player source.
auto bufferId() const -> unsigned int pure virtual
Returns the OpenAL id of the currently playing buffer.
auto bytesPerSample() const -> int pure virtual
Returns the number of bytes per sample.
auto numChannels() const -> int pure virtual
Returns the number of audio channels of the currently playing buffer.
auto frequency() const -> int pure virtual
Returns the samples frequency of the currently playing buffer.
auto numSamples() const -> unsigned long int pure virtual
Returns the number of samples.
auto duration() const -> float pure virtual
Returns the duration in seconds.
auto bufferSize() const -> unsigned long pure virtual
Returns the size of the currently playing buffer in bytes.
auto sampleOffset() const -> int virtual
Returns the playback position expressed in samples.
void setSampleOffset(int offset) virtual
Sets the playback position expressed in samples.
void play() pure virtual
Starts playing.
void pause() pure virtual
Pauses playing.
void stop() pure virtual
Stops playing and rewind.
auto state() const -> PlayerState
Returns the state of the player.
auto isPlaying() const -> bool
Queries the playing state of the player.
auto isPaused() const -> bool
Queries the paused state of the player.
auto isStopped() const -> bool
Queries the stopped state of the player.
auto isLooping() const -> bool
Queries the looping property of the player.
void setLooping(bool value) virtual
Sets player looping property.
auto isSourceRelative() const -> bool
Queries the source relative property of the player.
void setSourceRelative(bool value) virtual
Sets player source relative property.
auto isAs2D() const -> bool
void setAs2D(bool value) virtual
auto gain() const -> float
Returns player gain value.
void setGain(float gain) virtual
Sets player gain value.
auto pitch() const -> float
Returns player pitch value.
void setPitch(float pitch) virtual
Sets player pitch value.
auto lowPass() const -> float
Returns player low-pass value.
void setLowPass(float value) virtual
Sets player low-pass value.
auto position() const -> Vector3f
Returns player position value.
void setPosition(const Vector3f& position) virtual
Sets player position value through vector.

Protected types

enum class PlayerFlags { None = 0, Looping = 0x01, SourceRelative = 0x02, As2D = 0x04 }

Protected functions

auto GetFlags(PlayerFlags flag) const -> bool constexpr noexcept
void SetFlags(PlayerFlags flag, bool value) constexpr noexcept
void updateState() pure virtual
Updates the state of the player if the source has done playing.
void updateFilters() virtual
auto getAdjustedPosition(IAudioDevice& device, const Vector3f& pos, bool isSourceRelative, bool isAs2D) -> Vector3f virtual
void setPositionInternal(const Vector3f& position)

Protected variables

unsigned int sourceId_
The OpenAL source id.
PlayerState state_
Current player state.
PlayerFlags flags_
Player flags.
float gain_
Player gain value.
float pitch_
Player pitch value.
float lowPass_
Player low-pass value.
Vector3f position_
Player position in space.
unsigned int filterHandle_
Filter handle.

Function documentation

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

Updates the state of the player if the source has done playing.

It is called every frame by the IAudioDevice class and it is also responsible for buffer queueing/unqueueing in stream players.