cgv
|
This class provides easy sample loading, device enumeration and error retrieval. More...
#include <al_context.h>
Public Member Functions | |
OALContext (const std::string &device_name) | |
Construct context, connect to output device and make context current. | |
OALContext (const OALContext &other)=delete | |
OALContext (OALContext &&other)=default | |
OALContext & | operator= (const OALContext &other)=delete |
OALContext & | operator= (OALContext &&other)=default |
~OALContext () | |
detach context from output device and destruct | |
std::string | get_device_name () const |
return device name of contexts device | |
void | make_current () |
in case of multiple contexts, this makes this context current | |
void | create_buffer (const std::string &symbolic_name, const OALSoundFormat &format, const void *data, size_t data_length) |
create a named sound buffer from a format descriptor and a data buffer of given length in bytes | |
void | load_sample (std::string filepath, std::string symbolic_name="") |
Loads a sound into the internal buffer list. | |
void | load_sample (std::string symbolic_name, const void *data, size_t data_length) |
Loads a sound into the internal buffer list. | |
void | load_samples (std::string folder, bool recursive=false) |
Loads all audio files in a folder into the internal buffer list. | |
ALuint | get_buffer_id (std::string sound_name) const |
Gets the buffer identifier for the symbolic name. | |
std::string | get_error_string () |
Returns the last error from the OpenAL context. | |
bool | is_no_error () |
Determines if there were any errors since last call. | |
void | set_HRTF (bool active) |
Toggles the OpenAL output mode to use HRTF. | |
ALCdevice * | get_native_device () |
Gets the native device handle for direct OpenAL calls. | |
ALCcontext * | get_native_context () |
Gets the native context handle for direct OpenAL calls. | |
Static Public Member Functions | |
static std::vector< std::string > | enumerate_devices () |
Enumerate audio output devices available on system. | |
static std::string | get_default_device_name () |
returns name of system's default device | |
static bool | decode_sound_file (const void *data, size_t data_length, OALSoundFormat &format, std::vector< int16_t > &memory_buffer) |
decode sound file that is already in memory data with data_length bytes to a newly constructed memory buffer | |
static bool | load_sound_file (const std::string &filepath, OALSoundFormat &format, std::vector< int16_t > &memory_buffer) |
load and decode sound file to newly constructed memory buffer | |
This class provides easy sample loading, device enumeration and error retrieval.
Definition at line 39 of file al_context.h.
|
explicit |
Construct context, connect to output device and make context current.
[in] | device | The OpenAL device string identifier |
Definition at line 41 of file al_context.cxx.
cgv::audio::OALContext::~OALContext | ( | ) |
detach context from output device and destruct
Definition at line 58 of file al_context.cxx.
void cgv::audio::OALContext::create_buffer | ( | const std::string & | symbolic_name, |
const OALSoundFormat & | format, | ||
const void * | data, | ||
size_t | data_length | ||
) |
create a named sound buffer from a format descriptor and a data buffer of given length in bytes
Definition at line 149 of file al_context.cxx.
Referenced by load_sample(), and load_sample().
|
static |
decode sound file that is already in memory data with data_length bytes to a newly constructed memory buffer
Definition at line 92 of file al_context.cxx.
Referenced by load_sample().
|
static |
Enumerate audio output devices available on system.
Definition at line 25 of file al_context.cxx.
ALuint cgv::audio::OALContext::get_buffer_id | ( | std::string | sound_name | ) | const |
Gets the buffer identifier for the symbolic name.
[in] | sound_name | The symbolic sound name of the buffer. |
Definition at line 215 of file al_context.cxx.
|
static |
returns name of system's default device
Definition at line 19 of file al_context.cxx.
std::string cgv::audio::OALContext::get_device_name | ( | ) | const |
return device name of contexts device
Definition at line 53 of file al_context.cxx.
std::string cgv::audio::OALContext::get_error_string | ( | ) |
Returns the last error from the OpenAL context.
Definition at line 220 of file al_context.cxx.
ALCcontext * cgv::audio::OALContext::get_native_context | ( | ) |
Gets the native context handle for direct OpenAL calls.
Definition at line 235 of file al_context.cxx.
Referenced by cgv::audio::OALSource::append_sound(), and cgv::audio::OALSource::init().
ALCdevice * cgv::audio::OALContext::get_native_device | ( | ) |
Gets the native device handle for direct OpenAL calls.
Definition at line 233 of file al_context.cxx.
Referenced by set_HRTF().
bool cgv::audio::OALContext::is_no_error | ( | ) |
Determines if there were any errors since last call.
Definition at line 221 of file al_context.cxx.
Referenced by cgv::audio::OALSource::init().
void cgv::audio::OALContext::load_sample | ( | std::string | filepath, |
std::string | symbolic_name = "" |
||
) |
Loads a sound into the internal buffer list.
[in] | filepath | The filepath to the sample file |
[in] | symbolic_name | Sound is named by file stem or if given this parameter |
Definition at line 169 of file al_context.cxx.
References create_buffer(), and load_sound_file().
Referenced by load_samples().
void cgv::audio::OALContext::load_sample | ( | std::string | symbolic_name, |
const void * | data, | ||
size_t | data_length | ||
) |
Loads a sound into the internal buffer list.
[in] | symbolic_name | The symbolic name used as key for later retrieval |
[in] | data | A pointer to the first sample of the audio data |
[in] | data_length | The length of the audio data buffer in bytes |
Definition at line 184 of file al_context.cxx.
References create_buffer(), and decode_sound_file().
void cgv::audio::OALContext::load_samples | ( | std::string | folder, |
bool | recursive = false |
||
) |
Loads all audio files in a folder into the internal buffer list.
[in] | folder | The path to the folder |
[in] | recursive | True if subfolders should be traversed as well, False otherwise. |
Definition at line 192 of file al_context.cxx.
References load_sample().
|
static |
load and decode sound file to newly constructed memory buffer
Definition at line 137 of file al_context.cxx.
Referenced by load_sample().
void cgv::audio::OALContext::make_current | ( | ) |
in case of multiple contexts, this makes this context current
Definition at line 49 of file al_context.cxx.
void cgv::audio::OALContext::set_HRTF | ( | bool | active | ) |
Toggles the OpenAL output mode to use HRTF.
[in] | active | True if the output should be filtered with a head related transfer function, False otherwise. |
Definition at line 222 of file al_context.cxx.
References get_native_device().