Nsound
0.9.4
|
#include <Nsound/AudioPlayback.h>
Public Member Functions | |
AudioPlayback (const float64 &sample_rate=44100.0, const uint32 channels=1, const uint32 bits_per_sample=16) | |
~AudioPlayback () | |
uint32 | getBitsPerSample () |
void | setBitsPerSample (uint32 bits_per_sample) |
uint32 | getChannels () |
void | setChannels (uint32 channels) |
std::string | getError () |
Returns an error string describing any backend error. More... | |
std::string | getInfo () |
Returns information about the backend driver. More... | |
uint32 | getSampleRate () |
void | setSampleRate (uint32 sample_rate) |
AudioBackend::State | getState () |
Returns the backend state. More... | |
std::string | getStateString () |
Returns the backend state string. More... | |
std::string | getStateString (const AudioBackend::State &state) |
Returns the backend state string. More... | |
void | initialize () |
Initializes the backend and transitions to the BACKEND_READY state on success. More... | |
void | play (const AudioStream &a) |
Plays the AudioStream throuh the backend. More... | |
void | play (const Buffer &b) |
Plays the Buffer through the backend. More... | |
void | scanDevices () |
Scans for devices and tries to play a test sound. More... | |
void | setOption (const std::string &key, const std::string &value) |
Sets an options, must be called before initialize(). More... | |
void | shutdown () |
Shuts down the backend. More... | |
Static Public Member Functions | |
static void | setBackendType (const AudioBackendType ab) |
Sets the AudioBackendType. More... | |
static AudioBackendType | getBackendType () |
Gets the AudioBackendType that is currently set. More... | |
Private Member Functions | |
AudioPlayback (const AudioPlayback ©) | |
AudioPlayback & | operator= (const AudioPlayback &rhs) |
Private Attributes | |
uint32 | sample_rate_ |
uint32 | channels_ |
uint32 | bits_per_sample_ |
AudioBackend * | backend_ |
Static Private Attributes | |
static AudioBackendType | backend_type_ = BACKEND_TYPE_NONE |
Friends | |
void | operator>> (const AudioStream &lhs, AudioPlayback &rhs) |
void | operator>> (const Buffer &lhs, AudioPlayback &rhs) |
Definition at line 50 of file AudioPlayback.h.
AudioPlayback::AudioPlayback | ( | const float64 & | sample_rate = 44100.0 , |
const uint32 | channels = 1 , |
||
const uint32 | bits_per_sample = 16 |
||
) |
Definition at line 115 of file AudioPlayback.cc.
References allocate_backend(), backend_, backend_type_, Nsound::BACKEND_TYPE_NONE, bits_per_sample_, channels_, M_THROW, and sample_rate_.
AudioPlayback::~AudioPlayback | ( | ) |
Definition at line 139 of file AudioPlayback.cc.
References backend_, and Nsound::AudioBackend::shutdown().
|
inlineprivate |
Definition at line 143 of file AudioPlayback.h.
|
static |
Sets the AudioBackendType.
Definition at line 102 of file AudioPlayback.cc.
References backend_type_.
Referenced by Nsound::use().
|
static |
Gets the AudioBackendType that is currently set.
Definition at line 109 of file AudioPlayback.cc.
References backend_type_.
uint32 AudioPlayback::getBitsPerSample | ( | ) |
Definition at line 150 of file AudioPlayback.cc.
References backend_, bits_per_sample_, and Nsound::AudioBackend::getBitsPerSample().
|
inline |
uint32 AudioPlayback::getChannels | ( | ) |
Definition at line 162 of file AudioPlayback.cc.
References backend_, channels_, and Nsound::AudioBackend::getChannels().
|
inline |
std::string AudioPlayback::getError | ( | ) |
Returns an error string describing any backend error.
Definition at line 174 of file AudioPlayback.cc.
References backend_, and Nsound::AudioBackend::getError().
std::string AudioPlayback::getInfo | ( | ) |
Returns information about the backend driver.
Definition at line 193 of file AudioPlayback.cc.
References backend_, and Nsound::AudioBackend::getInfo().
uint32 AudioPlayback::getSampleRate | ( | ) |
Definition at line 212 of file AudioPlayback.cc.
References backend_, Nsound::AudioBackend::getSampleRate(), and sample_rate_.
|
inline |
AudioBackend::State AudioPlayback::getState | ( | ) |
Returns the backend state.
Definition at line 224 of file AudioPlayback.cc.
References backend_, Nsound::AudioBackend::BACKEND_NOT_INITIALIZED, and Nsound::AudioBackend::getState().
std::string AudioPlayback::getStateString | ( | ) |
Returns the backend state string.
Definition at line 236 of file AudioPlayback.cc.
References backend_, Nsound::AudioBackend::BACKEND_NOT_INITIALIZED, and Nsound::AudioBackend::getStateString().
std::string AudioPlayback::getStateString | ( | const AudioBackend::State & | state | ) |
Returns the backend state string.
Definition at line 248 of file AudioPlayback.cc.
References Nsound::AudioBackend::getStateString().
void AudioPlayback::initialize | ( | ) |
Initializes the backend and transitions to the BACKEND_READY state on success.
Definition at line 255 of file AudioPlayback.cc.
References allocate_backend(), backend_, Nsound::AudioBackend::BACKEND_READY, backend_type_, Nsound::BACKEND_TYPE_NONE, bits_per_sample_, channels_, Nsound::AudioBackend::getError(), Nsound::AudioBackend::getState(), Nsound::AudioBackend::initialize(), M_THROW, and sample_rate_.
Referenced by _play(), and scanDevices().
void AudioPlayback::play | ( | const AudioStream & | a | ) |
Plays the AudioStream throuh the backend.
Definition at line 435 of file AudioPlayback.cc.
References backend_.
Referenced by Nsound::operator>>(), Nsound::AudioBackendLibao::scanDevices(), and Nsound::AudioBackendLibportaudio::scanDevices().
void AudioPlayback::play | ( | const Buffer & | b | ) |
Plays the Buffer through the backend.
Definition at line 442 of file AudioPlayback.cc.
References backend_.
void AudioPlayback::scanDevices | ( | ) |
Scans for devices and tries to play a test sound.
Definition at line 449 of file AudioPlayback.cc.
References allocate_backend(), backend_, Nsound::AudioBackend::BACKEND_READY, bits_per_sample_, channels_, Nsound::getBackends(), Nsound::getBackendTypes(), Nsound::AudioBackend::getError(), Nsound::AudioBackend::getState(), initialize(), Nsound::GuitarBass::play(), sample_rate_, and Nsound::AudioBackend::scanDevices().
void AudioPlayback::setOption | ( | const std::string & | key, |
const std::string & | value | ||
) |
Sets an options, must be called before initialize().
Definition at line 510 of file AudioPlayback.cc.
References backend_, Nsound::AudioBackend::BACKEND_NOT_INITIALIZED, Nsound::AudioBackend::getState(), M_THROW, and Nsound::AudioBackend::setOption().
void AudioPlayback::shutdown | ( | ) |
Shuts down the backend.
Definition at line 530 of file AudioPlayback.cc.
References backend_, and Nsound::AudioBackend::shutdown().
|
inlineprivate |
Definition at line 150 of file AudioPlayback.h.
|
friend |
|
friend |
|
private |
Definition at line 150 of file AudioPlayback.h.
Referenced by AudioPlayback(), getSampleRate(), initialize(), scanDevices(), and setSampleRate().
|
private |
Definition at line 155 of file AudioPlayback.h.
Referenced by AudioPlayback(), getChannels(), initialize(), scanDevices(), and setChannels().
|
private |
Definition at line 156 of file AudioPlayback.h.
Referenced by AudioPlayback(), getBitsPerSample(), initialize(), scanDevices(), and setBitsPerSample().
|
private |
Definition at line 158 of file AudioPlayback.h.
Referenced by AudioPlayback(), getBitsPerSample(), getChannels(), getError(), getInfo(), getSampleRate(), getState(), getStateString(), initialize(), play(), scanDevices(), setOption(), shutdown(), and ~AudioPlayback().
|
staticprivate |
Definition at line 160 of file AudioPlayback.h.
Referenced by AudioPlayback(), getBackendType(), initialize(), and setBackendType().