3DRadSpace 0.1.0Alpha
3DRadSpace is a free, simple to use, rapid application development game engine.
Loading...
Searching...
No Matches
Engine3DRadSpace.Audio.AudioBuffer Class Reference

Represents a PCM audio buffer. More...

#include <AudioBuffer.hpp>

Inheritance diagram for Engine3DRadSpace.Audio.AudioBuffer:
Collaboration diagram for Engine3DRadSpace.Audio.AudioBuffer:

Public Types

enum class  WAVLoadError
 Type of loading error that could occur when loading a WAV file. More...
enum class  OGGLoadError
 Type of loading error that could occur when loading an OGG file. More...

Public Member Functions

 AudioBuffer (IntPtr buffer, int numChannels, int sampleRate, int bps, int format, int size)
 AudioBuffer (char *buffer, int numChannels, int sampleRate, int bps, int format, int size)
 Constructs a AudioBuffer from specified arguments.
 AudioBuffer (const AudioBuffer &)=delete
 AudioBuffer (AudioBuffer &&other) noexcept=default
 Move constructor. Transfers ownership of the PCM buffer to this instance.
AudioBuffer & operator= (const AudioBuffer &)=delete
AudioBuffer & operator= (AudioBuffer &&other) noexcept=default
 Move assignment operator. Transfers ownership of the PCM buffer to this instance.
 ~AudioBuffer ()=default
 Destructor. Releases the PCM buffer.
Public Member Functions inherited from Engine3DRadSpace.NatPtrWrapper
virtual void Dispose ()

Static Public Member Functions

static AudioBuffer FromWAV (string path)
static AudioBuffer FromOGG (string path)
static std::expected< AudioBuffer, WAVLoadError > FromWAV (const std::filesystem::path &path)
 Loads a WAV file from the given path and returns an AudioBuffer instance.
static std::expected< AudioBuffer, OGGLoadError > FromOGG (const std::filesystem::path &path)
 Loads an OGG file from the given path and returns an AudioBuffer instance.

Protected Attributes

std::unique_ptr< char[]> _buffer
int _channel = 0
int _sampleRate = 0
int _bps = 0
int _format = 0
int _size = 0
Protected Attributes inherited from Engine3DRadSpace.NatPtrWrapper
IntPtr _handle
bool _disposed

Friends

class Sound

Additional Inherited Members

Protected Member Functions inherited from Engine3DRadSpace.NatPtrWrapper
 NatPtrWrapper (IntPtr handle, Action< IntPtr > fnDestroy)
 NatPtrWrapper (Action< IntPtr > fnDestroy)
void Reset (IntPtr newObj)
void Dispose (bool disposing)
Properties inherited from Engine3DRadSpace.NatPtrWrapper
IntPtr Handle [get]

Detailed Description

Represents a PCM audio buffer.

Member Enumeration Documentation

◆ OGGLoadError

Type of loading error that could occur when loading an OGG file.

◆ WAVLoadError

Type of loading error that could occur when loading a WAV file.

Constructor & Destructor Documentation

◆ AudioBuffer() [1/4]

Engine3DRadSpace.Audio.AudioBuffer.AudioBuffer ( IntPtr buffer,
int numChannels,
int sampleRate,
int bps,
int format,
int size )
inline

◆ AudioBuffer() [2/4]

AudioBuffer::AudioBuffer ( char * buffer,
int numChannels,
int sampleRate,
int bps,
int format,
int size )

Constructs a AudioBuffer from specified arguments.

Parameters
bufferPCM buffer
numChannelsNumber of channels
sampleRateAudio sample rate
bpsBeats per second
formatOpenAL format
sizeBuffer size

◆ AudioBuffer() [3/4]

◆ AudioBuffer() [4/4]

Move constructor. Transfers ownership of the PCM buffer to this instance.

Parameters
otherThe AudioBuffer instance to move from

◆ ~AudioBuffer()

Engine3DRadSpace.Audio.AudioBuffer.~AudioBuffer ( )
default

Destructor. Releases the PCM buffer.

Member Function Documentation

◆ FromOGG() [1/2]

AudioBuffer Engine3DRadSpace.Audio.AudioBuffer.FromOGG ( string path)
inlinestatic

◆ FromOGG() [2/2]

std::expected< AudioBuffer, AudioBuffer::OGGLoadError > AudioBuffer::FromOGG ( const std::filesystem::path & path)
static

Loads an OGG file from the given path and returns an AudioBuffer instance.

Parameters
pathPath to the OGG file
Returns
AudioBuffer instance or OGGLoadError

◆ FromWAV() [1/2]

AudioBuffer Engine3DRadSpace.Audio.AudioBuffer.FromWAV ( string path)
inlinestatic

◆ FromWAV() [2/2]

std::expected< AudioBuffer, AudioBuffer::WAVLoadError > AudioBuffer::FromWAV ( const std::filesystem::path & path)
static

Loads a WAV file from the given path and returns an AudioBuffer instance.

◆ operator=() [1/2]

AudioBuffer & Engine3DRadSpace.Audio.AudioBuffer.operator= ( AudioBuffer && other)
defaultnoexcept

Move assignment operator. Transfers ownership of the PCM buffer to this instance.

Parameters
otherThe AudioBuffer instance to move from
Returns
Reference to this instance

◆ operator=() [2/2]

AudioBuffer & Engine3DRadSpace.Audio.AudioBuffer.operator= ( const AudioBuffer & )
delete

◆ Sound

friend class Sound
friend

Member Data Documentation

◆ _bps

int Engine3DRadSpace.Audio.AudioBuffer._bps = 0
protected

◆ _buffer

std::unique_ptr<char[]> Engine3DRadSpace.Audio.AudioBuffer._buffer
protected

◆ _channel

int Engine3DRadSpace.Audio.AudioBuffer._channel = 0
protected

◆ _format

int Engine3DRadSpace.Audio.AudioBuffer._format = 0
protected

◆ _sampleRate

int Engine3DRadSpace.Audio.AudioBuffer._sampleRate = 0
protected

◆ _size

int Engine3DRadSpace.Audio.AudioBuffer._size = 0
protected

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