Upgrade NazaraAudio
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Audio/Config.hpp>
|
||||
#include <Nazara/Audio/Enums.hpp>
|
||||
#include <Nazara/Audio/SoundBuffer.hpp>
|
||||
#include <Nazara/Audio/SoundStream.hpp>
|
||||
#include <Nazara/Core/Core.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
@@ -26,18 +28,23 @@ namespace Nz
|
||||
struct Config {};
|
||||
|
||||
Audio(Config /*config*/);
|
||||
Audio(const Audio&) = delete;
|
||||
Audio(Audio&&) = delete;
|
||||
~Audio();
|
||||
|
||||
AudioFormat GetAudioFormat(unsigned int channelCount);
|
||||
float GetDopplerFactor();
|
||||
float GetGlobalVolume();
|
||||
Vector3f GetListenerDirection();
|
||||
Vector3f GetListenerPosition();
|
||||
Quaternionf GetListenerRotation();
|
||||
Vector3f GetListenerVelocity();
|
||||
float GetSpeedOfSound();
|
||||
AudioFormat GetAudioFormat(unsigned int channelCount) const;
|
||||
float GetDopplerFactor() const;
|
||||
float GetGlobalVolume() const;
|
||||
Vector3f GetListenerDirection() const;
|
||||
Vector3f GetListenerPosition() const;
|
||||
Quaternionf GetListenerRotation() const;
|
||||
Vector3f GetListenerVelocity() const;
|
||||
const SoundBufferLoader& GetSoundBufferLoader() const;
|
||||
const SoundStreamLoader& GetSoundStreamLoader() const;
|
||||
float GetSpeedOfSound() const;
|
||||
|
||||
bool IsFormatSupported(AudioFormat format) const;
|
||||
|
||||
bool IsFormatSupported(AudioFormat format);
|
||||
void SetDopplerFactor(float dopplerFactor);
|
||||
void SetGlobalVolume(float volume);
|
||||
void SetListenerDirection(const Vector3f& direction);
|
||||
@@ -49,7 +56,13 @@ namespace Nz
|
||||
void SetListenerVelocity(float velX, float velY, float velZ);
|
||||
void SetSpeedOfSound(float speed);
|
||||
|
||||
Audio& operator=(const Audio&) = delete;
|
||||
Audio& operator=(Audio&&) = delete;
|
||||
|
||||
private:
|
||||
SoundBufferLoader m_soundBufferLoader;
|
||||
SoundStreamLoader m_soundStreamLoader;
|
||||
|
||||
static Audio* s_instance;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <Nazara/Audio/Enums.hpp>
|
||||
#include <Nazara/Audio/SoundEmitter.hpp>
|
||||
#include <Nazara/Audio/SoundStream.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -20,12 +19,12 @@ namespace Nz
|
||||
class NAZARA_AUDIO_API Music : public Resource, public SoundEmitter
|
||||
{
|
||||
public:
|
||||
Music() = default;
|
||||
Music();
|
||||
Music(const Music&) = delete;
|
||||
Music(Music&&) noexcept = default;
|
||||
Music(Music&&) noexcept;
|
||||
~Music();
|
||||
|
||||
bool Create(SoundStream* soundStream);
|
||||
bool Create(std::shared_ptr<SoundStream> soundStream);
|
||||
void Destroy();
|
||||
|
||||
void EnableLooping(bool loop) override;
|
||||
@@ -51,10 +50,10 @@ namespace Nz
|
||||
void Stop() override;
|
||||
|
||||
Music& operator=(const Music&) = delete;
|
||||
Music& operator=(Music&&) noexcept = default;
|
||||
Music& operator=(Music&&) noexcept;
|
||||
|
||||
private:
|
||||
MovablePtr<MusicImpl> m_impl;
|
||||
std::unique_ptr<MusicImpl> m_impl;
|
||||
|
||||
bool FillAndQueueBuffer(unsigned int buffer);
|
||||
void MusicThread();
|
||||
|
||||
@@ -18,14 +18,14 @@ namespace Nz
|
||||
{
|
||||
public:
|
||||
Sound() = default;
|
||||
Sound(const SoundBuffer* soundBuffer);
|
||||
Sound(const Sound& sound);
|
||||
Sound(std::shared_ptr<const SoundBuffer> soundBuffer);
|
||||
Sound(const Sound&) = default;
|
||||
Sound(Sound&&) noexcept = default;
|
||||
~Sound();
|
||||
|
||||
void EnableLooping(bool loop) override;
|
||||
|
||||
const SoundBuffer* GetBuffer() const;
|
||||
const std::shared_ptr<const SoundBuffer>& GetBuffer() const;
|
||||
UInt32 GetDuration() const override;
|
||||
UInt32 GetPlayingOffset() const override;
|
||||
SoundStatus GetStatus() const override;
|
||||
@@ -41,7 +41,7 @@ namespace Nz
|
||||
void Pause() override;
|
||||
void Play() override;
|
||||
|
||||
void SetBuffer(const SoundBuffer* buffer);
|
||||
void SetBuffer(std::shared_ptr<const SoundBuffer> soundBuffer);
|
||||
void SetPlayingOffset(UInt32 offset);
|
||||
|
||||
void Stop() override;
|
||||
@@ -50,7 +50,7 @@ namespace Nz
|
||||
Sound& operator=(Sound&&) noexcept = default;
|
||||
|
||||
private:
|
||||
SoundBufferConstRef m_buffer;
|
||||
std::shared_ptr<const SoundBuffer> m_buffer;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Audio/Config.hpp>
|
||||
#include <Nazara/Audio/Enums.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/ObjectLibrary.hpp>
|
||||
#include <Nazara/Core/RefCounted.hpp>
|
||||
@@ -32,24 +31,18 @@ namespace Nz
|
||||
class Sound;
|
||||
class SoundBuffer;
|
||||
|
||||
using SoundBufferConstRef = ObjectRef<const SoundBuffer>;
|
||||
using SoundBufferLibrary = ObjectLibrary<SoundBuffer>;
|
||||
using SoundBufferLoader = ResourceLoader<SoundBuffer, SoundBufferParams>;
|
||||
using SoundBufferManager = ResourceManager<SoundBuffer, SoundBufferParams>;
|
||||
using SoundBufferRef = ObjectRef<SoundBuffer>;
|
||||
|
||||
struct SoundBufferImpl;
|
||||
|
||||
class NAZARA_AUDIO_API SoundBuffer : public RefCounted, public Resource
|
||||
{
|
||||
friend Sound;
|
||||
friend SoundBufferLibrary;
|
||||
friend SoundBufferLoader;
|
||||
friend SoundBufferManager;
|
||||
friend class Audio;
|
||||
|
||||
public:
|
||||
SoundBuffer() = default;
|
||||
SoundBuffer();
|
||||
SoundBuffer(AudioFormat format, UInt64 sampleCount, UInt32 sampleRate, const Int16* samples);
|
||||
SoundBuffer(const SoundBuffer&) = delete;
|
||||
SoundBuffer(SoundBuffer&&) = delete;
|
||||
@@ -71,28 +64,14 @@ namespace Nz
|
||||
|
||||
static bool IsFormatSupported(AudioFormat format);
|
||||
|
||||
static SoundBufferRef LoadFromFile(const std::filesystem::path& filePath, const SoundBufferParams& params = SoundBufferParams());
|
||||
static SoundBufferRef LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params = SoundBufferParams());
|
||||
static SoundBufferRef LoadFromStream(Stream& stream, const SoundBufferParams& params = SoundBufferParams());
|
||||
|
||||
template<typename... Args> static SoundBufferRef New(Args&&... args);
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnSoundBufferDestroy, const SoundBuffer* /*soundBuffer*/);
|
||||
NazaraSignal(OnSoundBufferRelease, const SoundBuffer* /*soundBuffer*/);
|
||||
static std::shared_ptr<SoundBuffer> LoadFromFile(const std::filesystem::path& filePath, const SoundBufferParams& params = SoundBufferParams());
|
||||
static std::shared_ptr<SoundBuffer> LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params = SoundBufferParams());
|
||||
static std::shared_ptr<SoundBuffer> LoadFromStream(Stream& stream, const SoundBufferParams& params = SoundBufferParams());
|
||||
|
||||
private:
|
||||
unsigned int GetOpenALBuffer() const;
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
MovablePtr<SoundBufferImpl> m_impl = nullptr;
|
||||
|
||||
static SoundBufferLibrary::LibraryMap s_library;
|
||||
static SoundBufferLoader::LoaderList s_loaders;
|
||||
static SoundBufferManager::ManagerMap s_managerMap;
|
||||
static SoundBufferManager::ManagerParams s_managerParameters;
|
||||
std::unique_ptr<SoundBufferImpl> m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -2,26 +2,12 @@
|
||||
// This file is part of the "Nazara Engine - Audio module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Audio/SoundBuffer.hpp>
|
||||
#include <memory>
|
||||
#include <Nazara/Audio/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \brief Creates a new sound buffer from the arguments
|
||||
* \return A reference to the newly created sound buffer
|
||||
*
|
||||
* \param args Arguments for the sound buffer
|
||||
*/
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Audio/DebugOff.hpp>
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Audio/Config.hpp>
|
||||
#include <Nazara/Audio/Enums.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceParameters.hpp>
|
||||
@@ -29,12 +28,9 @@ namespace Nz
|
||||
class SoundStream;
|
||||
|
||||
using SoundStreamLoader = ResourceLoader<SoundStream, SoundStreamParams>;
|
||||
using SoundStreamRef = Nz::ObjectRef<SoundStream>;
|
||||
|
||||
class NAZARA_AUDIO_API SoundStream : public RefCounted, public Resource
|
||||
class NAZARA_AUDIO_API SoundStream : public Resource
|
||||
{
|
||||
friend SoundStreamLoader;
|
||||
|
||||
public:
|
||||
SoundStream() = default;
|
||||
virtual ~SoundStream();
|
||||
@@ -49,12 +45,9 @@ namespace Nz
|
||||
virtual void Seek(UInt64 offset) = 0;
|
||||
virtual UInt64 Tell() = 0;
|
||||
|
||||
static SoundStreamRef OpenFromFile(const std::filesystem::path& filePath, const SoundStreamParams& params = SoundStreamParams());
|
||||
static SoundStreamRef OpenFromMemory(const void* data, std::size_t size, const SoundStreamParams& params = SoundStreamParams());
|
||||
static SoundStreamRef OpenFromStream(Stream& stream, const SoundStreamParams& params = SoundStreamParams());
|
||||
|
||||
private:
|
||||
static SoundStreamLoader::LoaderList s_loaders;
|
||||
static std::shared_ptr<SoundStream> OpenFromFile(const std::filesystem::path& filePath, const SoundStreamParams& params = SoundStreamParams());
|
||||
static std::shared_ptr<SoundStream> OpenFromMemory(const void* data, std::size_t size, const SoundStreamParams& params = SoundStreamParams());
|
||||
static std::shared_ptr<SoundStream> OpenFromStream(Stream& stream, const SoundStreamParams& params = SoundStreamParams());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user