Added music class

Former-commit-id: 5288191ecea17cb81e30a175869a2b4ea29dbc2f
This commit is contained in:
Lynix
2012-11-29 17:33:58 +01:00
parent a536bf467b
commit 3f0bb8a8bb
5 changed files with 385 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
// Copyright (C) 2012 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_MUSIC_HPP
#define NAZARA_MUSIC_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Audio/Enums.hpp>
#include <Nazara/Audio/SoundEmitter.hpp>
#include <Nazara/Core/ResourceLoader.hpp>
struct NzMusicParams
{
bool IsValid() const;
};
class NzMusic;
class NzSoundStream;
class NzThread;
using NzMusicLoader = NzResourceLoader<NzMusic, NzMusicParams>;
struct NzMusicImpl;
class NAZARA_API NzMusic : public NzSoundEmitter
{
friend NzMusicLoader;
public:
NzMusic() = default;
~NzMusic();
bool Create(NzSoundStream* soundStream);
void Destroy();
void EnableLooping(bool loop);
nzUInt32 GetDuration() const;
nzAudioFormat GetFormat() const;
nzUInt32 GetPlayingOffset() const;
unsigned int GetSampleCount() const;
unsigned int GetSampleRate() const;
nzSoundStatus GetStatus() 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());
void Pause();
bool Play();
void SetPlayingOffset(nzUInt32 offset);
void Stop();
private:
NzMusicImpl* m_impl = nullptr;
bool FillBuffer(unsigned int buffer);
void MusicThread();
static NzMusicLoader::LoaderList s_loaders;
};
#endif // NAZARA_MUSIC_HPP

View File

@@ -0,0 +1,28 @@
// Copyright (C) 2012 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_SOUNDSTREAM_HPP
#define NAZARA_SOUNDSTREAM_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Audio/Enums.hpp>
class NAZARA_API NzSoundStream
{
public:
NzSoundStream() = default;
virtual ~NzSoundStream();
virtual nzUInt32 GetDuration() const = 0;
virtual nzAudioFormat GetFormat() const = 0;
virtual unsigned int GetSampleCount() const = 0;
virtual unsigned int GetSampleRate() const = 0;
virtual unsigned int Read(void* buffer, unsigned int sampleCount) = 0;
virtual void Seek(nzUInt32 offset) = 0;
};
#endif // NAZARA_SOUNDSTREAM_HPP