Fix issue in Rocket.lua script.
[Cafu-Engine.git] / Libs / SoundSystem / SoundSys.hpp
bloba99ff60188591c1ac5fb2d88ab57f3b6879fce45
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
7 #ifndef CAFU_SOUNDSYS_SOUNDSYS_INTERFACE_HPP_INCLUDED
8 #define CAFU_SOUNDSYS_SOUNDSYS_INTERFACE_HPP_INCLUDED
10 #include "Math3D/Vector3.hpp"
13 class SoundI;
14 class SoundShaderT;
17 /// This is an interface to the sound system.
18 /// The interface is specified as ABC in order to be able to share the sound system across exe/dll boundaries.
19 class SoundSysI
21 public:
23 /// Initializes the sound system.
24 virtual bool Initialize()=0;
26 /// Releases the sound system and removes all sound data from memory.
27 virtual void Release()=0;
29 /// Determine if the sound system is supported on this platform.
30 /// @return Whether or not the sound system is supported.
31 virtual bool IsSupported()=0;
33 /// Returns the preference number for this sound system, so calling code can decide which sound system to use.
34 /// @return Preference number.
35 virtual int GetPreferenceNr()=0;
37 /// Creates a 2 dimensional sound object using the properties of the passed sound shader.
38 /// @param SoundShader Sound shader to use with this sound object.
39 virtual SoundI* CreateSound2D(const SoundShaderT* SoundShader)=0;
41 /// Creates a 3 dimensional sound object using the properties of the passed sound shader.
42 /// @param SoundShader Sound shader to use with this sound object.
43 virtual SoundI* CreateSound3D(const SoundShaderT* SoundShader)=0;
45 /// Deletes a previously created sound object.
46 /// @param Sound The sound object to delete.
47 virtual void DeleteSound(SoundI* Sound)=0;
49 /// Plays a sound on a channel.
50 /// @param Sound The sound object that should be played.
51 /// @return true if sound is played on a channel, false if no channel was free (and playing sound have all greater priority
52 /// than this sound).
53 virtual bool PlaySound(const SoundI* Sound)=0;
55 /// Sets the master volume for this sound system.
56 /// @param Volume The new master volume. Value has to be [0, 1] (higher/lower values are clamped).
57 virtual void SetMasterVolume(float Volume)=0;
59 /// Gets the master volume currently set for this sound system.
60 /// @return The current master volume [0, 1].
61 virtual float GetMasterVolume()=0;
63 /// Updates the position, velocity and orientation of the listener.
64 /// @param Position Position of the listener in the 3D Space.
65 /// @param Velocity Velocity of the listener.
66 /// @param OrientationForward Forward orientation of the listener (unit length vector).
67 /// @param OrientationUp Upwards orientation of the listener (unit length vector).
68 virtual void UpdateListener(const Vector3dT& Position, const Vector3dT& Velocity, const Vector3fT& OrientationForward, const Vector3fT& OrientationUp)=0;
70 /// Upates all channels that are currently being played according to the properties of their sound object.
71 virtual void Update()=0;
73 /// The virtual destructor makes sure that deleting derived classes via a SoundSysI pointer works properly.
74 virtual ~SoundSysI() { }
77 /// A global pointer to the current soundsystem, for common access by all modules that use it.
78 /// Just set this after you loaded the desired sound DLL to the pointer returned by the DLLs GetSoundSys() function.
79 /// (And NULL it on unloading the DLL.)
80 extern SoundSysI* SoundSystem;
83 #endif