Initial commit -- moved from https://github.com/LaurentGomila/SFML (bindings/c)

This commit is contained in:
Laurent Gomila committed 2011-07-06 22:39:55 +02:00
commit 45d3b05d65
141 files changed
+19124

No files matched your search

+91
View File
@@ -0,0 +1,91 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_LISTENER_H
#define SFML_LISTENER_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
////////////////////////////////////////////////////////////
/// Change the global volume of all the sounds
///
/// \param volume : New global volume, in the range [0, 100]
///
////////////////////////////////////////////////////////////
CSFML_API void sfListener_SetGlobalVolume(float volume);
////////////////////////////////////////////////////////////
/// Get the current value of the global volume of all the sounds
///
/// \return Current global volume, in the range [0, 100]
///
////////////////////////////////////////////////////////////
CSFML_API float sfListener_GetGlobalVolume(void);
////////////////////////////////////////////////////////////
/// Change the position of the listener
///
/// \param x : X position of the listener in the world
/// \param y : Y position of the listener in the world
/// \param z : Z position of the listener in the world
///
////////////////////////////////////////////////////////////
CSFML_API void sfListener_SetPosition(float x, float y, float z);
////////////////////////////////////////////////////////////
/// Get the current position of the listener
///
/// \param x : X position of the listener in the world
/// \param y : Y position of the listener in the world
/// \param z : Z position of the listener in the world
///
////////////////////////////////////////////////////////////
CSFML_API void sfListener_GetPosition(float* x, float* y, float* z);
////////////////////////////////////////////////////////////
/// Change the orientation of the listener
///
/// \param x : X component of the listener's direction
/// \param y : Y component of the listener's direction
/// \param z : Z component of the listener's direction
///
////////////////////////////////////////////////////////////
CSFML_API void sfListener_SetDirection(float x, float y, float z);
////////////////////////////////////////////////////////////
/// Get the current orientation of the listener
///
/// \param x : X component of the listener's direction
/// \param y : Y component of the listener's direction
/// \param z : Z component of the listener's direction
///
////////////////////////////////////////////////////////////
CSFML_API void sfListener_GetDirection(float* x, float* y, float* z);
#endif // SFML_LISTENER_H
+292
View File
@@ -0,0 +1,292 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_MUSIC_H
#define SFML_MUSIC_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Audio/SoundStatus.h>
#include <SFML/Audio/Types.h>
////////////////////////////////////////////////////////////
/// Create a new music and load it from a file
///
/// \param filename : Path of the music file to open
///
/// \return A new sfMusic object (NULL if failed)
///
////////////////////////////////////////////////////////////
CSFML_API sfMusic* sfMusic_CreateFromFile(const char* filename);
////////////////////////////////////////////////////////////
/// Create a new music and load it from a file in memory
///
/// \param data : Pointer to the file data in memory
/// \param sizeInBytes : Size of the data to load, in bytes
///
/// \return A new sfMusic object (NULL if failed)
///
////////////////////////////////////////////////////////////
CSFML_API sfMusic* sfMusic_CreateFromMemory(const void* data, size_t sizeInBytes);
////////////////////////////////////////////////////////////
/// Destroy an existing music
///
/// \param music : Music to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfMusic_Destroy(sfMusic* music);
////////////////////////////////////////////////////////////
/// Set a music loop state
///
/// \param music : Music to set the loop state
/// \param loop : sfTrue to play in loop, sfFalse to play once
///
////////////////////////////////////////////////////////////
CSFML_API void sfMusic_SetLoop(sfMusic* music, sfBool loop);
////////////////////////////////////////////////////////////
/// Tell whether or not a music is looping
///
/// \param music : Music to get the loop state from
///
/// \return sfTrue if the music is looping, sfFalse otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfMusic_GetLoop(const sfMusic* music);
////////////////////////////////////////////////////////////
/// Get a music duration
///
/// \param music : Music to get the duration from
///
/// \return Music duration, in milliseconds
///
////////////////////////////////////////////////////////////
CSFML_API sfUint32 sfMusic_GetDuration(const sfMusic* music);
////////////////////////////////////////////////////////////
/// Start playing a music
///
/// \param music : Music to play
///
////////////////////////////////////////////////////////////
CSFML_API void sfMusic_Play(sfMusic* music);
////////////////////////////////////////////////////////////
/// Pause a music
///
/// \param music : Music to pause
///
////////////////////////////////////////////////////////////
CSFML_API void sfMusic_Pause(sfMusic* music);
////////////////////////////////////////////////////////////
/// Stop playing a music
///
/// \param music : Music to stop
///
////////////////////////////////////////////////////////////
CSFML_API void sfMusic_Stop(sfMusic* music);
////////////////////////////////////////////////////////////
/// Return the number of channels of a music (1 = mono, 2 = stereo)
///
/// \param music : Music to get the channels count from
///
/// \return Number of channels
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfMusic_GetChannelsCount(const sfMusic* music);
////////////////////////////////////////////////////////////
/// Get the stream sample rate of a music
///
/// \param music : Music to get the sample rate from
///
/// \return Stream frequency (number of samples per second)
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfMusic_GetSampleRate(const sfMusic* music);
////////////////////////////////////////////////////////////
/// Get the status of a music (stopped, paused, playing)
///
/// \param music : Music to get the status from
///
/// \return Current status of the sound
///
////////////////////////////////////////////////////////////
CSFML_API sfSoundStatus sfMusic_GetStatus(const sfMusic* music);
////////////////////////////////////////////////////////////
/// Get the current playing position of a music
///
/// \param music : Music to get the position from
///
/// \return Current playing position, in milliseconds
///
////////////////////////////////////////////////////////////
CSFML_API sfUint32 sfMusic_GetPlayingOffset(const sfMusic* music);
////////////////////////////////////////////////////////////
/// Set the pitch of a music
///
/// \param music : Music to modify
/// \param pitch : New pitch
///
////////////////////////////////////////////////////////////
CSFML_API void sfMusic_SetPitch(sfMusic* music, float pitch);
////////////////////////////////////////////////////////////
/// Set the volume of a music
///
/// \param music : Music to modify
/// \param volume : Volume (in range [0, 100])
///
////////////////////////////////////////////////////////////
CSFML_API void sfMusic_SetVolume(sfMusic* music, float volume);
////////////////////////////////////////////////////////////
/// Set the position of a music
///
/// \param music : Music to modify
/// \param x : X position of the sound in the world
/// \param y : Y position of the sound in the world
/// \param z : Z position of the sound in the world
///
////////////////////////////////////////////////////////////
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.
/// The default minimum distance is 1.0
///
/// \param music : Music to modify
/// \param distance : New minimum distance for the music
///
////////////////////////////////////////////////////////////
CSFML_API void sfMusic_SetMinDistance(sfMusic* music, float distance);
////////////////////////////////////////////////////////////
/// Set the attenuation factor - the higher the attenuation, the
/// more the sound will be attenuated with distance from listener.
/// The default attenuation factor 1.0
///
/// \param music : Music to modify
/// \param attenuation : New attenuation factor for the sound
///
////////////////////////////////////////////////////////////
CSFML_API void sfMusic_SetAttenuation(sfMusic* music, float attenuation);
////////////////////////////////////////////////////////////
/// Set the current playing position of a music
///
/// \param music : Music to modify
/// \param timeOffset : New playing position, in milliseconds
///
////////////////////////////////////////////////////////////
CSFML_API void sfMusic_SetPlayingOffset(sfMusic* music, sfUint32 timeOffset);
////////////////////////////////////////////////////////////
/// Get the pitch of a music
///
/// \param music : Music to get the pitch from
///
/// \return Pitch value
///
////////////////////////////////////////////////////////////
CSFML_API float sfMusic_GetPitch(const sfMusic* music);
////////////////////////////////////////////////////////////
/// Get the volume of a music
///
/// \param music : Music to get the volume from
///
/// \return Volume value (in range [1, 100])
///
////////////////////////////////////////////////////////////
CSFML_API float sfMusic_GetVolume(const sfMusic* music);
////////////////////////////////////////////////////////////
/// Get the position of a music
///
/// \param music : Music to get the position from
/// \param x : X position of the sound in the world
/// \param y : Y position of the sound in the world
/// \param z : Z position of the sound in the world
///
////////////////////////////////////////////////////////////
CSFML_API void sfMusic_GetPosition(const 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(const sfMusic* music);
////////////////////////////////////////////////////////////
/// Get the minimum distance of a music
///
/// \param music : Music to get the minimum distance from
///
/// \return Minimum distance for the music
///
////////////////////////////////////////////////////////////
CSFML_API float sfMusic_GetMinDistance(const sfMusic* music);
////////////////////////////////////////////////////////////
/// Get the attenuation factor of a music
///
/// \param music : Music to get the attenuation factor from
///
/// \return Attenuation factor for the a music
///
////////////////////////////////////////////////////////////
CSFML_API float sfMusic_GetAttenuation(const sfMusic* music);
#endif // SFML_MUSIC_H
+278
View File
@@ -0,0 +1,278 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOUND_H
#define SFML_SOUND_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Audio/SoundStatus.h>
#include <SFML/Audio/Types.h>
////////////////////////////////////////////////////////////
/// Construct a new sound
///
/// \return A new sfSound object (NULL if failed)
///
////////////////////////////////////////////////////////////
CSFML_API sfSound* sfSound_Create(void);
////////////////////////////////////////////////////////////
/// Copy an existing sound
///
/// \param sound : Sound to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfSound* sfSound_Copy(sfSound* sound);
////////////////////////////////////////////////////////////
/// Destroy an existing sound
///
/// \param sound : Sound to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfSound_Destroy(sfSound* sound);
////////////////////////////////////////////////////////////
/// Start playing a sound
///
/// \param sound : Sound to play
///
////////////////////////////////////////////////////////////
CSFML_API void sfSound_Play(sfSound* sound);
////////////////////////////////////////////////////////////
/// Pause a sound
///
/// \param sound : Sound to pause
///
////////////////////////////////////////////////////////////
CSFML_API void sfSound_Pause(sfSound* sound);
////////////////////////////////////////////////////////////
/// Stop playing a sound
///
/// \param sound : Sound to stop
///
////////////////////////////////////////////////////////////
CSFML_API void sfSound_Stop(sfSound* sound);
////////////////////////////////////////////////////////////
/// Bind a sound buffer to a sound
///
/// \param sound : Sound to set the loop state
/// \param buffer : Buffer to bind
///
////////////////////////////////////////////////////////////
CSFML_API void sfSound_SetBuffer(sfSound* sound, const sfSoundBuffer* buffer);
////////////////////////////////////////////////////////////
/// Get the sound buffer bound to a sound
///
/// \param sound : Sound to get the buffer from
///
/// \return Pointer to the sound's buffer
///
////////////////////////////////////////////////////////////
CSFML_API const sfSoundBuffer* sfSound_GetBuffer(const sfSound* sound);
////////////////////////////////////////////////////////////
/// Set a sound loop state
///
/// \param sound : Sound to set the loop state
/// \param loop : sfTrue to play in loop, sfFalse to play once
///
////////////////////////////////////////////////////////////
CSFML_API void sfSound_SetLoop(sfSound* sound, sfBool loop);
////////////////////////////////////////////////////////////
/// Tell whether or not a sound is looping
///
/// \param sound : Sound to get the loop state from
///
/// \return sfTrue if the sound is looping, sfFalse otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfSound_GetLoop(const sfSound* sound);
////////////////////////////////////////////////////////////
/// Get the status of a sound (stopped, paused, playing)
///
/// \param sound : Sound to get the status from
///
/// \return Current status of the sound
///
////////////////////////////////////////////////////////////
CSFML_API sfSoundStatus sfSound_GetStatus(const sfSound* sound);
////////////////////////////////////////////////////////////
/// Set the pitch of a sound
///
/// \param sound : Sound to modify
/// \param pitch : New pitch
///
////////////////////////////////////////////////////////////
CSFML_API void sfSound_SetPitch(sfSound* sound, float pitch);
////////////////////////////////////////////////////////////
/// Set the volume of a sound
///
/// \param sound : Sound to modify
/// \param volume : Volume (in range [0, 100])
///
////////////////////////////////////////////////////////////
CSFML_API void sfSound_SetVolume(sfSound* sound, float volume);
////////////////////////////////////////////////////////////
/// Set the position of a sound
///
/// \param sound : Sound to modify
/// \param x : X position of the sound in the world
/// \param y : Y position of the sound in the world
/// \param z : Z position of the sound in the world
///
////////////////////////////////////////////////////////////
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.
/// The default minimum distance is 1.0
///
/// \param sound : Sound to modify
/// \param distance : New minimum distance for the sound
///
////////////////////////////////////////////////////////////
CSFML_API void sfSound_SetMinDistance(sfSound* sound, float distance);
////////////////////////////////////////////////////////////
/// Set the attenuation factor - the higher the attenuation, the
/// more the sound will be attenuated with distance from listener.
/// The default attenuation factor is 1.0
///
/// \param sound : Sound to modify
/// \param attenuation : New attenuation factor for the sound
///
////////////////////////////////////////////////////////////
CSFML_API void sfSound_SetAttenuation(sfSound* sound, float attenuation);
////////////////////////////////////////////////////////////
/// Set the current playing position of a sound
///
/// \param sound : Sound to modify
/// \param timeOffset : New playing position, in milliseconds
///
////////////////////////////////////////////////////////////
CSFML_API void sfSound_SetPlayingOffset(sfSound* sound, sfUint32 timeOffset);
////////////////////////////////////////////////////////////
/// Get the pitch of a sound
///
/// \param sound : Sound to get the pitch from
///
/// \return Pitch value
///
////////////////////////////////////////////////////////////
CSFML_API float sfSound_GetPitch(const sfSound* sound);
////////////////////////////////////////////////////////////
/// Get the volume of a sound
///
/// \param sound : Sound to get the volume from
///
/// \return Volume value (in range [1, 100])
///
////////////////////////////////////////////////////////////
CSFML_API float sfSound_GetVolume(const sfSound* sound);
////////////////////////////////////////////////////////////
/// Get the position of a sound
///
/// \param sound : Sound to get the position from
/// \param x : X position of the sound in the world
/// \param y : Y position of the sound in the world
/// \param z : Z position of the sound in the world
///
////////////////////////////////////////////////////////////
CSFML_API void sfSound_GetPosition(const 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(const sfSound* sound);
////////////////////////////////////////////////////////////
/// Get the minimum distance of a sound
///
/// \param sound : Sound to get the minimum distance from
///
/// \return Minimum distance for the sound
///
////////////////////////////////////////////////////////////
CSFML_API float sfSound_GetMinDistance(const sfSound* sound);
////////////////////////////////////////////////////////////
/// Get the attenuation factor of a sound
///
/// \param sound : Sound to get the attenuation factor from
///
/// \return Attenuation factor for the sound
///
////////////////////////////////////////////////////////////
CSFML_API float sfSound_GetAttenuation(const sfSound* sound);
////////////////////////////////////////////////////////////
/// Get the current playing position of a sound
///
/// \param sound : Sound to get the position from
///
/// \return Current playing position, in milliseconds
///
////////////////////////////////////////////////////////////
CSFML_API sfUint32 sfSound_GetPlayingOffset(const sfSound* sound);
#endif // SFML_SOUND_H
+151
View File
@@ -0,0 +1,151 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOUNDBUFFER_H
#define SFML_SOUNDBUFFER_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Audio/Types.h>
////////////////////////////////////////////////////////////
/// Create a new sound buffer and load it from a file
///
/// \param filename : Path of the music file to open
///
/// \return A new sfSoundBuffer object (NULL if failed)
///
////////////////////////////////////////////////////////////
CSFML_API sfSoundBuffer* sfSoundBuffer_CreateFromFile(const char* filename);
////////////////////////////////////////////////////////////
/// Create a new sound buffer and load it from a file in memory
///
/// \param data : Pointer to the file data in memory
/// \param sizeInBytes : Size of the data to load, in bytes
///
/// \return A new sfSoundBuffer object (NULL if failed)
///
////////////////////////////////////////////////////////////
CSFML_API sfSoundBuffer* sfSoundBuffer_CreateFromMemory(const void* data, size_t sizeInBytes);
////////////////////////////////////////////////////////////
/// Create a new sound buffer and load it from an array of
/// samples in memory - assumed format for samples is
/// 16 bits signed integer
///
/// \param samples : Pointer to the samples in memory
/// \param samplesCount : Number of samples pointed by Samples
/// \param channelsCount : Number of channels (1 = mono, 2 = stereo, ...)
/// \param sampleRate : Frequency (number of samples to play per second)
///
/// \return A new sfSoundBuffer object (NULL if failed)
///
////////////////////////////////////////////////////////////
CSFML_API sfSoundBuffer* sfSoundBuffer_CreateFromSamples(const sfInt16* samples, size_t samplesCount, unsigned int channelsCount, unsigned int sampleRate);
////////////////////////////////////////////////////////////
/// Copy an existing sound buffer
///
/// \param soundBuffer : Sound buffer to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfSoundBuffer* sfSoundBuffer_Copy(sfSoundBuffer* soundBuffer);
////////////////////////////////////////////////////////////
/// Destroy an existing sound buffer
///
/// \param soundBuffer : Sound buffer to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundBuffer_Destroy(sfSoundBuffer* soundBuffer);
////////////////////////////////////////////////////////////
/// Save a sound buffer to a file
///
/// \param soundBuffer : Sound buffer to save
/// \param filename : Path of the sound file to write
///
/// \return sfTrue if saving has been successful
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfSoundBuffer_SaveToFile(const sfSoundBuffer* soundBuffer, const char* filename);
////////////////////////////////////////////////////////////
/// Return the samples contained in a sound buffer
///
/// \param soundBuffer : Sound buffer to get samples from
///
/// \return Pointer to the array of sound samples, in 16 bits signed integer format
///
////////////////////////////////////////////////////////////
CSFML_API const sfInt16* sfSoundBuffer_GetSamples(const sfSoundBuffer* soundBuffer);
////////////////////////////////////////////////////////////
/// Return the number of samples contained in a sound buffer
///
/// \param soundBuffer : Sound buffer to get samples count from
///
/// \return Number of samples
///
////////////////////////////////////////////////////////////
CSFML_API size_t sfSoundBuffer_GetSamplesCount(const sfSoundBuffer* soundBuffer);
////////////////////////////////////////////////////////////
/// Get the sample rate of a sound buffer
///
/// \param soundBuffer : Sound buffer to get sample rate from
///
/// \return Sound frequency (number of samples per second)
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfSoundBuffer_GetSampleRate(const sfSoundBuffer* soundBuffer);
////////////////////////////////////////////////////////////
/// Return the number of channels of a sound buffer (1 = mono, 2 = stereo, ...)
///
/// \param soundBuffer : Sound buffer to get channels count from
///
/// \return Number of channels
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfSoundBuffer_GetChannelsCount(const sfSoundBuffer* soundBuffer);
////////////////////////////////////////////////////////////
/// Get the duration of a sound buffer
///
/// \param soundBuffer : Sound buffer to get duration from
///
/// \return Sound duration, in milliseconds
///
////////////////////////////////////////////////////////////
CSFML_API sfUint32 sfSoundBuffer_GetDuration(const sfSoundBuffer* soundBuffer);
#endif // SFML_SOUNDBUFFER_H
+91
View File
@@ -0,0 +1,91 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOUNDBUFFERRECORDER_H
#define SFML_SOUNDBUFFERRECORDER_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Audio/Types.h>
////////////////////////////////////////////////////////////
/// Construct a new sound buffer recorder
///
/// \return A new sfSoundBufferRecorder object (NULL if failed)
///
////////////////////////////////////////////////////////////
CSFML_API sfSoundBufferRecorder* sfSoundBufferRecorder_Create(void);
////////////////////////////////////////////////////////////
/// Destroy an existing sound buffer recorder
///
/// \param soundBufferRecorder : Sound buffer recorder to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundBufferRecorder_Destroy(sfSoundBufferRecorder* soundBufferRecorder);
////////////////////////////////////////////////////////////
/// Start the capture.
/// Warning : only one capture can happen at the same time
///
/// \param soundBufferRecorder : Sound buffer recorder to start
/// \param sampleRate : Sound frequency (the more samples, the higher the quality)
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundBufferRecorder_Start(sfSoundBufferRecorder* soundBufferRecorder, unsigned int sampleRate);
////////////////////////////////////////////////////////////
/// Stop the capture
///
/// \param soundBufferRecorder : Sound buffer recorder to stop
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundBufferRecorder_Stop(sfSoundBufferRecorder* soundBufferRecorder);
////////////////////////////////////////////////////////////
/// Get the sample rate of a sound buffer recorder
///
/// \param soundBufferRecorder : Sound buffer recorder to get sample rate from
///
/// \return Frequency, in samples per second
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfSoundBufferRecorder_GetSampleRate(const sfSoundBufferRecorder* soundBufferRecorder);
////////////////////////////////////////////////////////////
/// Get the sound buffer containing the captured audio data
/// of a sound buffer recorder
///
/// \param soundBufferRecorder : Sound buffer recorder to get the sound buffer from
///
/// \return Pointer to the sound buffer (you don't need to destroy it after use)
///
////////////////////////////////////////////////////////////
CSFML_API const sfSoundBuffer* sfSoundBufferRecorder_GetBuffer(const sfSoundBufferRecorder* soundBufferRecorder);
#endif // SFML_SOUNDBUFFERRECORDER_H
+103
View File
@@ -0,0 +1,103 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOUNDRECORDER_H
#define SFML_SOUNDRECORDER_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Audio/Types.h>
typedef sfBool (*sfSoundRecorderStartCallback)(void*); ///< Type of the callback used when starting a capture
typedef sfBool (*sfSoundRecorderProcessCallback)(const sfInt16*, size_t, void*); ///< Type of the callback used to process audio data
typedef void (*sfSoundRecorderStopCallback)(void*); ///< Type of the callback used when stopping a capture
////////////////////////////////////////////////////////////
/// Construct a new sound recorder with callback functions
/// for processing captured samples
///
/// \param onStart : Callback function which will be called when a new capture starts (can be NULL)
/// \param onProcess : Callback function which will be called each time there's audio data to process
/// \param onStop : Callback function which will be called when the current capture stops (can be NULL)
/// \param userData : Data to pass to the callback function (can be NULL)
///
/// \return A new sfSoundRecorder object (NULL if failed)
///
////////////////////////////////////////////////////////////
CSFML_API sfSoundRecorder* sfSoundRecorder_Create(sfSoundRecorderStartCallback onStart,
sfSoundRecorderProcessCallback onProcess,
sfSoundRecorderStopCallback onStop,
void* userData);
////////////////////////////////////////////////////////////
/// Destroy an existing sound recorder
///
/// \param soundRecorder : Sound recorder to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundRecorder_Destroy(sfSoundRecorder* soundRecorder);
////////////////////////////////////////////////////////////
/// Start the capture.
/// Warning : only one capture can happen at the same time
///
/// \param soundRecorder : Sound recorder to start
/// \param sampleRate : Sound frequency (the more samples, the higher the quality)
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundRecorder_Start(sfSoundRecorder* soundRecorder, unsigned int sampleRate);
////////////////////////////////////////////////////////////
/// Stop the capture
///
/// \param soundRecorder : Sound recorder to stop
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundRecorder_Stop(sfSoundRecorder* soundRecorder);
////////////////////////////////////////////////////////////
/// Get the sample rate of a sound recorder
///
/// \param soundRecorder : Sound recorder to get sample rate from
///
/// \return Frequency, in samples per second
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfSoundRecorder_GetSampleRate(const sfSoundRecorder* soundRecorder);
////////////////////////////////////////////////////////////
/// Tell if the system supports sound capture.
/// If not, this class won't be usable
///
/// \return sfTrue if audio capture is supported
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfSoundRecorder_IsAvailable(void);
#endif // SFML_SOUNDRECORDER_H
+42
View File
@@ -0,0 +1,42 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOUNDSTATUS_H
#define SFML_SOUNDSTATUS_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
typedef enum
{
sfStopped, ///< Sound / music is not playing
sfPaused, ///< Sound / music is paused
sfPlaying ///< Sound / music is playing
} sfSoundStatus;
#endif // SFML_SOUNDSTATUS_H
+294
View File
@@ -0,0 +1,294 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOUNDSTREAM_H
#define SFML_SOUNDSTREAM_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Audio/SoundStatus.h>
#include <SFML/Audio/Types.h>
////////////////////////////////////////////////////////////
/// sfSoundStreamChunk defines the data to fill by the
/// OnGetData callback
////////////////////////////////////////////////////////////
typedef struct
{
sfInt16* Samples; ///< Pointer to the audio samples
unsigned int NbSamples; ///< Number of samples pointed by Samples
} sfSoundStreamChunk;
typedef sfBool (*sfSoundStreamGetDataCallback)(sfSoundStreamChunk*, void*); ///< Type of the callback used to get a sound stream data
typedef void (*sfSoundStreamSeekCallback)(sfUint32, void*); ///< Type of the callback used to seek in a sound stream
////////////////////////////////////////////////////////////
/// Construct a new sound stream
///
/// \param onGetData : Function called when the stream needs more data (can't be NULL)
/// \param onSeek : Function called when the stream seeks (can't be NULL)
/// \param channelsCount : Number of channels to use (1 = mono, 2 = stereo)
/// \param sampleRate : Sample rate of the sound (44100 = CD quality)
/// \param userData : Data to pass to the callback functions
///
/// \return A new sfSoundStream object (NULL if failed)
///
////////////////////////////////////////////////////////////
CSFML_API sfSoundStream* sfSoundStream_Create(sfSoundStreamGetDataCallback onGetData,
sfSoundStreamSeekCallback onSeek,
unsigned int channelsCount,
unsigned int sampleRate,
void* userData);
////////////////////////////////////////////////////////////
/// Destroy an existing sound stream
///
/// \param soundStream : Sound stream to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundStream_Destroy(sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// Start playing a sound stream
///
/// \param soundStream : Sound stream to play
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundStream_Play(sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// Pause a sound stream
///
/// \param soundStream : Sound stream to pause
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundStream_Pause(sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// Stop playing a sound stream
///
/// \param soundStream : Sound stream to stop
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundStream_Stop(sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// Get the status of a sound stream (stopped, paused, playing)
///
/// \param soundStream : Sound stream to get the status from
///
/// \return Current status of the sound stream
///
////////////////////////////////////////////////////////////
CSFML_API sfSoundStatus sfSoundStream_GetStatus(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// Return the number of channels of a sound stream
/// (1 = mono, 2 = stereo)
///
/// \param soundStream : Sound stream to get the channels count from
///
/// \return Number of channels
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfSoundStream_GetChannelsCount(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// Get the sample rate of a sound stream
///
/// \param soundStream : Sound stream to get the sample rate from
///
/// \return Stream frequency (number of samples per second)
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfSoundStream_GetSampleRate(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// Set the pitch of a sound stream
///
/// \param soundStream : Sound stream to modify
/// \param pitch : New pitch
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundStream_SetPitch(sfSoundStream* soundStream, float pitch);
////////////////////////////////////////////////////////////
/// Set the volume of a sound stream
///
/// \param soundStream : Sound stream to modify
/// \param volume : Volume (in range [0, 100])
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundStream_SetVolume(sfSoundStream* soundStream, float volume);
////////////////////////////////////////////////////////////
/// Set the position of a sound stream
///
/// \param soundStream : Sound stream to modify
/// \param x : X position of the sound stream in the world
/// \param y : Y position of the sound stream in the world
/// \param z : Z position of the sound stream in the world
///
////////////////////////////////////////////////////////////
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.
/// The default minimum distance is 1.0
///
/// \param soundStream : Sound stream to modify
/// \param distance : New minimum distance for the sound stream
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundStream_SetMinDistance(sfSoundStream* soundStream, float distance);
////////////////////////////////////////////////////////////
/// Set the attenuation factor - the higher the attenuation, the
/// more the sound stream will be attenuated with distance from listener.
/// The default attenuation factor 1.0
///
/// \param soundStream : Sound stream to modify
/// \param attenuation : New attenuation factor for the sound stream
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundStream_SetAttenuation(sfSoundStream* soundStream, float attenuation);
////////////////////////////////////////////////////////////
/// Set the current playing position of a stream
///
/// \param soundStream : Sound stream to modify
/// \param timeOffset : New playing position, in milliseconds
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundStream_SetPlayingOffset(sfSoundStream* soundStream, sfUint32 timeOffset);
////////////////////////////////////////////////////////////
/// Set a stream loop state
///
/// \param soundStream : Stream to set the loop state
/// \param loop : sfTrue to play in loop, sfFalse to play once
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundStream_SetLoop(sfSoundStream* soundStream, sfBool loop);
////////////////////////////////////////////////////////////
/// Get the pitch of a sound stream
///
/// \param soundStream : Sound stream to get the pitch from
///
/// \return Pitch value
///
////////////////////////////////////////////////////////////
CSFML_API float sfSoundStream_GetPitch(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// Get the volume of a sound stream
///
/// \param soundStream : Sound stream to get the volume from
///
/// \return Volume value (in range [1, 100])
///
////////////////////////////////////////////////////////////
CSFML_API float sfSoundStream_GetVolume(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// Get the position of a sound stream
///
/// \param soundStream : Sound stream to get the position from
/// \param x : X position of the sound stream in the world
/// \param y : Y position of the sound stream in the world
/// \param z : Z position of the sound stream in the world
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundStream_GetPosition(const 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(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// Get the minimum distance of a sound stream
///
/// \param soundStream : Sound stream to get the minimum distance from
///
/// \return Minimum distance for the sound stream
///
////////////////////////////////////////////////////////////
CSFML_API float sfSoundStream_GetMinDistance(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// Get the attenuation factor of a sound stream
///
/// \param soundStream : Sound stream to get the attenuation factor from
///
/// \return Attenuation factor for the sound stream
///
////////////////////////////////////////////////////////////
CSFML_API float sfSoundStream_GetAttenuation(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// Tell whether or not a stream is looping
///
/// \param soundStream : Soundstream to get the loop state from
///
/// \return sfTrue if the stream is looping, sfFalse otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfSoundStream_GetLoop(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// Get the current playing position of a sound stream
///
/// \param soundStream : Sound stream to get the position from
///
/// \return Current playing position, in milliseconds
///
////////////////////////////////////////////////////////////
CSFML_API sfUint32 sfSoundStream_GetPlayingOffset(const sfSoundStream* soundStream);
#endif // SFML_SOUNDSTREAM_H
+36
View File
@@ -0,0 +1,36 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_AUDIO_TYPES_H
#define SFML_AUDIO_TYPES_H
typedef struct sfMusic sfMusic;
typedef struct sfSound sfSound;
typedef struct sfSoundBuffer sfSoundBuffer;
typedef struct sfSoundBufferRecorder sfSoundBufferRecorder;
typedef struct sfSoundRecorder sfSoundRecorder;
typedef struct sfSoundStream sfSoundStream;
#endif // SFML_AUDIO_TYPES_H