Music.h File Reference

#include <SFML/Config.h>
#include <SFML/Audio/SoundStatus.h>
#include <SFML/Audio/Types.h>

Go to the source code of this file.


Functions

CSFML_API sfMusicsfMusic_CreateFromFile (const char *Filename)
 Create a new music and load it from a file.
CSFML_API sfMusicsfMusic_CreateFromMemory (const char *Data, size_t SizeInBytes)
 Create a new music and load it from a file in memory.
CSFML_API void sfMusic_Destroy (sfMusic *Music)
 Destroy an existing music.
CSFML_API void sfMusic_SetLoop (sfMusic *Music, sfBool Loop)
 Set a music loop state.
CSFML_API sfBool sfMusic_GetLoop (sfMusic *Music)
 Tell whether or not a music is looping.
CSFML_API float sfMusic_GetDuration (sfMusic *Music)
 Get a music duration.
CSFML_API void sfMusic_Play (sfMusic *Music)
 Start playing a music.
CSFML_API void sfMusic_Pause (sfMusic *Music)
 Pause a music.
CSFML_API void sfMusic_Stop (sfMusic *Music)
 Stop playing a music.
CSFML_API unsigned int sfMusic_GetChannelsCount (sfMusic *Music)
 Return the number of channels of a music (1 = mono, 2 = stereo).
CSFML_API unsigned int sfMusic_GetSampleRate (sfMusic *Music)
 Get the stream sample rate of a music.
CSFML_API sfSoundStatus sfMusic_GetStatus (sfMusic *Music)
 Get the status of a music (stopped, paused, playing).
CSFML_API float sfMusic_GetPlayingOffset (sfMusic *Music)
 Get the current playing position of a music.
CSFML_API void sfMusic_SetPitch (sfMusic *Music, float Pitch)
 Set the pitch of a music.
CSFML_API void sfMusic_SetVolume (sfMusic *Music, float Volume)
 Set the volume of a music.
CSFML_API void sfMusic_SetPosition (sfMusic *Music, float X, float Y, float Z)
 Set the position of a music.
CSFML_API void sfMusic_SetRelativeToListener (sfMusic *Music, sfBool Relative)
 Make the music's position relative to the listener's position, or absolute.
CSFML_API void sfMusic_SetMinDistance (sfMusic *Music, float MinDistance)
 Set the minimum distance - closer than this distance, the listener will hear the music at its maximum volume.
CSFML_API void sfMusic_SetAttenuation (sfMusic *Music, float Attenuation)
 Set the attenuation factor - the higher the attenuation, the more the sound will be attenuated with distance from listener.
CSFML_API float sfMusic_GetPitch (sfMusic *Music)
 Get the pitch of a music.
CSFML_API float sfMusic_GetVolume (sfMusic *Music)
 Get the volume of a music.
CSFML_API void sfMusic_GetPosition (sfMusic *Music, float *X, float *Y, float *Z)
 Get the position of a music.
CSFML_API sfBool sfMusic_IsRelativeToListener (sfMusic *Music)
 Tell if the music's position is relative to the listener's position, or if it's absolute.
CSFML_API float sfMusic_GetMinDistance (sfMusic *Music)
 Get the minimum distance of a music.
CSFML_API float sfMusic_GetAttenuation (sfMusic *Music)
 Get the attenuation factor of a music.

Function Documentation

CSFML_API sfMusic* sfMusic_CreateFromFile ( const char *  Filename  ) 

Create a new music and load it from a file.

Parameters:
Filename : Path of the music file to open
Returns:
A new sfMusic object (NULL if failed)

CSFML_API sfMusic* sfMusic_CreateFromMemory ( const char *  Data,
size_t  SizeInBytes 
)

Create a new music and load it from a file in memory.

Parameters:
Data : Pointer to the file data in memory
SizeInBytes : Size of the data to load, in bytes
Returns:
A new sfMusic object (NULL if failed)

CSFML_API void sfMusic_Destroy ( sfMusic Music  ) 

Destroy an existing music.

Parameters:
Music : Music to delete

CSFML_API float sfMusic_GetAttenuation ( sfMusic Music  ) 

Get the attenuation factor of a music.

Parameters:
Music : Music to get the attenuation factor from
Returns:
Attenuation factor for the a music

CSFML_API unsigned int sfMusic_GetChannelsCount ( sfMusic Music  ) 

Return the number of channels of a music (1 = mono, 2 = stereo).

Parameters:
Music : Music to get the channels count from
Returns:
Number of channels

CSFML_API float sfMusic_GetDuration ( sfMusic Music  ) 

Get a music duration.

Parameters:
Music : Music to get the duration from
Returns:
Music duration, in seconds

CSFML_API sfBool sfMusic_GetLoop ( sfMusic Music  ) 

Tell whether or not a music is looping.

Parameters:
Music : Music to get the loop state from
Returns:
sfTrue if the music is looping, sfFalse otherwise

CSFML_API float sfMusic_GetMinDistance ( sfMusic Music  ) 

Get the minimum distance of a music.

Parameters:
Music : Music to get the minimum distance from
Returns:
Minimum distance for the music

CSFML_API float sfMusic_GetPitch ( sfMusic Music  ) 

Get the pitch of a music.

Parameters:
Music : Music to get the pitch from
Returns:
Pitch value

CSFML_API float sfMusic_GetPlayingOffset ( sfMusic Music  ) 

Get the current playing position of a music.

Parameters:
Music : Music to get the position from
Returns:
Current playing position, expressed in seconds

CSFML_API void sfMusic_GetPosition ( sfMusic Music,
float *  X,
float *  Y,
float *  Z 
)

Get the position of a music.

Parameters:
Music : Music to get the position from
X : X position of the sound in the world
Y : Y position of the sound in the world
Z : Z position of the sound in the world

CSFML_API unsigned int sfMusic_GetSampleRate ( sfMusic Music  ) 

Get the stream sample rate of a music.

Parameters:
Music : Music to get the sample rate from
Returns:
Stream frequency (number of samples per second)

CSFML_API sfSoundStatus sfMusic_GetStatus ( sfMusic Music  ) 

Get the status of a music (stopped, paused, playing).

Parameters:
Music : Music to get the status from
Returns:
Current status of the sound

CSFML_API float sfMusic_GetVolume ( sfMusic Music  ) 

Get the volume of a music.

Parameters:
Music : Music to get the volume from
Returns:
Volume value (in range [1, 100])

CSFML_API sfBool sfMusic_IsRelativeToListener ( sfMusic Music  ) 

Tell if the music's position is relative to the listener's position, or if it's absolute.

Parameters:
Music : Music to check
Returns:
sfTrue if the position is relative, sfFalse if it's absolute

CSFML_API void sfMusic_Pause ( sfMusic Music  ) 

Pause a music.

Parameters:
Music : Music to pause

CSFML_API void sfMusic_Play ( sfMusic Music  ) 

Start playing a music.

Parameters:
Music : Music to play

CSFML_API void sfMusic_SetAttenuation ( sfMusic Music,
float  Attenuation 
)

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

Parameters:
Sound : Sound to modify
Attenuation : New attenuation factor for the sound

CSFML_API void sfMusic_SetLoop ( sfMusic Music,
sfBool  Loop 
)

Set a music loop state.

Parameters:
Music : Music to set the loop state
Loop : sfTrue to play in loop, sfFalse to play once

CSFML_API void sfMusic_SetMinDistance ( sfMusic Music,
float  MinDistance 
)

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

Parameters:
Music : Music to modify
MinDistance : New minimum distance for the music

CSFML_API void sfMusic_SetPitch ( sfMusic Music,
float  Pitch 
)

Set the pitch of a music.

Parameters:
Music : Music to modify
Pitch : New pitch

CSFML_API void sfMusic_SetPosition ( sfMusic Music,
float  X,
float  Y,
float  Z 
)

Set the position of a music.

Parameters:
Music : Music to modify
X : X position of the sound in the world
Y : Y position of the sound in the world
Z : Z position of the sound in the world

CSFML_API void sfMusic_SetRelativeToListener ( sfMusic Music,
sfBool  Relative 
)

Make the music's position relative to the listener's position, or absolute.

The default value is false (absolute)

Parameters:
Music : Music to modify
Relative : True to set the position relative, false to set it absolute

CSFML_API void sfMusic_SetVolume ( sfMusic Music,
float  Volume 
)

Set the volume of a music.

Parameters:
Music : Music to modify
Volume : Volume (in range [0, 100])

CSFML_API void sfMusic_Stop ( sfMusic Music  ) 

Stop playing a music.

Parameters:
Music : Music to stop