![]() |
nCine 2025.06.r503-24a4688
A cross-platform 2D game engine
|
Audio player interface class. More...
#include <IAudioPlayer.h>
Public Types | |
enum class | PlayerState { INITIAL = 0 , PLAYING , PAUSED , STOPPED } |
Player state. | |
![]() | |
enum class | ObjectType { BASE = 0 , TEXTURE , SHADER , SCENENODE , SPRITE , MESH_SPRITE , ANIMATED_SPRITE , PARTICLE , PARTICLE_SYSTEM , FONT , TEXTNODE , AUDIOBUFFER , AUDIOBUFFER_PLAYER , AUDIOSTREAM_PLAYER } |
Object types. | |
Public Member Functions | |
IAudioPlayer (ObjectType type, const char *name) | |
IAudioPlayer (ObjectType type) | |
IAudioPlayer (IAudioPlayer &&)=default | |
Default move constructor. | |
IAudioPlayer & | operator= (IAudioPlayer &&)=default |
Default move assignment operator. | |
bool | hasSource () const |
Returns true if a valid OpenAL source is currently assigned to the player. | |
unsigned int | sourceId () const |
Returns the OpenAL id of the player source. | |
virtual unsigned int | bufferId () const =0 |
Returns the OpenAL id of the currently playing buffer. | |
virtual int | bytesPerSample () const =0 |
Returns the number of bytes per sample. | |
virtual int | numChannels () const =0 |
Returns the number of audio channels of the currently playing buffer. | |
virtual int | frequency () const =0 |
Returns the samples frequency of the currently playing buffer. | |
virtual unsigned long int | numSamples () const =0 |
Returns the number of samples. | |
virtual float | duration () const =0 |
Returns the duration in seconds. | |
virtual unsigned long | bufferSize () const =0 |
Returns the size of the currently playing buffer in bytes. | |
int | sampleOffset () const |
Returns the playback position expressed in samples. | |
void | setSampleOffset (int offset) |
Sets the playback position expressed in samples. | |
bool | isSourceLocked () const |
Returns true if the OpenAL source is locked. | |
void | setSourceLocked (bool sourceLocked) |
Locks an OpenAL source so it is not released to the pool when the player stops. | |
virtual void | play ()=0 |
Starts playing. | |
virtual void | pause ()=0 |
Pauses playing. | |
virtual void | stop ()=0 |
Stops playing and rewinds. | |
PlayerState | state () const |
Returns the state of the player. | |
bool | isPlaying () const |
Returns true if the player is playing. | |
bool | isPaused () const |
Returns true if the player is paused. | |
bool | isStopped () const |
Returns true if the player is stopped. | |
bool | isLooping () const |
Returns the looping property of the player. | |
void | setLooping (bool isLooping) |
Sets the looping property of the player. | |
float | gain () const |
Returns the player gain value. | |
void | setGain (float gain) |
Sets the player gain value. | |
float | pitch () const |
Returns the player pitch value. | |
void | setPitch (float pitch) |
Sets the player pitch value. | |
Vector3f | position () const |
Returns the player position vector. | |
void | setPosition (const Vector3f &position) |
Sets the player position vector. | |
void | setPosition (float x, float y, float z) |
Sets the player position vector through components. | |
Vector3f | velocity () const |
Returns the player velocity vector. | |
void | setVelocity (const Vector3f &velocity) |
Sets the player velocity vector. | |
void | setVelocity (float x, float y, float z) |
Sets the player velocity vector through components. | |
Vector3f | direction () const |
Returns the player direction vector. | |
void | setDirection (const Vector3f &direction) |
Sets the player direction vector. | |
void | setDirection (float x, float y, float z) |
Sets the player direction vector through components. | |
float | coneInnerAngle () const |
Returns the player inside angle of the sound cone in degrees. | |
void | setConeInnerAngle (float coneAngle) |
Sets the player inside angle of the sound cone in degrees. | |
float | coneOuterAngle () const |
Returns the player outside angle of the sound cone in degrees. | |
void | setConeOuterAngle (float coneAngle) |
Sets the player outside angle of the sound cone in degrees. | |
float | coneOuterGain () const |
Returns the player multiplication factor to determine the gain outside the cone. | |
void | setConeOuterGain (float gain) |
Sets the player multiplication factor to determine the gain outside the cone. | |
![]() | |
Object (ObjectType type) | |
Constructs an object with a specified type and adds it to the index. | |
Object (ObjectType type, const char *name) | |
Constructs an object with a specified type and name and adds it to the index. | |
virtual | ~Object () |
Removes an object from the index and then destroys it. | |
Object (Object &&other) | |
Move constructor. | |
Object & | operator= (Object &&other) |
Move assignment operator. | |
unsigned int | id () const |
Returns the object identification number. | |
ObjectType | type () const |
Returns the object type (RTTI) | |
const char * | name () const |
Returns the object name. | |
void | setName (const char *name) |
Sets the object name. | |
Static Public Attributes | |
static const float | MinGain = 0.0f |
static const float | DefaultGain = 1.0f |
static const float | MaxGain = 1.0f |
static const float | MinPitch = 0.5f |
static const float | DefaultPitch = 1.0f |
static const float | MaxPitch = 2.0f |
static const float | MinConeAngle = 0.0f |
static const float | DefaultConeAngle = 360.0f |
static const float | MaxConeAngle = 360.0f |
static const float | MinConeOuterGain = 0.0f |
static const float | DefaultConeOuterGain = 0.0f |
static const float | MaxConeOuterGain = 1.0f |
static const float | MinAirAbsorptionFactor = 0.0f |
static const float | DefaultAirAbsorptionFactor = 0.0f |
static const float | MaxAirAbsorptionFactor = 10.0f |
static const float | MinRoomRolloffFactor = 0.0f |
static const float | DefaultRoomRolloffFactor = 0.0f |
static const float | MaxRoomRolloffFactor = 10.0f |
static const float | MinConeOuterGainHF = 0.0f |
static const float | DefaultConeOuterGainHF = 0.0f |
static const float | MaxConeOuterGainHF = 1.0f |
![]() | |
static const unsigned int | MaxNameLength = 128 |
Maximum length for an object name. | |
Protected Member Functions | |
virtual void | updateState ()=0 |
Updates the state of the player if the source has finished playing. | |
void | applySourceProperties () |
Applies source properties after registering a player. | |
![]() | |
Object (const Object &other) | |
Protected copy constructor used to clone objects. | |
Protected Attributes | |
unsigned int | sourceId_ |
The OpenAL source id. | |
bool | sourceLocked_ |
The flag indicating if an OpenAL source is locked and never released to the pool. | |
PlayerState | state_ |
Current player state. | |
bool | isLooping_ |
Looping status flag. | |
float | gain_ |
Player gain value. | |
float | pitch_ |
Player pitch value. | |
Vector3f | position_ |
Player position in space. | |
Vector3f | velocity_ |
Player velocity in space. | |
Vector3f | direction_ |
Player direction in space. | |
float | coneInnerAngle_ |
Inside angle of the sound cone in degrees. | |
float | coneOuterAngle_ |
Outside angle of the sound cone in degrees. | |
float | coneOuterGain_ |
Multiplication factor to determine the gain outside the cone. | |
float | airAbsorptionFactor_ |
Player air absorption factor value. | |
float | roomRooloffFactor_ |
Player room rolloff factor value. | |
float | coneOuterGainHF_ |
Player cone outer gain HF value. | |
unsigned int | effectSlotId_ |
The OpenAL effect slot id to use when playing. | |
unsigned int | auxFilterId_ |
The OpenAL auxiliary filter id to use when playing. | |
unsigned int | directFilterId_ |
The OpenAL direct filter id to use when playing. | |
![]() | |
ObjectType | type_ |
Object type. | |
Friends | |
class | ALAudioDevice |
Additional Inherited Members | |
![]() | |
static ObjectType | sType () |
Static method to return class type. | |
template<class T > | |
static T * | fromId (unsigned int id) |
Returns a casted pointer to the object with the specified id, if any exists. | |
Audio player interface class.
|
pure virtual |
Returns the OpenAL id of the currently playing buffer.
Implemented in ncine::AudioBufferPlayer, and ncine::AudioStreamPlayer.
|
pure virtual |
Returns the size of the currently playing buffer in bytes.
Implemented in ncine::AudioBufferPlayer, and ncine::AudioStreamPlayer.
|
pure virtual |
Returns the number of bytes per sample.
Implemented in ncine::AudioBufferPlayer, and ncine::AudioStreamPlayer.
|
pure virtual |
Returns the duration in seconds.
Implemented in ncine::AudioBufferPlayer, and ncine::AudioStreamPlayer.
|
pure virtual |
Returns the samples frequency of the currently playing buffer.
Implemented in ncine::AudioBufferPlayer, and ncine::AudioStreamPlayer.
|
pure virtual |
Returns the number of audio channels of the currently playing buffer.
Implemented in ncine::AudioBufferPlayer, and ncine::AudioStreamPlayer.
|
pure virtual |
Returns the number of samples.
Implemented in ncine::AudioBufferPlayer, and ncine::AudioStreamPlayer.
|
pure virtual |
Pauses playing.
Implemented in ncine::AudioBufferPlayer, and ncine::AudioStreamPlayer.
|
pure virtual |
Starts playing.
Implemented in ncine::AudioBufferPlayer, and ncine::AudioStreamPlayer.
void ncine::IAudioPlayer::setDirection | ( | const Vector3f & | direction | ) |
Sets the player direction vector.
void ncine::IAudioPlayer::setDirection | ( | float | x, |
float | y, | ||
float | z | ||
) |
Sets the player direction vector through components.
void ncine::IAudioPlayer::setSourceLocked | ( | bool | sourceLocked | ) |
Locks an OpenAL source so it is not released to the pool when the player stops.
|
pure virtual |
Stops playing and rewinds.
Implemented in ncine::AudioBufferPlayer, and ncine::AudioStreamPlayer.
|
protectedpure virtual |
Updates the state of the player if the source has finished playing.
It is called every frame by the IAudioDevice
class and it is also responsible for buffer queueing/unqueueing in stream players.
Implemented in ncine::AudioBufferPlayer, and ncine::AudioStreamPlayer.
|
protected |
Inside angle of the sound cone in degrees.
|
protected |
Outside angle of the sound cone in degrees.
|
protected |
Player direction in space.