Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Sound.hpp
1 // Copyright (C) 2017 Jérôme Leclercq
2 // This file is part of the "Nazara Engine - Audio module"
3 // For conditions of distribution and use, see copyright notice in Config.hpp
4 
5 #pragma once
6 
7 #ifndef NAZARA_SOUND_HPP
8 #define NAZARA_SOUND_HPP
9 
10 #include <Nazara/Prerequesites.hpp>
11 #include <Nazara/Audio/Enums.hpp>
12 #include <Nazara/Audio/SoundBuffer.hpp>
13 #include <Nazara/Audio/SoundEmitter.hpp>
14 
15 namespace Nz
16 {
17  class NAZARA_AUDIO_API Sound : public SoundEmitter
18  {
19  public:
20  Sound() = default;
21  Sound(const SoundBuffer* soundBuffer);
22  Sound(const Sound& sound);
23  Sound(Sound&&) = default;
24  ~Sound();
25 
26  void EnableLooping(bool loop) override;
27 
28  const SoundBuffer* GetBuffer() const;
29  UInt32 GetDuration() const override;
30  UInt32 GetPlayingOffset() const override;
31  SoundStatus GetStatus() const override;
32 
33  bool IsLooping() const override;
34  bool IsPlayable() const;
35  bool IsPlaying() const;
36 
37  bool LoadFromFile(const String& filePath, const SoundBufferParams& params = SoundBufferParams());
38  bool LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params = SoundBufferParams());
39  bool LoadFromStream(Stream& stream, const SoundBufferParams& params = SoundBufferParams());
40 
41  void Pause() override;
42  void Play() override;
43 
44  void SetBuffer(const SoundBuffer* buffer);
45  void SetPlayingOffset(UInt32 offset);
46 
47  void Stop() override;
48 
49  Sound& operator=(const Sound&) = delete;
50  Sound& operator=(Sound&&) = default;
51 
52  private:
53  SoundBufferConstRef m_buffer;
54  };
55 }
56 
57 #endif // NAZARA_SOUND_HPP
TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
Core class that represents a string.
Definition: String.hpp:22
Audio class that represents a sound.
Definition: Sound.hpp:17
Audio class that represents a sound source, that emits sound.
Definition: SoundEmitter.hpp:19
Audio class that represents a buffer for sound.
Definition: SoundBuffer.hpp:43
Core class that represents a stream.
Definition: Stream.hpp:19