Improved the API documentation in the audio module
Removed the bufferSize parameter from sf::Music constructor git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1252 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
33f54ad6cd
commit
3c0d42fdd0
6 changed files with 249 additions and 167 deletions
|
@ -36,19 +36,14 @@
|
|||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Construct the music with a buffer size
|
||||
////////////////////////////////////////////////////////////
|
||||
Music::Music(std::size_t bufferSize) :
|
||||
Music::Music() :
|
||||
myFile (new priv::SoundFile),
|
||||
myDuration(0.f),
|
||||
mySamples (bufferSize)
|
||||
myDuration(0.f)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
////////////////////////////////////////////////////////////
|
||||
Music::~Music()
|
||||
{
|
||||
|
@ -59,8 +54,6 @@ Music::~Music()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Open a music file (doesn't play it -- call Play() for that)
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Music::OpenFromFile(const std::string& filename)
|
||||
{
|
||||
|
@ -77,6 +70,9 @@ bool Music::OpenFromFile(const std::string& filename)
|
|||
// Compute the duration
|
||||
myDuration = static_cast<float>(myFile->GetSamplesCount()) / myFile->GetSampleRate() / myFile->GetChannelsCount();
|
||||
|
||||
// Resize the internal buffer so that it can contain 1 second of audio samples
|
||||
mySamples.resize(myFile->GetSampleRate());
|
||||
|
||||
// Initialize the stream
|
||||
Initialize(myFile->GetChannelsCount(), myFile->GetSampleRate());
|
||||
|
||||
|
@ -84,8 +80,6 @@ bool Music::OpenFromFile(const std::string& filename)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Open a music file from memory (doesn't play it -- call Play() for that)
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Music::OpenFromMemory(const char* data, std::size_t sizeInBytes)
|
||||
{
|
||||
|
@ -100,7 +94,10 @@ bool Music::OpenFromMemory(const char* data, std::size_t sizeInBytes)
|
|||
}
|
||||
|
||||
// Compute the duration
|
||||
myDuration = static_cast<float>(myFile->GetSamplesCount()) / myFile->GetSampleRate();
|
||||
myDuration = static_cast<float>(myFile->GetSamplesCount()) / myFile->GetSampleRate() / myFile->GetChannelsCount();
|
||||
|
||||
// Resize the internal buffer so that it can contain 1 second of audio samples
|
||||
mySamples.resize(myFile->GetSampleRate());
|
||||
|
||||
// Initialize the stream
|
||||
Initialize(myFile->GetChannelsCount(), myFile->GetSampleRate());
|
||||
|
@ -109,8 +106,6 @@ bool Music::OpenFromMemory(const char* data, std::size_t sizeInBytes)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the sound duration
|
||||
////////////////////////////////////////////////////////////
|
||||
float Music::GetDuration() const
|
||||
{
|
||||
|
@ -118,8 +113,6 @@ float Music::GetDuration() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see SoundStream::OnGetData
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Music::OnGetData(SoundStream::Chunk& data)
|
||||
{
|
||||
|
|
|
@ -33,8 +33,6 @@
|
|||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
////////////////////////////////////////////////////////////
|
||||
Sound::Sound()
|
||||
{
|
||||
ALCheck(alGenSources(1, &mySource));
|
||||
|
@ -42,8 +40,6 @@ Sound::Sound()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Construct the sound from its parameters
|
||||
////////////////////////////////////////////////////////////
|
||||
Sound::Sound(const SoundBuffer& buffer, bool loop, float pitch, float volume, const Vector3f& position) :
|
||||
myBuffer(NULL)
|
||||
|
@ -58,8 +54,6 @@ myBuffer(NULL)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Copy constructor
|
||||
////////////////////////////////////////////////////////////
|
||||
Sound::Sound(const Sound& copy) :
|
||||
myBuffer(NULL)
|
||||
|
@ -78,8 +72,6 @@ myBuffer(NULL)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
////////////////////////////////////////////////////////////
|
||||
Sound::~Sound()
|
||||
{
|
||||
|
@ -95,8 +87,6 @@ Sound::~Sound()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Play the sound
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::Play()
|
||||
{
|
||||
|
@ -104,8 +94,6 @@ void Sound::Play()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Pause the sound
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::Pause()
|
||||
{
|
||||
|
@ -113,8 +101,6 @@ void Sound::Pause()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Stop the sound
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::Stop()
|
||||
{
|
||||
|
@ -122,8 +108,6 @@ void Sound::Stop()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the source buffer
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::SetBuffer(const SoundBuffer& buffer)
|
||||
{
|
||||
|
@ -132,8 +116,6 @@ void Sound::SetBuffer(const SoundBuffer& buffer)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the sound loop state
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::SetLoop(bool Loop)
|
||||
{
|
||||
|
@ -141,8 +123,6 @@ void Sound::SetLoop(bool Loop)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the sound pitch
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::SetPitch(float pitch)
|
||||
{
|
||||
|
@ -150,17 +130,12 @@ void Sound::SetPitch(float pitch)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the sound volume
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::SetVolume(float volume)
|
||||
{
|
||||
ALCheck(alSourcef(mySource, AL_GAIN, volume * 0.01f));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the sound position (take 3 values).
|
||||
/// The default position is (0, 0, 0)
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::SetPosition(float x, float y, float z)
|
||||
{
|
||||
|
@ -168,9 +143,6 @@ void Sound::SetPosition(float x, float y, float z)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the sound position (take a 3D vector).
|
||||
/// The default position is (0, 0, 0)
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::SetPosition(const Vector3f& position)
|
||||
{
|
||||
|
@ -178,10 +150,6 @@ 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)
|
||||
{
|
||||
|
@ -189,10 +157,6 @@ void Sound::SetRelativeToListener(bool 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
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::SetMinDistance(float distance)
|
||||
{
|
||||
|
@ -200,10 +164,6 @@ void Sound::SetMinDistance(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
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::SetAttenuation(float attenuation)
|
||||
{
|
||||
|
@ -211,8 +171,6 @@ void Sound::SetAttenuation(float attenuation)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the current playing position of the sound
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::SetPlayingOffset(float timeOffset)
|
||||
{
|
||||
|
@ -220,8 +178,6 @@ void Sound::SetPlayingOffset(float timeOffset)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the source buffer
|
||||
////////////////////////////////////////////////////////////
|
||||
const SoundBuffer* Sound::GetBuffer() const
|
||||
{
|
||||
|
@ -229,8 +185,6 @@ const SoundBuffer* Sound::GetBuffer() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Tell whether or not the sound is looping
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Sound::GetLoop() const
|
||||
{
|
||||
|
@ -241,8 +195,6 @@ bool Sound::GetLoop() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the pitch
|
||||
////////////////////////////////////////////////////////////
|
||||
float Sound::GetPitch() const
|
||||
{
|
||||
|
@ -253,8 +205,6 @@ float Sound::GetPitch() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the volume
|
||||
////////////////////////////////////////////////////////////
|
||||
float Sound::GetVolume() const
|
||||
{
|
||||
|
@ -265,8 +215,6 @@ float Sound::GetVolume() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the sound position
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector3f Sound::GetPosition() const
|
||||
{
|
||||
|
@ -277,9 +225,6 @@ 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
|
||||
{
|
||||
|
@ -290,8 +235,6 @@ bool Sound::IsRelativeToListener() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the minimum distance
|
||||
////////////////////////////////////////////////////////////
|
||||
float Sound::GetMinDistance() const
|
||||
{
|
||||
|
@ -302,8 +245,6 @@ float Sound::GetMinDistance() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the attenuation factor
|
||||
////////////////////////////////////////////////////////////
|
||||
float Sound::GetAttenuation() const
|
||||
{
|
||||
|
@ -314,8 +255,6 @@ float Sound::GetAttenuation() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the current playing position of the sound
|
||||
////////////////////////////////////////////////////////////
|
||||
float Sound::GetPlayingOffset() const
|
||||
{
|
||||
|
@ -326,8 +265,6 @@ float Sound::GetPlayingOffset() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the status of the sound (stopped, paused, playing)
|
||||
////////////////////////////////////////////////////////////
|
||||
Sound::Status Sound::GetStatus() const
|
||||
{
|
||||
|
@ -346,8 +283,6 @@ Sound::Status Sound::GetStatus() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Assignment operator
|
||||
////////////////////////////////////////////////////////////
|
||||
Sound& Sound::operator =(const Sound& other)
|
||||
{
|
||||
|
|
|
@ -36,8 +36,6 @@
|
|||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
////////////////////////////////////////////////////////////
|
||||
SoundBuffer::SoundBuffer() :
|
||||
myBuffer (0),
|
||||
myDuration(0.f)
|
||||
|
@ -47,8 +45,6 @@ myDuration(0.f)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Copy constructor
|
||||
////////////////////////////////////////////////////////////
|
||||
SoundBuffer::SoundBuffer(const SoundBuffer& copy) :
|
||||
Resource<SoundBuffer>(copy),
|
||||
|
@ -64,8 +60,6 @@ myDuration (copy.myDuration)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
////////////////////////////////////////////////////////////
|
||||
SoundBuffer::~SoundBuffer()
|
||||
{
|
||||
|
@ -74,8 +68,6 @@ SoundBuffer::~SoundBuffer()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Load the sound buffer from a file
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBuffer::LoadFromFile(const std::string& filename)
|
||||
{
|
||||
|
@ -107,8 +99,6 @@ bool SoundBuffer::LoadFromFile(const std::string& filename)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Load the sound buffer from a file in memory
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBuffer::LoadFromMemory(const char* data, std::size_t sizeInBytes)
|
||||
{
|
||||
|
@ -140,9 +130,6 @@ bool SoundBuffer::LoadFromMemory(const char* data, std::size_t sizeInBytes)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Load the sound buffer from an array of samples - assumed format for
|
||||
/// samples is 16 bits signed integer
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBuffer::LoadFromSamples(const Int16* samples, std::size_t samplesCount, unsigned int channelsCount, unsigned int sampleRate)
|
||||
{
|
||||
|
@ -169,8 +156,6 @@ bool SoundBuffer::LoadFromSamples(const Int16* samples, std::size_t samplesCount
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Save the sound buffer to a file
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBuffer::SaveToFile(const std::string& filename) const
|
||||
{
|
||||
|
@ -190,8 +175,6 @@ bool SoundBuffer::SaveToFile(const std::string& filename) const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Return the sound samples
|
||||
////////////////////////////////////////////////////////////
|
||||
const Int16* SoundBuffer::GetSamples() const
|
||||
{
|
||||
|
@ -199,8 +182,6 @@ const Int16* SoundBuffer::GetSamples() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Return the samples count
|
||||
////////////////////////////////////////////////////////////
|
||||
std::size_t SoundBuffer::GetSamplesCount() const
|
||||
{
|
||||
|
@ -208,8 +189,6 @@ std::size_t SoundBuffer::GetSamplesCount() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the sample rate
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int SoundBuffer::GetSampleRate() const
|
||||
{
|
||||
|
@ -220,8 +199,6 @@ unsigned int SoundBuffer::GetSampleRate() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Return the number of channels (1 = mono, 2 = stereo, ...)
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int SoundBuffer::GetChannelsCount() const
|
||||
{
|
||||
|
@ -232,8 +209,6 @@ unsigned int SoundBuffer::GetChannelsCount() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the sound duration
|
||||
////////////////////////////////////////////////////////////
|
||||
float SoundBuffer::GetDuration() const
|
||||
{
|
||||
|
@ -241,8 +216,6 @@ float SoundBuffer::GetDuration() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Assignment operator
|
||||
////////////////////////////////////////////////////////////
|
||||
SoundBuffer& SoundBuffer::operator =(const SoundBuffer& other)
|
||||
{
|
||||
|
@ -256,8 +229,6 @@ SoundBuffer& SoundBuffer::operator =(const SoundBuffer& other)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Update the internal buffer with the audio samples
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBuffer::Update(unsigned int channelsCount, unsigned int sampleRate)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue