diff --git a/CSFML/VC2005/csfml-audio-d.def b/CSFML/VC2005/csfml-audio-d.def index 5e2d700e8..ebfb7f04e 100644 --- a/CSFML/VC2005/csfml-audio-d.def +++ b/CSFML/VC2005/csfml-audio-d.def @@ -21,11 +21,13 @@ EXPORTS sfMusic_SetPitch sfMusic_SetVolume sfMusic_SetPosition + sfMusic_SetRelativeToListener sfMusic_SetMinDistance sfMusic_SetAttenuation sfMusic_GetPitch sfMusic_GetVolume sfMusic_GetPosition + sfMusic_IsRelativeToListener sfMusic_GetMinDistance sfMusic_GetAttenuation sfMusic_GetPlayingOffset @@ -42,12 +44,14 @@ EXPORTS sfSound_SetPitch sfSound_SetVolume sfSound_SetPosition + sfSound_SetRelativeToListener sfSound_SetMinDistance sfSound_SetAttenuation sfSound_SetPlayingOffset sfSound_GetPitch sfSound_GetVolume sfSound_GetPosition + sfSound_IsRelativeToListener sfSound_GetPlayingOffset sfSound_GetMinDistance sfSound_GetAttenuation @@ -84,12 +88,14 @@ EXPORTS sfSoundStream_SetPitch sfSoundStream_SetVolume sfSoundStream_SetPosition + sfSoundStream_SetRelativeToListener sfSoundStream_SetMinDistance sfSoundStream_SetAttenuation sfSoundStream_SetLoop sfSoundStream_GetPitch sfSoundStream_GetVolume sfSoundStream_GetPosition + sfSoundStream_IsRelativeToListener sfSoundStream_GetMinDistance sfSoundStream_GetAttenuation sfSoundStream_GetLoop diff --git a/CSFML/VC2005/csfml-audio.def b/CSFML/VC2005/csfml-audio.def index fb211e825..3bf96b32d 100644 --- a/CSFML/VC2005/csfml-audio.def +++ b/CSFML/VC2005/csfml-audio.def @@ -21,11 +21,13 @@ EXPORTS sfMusic_SetPitch sfMusic_SetVolume sfMusic_SetPosition + sfMusic_SetRelativeToListener sfMusic_SetMinDistance sfMusic_SetAttenuation sfMusic_GetPitch sfMusic_GetVolume sfMusic_GetPosition + sfMusic_IsRelativeToListener sfMusic_GetMinDistance sfMusic_GetAttenuation sfMusic_GetPlayingOffset @@ -42,12 +44,14 @@ EXPORTS sfSound_SetPitch sfSound_SetVolume sfSound_SetPosition + sfSound_SetRelativeToListener sfSound_SetMinDistance sfSound_SetAttenuation sfSound_SetPlayingOffset sfSound_GetPitch sfSound_GetVolume sfSound_GetPosition + sfSound_IsRelativeToListener sfSound_GetPlayingOffset sfSound_GetMinDistance sfSound_GetAttenuation @@ -84,12 +88,14 @@ EXPORTS sfSoundStream_SetPitch sfSoundStream_SetVolume sfSoundStream_SetPosition + sfSoundStream_SetRelativeToListener sfSoundStream_SetMinDistance sfSoundStream_SetAttenuation sfSoundStream_SetLoop sfSoundStream_GetPitch sfSoundStream_GetVolume sfSoundStream_GetPosition + sfSoundStream_IsRelativeToListener sfSoundStream_GetMinDistance sfSoundStream_GetAttenuation sfSoundStream_GetLoop diff --git a/CSFML/include/SFML/Audio/Music.h b/CSFML/include/SFML/Audio/Music.h index cc87f42a1..bdad5b4be 100644 --- a/CSFML/include/SFML/Audio/Music.h +++ b/CSFML/include/SFML/Audio/Music.h @@ -184,6 +184,17 @@ CSFML_API void sfMusic_SetVolume(sfMusic* Music, float Volume); //////////////////////////////////////////////////////////// CSFML_API void sfMusic_SetPosition(sfMusic* Music, float X, float Y, float Z); +//////////////////////////////////////////////////////////// +/// Make the music's position relative to the listener's +/// position, or absolute. +/// The default value is false (absolute) +/// +/// \param Music : Music to modify +/// \param Relative : True to set the position relative, false to set it absolute +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfMusic_SetRelativeToListener(sfMusic* Music, sfBool Relative); + //////////////////////////////////////////////////////////// /// Set the minimum distance - closer than this distance, /// the listener will hear the music at its maximum volume. @@ -237,6 +248,17 @@ CSFML_API float sfMusic_GetVolume(sfMusic* Music); //////////////////////////////////////////////////////////// CSFML_API void sfMusic_GetPosition(sfMusic* Music, float* X, float* Y, float* Z); +//////////////////////////////////////////////////////////// +/// Tell if the music's position is relative to the listener's +/// position, or if it's absolute +/// +/// \param Music : Music to check +/// +/// \return sfTrue if the position is relative, sfFalse if it's absolute +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfMusic_IsRelativeToListener(sfMusic* Music); + //////////////////////////////////////////////////////////// /// Get the minimum distance of a music /// diff --git a/CSFML/include/SFML/Audio/Sound.h b/CSFML/include/SFML/Audio/Sound.h index eb7b2d443..d694f8986 100644 --- a/CSFML/include/SFML/Audio/Sound.h +++ b/CSFML/include/SFML/Audio/Sound.h @@ -150,6 +150,17 @@ CSFML_API void sfSound_SetVolume(sfSound* Sound, float Volume); //////////////////////////////////////////////////////////// CSFML_API void sfSound_SetPosition(sfSound* Sound, float X, float Y, float Z); +//////////////////////////////////////////////////////////// +/// Make the sound's position relative to the listener's +/// position, or absolute. +/// The default value is false (absolute) +/// +/// \param Sound : Sound to modify +/// \param Relative : True to set the position relative, false to set it absolute +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSound_SetRelativeToListener(sfSound* Sound, sfBool Relative); + //////////////////////////////////////////////////////////// /// Set the minimum distance - closer than this distance, /// the listener will hear the sound at its maximum volume. @@ -212,6 +223,17 @@ CSFML_API float sfSound_GetVolume(sfSound* Sound); //////////////////////////////////////////////////////////// CSFML_API void sfSound_GetPosition(sfSound* Sound, float* X, float* Y, float* Z); +//////////////////////////////////////////////////////////// +/// Tell if the sound's position is relative to the listener's +/// position, or if it's absolute +/// +/// \param Sound : Sound to check +/// +/// \return sfTrue if the position is relative, sfFalse if it's absolute +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfSound_IsRelativeToListener(sfSound* Sound); + //////////////////////////////////////////////////////////// /// Get the minimum distance of a sound /// diff --git a/CSFML/include/SFML/Audio/SoundStream.h b/CSFML/include/SFML/Audio/SoundStream.h index 9b3f0f960..5fe452266 100644 --- a/CSFML/include/SFML/Audio/SoundStream.h +++ b/CSFML/include/SFML/Audio/SoundStream.h @@ -157,6 +157,17 @@ CSFML_API void sfSoundStream_SetVolume(sfSoundStream* SoundStream, float Volume) //////////////////////////////////////////////////////////// CSFML_API void sfSoundStream_SetPosition(sfSoundStream* SoundStream, float X, float Y, float Z); +//////////////////////////////////////////////////////////// +/// Make the sound stream's position relative to the listener's +/// position, or absolute. +/// The default value is false (absolute) +/// +/// \param SoundStream : Sound stream to modify +/// \param Relative : True to set the position relative, false to set it absolute +/// +//////////////////////////////////////////////////////////// +CSFML_API void sfSoundStream_SetRelativeToListener(sfSoundStream* SoundStream, sfBool Relative); + //////////////////////////////////////////////////////////// /// Set the minimum distance - closer than this distance, /// the listener will hear the sound stream at its maximum volume. @@ -219,6 +230,17 @@ CSFML_API float sfSoundStream_GetVolume(sfSoundStream* SoundStream); //////////////////////////////////////////////////////////// CSFML_API void sfSoundStream_GetPosition(sfSoundStream* SoundStream, float* X, float* Y, float* Z); +//////////////////////////////////////////////////////////// +/// Tell if the sound stream's position is relative to the listener's +/// position, or if it's absolute +/// +/// \param SoundStream : Sound stream to check +/// +/// \return sfTrue if the position is relative, sfFalse if it's absolute +/// +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfSoundStream_IsRelativeToListener(sfSoundStream* SoundStream); + //////////////////////////////////////////////////////////// /// Get the minimum distance of a sound stream /// diff --git a/CSFML/src/SFML/Audio/Music.cpp b/CSFML/src/SFML/Audio/Music.cpp index 647e82ff0..b946a2e92 100644 --- a/CSFML/src/SFML/Audio/Music.cpp +++ b/CSFML/src/SFML/Audio/Music.cpp @@ -198,6 +198,17 @@ void sfMusic_SetPosition(sfMusic* Music, float X, float Y, float Z) } +//////////////////////////////////////////////////////////// +/// Make the music's position relative to the listener's +/// position, or absolute. +/// The default value is false (absolute) +//////////////////////////////////////////////////////////// +void sfMusic_SetRelativeToListener(sfMusic* music, sfBool Relative) +{ + CSFML_CALL(music, SetRelativeToListener(Relative == sfTrue)); +} + + //////////////////////////////////////////////////////////// /// Set the minimum distance - closer than this distance, /// the listener will hear the music at its maximum volume. @@ -255,6 +266,16 @@ void sfMusic_GetPosition(sfMusic* Music, float* X, float* Y, float* Z) } +//////////////////////////////////////////////////////////// +/// Tell if the music's position is relative to the listener's +/// position, or if it's absolute +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfMusic_IsRelativeToListener(sfMusic* Music) +{ + CSFML_CALL_RETURN(Music, IsRelativeToListener(), sfFalse); +} + + //////////////////////////////////////////////////////////// /// Get the minimum distance of a music //////////////////////////////////////////////////////////// diff --git a/CSFML/src/SFML/Audio/Sound.cpp b/CSFML/src/SFML/Audio/Sound.cpp index 2b6f22b6a..dd2a64a71 100644 --- a/CSFML/src/SFML/Audio/Sound.cpp +++ b/CSFML/src/SFML/Audio/Sound.cpp @@ -168,6 +168,17 @@ void sfSound_SetPosition(sfSound* Sound, float X, float Y, float Z) } +//////////////////////////////////////////////////////////// +/// Make the sound's position relative to the listener's +/// position, or absolute. +/// The default value is false (absolute) +//////////////////////////////////////////////////////////// +void sfSound_SetRelativeToListener(sfSound* Sound, sfBool Relative) +{ + CSFML_CALL(Sound, SetRelativeToListener(Relative == sfTrue)); +} + + //////////////////////////////////////////////////////////// /// Set the minimum distance - closer than this distance, /// the listener will hear the sound at its maximum volume. @@ -231,6 +242,16 @@ void sfSound_GetPosition(sfSound* Sound, float* X, float* Y, float* Z) } +//////////////////////////////////////////////////////////// +/// Tell if the sound's position is relative to the listener's +/// position, or if it's absolute +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfSound_IsRelativeToListener(sfSound* Sound) +{ + CSFML_CALL_RETURN(Sound, IsRelativeToListener(), sfFalse); +} + + //////////////////////////////////////////////////////////// /// Get the minimum distance of a sound //////////////////////////////////////////////////////////// diff --git a/CSFML/src/SFML/Audio/SoundStream.cpp b/CSFML/src/SFML/Audio/SoundStream.cpp index d89196294..3208c0373 100644 --- a/CSFML/src/SFML/Audio/SoundStream.cpp +++ b/CSFML/src/SFML/Audio/SoundStream.cpp @@ -195,6 +195,17 @@ void sfSoundStream_SetPosition(sfSoundStream* SoundStream, float X, float Y, flo } +//////////////////////////////////////////////////////////// +/// Make the sound stream's position relative to the listener's +/// position, or absolute. +/// The default value is false (absolute) +//////////////////////////////////////////////////////////// +void sfSoundStream_SetRelativeToListener(sfSoundStream* SoundStream, sfBool Relative) +{ + CSFML_CALL(SoundStream, SetRelativeToListener(Relative == sfTrue)); +} + + //////////////////////////////////////////////////////////// /// Set the minimum distance - closer than this distance, /// the listener will hear the sound stream at its maximum volume. @@ -258,6 +269,16 @@ void sfSoundStream_GetPosition(sfSoundStream* SoundStream, float* X, float* Y, f } +//////////////////////////////////////////////////////////// +/// Tell if the sound stream's position is relative to the listener's +/// position, or if it's absolute +//////////////////////////////////////////////////////////// +CSFML_API sfBool sfSoundStream_IsRelativeToListener(sfSoundStream* SoundStream) +{ + CSFML_CALL_RETURN(SoundStream, IsRelativeToListener(), sfFalse); +} + + //////////////////////////////////////////////////////////// /// Get the minimum distance of a sound stream //////////////////////////////////////////////////////////// diff --git a/dotnet/extlibs/csfml-audio.dll b/dotnet/extlibs/csfml-audio.dll index a15fb3d65..cc3a3ca69 100644 Binary files a/dotnet/extlibs/csfml-audio.dll and b/dotnet/extlibs/csfml-audio.dll differ diff --git a/dotnet/extlibs/csfml-graphics.dll b/dotnet/extlibs/csfml-graphics.dll index 8ab5f215e..f46bee592 100644 Binary files a/dotnet/extlibs/csfml-graphics.dll and b/dotnet/extlibs/csfml-graphics.dll differ diff --git a/dotnet/extlibs/csfml-window.dll b/dotnet/extlibs/csfml-window.dll index f3529bb3c..4e162f7b5 100644 Binary files a/dotnet/extlibs/csfml-window.dll and b/dotnet/extlibs/csfml-window.dll differ diff --git a/dotnet/src/Audio/Listener.cs b/dotnet/src/Audio/Listener.cs index da0c2237f..03f97daa4 100644 --- a/dotnet/src/Audio/Listener.cs +++ b/dotnet/src/Audio/Listener.cs @@ -20,7 +20,7 @@ namespace SFML /// Global volume of all sounds, in range [0 .. 100] (default is 100) /// //////////////////////////////////////////////////////////// - static float GlobalVolume + public static float GlobalVolume { get {return sfListener_GetGlobalVolume();} set {sfListener_SetGlobalVolume(value);} @@ -31,7 +31,7 @@ namespace SFML /// 3D position of the listener (default is (0, 0, 0)) /// //////////////////////////////////////////////////////////// - static Vector3 Position + public static Vector3 Position { get {Vector3 v; sfListener_GetPosition(out v.X, out v.Y, out v.Z); return v;} set {sfListener_SetPosition(value.X, value.Y, value.Z);} @@ -43,7 +43,7 @@ namespace SFML /// (default is (0, 0, -1)) /// //////////////////////////////////////////////////////////// - static Vector3 Target + public static Vector3 Target { get {Vector3 v; sfListener_GetTarget(out v.X, out v.Y, out v.Z); return v;} set {sfListener_SetTarget(value.X, value.Y, value.Z);} diff --git a/dotnet/src/Audio/Music.cs b/dotnet/src/Audio/Music.cs index 988761ea7..41be7c6e1 100644 --- a/dotnet/src/Audio/Music.cs +++ b/dotnet/src/Audio/Music.cs @@ -165,6 +165,19 @@ namespace SFML set {sfMusic_SetPosition(This, value.X, value.Y, value.Z);} } + //////////////////////////////////////////////////////////// + /// + /// Is the music's position relative to the listener's position, + /// or is it absolute? + /// Default value is false (absolute) + /// + //////////////////////////////////////////////////////////// + public bool RelativeToListener + { + get {return sfMusic_IsRelativeToListener(This);} + set {sfMusic_SetRelativeToListener(This, value);} + } + //////////////////////////////////////////////////////////// /// /// Minimum distance of the music. Closer than this distance, @@ -213,70 +226,76 @@ namespace SFML } #region Imports - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern IntPtr sfMusic_CreateFromFile(string Filename); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] unsafe static extern IntPtr sfMusic_CreateFromMemory(char* Data, uint SizeInBytes); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfMusic_Destroy(IntPtr MusicStream); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfMusic_Play(IntPtr Music); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfMusic_Pause(IntPtr Music); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfMusic_Stop(IntPtr Music); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern SoundStatus sfMusic_GetStatus(IntPtr Music); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern float sfMusic_GetDuration(IntPtr Music); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern uint sfMusic_GetChannelsCount(IntPtr Music); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern uint sfMusic_GetSampleRate(IntPtr Music); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfMusic_SetPitch(IntPtr Music, float Pitch); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfMusic_SetLoop(IntPtr Music, bool Loop); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfMusic_SetVolume(IntPtr Music, float Volume); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfMusic_SetPosition(IntPtr Music, float X, float Y, float Z); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] + static extern void sfMusic_SetRelativeToListener(IntPtr Music, bool Relative); + + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfMusic_SetMinDistance(IntPtr Music, float MinDistance); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfMusic_SetAttenuation(IntPtr Music, float Attenuation); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern bool sfMusic_GetLoop(IntPtr Music); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern float sfMusic_GetPitch(IntPtr Music); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern float sfMusic_GetVolume(IntPtr Music); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfMusic_GetPosition(IntPtr Music, out float X, out float Y, out float Z); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] + static extern bool sfMusic_IsRelativeToListener(IntPtr Music); + + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern float sfMusic_GetMinDistance(IntPtr Music); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern float sfMusic_GetAttenuation(IntPtr Music); [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] diff --git a/dotnet/src/Audio/Sound.cs b/dotnet/src/Audio/Sound.cs index d6d499ede..93eb34481 100644 --- a/dotnet/src/Audio/Sound.cs +++ b/dotnet/src/Audio/Sound.cs @@ -159,6 +159,19 @@ namespace SFML set {sfSound_SetPosition(This, value.X, value.Y, value.Z);} } + //////////////////////////////////////////////////////////// + /// + /// Is the sound's position relative to the listener's position, + /// or is it absolute? + /// Default value is false (absolute) + /// + //////////////////////////////////////////////////////////// + public bool RelativeToListener + { + get {return sfSound_IsRelativeToListener(This);} + set {sfSound_SetRelativeToListener(This, value);} + } + //////////////////////////////////////////////////////////// /// /// Minimum distance of the sound. Closer than this distance, @@ -238,6 +251,9 @@ namespace SFML [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfSound_SetPosition(IntPtr Sound, float X, float Y, float Z); + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] + static extern void sfSound_SetRelativeToListener(IntPtr Sound, bool Relative); + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfSound_SetMinDistance(IntPtr Sound, float MinDistance); @@ -256,6 +272,9 @@ namespace SFML [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfSound_GetPosition(IntPtr Sound, out float X, out float Y, out float Z); + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] + static extern bool sfSound_IsRelativeToListener(IntPtr Sound); + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern float sfSound_GetMinDistance(IntPtr Sound); diff --git a/dotnet/src/Audio/SoundRecorder.cs b/dotnet/src/Audio/SoundRecorder.cs index 3f39c5a54..1c8e79d04 100644 --- a/dotnet/src/Audio/SoundRecorder.cs +++ b/dotnet/src/Audio/SoundRecorder.cs @@ -157,22 +157,22 @@ namespace SFML private StopCallback myStopCallback; #region Imports - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern IntPtr sfSoundRecorder_Create(StartCallback OnStart, ProcessCallback OnProcess, StopCallback OnStop, IntPtr UserData); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfSoundRecorder_Destroy(IntPtr SoundRecorder); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfSoundRecorder_Start(IntPtr SoundRecorder, uint SampleRate); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfSoundRecorder_Stop(IntPtr SoundRecorder); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern uint sfSoundRecorder_GetSampleRate(IntPtr SoundRecorder); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern bool sfSoundRecorder_CanCapture(); #endregion } diff --git a/dotnet/src/Audio/SoundStream.cs b/dotnet/src/Audio/SoundStream.cs index c8d019c32..b0c4a8063 100644 --- a/dotnet/src/Audio/SoundStream.cs +++ b/dotnet/src/Audio/SoundStream.cs @@ -130,6 +130,19 @@ namespace SFML set {sfSoundStream_SetPosition(This, value.X, value.Y, value.Z);} } + //////////////////////////////////////////////////////////// + /// + /// Is the sound stream's position relative to the listener's position, + /// or is it absolute? + /// Default value is false (absolute) + /// + //////////////////////////////////////////////////////////// + public bool RelativeToListener + { + get {return sfSoundStream_IsRelativeToListener(This);} + set {sfSoundStream_SetRelativeToListener(This, value);} + } + //////////////////////////////////////////////////////////// /// /// Minimum distance of the sound stream. Closer than this distance, @@ -275,64 +288,70 @@ namespace SFML private short[] myTempBuffer; #region Imports - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern IntPtr sfSoundStream_Create(StartCallbackType OnStart, GetDataCallbackType OnGetData, uint ChannelsCount, uint SampleRate, IntPtr UserData); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfSoundStream_Destroy(IntPtr SoundStreamStream); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfSoundStream_Play(IntPtr SoundStream); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfSoundStream_Pause(IntPtr SoundStream); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfSoundStream_Stop(IntPtr SoundStream); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern SoundStatus sfSoundStream_GetStatus(IntPtr SoundStream); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern uint sfSoundStream_GetChannelsCount(IntPtr SoundStream); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern uint sfSoundStream_GetSampleRate(IntPtr SoundStream); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfSoundStream_SetLoop(IntPtr SoundStream, bool Loop); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfSoundStream_SetPitch(IntPtr SoundStream, float Pitch); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfSoundStream_SetVolume(IntPtr SoundStream, float Volume); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfSoundStream_SetPosition(IntPtr SoundStream, float X, float Y, float Z); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] + static extern void sfSoundStream_SetRelativeToListener(IntPtr SoundStream, bool Relative); + + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfSoundStream_SetMinDistance(IntPtr SoundStream, float MinDistance); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfSoundStream_SetAttenuation(IntPtr SoundStream, float Attenuation); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern bool sfSoundStream_GetLoop(IntPtr SoundStream); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern float sfSoundStream_GetPitch(IntPtr SoundStream); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern float sfSoundStream_GetVolume(IntPtr SoundStream); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern void sfSoundStream_GetPosition(IntPtr SoundStream, out float X, out float Y, out float Z); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] + static extern bool sfSoundStream_IsRelativeToListener(IntPtr SoundStream); + + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern float sfSoundStream_GetMinDistance(IntPtr SoundStream); - [DllImport("csfml-audio")] + [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] static extern float sfSoundStream_GetAttenuation(IntPtr SoundStream); [DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity] diff --git a/dotnet/src/Graphics/RenderWindow.cs b/dotnet/src/Graphics/RenderWindow.cs index 3b23ee2ce..9553c9e77 100644 --- a/dotnet/src/Graphics/RenderWindow.cs +++ b/dotnet/src/Graphics/RenderWindow.cs @@ -519,7 +519,7 @@ namespace SFML [DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity] static extern void sfRenderWindow_EnableKeyRepeat(IntPtr This, bool Enable); - [DllImport("csfml-graphics")] + [DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity] unsafe static extern void sfRenderWindow_SetIcon(IntPtr This, uint Width, uint Height, byte* Pixels); [DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity] diff --git a/include/SFML/Audio/Sound.hpp b/include/SFML/Audio/Sound.hpp index cced19e1c..a7369fc38 100644 --- a/include/SFML/Audio/Sound.hpp +++ b/include/SFML/Audio/Sound.hpp @@ -159,6 +159,16 @@ public : //////////////////////////////////////////////////////////// void SetPosition(const Vector3f& Position); + //////////////////////////////////////////////////////////// + /// Make the sound's position relative to the listener's + /// position, or absolute. + /// The default value is false (absolute) + /// + /// \param Relative : True to set the position relative, false to set it absolute + /// + //////////////////////////////////////////////////////////// + void SetRelativeToListener(bool Relative); + //////////////////////////////////////////////////////////// /// Set the minimum distance - closer than this distance, /// the listener will hear the sound at its maximum volume. @@ -227,6 +237,15 @@ public : //////////////////////////////////////////////////////////// Vector3f GetPosition() const; + //////////////////////////////////////////////////////////// + /// Tell if the sound's position is relative to the listener's + /// position, or if it's absolute + /// + /// \return True if the position is relative, false if it's absolute + /// + //////////////////////////////////////////////////////////// + bool IsRelativeToListener() const; + //////////////////////////////////////////////////////////// /// Get the minimum distance /// diff --git a/include/SFML/Audio/SoundStream.hpp b/include/SFML/Audio/SoundStream.hpp index 8cc2024b8..db0b19e93 100644 --- a/include/SFML/Audio/SoundStream.hpp +++ b/include/SFML/Audio/SoundStream.hpp @@ -53,11 +53,13 @@ public : using Sound::SetPitch; using Sound::SetVolume; using Sound::SetPosition; + using Sound::SetRelativeToListener; using Sound::SetMinDistance; using Sound::SetAttenuation; using Sound::GetPitch; using Sound::GetVolume; using Sound::GetPosition; + using Sound::IsRelativeToListener; using Sound::GetMinDistance; using Sound::GetAttenuation; diff --git a/src/SFML/Audio/Sound.cpp b/src/SFML/Audio/Sound.cpp index 01d792b83..17f8fab2b 100644 --- a/src/SFML/Audio/Sound.cpp +++ b/src/SFML/Audio/Sound.cpp @@ -175,6 +175,17 @@ void Sound::SetPosition(const Vector3f& Position) } +//////////////////////////////////////////////////////////// +/// Make the sound's position relative to the listener's +/// position, or absolute. +/// The default value is false (absolute) +//////////////////////////////////////////////////////////// +void Sound::SetRelativeToListener(bool Relative) +{ + ALCheck(alSourcei(mySource, AL_SOURCE_RELATIVE, Relative)); +} + + //////////////////////////////////////////////////////////// /// Set the minimum distance - closer than this distance, /// the listener will hear the sound at its maximum volume. @@ -263,6 +274,19 @@ Vector3f Sound::GetPosition() const } +//////////////////////////////////////////////////////////// +/// Tell if the sound's position is relative to the listener's +/// position, or if it's absolute +//////////////////////////////////////////////////////////// +bool Sound::IsRelativeToListener() const +{ + ALint Relative; + ALCheck(alGetSourcei(mySource, AL_SOURCE_RELATIVE, &Relative)); + + return Relative != 0; +} + + //////////////////////////////////////////////////////////// /// Get the minimum distance ////////////////////////////////////////////////////////////