2009-01-29 00:18:34 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// SFML - Simple and Fast Multimedia Library
|
2009-02-13 01:48:35 +08:00
|
|
|
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
|
2009-01-29 00:18:34 +08:00
|
|
|
//
|
|
|
|
// 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>
|
2009-01-30 22:58:43 +08:00
|
|
|
#include <SFML/Audio/Types.h>
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// 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
|
2009-04-11 06:50:08 +08:00
|
|
|
typedef void (*sfSoundStreamSeekCallback)(float, void*); ///< Type of the callback used to seek in a sound stream
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Construct a new sound stream
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \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
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
/// \return A new sfSoundStream object (NULL if failed)
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API sfSoundStream* sfSoundStream_Create(sfSoundStreamGetDataCallback onGetData,
|
|
|
|
sfSoundStreamSeekCallback onSeek,
|
|
|
|
unsigned int channelsCount,
|
|
|
|
unsigned int sampleRate,
|
|
|
|
void* userData);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Destroy an existing sound stream
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to delete
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API void sfSoundStream_Destroy(sfSoundStream* soundStream);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Start playing a sound stream
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to play
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API void sfSoundStream_Play(sfSoundStream* soundStream);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Pause a sound stream
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to pause
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API void sfSoundStream_Pause(sfSoundStream* soundStream);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Stop playing a sound stream
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to stop
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API void sfSoundStream_Stop(sfSoundStream* soundStream);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Get the status of a sound stream (stopped, paused, playing)
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to get the status from
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
/// \return Current status of the sound stream
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API sfSoundStatus sfSoundStream_GetStatus(sfSoundStream* soundStream);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Return the number of channels of a sound stream
|
|
|
|
/// (1 = mono, 2 = stereo)
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to get the channels count from
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
/// \return Number of channels
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API unsigned int sfSoundStream_GetChannelsCount(sfSoundStream* soundStream);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Get the sample rate of a sound stream
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to get the sample rate from
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
/// \return Stream frequency (number of samples per second)
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API unsigned int sfSoundStream_GetSampleRate(sfSoundStream* soundStream);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Set the pitch of a sound stream
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to modify
|
|
|
|
/// \param pitch : New pitch
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API void sfSoundStream_SetPitch(sfSoundStream* soundStream, float pitch);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Set the volume of a sound stream
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to modify
|
|
|
|
/// \param volume : Volume (in range [0, 100])
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API void sfSoundStream_SetVolume(sfSoundStream* soundStream, float volume);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Set the position of a sound stream
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \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
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API void sfSoundStream_SetPosition(sfSoundStream* soundStream, float x, float y, float z);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
2009-03-23 02:36:03 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Make the sound stream's position relative to the listener's
|
|
|
|
/// position, or absolute.
|
|
|
|
/// The default value is false (absolute)
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to modify
|
|
|
|
/// \param relative : True to set the position relative, false to set it absolute
|
2009-03-23 02:36:03 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API void sfSoundStream_SetRelativeToListener(sfSoundStream* soundStream, sfBool relative);
|
2009-03-23 02:36:03 +08:00
|
|
|
|
2009-01-29 00:18:34 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// 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
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to modify
|
|
|
|
/// \param distance : New minimum distance for the sound stream
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API void sfSoundStream_SetMinDistance(sfSoundStream* soundStream, float distance);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// 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
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to modify
|
|
|
|
/// \param attenuation : New attenuation factor for the sound stream
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API void sfSoundStream_SetAttenuation(sfSoundStream* soundStream, float attenuation);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
2009-04-11 06:50:08 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Set the current playing position of a stream
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to modify
|
|
|
|
/// \param timeOffset : New playing position, expressed in seconds
|
2009-04-11 06:50:08 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API void sfSoundStream_SetPlayingOffset(sfSoundStream* soundStream, float timeOffset);
|
2009-04-11 06:50:08 +08:00
|
|
|
|
2009-01-29 00:18:34 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Set a stream loop state
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Stream to set the loop state
|
|
|
|
/// \param loop : sfTrue to play in loop, sfFalse to play once
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API void sfSoundStream_SetLoop(sfSoundStream* soundStream, sfBool loop);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Get the pitch of a sound stream
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to get the pitch from
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
/// \return Pitch value
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API float sfSoundStream_GetPitch(sfSoundStream* soundStream);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Get the volume of a sound stream
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to get the volume from
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
/// \return Volume value (in range [1, 100])
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API float sfSoundStream_GetVolume(sfSoundStream* soundStream);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Get the position of a sound stream
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \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
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API void sfSoundStream_GetPosition(sfSoundStream* soundStream, float* x, float* y, float* z);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
2009-03-23 02:36:03 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Tell if the sound stream's position is relative to the listener's
|
|
|
|
/// position, or if it's absolute
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to check
|
2009-03-23 02:36:03 +08:00
|
|
|
///
|
|
|
|
/// \return sfTrue if the position is relative, sfFalse if it's absolute
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API sfBool sfSoundStream_IsRelativeToListener(sfSoundStream* soundStream);
|
2009-03-23 02:36:03 +08:00
|
|
|
|
2009-01-29 00:18:34 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Get the minimum distance of a sound stream
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to get the minimum distance from
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
/// \return Minimum distance for the sound stream
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API float sfSoundStream_GetMinDistance(sfSoundStream* soundStream);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Get the attenuation factor of a sound stream
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to get the attenuation factor from
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
/// \return Attenuation factor for the sound stream
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API float sfSoundStream_GetAttenuation(sfSoundStream* soundStream);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Tell whether or not a stream is looping
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Soundstream to get the loop state from
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
/// \return sfTrue if the stream is looping, sfFalse otherwise
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API sfBool sfSoundStream_GetLoop(sfSoundStream* soundStream);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// Get the current playing position of a sound stream
|
|
|
|
///
|
2009-07-12 06:17:24 +08:00
|
|
|
/// \param soundStream : Sound stream to get the position from
|
2009-01-29 00:18:34 +08:00
|
|
|
///
|
|
|
|
/// \return Current playing position, expressed in seconds
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-12 06:17:24 +08:00
|
|
|
CSFML_API float sfSoundStream_GetPlayingOffset(sfSoundStream* soundStream);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
#endif // SFML_SOUNDSTREAM_H
|