// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_SOUNDBUFFER_HPP #define NAZARA_SOUNDBUFFER_HPP #include #include #include #include #include #include #include #include #include #include #include #include namespace Nz { struct SoundBufferParams : ResourceParameters { bool forceMono = false; bool IsValid() const; }; class Sound; class SoundBuffer; using SoundBufferConstRef = ObjectRef; using SoundBufferLibrary = ObjectLibrary; using SoundBufferLoader = ResourceLoader; using SoundBufferManager = ResourceManager; using SoundBufferRef = ObjectRef; 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(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples); SoundBuffer(const SoundBuffer&) = delete; SoundBuffer(SoundBuffer&&) = delete; ~SoundBuffer(); bool Create(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples); void Destroy(); UInt32 GetDuration() const; AudioFormat GetFormat() const; const Int16* GetSamples() const; UInt32 GetSampleCount() const; UInt32 GetSampleRate() const; 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(Stream& stream, const SoundBufferParams& params = SoundBufferParams()); static bool IsFormatSupported(AudioFormat format); template 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 #endif // NAZARA_SOUNDBUFFER_HPP