SoundBuffer.hpp
1// Copyright 2019 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4
5#ifndef SMK_SOUND_BUFFER_HPP
6#define SMK_SOUND_BUFFER_HPP
7
8#include <string>
9
10namespace smk {
11class Sound;
12
13// Please make sure to init OpenAL in main() before loading any file. You can
14// initialize the "empty" version first and then std::move the one associated
15// with a file.
16//
17
18/// @brief A sound file loaded in memory.
19/// @see Sound
20///
21/// Example
22/// -------
23/// ~~~cpp
24/// // Load a sound file.
25/// auto sound_buffer = smk::SoundBuffer(asset::water_mp3);
26///
27/// // Create a sound source.
28/// auto sound = smk::Sound(sound_buffer);
29///
30/// // Start playing.
31/// sound.Play()
32/// ~~~
34 public:
35 SoundBuffer(); // Empty sound buffer
36 SoundBuffer(const std::string& filename);
37
39
40 // --- Move only resource ----------------------------------------------------
41 SoundBuffer(SoundBuffer&&) noexcept;
42 SoundBuffer(const SoundBuffer&) = delete;
43 SoundBuffer& operator=(SoundBuffer&&) noexcept;
44 SoundBuffer& operator=(const SoundBuffer&) = delete;
45 // ---------------------------------------------------------------------------
46
47 unsigned int buffer() const;
48
49 private:
50 unsigned int buffer_ = 0;
51};
52} // namespace smk
53
54#endif /* end of include guard: SMK_SOUND_BUFFER_HPP */
A sound file loaded in memory.
Definition: SoundBuffer.hpp:33