nCine 2025.06.r503-24a4688
A cross-platform 2D game engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
ncine::AudioBufferPlayer Class Reference

Audio buffer player class. More...

#include <AudioBufferPlayer.h>

Inheritance diagram for ncine::AudioBufferPlayer:
Inheritance graph
[legend]
Collaboration diagram for ncine::AudioBufferPlayer:
Collaboration graph
[legend]

Public Member Functions

 AudioBufferPlayer ()
 Default constructor.
 
 AudioBufferPlayer (AudioBuffer *audioBuffer)
 A constructor creating a player from a shared buffer.
 
 AudioBufferPlayer (AudioBufferPlayer &&)=default
 Default move constructor.
 
AudioBufferPlayeroperator= (AudioBufferPlayer &&)=default
 Default move assignment operator.
 
unsigned int bufferId () const override
 Returns the OpenAL id of the currently playing buffer.
 
int bytesPerSample () const override
 Returns the number of bytes per sample.
 
int numChannels () const override
 Returns the number of audio channels of the currently playing buffer.
 
int frequency () const override
 Returns the samples frequency of the currently playing buffer.
 
unsigned long int numSamples () const override
 Returns the number of samples.
 
float duration () const override
 Returns the duration in seconds.
 
unsigned long int bufferSize () const override
 Returns the size of the currently playing buffer in bytes.
 
const AudioBufferaudioBuffer () const
 Gets the audio buffer used for playing.
 
void setAudioBuffer (AudioBuffer *audioBuffer)
 Sets the audio buffer used for playing.
 
void play () override
 Starts playing.
 
void pause () override
 Pauses playing.
 
void stop () override
 Stops playing and rewinds.
 
- Public Member Functions inherited from ncine::IAudioPlayer
 IAudioPlayer (ObjectType type, const char *name)
 
 IAudioPlayer (ObjectType type)
 
 IAudioPlayer (IAudioPlayer &&)=default
 Default move constructor.
 
IAudioPlayeroperator= (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.
 
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.
 
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.
 
- Public Member Functions inherited from ncine::Object
 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.
 
Objectoperator= (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 Member Functions

static ObjectType sType ()
 
- Static Public Member Functions inherited from ncine::Object
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.
 

Protected Member Functions

void updateState () override
 Updates the player state.
 
- Protected Member Functions inherited from ncine::IAudioPlayer
void applySourceProperties ()
 Applies source properties after registering a player.
 
- Protected Member Functions inherited from ncine::Object
 Object (const Object &other)
 Protected copy constructor used to clone objects.
 

Additional Inherited Members

- Public Types inherited from ncine::IAudioPlayer
enum class  PlayerState { INITIAL = 0 , PLAYING , PAUSED , STOPPED }
 Player state.
 
- Public Types inherited from ncine::Object
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.
 
- Static Public Attributes inherited from ncine::IAudioPlayer
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 Public Attributes inherited from ncine::Object
static const unsigned int MaxNameLength = 128
 Maximum length for an object name.
 
- Protected Attributes inherited from ncine::IAudioPlayer
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.
 
- Protected Attributes inherited from ncine::Object
ObjectType type_
 Object type.
 

Detailed Description

Audio buffer player class.

Member Function Documentation

◆ bufferId()

unsigned int ncine::AudioBufferPlayer::bufferId ( ) const
overridevirtual

Returns the OpenAL id of the currently playing buffer.

Implements ncine::IAudioPlayer.

◆ bufferSize()

unsigned long int ncine::AudioBufferPlayer::bufferSize ( ) const
overridevirtual

Returns the size of the currently playing buffer in bytes.

Implements ncine::IAudioPlayer.

◆ bytesPerSample()

int ncine::AudioBufferPlayer::bytesPerSample ( ) const
overridevirtual

Returns the number of bytes per sample.

Implements ncine::IAudioPlayer.

◆ duration()

float ncine::AudioBufferPlayer::duration ( ) const
overridevirtual

Returns the duration in seconds.

Implements ncine::IAudioPlayer.

◆ frequency()

int ncine::AudioBufferPlayer::frequency ( ) const
overridevirtual

Returns the samples frequency of the currently playing buffer.

Implements ncine::IAudioPlayer.

◆ numChannels()

int ncine::AudioBufferPlayer::numChannels ( ) const
overridevirtual

Returns the number of audio channels of the currently playing buffer.

Implements ncine::IAudioPlayer.

◆ numSamples()

unsigned long int ncine::AudioBufferPlayer::numSamples ( ) const
overridevirtual

Returns the number of samples.

Implements ncine::IAudioPlayer.

◆ pause()

void ncine::AudioBufferPlayer::pause ( )
overridevirtual

Pauses playing.

Implements ncine::IAudioPlayer.

◆ play()

void ncine::AudioBufferPlayer::play ( )
overridevirtual

Starts playing.

Implements ncine::IAudioPlayer.

◆ stop()

void ncine::AudioBufferPlayer::stop ( )
overridevirtual

Stops playing and rewinds.

Implements ncine::IAudioPlayer.

◆ updateState()

void ncine::AudioBufferPlayer::updateState ( )
overrideprotectedvirtual

Updates the player state.

Implements ncine::IAudioPlayer.


The documentation for this class was generated from the following files: