Sound.hpp
1 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2014 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 #ifndef CPP3DS_SOUND_HPP
26 #define CPP3DS_SOUND_HPP
27 
29 // Headers
31 #ifndef EMULATION
32 #include <3ds.h>
33 #endif
34 #include <cpp3ds/Audio/SoundSource.hpp>
35 #include <cpp3ds/System/Time.hpp>
36 #include <cstdlib>
37 
38 
39 namespace cpp3ds
40 {
41 class SoundBuffer;
42 
47 class Sound : public SoundSource
48 {
49 public :
50 
55  Sound();
56 
63  explicit Sound(const SoundBuffer& buffer);
64 
71  Sound(const Sound& copy);
72 
77  ~Sound();
78 
91  void play();
92 
102  void pause();
103 
114  void stop();
115 
128  void setBuffer(const SoundBuffer& buffer);
129 
143  void setLoop(bool loop);
144 
156  void setPlayingOffset(Time timeOffset);
157 
164  const SoundBuffer* getBuffer() const;
165 
174  bool getLoop() const;
175 
176  bool getStateADPCM() const;
177 
178  void setStateADPCM(bool enable);
179 
188  Time getPlayingOffset() const;
189 
196  Status getStatus() const;
197 
206  Sound& operator =(const Sound& right);
207 
217  void resetBuffer();
218 
219 private :
220 
222  // Member data
224  const SoundBuffer* m_buffer;
225  bool m_loop;
226  bool m_isADPCM;
227 };
228 
229 } // namespace cpp3ds
230 
231 
232 #endif // CPP3DS_SOUND_HPP
233 
234 
void resetBuffer()
Reset the internal buffer of the sound.
void setLoop(bool loop)
Set whether or not the sound should loop after reaching the end.
Base class defining a sound's properties.
Definition: SoundSource.hpp:44
Time getPlayingOffset() const
Get the current playing position of the sound.
Status getStatus() const
Get the current status of the sound (stopped, paused, playing)
void stop()
stop playing the sound
~Sound()
Destructor.
void play()
Start or resume playing the sound.
Represents a time value.
Definition: Time.hpp:37
Status
Enumeration of the sound source states.
Definition: SoundSource.hpp:52
Storage for audio samples defining a sound.
Definition: SoundBuffer.hpp:51
Regular sound that can be played in the audio environment.
Definition: Sound.hpp:47
bool getLoop() const
Tell whether or not the sound is in loop mode.
void pause()
Pause the sound.
void setBuffer(const SoundBuffer &buffer)
Set the source buffer containing the audio data to play.
Sound & operator=(const Sound &right)
Overload of assignment operator.
void setPlayingOffset(Time timeOffset)
Change the current playing position of the sound.
Sound()
Default constructor.
const SoundBuffer * getBuffer() const
Get the audio buffer attached to the sound.