// 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 struct NzSoundBufferParams { bool forceMono = false; bool IsValid() const; }; class NzSound; class NzSoundBuffer; using NzSoundBufferConstListener = NzObjectListenerWrapper; using NzSoundBufferConstRef = NzObjectRef; using NzSoundBufferListener = NzObjectListenerWrapper; using NzSoundBufferLoader = NzResourceLoader; using NzSoundBufferRef = NzObjectRef; struct NzSoundBufferImpl; class NAZARA_API NzSoundBuffer : public NzRefCounted, public NzResource, NzNonCopyable { friend NzSound; friend NzSoundBufferLoader; public: NzSoundBuffer() = default; NzSoundBuffer(nzAudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const nzInt16* samples); ~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; unsigned int GetSampleCount() const; unsigned int GetSampleRate() const; 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()); static bool IsFormatSupported(nzAudioFormat format); template static NzSoundBufferRef New(Args&&... args); private: unsigned int GetOpenALBuffer() const; NzSoundBufferImpl* m_impl = nullptr; static NzSoundBufferLoader::LoaderList s_loaders; }; #include #endif // NAZARA_SOUNDBUFFER_HPP