Upgrade NazaraAudio
This commit is contained in:
@@ -30,22 +30,16 @@ namespace Nz
|
||||
if (!OpenAL::Initialize())
|
||||
throw std::runtime_error("failed to initialize OpenAL");
|
||||
|
||||
if (!SoundBuffer::Initialize())
|
||||
throw std::runtime_error("failed to initialize sound buffers");
|
||||
|
||||
// Definition of the orientation by default
|
||||
SetListenerDirection(Vector3f::Forward());
|
||||
|
||||
// Loaders
|
||||
Loaders::Register_sndfile();
|
||||
m_soundBufferLoader.RegisterLoader(Loaders::GetSoundBufferLoader_sndfile());
|
||||
m_soundStreamLoader.RegisterLoader(Loaders::GetSoundStreamLoader_sndfile());
|
||||
}
|
||||
|
||||
Audio::~Audio()
|
||||
{
|
||||
// Loaders
|
||||
Loaders::Unregister_sndfile();
|
||||
|
||||
SoundBuffer::Uninitialize();
|
||||
OpenAL::Uninitialize();
|
||||
}
|
||||
|
||||
@@ -58,7 +52,7 @@ namespace Nz
|
||||
* \remark Produces a NazaraError if the number of channels is erroneous (3 or 5) and AudioFormat_Unknown is returned
|
||||
*/
|
||||
|
||||
AudioFormat Audio::GetAudioFormat(unsigned int channelCount)
|
||||
AudioFormat Audio::GetAudioFormat(unsigned int channelCount) const
|
||||
{
|
||||
switch (channelCount)
|
||||
{
|
||||
@@ -80,8 +74,7 @@ namespace Nz
|
||||
* \brief Gets the factor of the doppler effect
|
||||
* \return Global factor of the doppler effect
|
||||
*/
|
||||
|
||||
float Audio::GetDopplerFactor()
|
||||
float Audio::GetDopplerFactor() const
|
||||
{
|
||||
return alGetFloat(AL_DOPPLER_FACTOR);
|
||||
}
|
||||
@@ -90,8 +83,7 @@ namespace Nz
|
||||
* \brief Gets the global volume
|
||||
* \return Float between [0, inf) with 100.f being the default
|
||||
*/
|
||||
|
||||
float Audio::GetGlobalVolume()
|
||||
float Audio::GetGlobalVolume() const
|
||||
{
|
||||
ALfloat gain = 0.f;
|
||||
alGetListenerf(AL_GAIN, &gain);
|
||||
@@ -105,8 +97,7 @@ namespace Nz
|
||||
*
|
||||
* \see GetListenerRotation
|
||||
*/
|
||||
|
||||
Vector3f Audio::GetListenerDirection()
|
||||
Vector3f Audio::GetListenerDirection() const
|
||||
{
|
||||
ALfloat orientation[6];
|
||||
alGetListenerfv(AL_ORIENTATION, orientation);
|
||||
@@ -120,8 +111,7 @@ namespace Nz
|
||||
*
|
||||
* \see GetListenerVelocity
|
||||
*/
|
||||
|
||||
Vector3f Audio::GetListenerPosition()
|
||||
Vector3f Audio::GetListenerPosition() const
|
||||
{
|
||||
Vector3f position;
|
||||
alGetListenerfv(AL_POSITION, &position.x);
|
||||
@@ -133,8 +123,7 @@ namespace Nz
|
||||
* \brief Gets the rotation of the listener
|
||||
* \return Rotation of the listener
|
||||
*/
|
||||
|
||||
Quaternionf Audio::GetListenerRotation()
|
||||
Quaternionf Audio::GetListenerRotation() const
|
||||
{
|
||||
ALfloat orientation[6];
|
||||
alGetListenerfv(AL_ORIENTATION, orientation);
|
||||
@@ -150,8 +139,7 @@ namespace Nz
|
||||
*
|
||||
* \see GetListenerPosition
|
||||
*/
|
||||
|
||||
Vector3f Audio::GetListenerVelocity()
|
||||
Vector3f Audio::GetListenerVelocity() const
|
||||
{
|
||||
Vector3f velocity;
|
||||
alGetListenerfv(AL_VELOCITY, &velocity.x);
|
||||
@@ -159,12 +147,29 @@ namespace Nz
|
||||
return velocity;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the default SoundBuffer loader
|
||||
* \return A constant reference to the default SoundBuffer loader
|
||||
*/
|
||||
const SoundBufferLoader& Audio::GetSoundBufferLoader() const
|
||||
{
|
||||
return m_soundBufferLoader;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the default SoundStream loader
|
||||
* \return A constant reference to the default SoundStream loader
|
||||
*/
|
||||
const SoundStreamLoader& Audio::GetSoundStreamLoader() const
|
||||
{
|
||||
return m_soundStreamLoader;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the speed of sound
|
||||
* \return Speed of sound
|
||||
*/
|
||||
|
||||
float Audio::GetSpeedOfSound()
|
||||
float Audio::GetSpeedOfSound() const
|
||||
{
|
||||
return alGetFloat(AL_SPEED_OF_SOUND);
|
||||
}
|
||||
@@ -175,8 +180,7 @@ namespace Nz
|
||||
*
|
||||
* \param format Format to check
|
||||
*/
|
||||
|
||||
bool Audio::IsFormatSupported(AudioFormat format)
|
||||
bool Audio::IsFormatSupported(AudioFormat format) const
|
||||
{
|
||||
if (format == AudioFormat_Unknown)
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user