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

A class representing an OpenAL buffer. More...

#include <AudioBuffer.h>

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

Public Types

enum class  Format { MONO8 , STEREO8 , MONO16 , STEREO16 }
 
- 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.
 

Public Member Functions

 AudioBuffer ()
 Creates an OpenAL buffer name.
 
 AudioBuffer (const char *bufferName, const unsigned char *bufferPtr, unsigned long int bufferSize)
 A constructor creating a buffer from memory.
 
 AudioBuffer (const char *filename)
 A constructor creating a buffer from a file.
 
 AudioBuffer (AudioBuffer &&other)
 Move constructor.
 
AudioBufferoperator= (AudioBuffer &&other)
 Move assignment operator.
 
void init (const char *name, Format format, int frequency)
 Initializes an empty buffer with the specified format and frequency.
 
bool loadFromMemory (const char *bufferName, const unsigned char *bufferPtr, unsigned long int bufferSize)
 
bool loadFromFile (const char *filename)
 
bool loadFromSamples (const unsigned char *bufferPtr, unsigned long int bufferSize)
 Loads samples in raw PCM format from a memory buffer.
 
unsigned int bufferId () const
 Returns the OpenAL buffer id.
 
int bytesPerSample () const
 Returns the number of bytes per sample.
 
int numChannels () const
 Returns the number of audio channels.
 
int frequency () const
 Returns the samples frequency.
 
unsigned long int numSamples () const
 Returns number of samples.
 
float duration () const
 Returns the duration in seconds.
 
unsigned long bufferSize () const
 Returns the size of the buffer in bytes.
 
- 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.
 

Additional Inherited Members

- Static Public Attributes inherited from ncine::Object
static const unsigned int MaxNameLength = 128
 Maximum length for an object name.
 
- Protected Member Functions inherited from ncine::Object
 Object (const Object &other)
 Protected copy constructor used to clone objects.
 
- Protected Attributes inherited from ncine::Object
ObjectType type_
 Object type.
 

Detailed Description

A class representing an OpenAL buffer.

It inherits from Object because a buffer can be shared by more than one AudioBufferPlayer object.


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