SoundSource.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_SOUNDSOURCE_HPP
26 #define CPP3DS_SOUNDSOURCE_HPP
27 
29 // Headers
31 #include <cpp3ds/Audio/AlResource.hpp>
32 #include <cpp3ds/System/Vector3.hpp>
33 #include <cpp3ds/System/Time.hpp>
34 #ifndef EMULATION
35 #include <3ds.h>
36 #endif
37 
38 namespace cpp3ds
39 {
45 {
46 public :
47 
52  enum Status
53  {
57  };
58 
65  SoundSource(const SoundSource& copy);
66 
71  virtual ~SoundSource();
72 
87  void setPitch(float pitch);
88 
100  void setVolume(float volume);
101 
116  void setPosition(float x, float y, float z);
117 
130  void setPosition(const Vector3f& position);
131 
146  void setRelativeToListener(bool relative);
147 
163  void setMinDistance(float distance);
164 
182  void setAttenuation(float attenuation);
183 
192  float getPitch() const;
193 
202  float getVolume() const;
203 
212  Vector3f getPosition() const;
213 
223  bool isRelativeToListener() const;
224 
233  float getMinDistance() const;
234 
243  float getAttenuation() const;
244 
253  SoundSource& operator =(const SoundSource& right);
254 
255 protected :
256 
263  SoundSource();
264 
271  Status getStatus() const;
272 
274  // Member data
276  unsigned int m_source;
277  int m_channel;
278  Time m_playOffset;
279  Time m_pauseOffset;
280 #ifndef EMULATION
281  ndspWaveBuf m_ndspWaveBuf;
282 #endif
283 
284 };
285 
286 } // namespace cpp3ds
287 
288 
289 #endif // CPP3DS_SOUNDSOURCE_HPP
290 
291 
float getVolume() const
Get the volume of the sound.
Base class defining a sound's properties.
Definition: SoundSource.hpp:44
bool isRelativeToListener() const
Tell whether the sound's position is relative to the listener or is absolute.
float getMinDistance() const
Get the minimum distance of the sound.
void setRelativeToListener(bool relative)
Make the sound's position relative to the listener or absolute.
SoundSource()
Default constructor.
void setVolume(float volume)
Set the volume of the sound.
unsigned int m_source
OpenAL source identifier.
Represents a time value.
Definition: Time.hpp:37
int m_channel
Current DSP channel for this sound source.
Status
Enumeration of the sound source states.
Definition: SoundSource.hpp:52
float getAttenuation() const
Get the attenuation factor of the sound.
void setMinDistance(float distance)
Set the minimum distance of the sound.
SoundSource & operator=(const SoundSource &right)
Overload of assignment operator.
virtual ~SoundSource()
Destructor.
Sound is not playing.
Definition: SoundSource.hpp:54
Vector3f getPosition() const
Get the 3D position of the sound in the audio scene.
void setPitch(float pitch)
Set the pitch of the sound.
void setAttenuation(float attenuation)
Set the attenuation factor of the sound.
Base class for classes that require an OpenAL context.
Definition: AlResource.hpp:39
float getPitch() const
Get the pitch of the sound.
Status getStatus() const
Get the current status of the sound (stopped, paused, playing)
void setPosition(float x, float y, float z)
Set the 3D position of the sound in the audio scene.