Spinning Topp Logo BlackTopp Studios
inc
soundproxy.h
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
41 // This file is part of the "cAudio Engine"
42 // For conditions of distribution and use, see copyright notice in cAudio-ZLIBLicense.txt
43 #ifndef _audiosoundproxy_h
44 #define _audiosoundproxy_h
45 
46 #include "worldproxy.h"
47 #include "Audio/sound.h"
48 
49 namespace Mezzanine
50 {
51  namespace Audio
52  {
53  ///////////////////////////////////////////////////////////////////////////////
54  /// @brief This is a proxy class for representing a sound being played in 3D space.
55  /// @details
56  ///////////////////////////////////////
57  class MEZZ_LIB SoundProxy : public WorldProxy, public iSound
58  {
59  protected:
60  public:
61  /// @brief Class constructor.
62  /// @param ID The unique ID of this SoundProxy.
63  SoundProxy(const UInt32 ID) :
64  WorldProxy(ID)
65  { }
66  /// @brief Class destructor.
67  virtual ~SoundProxy()
68  { }
69 
70  ///////////////////////////////////////////////////////////////////////////////
71  // Utility
72 
73  /// @brief Sets whether or not sounds generated by this sound proxy will be emitted in a specified direction.
74  /// @param Enable True to enable this sound proxy to direct it's audio, false to have it emit in all directions.
75  virtual void SetDirectSound(Boole Enable) = 0;
76  /// @brief Gets whether or not this sound proxy is emitting in a specific direction.
77  /// @return Returns true if this sound proxy is emitting in a specific direction, false if it's emitting in all directions.
78  virtual Boole IsDirectingSound() const = 0;
79 
80  /// @copydoc Mezzanine::WorldProxy::AddToWorld()
81  /// @remarks Some implementations such as the OALS sound system will pause playback when a SoundProxy is removed from the
82  /// world and resume it's playback when added back in. You also cannot start playback while outside of the world. If you
83  /// want to prevent the resuming of playback when added back into the world be sure to manually call "Stop()" before adding
84  /// the proxy back into the world.
85  virtual void AddToWorld() = 0;
86  /// @copydoc Mezzanine::WorldProxy::RemoveFromWorld()
87  /// @remarks Some implementations such as the OALS sound system will pause playback when a SoundProxy is removed from the
88  /// world and resume it's playback when added back in. You also cannot start playback while outside of the world. If you
89  /// want to prevent the resuming of playback when added back into the world be sure to manually call "Stop()" before adding
90  /// the proxy back into the world.
91  virtual void RemoveFromWorld() = 0;
92  /// @copydoc Mezzanine::WorldProxy::IsInWorld()
93  virtual Boole IsInWorld() const = 0;
94 
95  ///////////////////////////////////////////////////////////////////////////////
96  // 3 Dimensional Configuration
97 
98  /// @brief Sets the Rolloff factor used to attenuate the sound over a distance.
99  /// @details This function will set how much the sound source will attenuate over
100  /// a distance. Larger values will make the sound attenuate faster/shorter distnaces,
101  /// smaller values will make the sound carry better.
102  /// @param Rolloff The factor at which the sound will attenuate.
103  virtual void SetRolloffFactor(const Real& Rolloff) = 0;
104  /// @brief Gets the Rolloff factor of the sound source.
105  /// @details This function will get the factor used in attenuating the source over distance.
106  /// @return Returns the factor used in attenuating the source over distance.
107  virtual Real GetRolloffFactor() const = 0;
108  /// @brief Sets the distance from the sound source where attenuation will start.
109  /// @details This function will set the distance from the sound source where attenuation
110  /// effects will start being applied.
111  /// @param MinDistance The distance at which attenuation effects start being applied.
112  virtual void SetMinDistance(const Real& MinDistance) = 0;
113  /// @brief Gets the distance at which sound attenuation will start.
114  /// @return Returns the distance from the source where attenuation will start.
115  virtual Real GetMinDistance() const = 0;
116  /// @brief Sets the distance from the sound source where attenuation will stop.
117  /// @details This function will set the distance from the sound source where attenuation
118  /// effects will stop being applied.
119  /// @param MaxDistance The distance at which attenuation effects stop being applied.
120  virtual void SetMaxDistance(const Real& MaxDistance) = 0;
121  /// @brief Gets the distance at which sound attenuation will stop.
122  /// @return Returns the distance from the source where attenuation will stop.
123  virtual Real GetMaxDistance() const = 0;
124  /// @brief Sets the inner cone angle of the sound source if you want the sound to be projected as a cone.
125  /// @details This function will set the angle for the inner cone which the sound will be projected. The
126  /// cone will open up in the direction set by SetDirection(). Sounds are at their loudest only if the
127  /// listener is within the inner cone.
128  /// @param InnerAngle The angle of the inner cone. Range is: 0.0 to 360.0. Default: 360.0 (broadcast)
129  virtual void SetInnerConeAngle(const Real& InnerAngle) = 0;
130  /// @brief Gets the inner cone angle of the sound source.
131  /// @return Returns the angle of the inner sound cone of the source.
132  virtual Real GetInnerConeAngle() const = 0;
133  /// @brief Sets the outer cone angle of the sound source if you want the sound to be projected as a cone.
134  /// @details This function will set the angle for the outer cone which the sound will be projected. The
135  /// cone will open up in the direction set by SetDirection(). Sounds connot be heard if the listener is
136  /// outside the outer cone.
137  /// @param OuterAngle The angle of the outer cone. Range is: 0.0 to 360.0. Default: 360.0 (broadcast)
138  virtual void SetOuterConeAngle(const Real& OuterAngle) = 0;
139  /// @brief Gets the outer cone angle of the sound source.
140  /// @return Returns the angle of the outer sound cone of the source.
141  virtual Real GetOuterConeAngle() const = 0;
142  /// @brief Sets how much the volume is scaled in the outer cone.
143  /// @details This function will set how much the volume is scaled by for sounds in the outer
144  /// cone of the sound source.
145  /// @param OuterVolume The scale for volume for sounds in the outer cone.
146  virtual void SetOuterConeVolume(const Real& OuterVolume) = 0;
147  /// @brief Gets the outer cone volume of the sound source.
148  /// @return Returns how much the volume of the source is scaled in the outer cone.
149  virtual Real GetOuterConeVolume() const = 0;
150  /// @brief Sets the doppler strength, which impacts the doppler effect.
151  /// @details This function will set the doppler strength of the sound source, which can
152  /// enhance or diminish the doppler effect given off by this sound source. Default: 1.0
153  /// @param DopStr The doppler strength to be applied to this sound source.
154  virtual void SetDopplerStrength(const Real& DopStr) = 0;
155  /// @brief Gets the Doppler Strength of the sound.
156  /// @return Returns the doppler strength.
157  virtual Real GetDopplerStrength() const = 0;
158  /// @brief Sets the doppler velocity vector.
159  /// @details In most cases you shouldn't need to call this as this is handled by the engine.
160  /// Is called every time position, velocity, or direction is altered.
161  /// @param DopVel A vector3 representing the doppler velocity to be applied.
162  virtual void SetDopplerVelocity(const Vector3& DopVel) = 0;
163  /// @brief Gets the doppler velocity vector.
164  /// @return Returns the override for the doppler velocity vector.
165  virtual Vector3 GetDopplerVelocity() const = 0;
166  /// @brief Sets the velocity of this sound proxy.
167  /// @param Vel The velocity to be given to this sound proxy.
168  virtual void SetVelocity(const Vector3& Vel) = 0;
169  /// @brief Gets the current velocity of this sound proxy.
170  /// @return Returns a Vector3 representing this proxy's current velocity.
171  virtual Vector3 GetVelocity() const = 0;
172 
173  ///////////////////////////////////////////////////////////////////////////////
174  // Serialization
175 
176  /// @brief Get the name of the the XML tag the Renderable class will leave behind as its instances are serialized.
177  /// @return A string containing the name of this class.
178  static String GetSerializableName() { return "SoundProxy"; }
179  };//SoundProxy
180  }//Audio
181 }//Mezzanine
182 
183 #endif
This is a proxy class for representing a sound being played in 3D space.
Definition: soundproxy.h:57
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
SoundProxy(const UInt32 ID)
Class constructor.
Definition: soundproxy.h:63
This is an interface class for a non-spacialized sound.
Definition: sound.h:60
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
This is the base class for proxy objects belonging to the various 3D subsystems.
Definition: worldproxy.h:53
uint32_t UInt32
An 32-bit unsigned integer.
Definition: datatypes.h:126
virtual ~SoundProxy()
Class destructor.
Definition: soundproxy.h:67
This is used to represent a point in space, or a vector through space.
Definition: vector3.h:77
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
static String GetSerializableName()
Get the name of the the XML tag the Renderable class will leave behind as its instances are serialize...
Definition: soundproxy.h:178
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159