MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
soundproxy.h
1 // © Copyright 2010 - 2014 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  SoundProxy() { }
63  /// @brief Class destructor.
64  virtual ~SoundProxy() { }
65 
66  ///////////////////////////////////////////////////////////////////////////////
67  // Utility
68 
69  /// @brief Sets whether or not sounds generated by this sound proxy will be emitted in a specified direction.
70  /// @param Enable True to enable this sound proxy to direct it's audio, false to have it emit in all directions.
71  virtual void SetDirectSound(bool Enable) = 0;
72  /// @brief Gets whether or not this sound proxy is emitting in a specific direction.
73  /// @return Returns true if this sound proxy is emitting in a specific direction, false if it's emitting in all directions.
74  virtual bool IsDirectingSound() const = 0;
75 
76  /// @copydoc Audio::SoundProxy::AddToWorld()
77  /// @remarks Some implementations such as the OALS sound system will pause playback when a SoundProxy is removed from the
78  /// world and resume it's playback when added back in. You also cannot start playback while outside of the world. If you
79  /// want to prevent the resuming of playback when added back into the world be sure to manually call "Stop()" before adding
80  /// the proxy back into the world.
81  virtual void AddToWorld() = 0;
82  /// @copydoc Audio::SoundProxy::RemoveFromWorld()
83  /// @remarks Some implementations such as the OALS sound system will pause playback when a SoundProxy is removed from the
84  /// world and resume it's playback when added back in. You also cannot start playback while outside of the world. If you
85  /// want to prevent the resuming of playback when added back into the world be sure to manually call "Stop()" before adding
86  /// the proxy back into the world.
87  virtual void RemoveFromWorld() = 0;
88  /// @copydoc WorldProxy::IsInWorld()
89  virtual bool IsInWorld() const = 0;
90 
91  ///////////////////////////////////////////////////////////////////////////////
92  // 3 Dimensional Configuration
93 
94  /// @brief Sets the Rolloff factor used to attenuate the sound over a distance.
95  /// @details This function will set how much the sound source will attenuate over
96  /// a distance. Larger values will make the sound attenuate faster/shorter distnaces,
97  /// smaller values will make the sound carry better.
98  /// @param Rolloff The factor at which the sound will attenuate.
99  virtual void SetRolloffFactor(const Real& Rolloff) = 0;
100  /// @brief Gets the Rolloff factor of the sound source.
101  /// @details This function will get the factor used in attenuating the source over distance.
102  /// @return Returns the factor used in attenuating the source over distance.
103  virtual Real GetRolloffFactor() const = 0;
104  /// @brief Sets the distance from the sound source where attenuation will start.
105  /// @details This function will set the distance from the sound source where attenuation
106  /// effects will start being applied.
107  /// @param MinDistance The distance at which attenuation effects start being applied.
108  virtual void SetMinDistance(const Real& MinDistance) = 0;
109  /// @brief Gets the distance at which sound attenuation will start.
110  /// @return Returns the distance from the source where attenuation will start.
111  virtual Real GetMinDistance() const = 0;
112  /// @brief Sets the distance from the sound source where attenuation will stop.
113  /// @details This function will set the distance from the sound source where attenuation
114  /// effects will stop being applied.
115  /// @param MaxDistance The distance at which attenuation effects stop being applied.
116  virtual void SetMaxDistance(const Real& MaxDistance) = 0;
117  /// @brief Gets the distance at which sound attenuation will stop.
118  /// @return Returns the distance from the source where attenuation will stop.
119  virtual Real GetMaxDistance() const = 0;
120  /// @brief Sets the inner cone angle of the sound source if you want the sound to be projected as a cone.
121  /// @details This function will set the angle for the inner cone which the sound will be projected. The
122  /// cone will open up in the direction set by SetDirection(). Sounds are at their loudest only if the
123  /// listener is within the inner cone.
124  /// @param InnerAngle The angle of the inner cone. Range is: 0.0 to 360.0. Default: 360.0 (broadcast)
125  virtual void SetInnerConeAngle(const Real& InnerAngle) = 0;
126  /// @brief Gets the inner cone angle of the sound source.
127  /// @return Returns the angle of the inner sound cone of the source.
128  virtual Real GetInnerConeAngle() const = 0;
129  /// @brief Sets the outer cone angle of the sound source if you want the sound to be projected as a cone.
130  /// @details This function will set the angle for the outer cone which the sound will be projected. The
131  /// cone will open up in the direction set by SetDirection(). Sounds connot be heard if the listener is
132  /// outside the outer cone.
133  /// @param OuterAngle The angle of the outer cone. Range is: 0.0 to 360.0. Default: 360.0 (broadcast)
134  virtual void SetOuterConeAngle(const Real& OuterAngle) = 0;
135  /// @brief Gets the outer cone angle of the sound source.
136  /// @return Returns the angle of the outer sound cone of the source.
137  virtual Real GetOuterConeAngle() const = 0;
138  /// @brief Sets how much the volume is scaled in the outer cone.
139  /// @details This function will set how much the volume is scaled by for sounds in the outer
140  /// cone of the sound source.
141  /// @param OuterVolume The scale for volume for sounds in the outer cone.
142  virtual void SetOuterConeVolume(const Real& OuterVolume) = 0;
143  /// @brief Gets the outer cone volume of the sound source.
144  /// @return Returns how much the volume of the source is scaled in the outer cone.
145  virtual Real GetOuterConeVolume() const = 0;
146  /// @brief Sets the doppler strength, which impacts the doppler effect.
147  /// @details This function will set the doppler strength of the sound source, which can
148  /// enhance or diminish the doppler effect given off by this sound source. Default: 1.0
149  /// @param DopStr The doppler strength to be applied to this sound source.
150  virtual void SetDopplerStrength(const Real& DopStr) = 0;
151  /// @brief Gets the Doppler Strength of the sound.
152  /// @return Returns the doppler strength.
153  virtual Real GetDopplerStrength() const = 0;
154  /// @brief Sets the doppler velocity vector.
155  /// @details In most cases you shouldn't need to call this as this is handled by the engine.
156  /// Is called every time position, velocity, or direction is altered.
157  /// @param DopVel A vector3 representing the doppler velocity to be applied.
158  virtual void SetDopplerVelocity(const Vector3& DopVel) = 0;
159  /// @brief Gets the doppler velocity vector.
160  /// @return Returns the override for the doppler velocity vector.
161  virtual Vector3 GetDopplerVelocity() const = 0;
162  /// @brief Sets the velocity of this sound proxy.
163  /// @param Vel The velocity to be given to this sound proxy.
164  virtual void SetVelocity(const Vector3& Vel) = 0;
165  /// @brief Gets the current velocity of this sound proxy.
166  /// @return Returns a Vector3 representing this proxy's current velocity.
167  virtual Vector3 GetVelocity() const = 0;
168 
169  ///////////////////////////////////////////////////////////////////////////////
170  // Serialization
171 
172  /// @brief Get the name of the the XML tag the Renderable class will leave behind as its instances are serialized.
173  /// @return A string containing the name of this class.
174  static String SerializableName() { return "SoundProxy"; }
175  };//SoundProxy
176  }//Audio
177 }//Mezzanine
178 
179 #endif