Switch from Nz prefix to namespace Nz
What a huge commit Former-commit-id: 38ac5eebf70adc1180f571f6006192d28fb99897
This commit is contained in:
@@ -9,7 +9,10 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
template<typename T> void NzMixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount);
|
||||
namespace Nz
|
||||
{
|
||||
template<typename T> void MixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount);
|
||||
}
|
||||
|
||||
#include <Nazara/Audio/Algorithm.inl>
|
||||
|
||||
|
||||
@@ -5,21 +5,24 @@
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Audio/Debug.hpp>
|
||||
|
||||
template<typename T>
|
||||
void NzMixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount)
|
||||
namespace Nz
|
||||
{
|
||||
///DOC: Le buffer d'entrée peut être le même que le buffer de sortie
|
||||
// Pour éviter l'overflow, on utilise comme accumulateur un type assez grand, (u)int 64 bits pour les entiers, double pour les flottants
|
||||
typedef typename std::conditional<std::is_unsigned<T>::value, nzUInt64, nzInt64>::type BiggestInt;
|
||||
typedef typename std::conditional<std::is_integral<T>::value, BiggestInt, double>::type Biggest;
|
||||
|
||||
for (unsigned int i = 0; i < frameCount; ++i)
|
||||
template<typename T>
|
||||
void MixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount)
|
||||
{
|
||||
Biggest acc = Biggest(0);
|
||||
for (unsigned int j = 0; j < channelCount; ++j)
|
||||
acc += input[i*channelCount + j];
|
||||
///DOC: Le buffer d'entrée peut être le même que le buffer de sortie
|
||||
// Pour éviter l'overflow, on utilise comme accumulateur un type assez grand, (u)int 64 bits pour les entiers, double pour les flottants
|
||||
typedef typename std::conditional<std::is_unsigned<T>::value, UInt64, Int64>::type BiggestInt;
|
||||
typedef typename std::conditional<std::is_integral<T>::value, BiggestInt, double>::type Biggest;
|
||||
|
||||
output[i] = static_cast<T>(acc/channelCount);
|
||||
for (unsigned int i = 0; i < frameCount; ++i)
|
||||
{
|
||||
Biggest acc = Biggest(0);
|
||||
for (unsigned int j = 0; j < channelCount; ++j)
|
||||
acc += input[i*channelCount + j];
|
||||
|
||||
output[i] = static_cast<T>(acc / channelCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,41 +14,44 @@
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
class NAZARA_AUDIO_API NzAudio
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzAudio() = delete;
|
||||
~NzAudio() = delete;
|
||||
class NAZARA_AUDIO_API Audio
|
||||
{
|
||||
public:
|
||||
Audio() = delete;
|
||||
~Audio() = delete;
|
||||
|
||||
static nzAudioFormat GetAudioFormat(unsigned int channelCount);
|
||||
static float GetDopplerFactor();
|
||||
static float GetGlobalVolume();
|
||||
static NzVector3f GetListenerDirection();
|
||||
static NzVector3f GetListenerPosition();
|
||||
static NzQuaternionf GetListenerRotation();
|
||||
static NzVector3f GetListenerVelocity();
|
||||
static float GetSpeedOfSound();
|
||||
static AudioFormat GetAudioFormat(unsigned int channelCount);
|
||||
static float GetDopplerFactor();
|
||||
static float GetGlobalVolume();
|
||||
static Vector3f GetListenerDirection();
|
||||
static Vector3f GetListenerPosition();
|
||||
static Quaternionf GetListenerRotation();
|
||||
static Vector3f GetListenerVelocity();
|
||||
static float GetSpeedOfSound();
|
||||
|
||||
static bool Initialize();
|
||||
static bool Initialize();
|
||||
|
||||
static bool IsFormatSupported(nzAudioFormat format);
|
||||
static bool IsInitialized();
|
||||
static bool IsFormatSupported(AudioFormat format);
|
||||
static bool IsInitialized();
|
||||
|
||||
static void SetDopplerFactor(float dopplerFactor);
|
||||
static void SetGlobalVolume(float volume);
|
||||
static void SetListenerDirection(const NzVector3f& direction);
|
||||
static void SetListenerDirection(float dirX, float dirY, float dirZ);
|
||||
static void SetListenerPosition(const NzVector3f& position);
|
||||
static void SetListenerPosition(float x, float y, float z);
|
||||
static void SetListenerRotation(const NzQuaternionf& rotation);
|
||||
static void SetListenerVelocity(const NzVector3f& velocity);
|
||||
static void SetListenerVelocity(float velX, float velY, float velZ);
|
||||
static void SetSpeedOfSound(float speed);
|
||||
static void SetDopplerFactor(float dopplerFactor);
|
||||
static void SetGlobalVolume(float volume);
|
||||
static void SetListenerDirection(const Vector3f& direction);
|
||||
static void SetListenerDirection(float dirX, float dirY, float dirZ);
|
||||
static void SetListenerPosition(const Vector3f& position);
|
||||
static void SetListenerPosition(float x, float y, float z);
|
||||
static void SetListenerRotation(const Quaternionf& rotation);
|
||||
static void SetListenerVelocity(const Vector3f& velocity);
|
||||
static void SetListenerVelocity(float velX, float velY, float velZ);
|
||||
static void SetSpeedOfSound(float speed);
|
||||
|
||||
static void Uninitialize();
|
||||
static void Uninitialize();
|
||||
|
||||
private:
|
||||
static unsigned int s_moduleReferenceCounter;
|
||||
};
|
||||
private:
|
||||
static unsigned int s_moduleReferenceCounter;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_AUDIO_HPP
|
||||
|
||||
@@ -7,26 +7,30 @@
|
||||
#ifndef NAZARA_ENUMS_HPP
|
||||
#define NAZARA_ENUMS_HPP
|
||||
|
||||
enum nzAudioFormat
|
||||
namespace Nz
|
||||
{
|
||||
nzAudioFormat_Unknown = -1,
|
||||
|
||||
// La valeur entière est le nombre de canaux possédés par ce format
|
||||
nzAudioFormat_Mono = 1,
|
||||
nzAudioFormat_Stereo = 2,
|
||||
nzAudioFormat_Quad = 4,
|
||||
nzAudioFormat_5_1 = 6,
|
||||
nzAudioFormat_6_1 = 7,
|
||||
nzAudioFormat_7_1 = 8,
|
||||
enum AudioFormat
|
||||
{
|
||||
AudioFormat_Unknown = -1,
|
||||
|
||||
nzAudioFormat_Max = nzAudioFormat_7_1
|
||||
};
|
||||
// La valeur entière est le nombre de canaux possédés par ce format
|
||||
AudioFormat_Mono = 1,
|
||||
AudioFormat_Stereo = 2,
|
||||
AudioFormat_Quad = 4,
|
||||
AudioFormat_5_1 = 6,
|
||||
AudioFormat_6_1 = 7,
|
||||
AudioFormat_7_1 = 8,
|
||||
|
||||
enum nzSoundStatus
|
||||
{
|
||||
nzSoundStatus_Playing,
|
||||
nzSoundStatus_Paused,
|
||||
nzSoundStatus_Stopped
|
||||
};
|
||||
AudioFormat_Max = AudioFormat_7_1
|
||||
};
|
||||
|
||||
enum SoundStatus
|
||||
{
|
||||
SoundStatus_Playing,
|
||||
SoundStatus_Paused,
|
||||
SoundStatus_Stopped
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_ENUMS_HPP
|
||||
|
||||
@@ -13,65 +13,68 @@
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
|
||||
struct NzMusicParams
|
||||
namespace Nz
|
||||
{
|
||||
bool forceMono = false;
|
||||
struct MusicParams
|
||||
{
|
||||
bool forceMono = false;
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
||||
class NzMusic;
|
||||
class NzSoundStream;
|
||||
class Music;
|
||||
class SoundStream;
|
||||
|
||||
using NzMusicLoader = NzResourceLoader<NzMusic, NzMusicParams>;
|
||||
using MusicLoader = ResourceLoader<Music, MusicParams>;
|
||||
|
||||
struct NzMusicImpl;
|
||||
struct MusicImpl;
|
||||
|
||||
class NAZARA_AUDIO_API NzMusic : public NzResource, public NzSoundEmitter
|
||||
{
|
||||
friend NzMusicLoader;
|
||||
class NAZARA_AUDIO_API Music : public Resource, public SoundEmitter
|
||||
{
|
||||
friend MusicLoader;
|
||||
|
||||
public:
|
||||
NzMusic() = default;
|
||||
NzMusic(const NzMusic&) = delete;
|
||||
NzMusic(NzMusic&&) = delete; ///TODO
|
||||
~NzMusic();
|
||||
public:
|
||||
Music() = default;
|
||||
Music(const Music&) = delete;
|
||||
Music(Music&&) = delete; ///TODO
|
||||
~Music();
|
||||
|
||||
bool Create(NzSoundStream* soundStream);
|
||||
void Destroy();
|
||||
bool Create(SoundStream* soundStream);
|
||||
void Destroy();
|
||||
|
||||
void EnableLooping(bool loop);
|
||||
void EnableLooping(bool loop);
|
||||
|
||||
nzUInt32 GetDuration() const;
|
||||
nzAudioFormat GetFormat() const;
|
||||
nzUInt32 GetPlayingOffset() const;
|
||||
nzUInt32 GetSampleCount() const;
|
||||
nzUInt32 GetSampleRate() const;
|
||||
nzSoundStatus GetStatus() const;
|
||||
UInt32 GetDuration() const;
|
||||
AudioFormat GetFormat() const;
|
||||
UInt32 GetPlayingOffset() const;
|
||||
UInt32 GetSampleCount() const;
|
||||
UInt32 GetSampleRate() const;
|
||||
SoundStatus GetStatus() const;
|
||||
|
||||
bool IsLooping() const;
|
||||
bool IsLooping() const;
|
||||
|
||||
bool OpenFromFile(const NzString& filePath, const NzMusicParams& params = NzMusicParams());
|
||||
bool OpenFromMemory(const void* data, std::size_t size, const NzMusicParams& params = NzMusicParams());
|
||||
bool OpenFromStream(NzInputStream& stream, const NzMusicParams& params = NzMusicParams());
|
||||
bool OpenFromFile(const String& filePath, const MusicParams& params = MusicParams());
|
||||
bool OpenFromMemory(const void* data, std::size_t size, const MusicParams& params = MusicParams());
|
||||
bool OpenFromStream(InputStream& stream, const MusicParams& params = MusicParams());
|
||||
|
||||
void Pause();
|
||||
void Play();
|
||||
void Pause();
|
||||
void Play();
|
||||
|
||||
void SetPlayingOffset(nzUInt32 offset);
|
||||
void SetPlayingOffset(UInt32 offset);
|
||||
|
||||
void Stop();
|
||||
void Stop();
|
||||
|
||||
NzMusic& operator=(const NzMusic&) = delete;
|
||||
NzMusic& operator=(NzMusic&&) = delete; ///TODO
|
||||
Music& operator=(const Music&) = delete;
|
||||
Music& operator=(Music&&) = delete; ///TODO
|
||||
|
||||
private:
|
||||
NzMusicImpl* m_impl = nullptr;
|
||||
private:
|
||||
MusicImpl* m_impl = nullptr;
|
||||
|
||||
bool FillAndQueueBuffer(unsigned int buffer);
|
||||
void MusicThread();
|
||||
bool FillAndQueueBuffer(unsigned int buffer);
|
||||
void MusicThread();
|
||||
|
||||
static NzMusicLoader::LoaderList s_loaders;
|
||||
};
|
||||
static MusicLoader::LoaderList s_loaders;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_MUSIC_HPP
|
||||
|
||||
@@ -20,168 +20,171 @@
|
||||
// Étant donné que les headers OpenAL ne nous permettent pas de n'avoir que les signatures sans les pointeurs de fonctions
|
||||
// Et que je ne souhaite pas les modifier, je suis contraint de les placer dans un espace de nom différent pour ensuite
|
||||
// remettre dans l'espace global les choses intéressantes (les typedef notamment)
|
||||
namespace NzOpenALDetail
|
||||
namespace OpenALDetail
|
||||
{
|
||||
#include <AL/al.h>
|
||||
#include <AL/alc.h>
|
||||
}
|
||||
|
||||
// Si quelqu'un a une meilleure idée ...
|
||||
using NzOpenALDetail::ALboolean;
|
||||
using NzOpenALDetail::ALbyte;
|
||||
using NzOpenALDetail::ALchar;
|
||||
using NzOpenALDetail::ALdouble;
|
||||
using NzOpenALDetail::ALenum;
|
||||
using NzOpenALDetail::ALfloat;
|
||||
using NzOpenALDetail::ALint;
|
||||
using NzOpenALDetail::ALshort;
|
||||
using NzOpenALDetail::ALsizei;
|
||||
using NzOpenALDetail::ALubyte;
|
||||
using NzOpenALDetail::ALuint;
|
||||
using NzOpenALDetail::ALushort;
|
||||
using NzOpenALDetail::ALvoid;
|
||||
using OpenALDetail::ALboolean;
|
||||
using OpenALDetail::ALbyte;
|
||||
using OpenALDetail::ALchar;
|
||||
using OpenALDetail::ALdouble;
|
||||
using OpenALDetail::ALenum;
|
||||
using OpenALDetail::ALfloat;
|
||||
using OpenALDetail::ALint;
|
||||
using OpenALDetail::ALshort;
|
||||
using OpenALDetail::ALsizei;
|
||||
using OpenALDetail::ALubyte;
|
||||
using OpenALDetail::ALuint;
|
||||
using OpenALDetail::ALushort;
|
||||
using OpenALDetail::ALvoid;
|
||||
|
||||
using NzOpenALDetail::ALCboolean;
|
||||
using NzOpenALDetail::ALCbyte;
|
||||
using NzOpenALDetail::ALCchar;
|
||||
using NzOpenALDetail::ALCcontext;
|
||||
using NzOpenALDetail::ALCdevice;
|
||||
using NzOpenALDetail::ALCdouble;
|
||||
using NzOpenALDetail::ALCenum;
|
||||
using NzOpenALDetail::ALCfloat;
|
||||
using NzOpenALDetail::ALCint;
|
||||
using NzOpenALDetail::ALCshort;
|
||||
using NzOpenALDetail::ALCsizei;
|
||||
using NzOpenALDetail::ALCubyte;
|
||||
using NzOpenALDetail::ALCuint;
|
||||
using NzOpenALDetail::ALCushort;
|
||||
using NzOpenALDetail::ALCvoid;
|
||||
using OpenALDetail::ALCboolean;
|
||||
using OpenALDetail::ALCbyte;
|
||||
using OpenALDetail::ALCchar;
|
||||
using OpenALDetail::ALCcontext;
|
||||
using OpenALDetail::ALCdevice;
|
||||
using OpenALDetail::ALCdouble;
|
||||
using OpenALDetail::ALCenum;
|
||||
using OpenALDetail::ALCfloat;
|
||||
using OpenALDetail::ALCint;
|
||||
using OpenALDetail::ALCshort;
|
||||
using OpenALDetail::ALCsizei;
|
||||
using OpenALDetail::ALCubyte;
|
||||
using OpenALDetail::ALCuint;
|
||||
using OpenALDetail::ALCushort;
|
||||
using OpenALDetail::ALCvoid;
|
||||
|
||||
using NzOpenALFunc = void (*)();
|
||||
|
||||
class NAZARA_AUDIO_API NzOpenAL
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
static NzOpenALFunc GetEntry(const NzString& entryPoint);
|
||||
static NzString GetRendererName();
|
||||
static NzString GetVendorName();
|
||||
static unsigned int GetVersion();
|
||||
using OpenALFunc = void(*)();
|
||||
|
||||
static bool Initialize(bool openDevice = true);
|
||||
class NAZARA_AUDIO_API OpenAL
|
||||
{
|
||||
public:
|
||||
static OpenALFunc GetEntry(const String& entryPoint);
|
||||
static String GetRendererName();
|
||||
static String GetVendorName();
|
||||
static unsigned int GetVersion();
|
||||
|
||||
static bool IsInitialized();
|
||||
static bool Initialize(bool openDevice = true);
|
||||
|
||||
static unsigned int QueryInputDevices(std::vector<NzString>& devices);
|
||||
static unsigned int QueryOutputDevices(std::vector<NzString>& devices);
|
||||
static bool IsInitialized();
|
||||
|
||||
static bool SetDevice(const NzString& deviceName);
|
||||
static unsigned int QueryInputDevices(std::vector<String>& devices);
|
||||
static unsigned int QueryOutputDevices(std::vector<String>& devices);
|
||||
|
||||
static void Uninitialize();
|
||||
static bool SetDevice(const String& deviceName);
|
||||
|
||||
static ALenum AudioFormat[nzAudioFormat_Max+1];
|
||||
static void Uninitialize();
|
||||
|
||||
private:
|
||||
static void CloseDevice();
|
||||
static bool OpenDevice();
|
||||
static NzOpenALFunc LoadEntry(const char* name, bool throwException = false);
|
||||
};
|
||||
static ALenum AudioFormat[AudioFormat_Max + 1];
|
||||
|
||||
private:
|
||||
static void CloseDevice();
|
||||
static bool OpenDevice();
|
||||
static OpenALFunc LoadEntry(const char* name, bool throwException = false);
|
||||
};
|
||||
}
|
||||
|
||||
// al
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALBUFFER3F alBuffer3f;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALBUFFER3I alBuffer3i;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALBUFFERDATA alBufferData;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALBUFFERF alBufferf;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALBUFFERFV alBufferfv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALBUFFERI alBufferi;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALBUFFERIV alBufferiv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALDELETEBUFFERS alDeleteBuffers;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALDELETESOURCES alDeleteSources;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALDISABLE alDisable;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALDISTANCEMODEL alDistanceModel;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALDOPPLERFACTOR alDopplerFactor;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALDOPPLERVELOCITY alDopplerVelocity;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALENABLE alEnable;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGENBUFFERS alGenBuffers;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGENSOURCES alGenSources;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETBOOLEAN alGetBoolean;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETBOOLEANV alGetBooleanv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETBUFFER3F alGetBuffer3f;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETBUFFER3I alGetBuffer3i;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETBUFFERF alGetBufferf;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETBUFFERFV alGetBufferfv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETBUFFERI alGetBufferi;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETBUFFERIV alGetBufferiv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETDOUBLE alGetDouble;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETDOUBLEV alGetDoublev;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETENUMVALUE alGetEnumValue;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETERROR alGetError;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETFLOAT alGetFloat;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETFLOATV alGetFloatv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETINTEGER alGetInteger;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETINTEGERV alGetIntegerv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETLISTENER3F alGetListener3f;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETLISTENER3I alGetListener3i;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETLISTENERF alGetListenerf;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETLISTENERFV alGetListenerfv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETLISTENERI alGetListeneri;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETLISTENERIV alGetListeneriv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETPROCADDRESS alGetProcAddress;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETSOURCE3F alGetSource3f;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETSOURCE3I alGetSource3i;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETSOURCEF alGetSourcef;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETSOURCEFV alGetSourcefv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETSOURCEI alGetSourcei;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETSOURCEIV alGetSourceiv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETSTRING alGetString;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALISBUFFER alIsBuffer;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALISENABLED alIsEnabled;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALISEXTENSIONPRESENT alIsExtensionPresent;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALISSOURCE alIsSource;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALLISTENER3F alListener3f;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALLISTENER3I alListener3i;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALLISTENERF alListenerf;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALLISTENERFV alListenerfv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALLISTENERI alListeneri;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALLISTENERIV alListeneriv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCE3F alSource3f;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCE3I alSource3i;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEF alSourcef;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEFV alSourcefv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEI alSourcei;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEIV alSourceiv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEPAUSE alSourcePause;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEPAUSEV alSourcePausev;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEPLAY alSourcePlay;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEPLAYV alSourcePlayv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEREWIND alSourceRewind;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEREWINDV alSourceRewindv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCESTOP alSourceStop;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCESTOPV alSourceStopv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSPEEDOFSOUND alSpeedOfSound;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALBUFFER3F alBuffer3f;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALBUFFER3I alBuffer3i;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALBUFFERDATA alBufferData;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALBUFFERF alBufferf;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALBUFFERFV alBufferfv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALBUFFERI alBufferi;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALBUFFERIV alBufferiv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALDELETEBUFFERS alDeleteBuffers;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALDELETESOURCES alDeleteSources;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALDISABLE alDisable;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALDISTANCEMODEL alDistanceModel;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALDOPPLERFACTOR alDopplerFactor;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALDOPPLERVELOCITY alDopplerVelocity;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALENABLE alEnable;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGENBUFFERS alGenBuffers;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGENSOURCES alGenSources;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETBOOLEAN alGetBoolean;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETBOOLEANV alGetBooleanv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETBUFFER3F alGetBuffer3f;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETBUFFER3I alGetBuffer3i;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETBUFFERF alGetBufferf;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETBUFFERFV alGetBufferfv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETBUFFERI alGetBufferi;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETBUFFERIV alGetBufferiv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETDOUBLE alGetDouble;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETDOUBLEV alGetDoublev;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETENUMVALUE alGetEnumValue;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETERROR alGetError;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETFLOAT alGetFloat;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETFLOATV alGetFloatv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETINTEGER alGetInteger;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETINTEGERV alGetIntegerv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETLISTENER3F alGetListener3f;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETLISTENER3I alGetListener3i;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETLISTENERF alGetListenerf;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETLISTENERFV alGetListenerfv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETLISTENERI alGetListeneri;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETLISTENERIV alGetListeneriv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETPROCADDRESS alGetProcAddress;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETSOURCE3F alGetSource3f;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETSOURCE3I alGetSource3i;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETSOURCEF alGetSourcef;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETSOURCEFV alGetSourcefv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETSOURCEI alGetSourcei;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETSOURCEIV alGetSourceiv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETSTRING alGetString;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALISBUFFER alIsBuffer;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALISENABLED alIsEnabled;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALISEXTENSIONPRESENT alIsExtensionPresent;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALISSOURCE alIsSource;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALLISTENER3F alListener3f;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALLISTENER3I alListener3i;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALLISTENERF alListenerf;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALLISTENERFV alListenerfv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALLISTENERI alListeneri;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALLISTENERIV alListeneriv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCE3F alSource3f;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCE3I alSource3i;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEF alSourcef;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEFV alSourcefv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEI alSourcei;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEIV alSourceiv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEPAUSE alSourcePause;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEPAUSEV alSourcePausev;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEPLAY alSourcePlay;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEPLAYV alSourcePlayv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEREWIND alSourceRewind;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEREWINDV alSourceRewindv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCESTOP alSourceStop;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCESTOPV alSourceStopv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSPEEDOFSOUND alSpeedOfSound;
|
||||
|
||||
// alc
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCCAPTURECLOSEDEVICE alcCaptureCloseDevice;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCCAPTUREOPENDEVICE alcCaptureOpenDevice;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCCAPTURESAMPLES alcCaptureSamples;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCCAPTURESTART alcCaptureStart;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCCAPTURESTOP alcCaptureStop;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCCLOSEDEVICE alcCloseDevice;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCCREATECONTEXT alcCreateContext;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCDESTROYCONTEXT alcDestroyContext;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCGETCONTEXTSDEVICE alcGetContextsDevice;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCGETCURRENTCONTEXT alcGetCurrentContext;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCGETENUMVALUE alcGetEnumValue;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCGETERROR alcGetError;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCGETINTEGERV alcGetIntegerv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCGETPROCADDRESS alcGetProcAddress;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCGETSTRING alcGetString;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCISEXTENSIONPRESENT alcIsExtensionPresent;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCMAKECONTEXTCURRENT alcMakeContextCurrent;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCOPENDEVICE alcOpenDevice;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCPROCESSCONTEXT alcProcessContext;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCSUSPENDCONTEXT alcSuspendContext;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCCAPTURECLOSEDEVICE alcCaptureCloseDevice;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCCAPTUREOPENDEVICE alcCaptureOpenDevice;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCCAPTURESAMPLES alcCaptureSamples;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCCAPTURESTART alcCaptureStart;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCCAPTURESTOP alcCaptureStop;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCCLOSEDEVICE alcCloseDevice;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCCREATECONTEXT alcCreateContext;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCDESTROYCONTEXT alcDestroyContext;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCGETCONTEXTSDEVICE alcGetContextsDevice;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCGETCURRENTCONTEXT alcGetCurrentContext;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCGETENUMVALUE alcGetEnumValue;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCGETERROR alcGetError;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCGETINTEGERV alcGetIntegerv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCGETPROCADDRESS alcGetProcAddress;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCGETSTRING alcGetString;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCISEXTENSIONPRESENT alcIsExtensionPresent;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCMAKECONTEXTCURRENT alcMakeContextCurrent;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCOPENDEVICE alcOpenDevice;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCPROCESSCONTEXT alcProcessContext;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCSUSPENDCONTEXT alcSuspendContext;
|
||||
|
||||
#endif // NAZARA_AUDIO_OPENAL
|
||||
|
||||
|
||||
@@ -12,43 +12,46 @@
|
||||
#include <Nazara/Audio/SoundBuffer.hpp>
|
||||
#include <Nazara/Audio/SoundEmitter.hpp>
|
||||
|
||||
class NAZARA_AUDIO_API NzSound : public NzSoundEmitter
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzSound() = default;
|
||||
NzSound(const NzSoundBuffer* soundBuffer);
|
||||
NzSound(const NzSound& sound);
|
||||
NzSound(NzSound&&) = default;
|
||||
~NzSound();
|
||||
class NAZARA_AUDIO_API Sound : public SoundEmitter
|
||||
{
|
||||
public:
|
||||
Sound() = default;
|
||||
Sound(const SoundBuffer* soundBuffer);
|
||||
Sound(const Sound& sound);
|
||||
Sound(Sound&&) = default;
|
||||
~Sound();
|
||||
|
||||
void EnableLooping(bool loop);
|
||||
void EnableLooping(bool loop);
|
||||
|
||||
const NzSoundBuffer* GetBuffer() const;
|
||||
nzUInt32 GetDuration() const;
|
||||
nzUInt32 GetPlayingOffset() const;
|
||||
nzSoundStatus GetStatus() const;
|
||||
const SoundBuffer* GetBuffer() const;
|
||||
UInt32 GetDuration() const;
|
||||
UInt32 GetPlayingOffset() const;
|
||||
SoundStatus GetStatus() const;
|
||||
|
||||
bool IsLooping() const;
|
||||
bool IsPlayable() const;
|
||||
bool IsPlaying() const;
|
||||
bool IsLooping() const;
|
||||
bool IsPlayable() const;
|
||||
bool IsPlaying() const;
|
||||
|
||||
bool LoadFromFile(const NzString& filePath, const NzSoundBufferParams& params = NzSoundBufferParams());
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const NzSoundBufferParams& params = NzSoundBufferParams());
|
||||
bool LoadFromStream(NzInputStream& stream, const NzSoundBufferParams& params = NzSoundBufferParams());
|
||||
bool LoadFromFile(const String& filePath, const SoundBufferParams& params = SoundBufferParams());
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params = SoundBufferParams());
|
||||
bool LoadFromStream(InputStream& stream, const SoundBufferParams& params = SoundBufferParams());
|
||||
|
||||
void Pause();
|
||||
void Play();
|
||||
void Pause();
|
||||
void Play();
|
||||
|
||||
void SetBuffer(const NzSoundBuffer* buffer);
|
||||
void SetPlayingOffset(nzUInt32 offset);
|
||||
void SetBuffer(const SoundBuffer* buffer);
|
||||
void SetPlayingOffset(UInt32 offset);
|
||||
|
||||
void Stop();
|
||||
void Stop();
|
||||
|
||||
NzSound& operator=(const NzSound&) = delete; ///TODO?
|
||||
NzSound& operator=(NzSound&&) = default;
|
||||
Sound& operator=(const Sound&) = delete; ///TODO?
|
||||
Sound& operator=(Sound&&) = default;
|
||||
|
||||
private:
|
||||
NzSoundBufferConstRef m_buffer;
|
||||
};
|
||||
private:
|
||||
SoundBufferConstRef m_buffer;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_SOUND_HPP
|
||||
|
||||
@@ -19,77 +19,80 @@
|
||||
#include <Nazara/Core/ResourceManager.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
|
||||
struct NzSoundBufferParams
|
||||
namespace Nz
|
||||
{
|
||||
bool forceMono = false;
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
||||
class NzSound;
|
||||
class NzSoundBuffer;
|
||||
|
||||
using NzSoundBufferConstRef = NzObjectRef<const NzSoundBuffer>;
|
||||
using NzSoundBufferLibrary = NzObjectLibrary<NzSoundBuffer>;
|
||||
using NzSoundBufferLoader = NzResourceLoader<NzSoundBuffer, NzSoundBufferParams>;
|
||||
using NzSoundBufferManager = NzResourceManager<NzSoundBuffer, NzSoundBufferParams>;
|
||||
using NzSoundBufferRef = NzObjectRef<NzSoundBuffer>;
|
||||
|
||||
struct NzSoundBufferImpl;
|
||||
|
||||
class NAZARA_AUDIO_API NzSoundBuffer : public NzRefCounted, public NzResource
|
||||
{
|
||||
friend NzSound;
|
||||
friend NzSoundBufferLibrary;
|
||||
friend NzSoundBufferLoader;
|
||||
friend NzSoundBufferManager;
|
||||
friend class NzAudio;
|
||||
|
||||
public:
|
||||
NzSoundBuffer() = default;
|
||||
NzSoundBuffer(nzAudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const nzInt16* samples);
|
||||
NzSoundBuffer(const NzSoundBuffer&) = delete;
|
||||
NzSoundBuffer(NzSoundBuffer&&) = delete;
|
||||
~NzSoundBuffer();
|
||||
|
||||
bool Create(nzAudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const nzInt16* samples);
|
||||
void Destroy();
|
||||
|
||||
nzUInt32 GetDuration() const;
|
||||
nzAudioFormat GetFormat() const;
|
||||
const nzInt16* GetSamples() const;
|
||||
nzUInt32 GetSampleCount() const;
|
||||
nzUInt32 GetSampleRate() const;
|
||||
struct SoundBufferParams
|
||||
{
|
||||
bool forceMono = false;
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
||||
bool LoadFromFile(const NzString& filePath, const NzSoundBufferParams& params = NzSoundBufferParams());
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const NzSoundBufferParams& params = NzSoundBufferParams());
|
||||
bool LoadFromStream(NzInputStream& stream, const NzSoundBufferParams& params = NzSoundBufferParams());
|
||||
class Sound;
|
||||
class SoundBuffer;
|
||||
|
||||
static bool IsFormatSupported(nzAudioFormat format);
|
||||
template<typename... Args> static NzSoundBufferRef New(Args&&... args);
|
||||
using SoundBufferConstRef = ObjectRef<const SoundBuffer>;
|
||||
using SoundBufferLibrary = ObjectLibrary<SoundBuffer>;
|
||||
using SoundBufferLoader = ResourceLoader<SoundBuffer, SoundBufferParams>;
|
||||
using SoundBufferManager = ResourceManager<SoundBuffer, SoundBufferParams>;
|
||||
using SoundBufferRef = ObjectRef<SoundBuffer>;
|
||||
|
||||
NzSoundBuffer& operator=(const NzSoundBuffer&) = delete;
|
||||
NzSoundBuffer& operator=(NzSoundBuffer&&) = delete; ///TODO
|
||||
struct SoundBufferImpl;
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnSoundBufferDestroy, const NzSoundBuffer* /*soundBuffer*/);
|
||||
NazaraSignal(OnSoundBufferRelease, const NzSoundBuffer* /*soundBuffer*/);
|
||||
class NAZARA_AUDIO_API SoundBuffer : public RefCounted, public Resource
|
||||
{
|
||||
friend Sound;
|
||||
friend SoundBufferLibrary;
|
||||
friend SoundBufferLoader;
|
||||
friend SoundBufferManager;
|
||||
friend class Audio;
|
||||
|
||||
private:
|
||||
unsigned int GetOpenALBuffer() const;
|
||||
public:
|
||||
SoundBuffer() = default;
|
||||
SoundBuffer(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples);
|
||||
SoundBuffer(const SoundBuffer&) = delete;
|
||||
SoundBuffer(SoundBuffer&&) = delete;
|
||||
~SoundBuffer();
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
bool Create(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples);
|
||||
void Destroy();
|
||||
|
||||
NzSoundBufferImpl* m_impl = nullptr;
|
||||
UInt32 GetDuration() const;
|
||||
AudioFormat GetFormat() const;
|
||||
const Int16* GetSamples() const;
|
||||
UInt32 GetSampleCount() const;
|
||||
UInt32 GetSampleRate() const;
|
||||
|
||||
static NzSoundBufferLibrary::LibraryMap s_library;
|
||||
static NzSoundBufferLoader::LoaderList s_loaders;
|
||||
static NzSoundBufferManager::ManagerMap s_managerMap;
|
||||
static NzSoundBufferManager::ManagerParams s_managerParameters;
|
||||
};
|
||||
bool IsValid() const;
|
||||
|
||||
bool LoadFromFile(const String& filePath, const SoundBufferParams& params = SoundBufferParams());
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params = SoundBufferParams());
|
||||
bool LoadFromStream(InputStream& stream, const SoundBufferParams& params = SoundBufferParams());
|
||||
|
||||
static bool IsFormatSupported(AudioFormat format);
|
||||
template<typename... Args> static SoundBufferRef New(Args&&... args);
|
||||
|
||||
SoundBuffer& operator=(const SoundBuffer&) = delete;
|
||||
SoundBuffer& operator=(SoundBuffer&&) = delete; ///TODO
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnSoundBufferDestroy, const SoundBuffer* /*soundBuffer*/);
|
||||
NazaraSignal(OnSoundBufferRelease, const SoundBuffer* /*soundBuffer*/);
|
||||
|
||||
private:
|
||||
unsigned int GetOpenALBuffer() const;
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
SoundBufferImpl* m_impl = nullptr;
|
||||
|
||||
static SoundBufferLibrary::LibraryMap s_library;
|
||||
static SoundBufferLoader::LoaderList s_loaders;
|
||||
static SoundBufferManager::ManagerMap s_managerMap;
|
||||
static SoundBufferManager::ManagerParams s_managerParameters;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Audio/SoundBuffer.inl>
|
||||
|
||||
|
||||
@@ -5,13 +5,16 @@
|
||||
#include <memory>
|
||||
#include <Nazara/Audio/Debug.hpp>
|
||||
|
||||
template<typename... Args>
|
||||
NzSoundBufferRef NzSoundBuffer::New(Args&&... args)
|
||||
namespace Nz
|
||||
{
|
||||
std::unique_ptr<NzSoundBuffer> object(new NzSoundBuffer(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
template<typename... Args>
|
||||
SoundBufferRef SoundBuffer::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<SoundBuffer> object(new SoundBuffer(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
return object.release();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Audio/DebugOff.hpp>
|
||||
|
||||
@@ -15,52 +15,54 @@
|
||||
|
||||
///TODO: Faire hériter SoundEmitter de Node
|
||||
|
||||
class NAZARA_AUDIO_API NzSoundEmitter
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
virtual ~NzSoundEmitter();
|
||||
class NAZARA_AUDIO_API SoundEmitter
|
||||
{
|
||||
public:
|
||||
virtual ~SoundEmitter();
|
||||
|
||||
virtual void EnableLooping(bool loop) = 0;
|
||||
void EnableSpatialization(bool spatialization);
|
||||
virtual void EnableLooping(bool loop) = 0;
|
||||
void EnableSpatialization(bool spatialization);
|
||||
|
||||
float GetAttenuation() const;
|
||||
virtual nzUInt32 GetDuration() const = 0;
|
||||
float GetMinDistance() const;
|
||||
float GetPitch() const;
|
||||
virtual nzUInt32 GetPlayingOffset() const = 0;
|
||||
NzVector3f GetPosition() const;
|
||||
NzVector3f GetVelocity() const;
|
||||
virtual nzSoundStatus GetStatus() const = 0;
|
||||
float GetVolume() const;
|
||||
float GetAttenuation() const;
|
||||
virtual UInt32 GetDuration() const = 0;
|
||||
float GetMinDistance() const;
|
||||
float GetPitch() const;
|
||||
virtual UInt32 GetPlayingOffset() const = 0;
|
||||
Vector3f GetPosition() const;
|
||||
Vector3f GetVelocity() const;
|
||||
virtual SoundStatus GetStatus() const = 0;
|
||||
float GetVolume() const;
|
||||
|
||||
virtual bool IsLooping() const = 0;
|
||||
bool IsSpatialized() const;
|
||||
virtual bool IsLooping() const = 0;
|
||||
bool IsSpatialized() const;
|
||||
|
||||
virtual void Pause() = 0;
|
||||
virtual void Play() = 0;
|
||||
virtual void Pause() = 0;
|
||||
virtual void Play() = 0;
|
||||
|
||||
void SetAttenuation(float attenuation);
|
||||
void SetMinDistance(float minDistance);
|
||||
void SetPitch(float pitch);
|
||||
void SetPosition(const NzVector3f& position);
|
||||
void SetPosition(float x, float y, float z);
|
||||
void SetVelocity(const NzVector3f& velocity);
|
||||
void SetVelocity(float velX, float velY, float velZ);
|
||||
void SetVolume(float volume);
|
||||
void SetAttenuation(float attenuation);
|
||||
void SetMinDistance(float minDistance);
|
||||
void SetPitch(float pitch);
|
||||
void SetPosition(const Vector3f& position);
|
||||
void SetPosition(float x, float y, float z);
|
||||
void SetVelocity(const Vector3f& velocity);
|
||||
void SetVelocity(float velX, float velY, float velZ);
|
||||
void SetVolume(float volume);
|
||||
|
||||
virtual void Stop() = 0;
|
||||
virtual void Stop() = 0;
|
||||
|
||||
NzSoundEmitter& operator=(const NzSoundEmitter&) = delete; ///TODO
|
||||
NzSoundEmitter& operator=(NzSoundEmitter&&) = delete; ///TODO
|
||||
SoundEmitter& operator=(const SoundEmitter&) = delete; ///TODO
|
||||
SoundEmitter& operator=(SoundEmitter&&) = delete; ///TODO
|
||||
|
||||
protected:
|
||||
NzSoundEmitter();
|
||||
NzSoundEmitter(const NzSoundEmitter& emitter);
|
||||
NzSoundEmitter(NzSoundEmitter&&) = delete; ///TODO
|
||||
protected:
|
||||
SoundEmitter();
|
||||
SoundEmitter(const SoundEmitter& emitter);
|
||||
SoundEmitter(SoundEmitter&&) = delete; ///TODO
|
||||
|
||||
nzSoundStatus GetInternalStatus() const;
|
||||
|
||||
unsigned int m_source;
|
||||
};
|
||||
SoundStatus GetInternalStatus() const;
|
||||
|
||||
unsigned int m_source;
|
||||
};
|
||||
}
|
||||
#endif // NAZARA_SOUNDEMITTER_HPP
|
||||
|
||||
@@ -11,19 +11,22 @@
|
||||
#include <Nazara/Audio/Config.hpp>
|
||||
#include <Nazara/Audio/Enums.hpp>
|
||||
|
||||
class NAZARA_AUDIO_API NzSoundStream
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzSoundStream() = default;
|
||||
virtual ~NzSoundStream();
|
||||
class NAZARA_AUDIO_API SoundStream
|
||||
{
|
||||
public:
|
||||
SoundStream() = default;
|
||||
virtual ~SoundStream();
|
||||
|
||||
virtual nzUInt32 GetDuration() const = 0;
|
||||
virtual nzAudioFormat GetFormat() const = 0;
|
||||
virtual nzUInt32 GetSampleCount() const = 0;
|
||||
virtual nzUInt32 GetSampleRate() const = 0;
|
||||
virtual UInt32 GetDuration() const = 0;
|
||||
virtual AudioFormat GetFormat() const = 0;
|
||||
virtual UInt32 GetSampleCount() const = 0;
|
||||
virtual UInt32 GetSampleRate() const = 0;
|
||||
|
||||
virtual unsigned int Read(void* buffer, unsigned int sampleCount) = 0;
|
||||
virtual void Seek(nzUInt32 offset) = 0;
|
||||
};
|
||||
virtual unsigned int Read(void* buffer, unsigned int sampleCount) = 0;
|
||||
virtual void Seek(UInt32 offset) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_SOUNDSTREAM_HPP
|
||||
|
||||
Reference in New Issue
Block a user