CSFML

- Main Page
- Data Structures
- Files

- File List
- Globals

Data Structures | Typedefs | Functions
SoundStream.h File Reference
`#include <SFML/Audio/Export.h>`
`#include <SFML/Audio/SoundStatus.h>`
`#include <SFML/Audio/Types.h>`
`#include <SFML/System/Time.h>`
`#include <SFML/System/Vector3.h>`

Go to the source code of this file.

## Data Structures
struct | sfSoundStreamChunk
| defines the data to fill by the OnGetData callback More...

## Typedefs
typedef sfBool(* | sfSoundStreamGetDataCallback )(sfSoundStreamChunk *, void *)
| Type of the callback used to get a sound stream data. More...
typedef void(* | sfSoundStreamSeekCallback )(sfTime, void *)
| Type of the callback used to seek in a sound stream. More...

## Functions
CSFML_AUDIO_API sfSoundStream * | sfSoundStream_create (sfSoundStreamGetDataCallback onGetData, sfSoundStreamSeekCallback onSeek, unsigned int channelCount, unsigned int sampleRate, void *userData)
| Create a new sound stream. More...
CSFML_AUDIO_API void | sfSoundStream_destroy (sfSoundStream *soundStream)
| Destroy a sound stream. More...
CSFML_AUDIO_API void | sfSoundStream_play (sfSoundStream *soundStream)
| Start or resume playing a sound stream. More...
CSFML_AUDIO_API void | sfSoundStream_pause (sfSoundStream *soundStream)
| Pause a sound stream. More...
CSFML_AUDIO_API void | sfSoundStream_stop (sfSoundStream *soundStream)
| Stop playing a sound stream. More...
CSFML_AUDIO_API sfSoundStatus | sfSoundStream_getStatus (const sfSoundStream *soundStream)
| Get the current status of a sound stream (stopped, paused, playing) More...
CSFML_AUDIO_API unsigned int | sfSoundStream_getChannelCount (const sfSoundStream *soundStream)
| Return the number of channels of a sound stream. More...
CSFML_AUDIO_API unsigned int | sfSoundStream_getSampleRate (const sfSoundStream *soundStream)
| Get the sample rate of a sound stream. More...
CSFML_AUDIO_API void | sfSoundStream_setPitch (sfSoundStream *soundStream, float pitch)
| Set the pitch of a sound stream. More...
CSFML_AUDIO_API void | sfSoundStream_setVolume (sfSoundStream *soundStream, float volume)
| Set the volume of a sound stream. More...
CSFML_AUDIO_API void | sfSoundStream_setPosition (sfSoundStream *soundStream, sfVector3f position)
| Set the 3D position of a sound stream in the audio scene. More...
CSFML_AUDIO_API void | sfSoundStream_setRelativeToListener (sfSoundStream *soundStream, sfBool relative)
| Make a sound stream's position relative to the listener or absolute. More...
CSFML_AUDIO_API void | sfSoundStream_setMinDistance (sfSoundStream *soundStream, float distance)
| Set the minimum distance of a sound stream. More...
CSFML_AUDIO_API void | sfSoundStream_setAttenuation (sfSoundStream *soundStream, float attenuation)
| Set the attenuation factor of a sound stream. More...
CSFML_AUDIO_API void | sfSoundStream_setPlayingOffset (sfSoundStream *soundStream, sfTime timeOffset)
| Change the current playing position of a sound stream. More...
CSFML_AUDIO_API void | sfSoundStream_setLoop (sfSoundStream *soundStream, sfBool loop)
| Set whether or not a sound stream should loop after reaching the end. More...
CSFML_AUDIO_API float | sfSoundStream_getPitch (const sfSoundStream *soundStream)
| Get the pitch of a sound stream. More...
CSFML_AUDIO_API float | sfSoundStream_getVolume (const sfSoundStream *soundStream)
| Get the volume of a sound stream. More...
CSFML_AUDIO_API sfVector3f | sfSoundStream_getPosition (const sfSoundStream *soundStream)
| Get the 3D position of a sound stream in the audio scene. More...
CSFML_AUDIO_API sfBool | sfSoundStream_isRelativeToListener (const sfSoundStream *soundStream)
| Tell whether a sound stream's position is relative to the listener or is absolute. More...
CSFML_AUDIO_API float | sfSoundStream_getMinDistance (const sfSoundStream *soundStream)
| Get the minimum distance of a sound stream. More...
CSFML_AUDIO_API float | sfSoundStream_getAttenuation (const sfSoundStream *soundStream)
| Get the attenuation factor of a sound stream. More...
CSFML_AUDIO_API sfBool | sfSoundStream_getLoop (const sfSoundStream *soundStream)
| Tell whether or not a sound stream is in loop mode. More...
CSFML_AUDIO_API sfTime | sfSoundStream_getPlayingOffset (const sfSoundStream *soundStream)
| Get the current playing position of a sound stream. More...

## Typedef Documentation

typedef sfBool(* sfSoundStreamGetDataCallback)(sfSoundStreamChunk *, void *)

Type of the callback used to get a sound stream data.

Definition at line 48 of file SoundStream.h.

typedef void(* sfSoundStreamSeekCallback)(sfTime, void *)

Type of the callback used to seek in a sound stream.

Definition at line 49 of file SoundStream.h.

## Function Documentation

CSFML_AUDIO_API sfSoundStream* sfSoundStream_create | ( | sfSoundStreamGetDataCallback | onGetData,
|  | sfSoundStreamSeekCallback | onSeek,
|  | unsigned int | channelCount,
|  | unsigned int | sampleRate,
|  | void * | userData
| ) |  |

Create a new sound stream.

Parameters

  onGetData | Function called when the stream needs more data (can't be NULL)
  onSeek | Function called when the stream seeks (can't be NULL)
  channelCount | Number of channels to use (1 = mono, 2 = stereo)
  sampleRate | Sample rate of the sound (44100 = CD quality)
  userData | Data to pass to the callback functions

Returns
  A new sfSoundStream object

CSFML_AUDIO_API void sfSoundStream_destroy | ( | sfSoundStream * | soundStream) |  |

Destroy a sound stream.

Parameters

  soundStream | Sound stream to destroy

CSFML_AUDIO_API float sfSoundStream_getAttenuation | ( | const sfSoundStream * | soundStream) |  |

Get the attenuation factor of a sound stream.

Parameters

  soundStream | Sound stream object

Returns
  Attenuation factor of the stream

CSFML_AUDIO_API unsigned int sfSoundStream_getChannelCount | ( | const sfSoundStream * | soundStream) |  |

Return the number of channels of a sound stream.

1 channel means a mono sound, 2 means stereo, etc.

Parameters

  soundStream | Sound stream object

Returns
  Number of channels

CSFML_AUDIO_API sfBool sfSoundStream_getLoop | ( | const sfSoundStream * | soundStream) |  |

Tell whether or not a sound stream is in loop mode.

Parameters

  soundStream | Sound stream object

Returns
  sfTrue if the music is looping, sfFalse otherwise

CSFML_AUDIO_API float sfSoundStream_getMinDistance | ( | const sfSoundStream * | soundStream) |  |

Get the minimum distance of a sound stream.

Parameters

  soundStream | Sound stream object

Returns
  Minimum distance of the stream

CSFML_AUDIO_API float sfSoundStream_getPitch | ( | const sfSoundStream * | soundStream) |  |

Get the pitch of a sound stream.

Parameters

  soundStream | Sound stream object

Returns
  Pitch of the stream

CSFML_AUDIO_API sfTime sfSoundStream_getPlayingOffset | ( | const sfSoundStream * | soundStream) |  |

Get the current playing position of a sound stream.

Parameters

  soundStream | Sound stream object

Returns
  Current playing position

CSFML_AUDIO_API sfVector3f sfSoundStream_getPosition | ( | const sfSoundStream * | soundStream) |  |

Get the 3D position of a sound stream in the audio scene.

Parameters

  soundStream | Sound stream object

Returns
  Position of the stream in the world

CSFML_AUDIO_API unsigned int sfSoundStream_getSampleRate | ( | const sfSoundStream * | soundStream) |  |

Get the sample rate of a sound stream.

The sample rate is the number of audio samples played per second. The higher, the better the quality.

Parameters

  soundStream | Sound stream object

Returns
  Sample rate, in number of samples per second

CSFML_AUDIO_API sfSoundStatus sfSoundStream_getStatus | ( | const sfSoundStream * | soundStream) |  |

Get the current status of a sound stream (stopped, paused, playing)

Parameters

  soundStream | Sound stream object

Returns
  Current status

CSFML_AUDIO_API float sfSoundStream_getVolume | ( | const sfSoundStream * | soundStream) |  |

Get the volume of a sound stream.

Parameters

  soundStream | Sound stream object

Returns
  Volume of the stream, in the range [0, 100]

CSFML_AUDIO_API sfBool sfSoundStream_isRelativeToListener | ( | const sfSoundStream * | soundStream) |  |

Tell whether a sound stream's position is relative to the listener or is absolute.

Parameters

  soundStream | Sound stream object

Returns
  sfTrue if the position is relative, sfFalse if it's absolute

CSFML_AUDIO_API void sfSoundStream_pause | ( | sfSoundStream * | soundStream) |  |

Pause a sound stream.

This function pauses the stream if it was playing, otherwise (stream already paused or stopped) it has no effect.

Parameters

  soundStream | Sound stream object

CSFML_AUDIO_API void sfSoundStream_play | ( | sfSoundStream * | soundStream) |  |

Start or resume playing a sound stream.

This function starts the stream if it was stopped, resumes it if it was paused, and restarts it from beginning if it was it already playing. This function uses its own thread so that it doesn't block the rest of the program while the music is played.

Parameters

  soundStream | Sound stream object

CSFML_AUDIO_API void sfSoundStream_setAttenuation | ( | sfSoundStream * | soundStream,
|  | float | attenuation
| ) |  |

Set the attenuation factor of a sound stream.

The attenuation is a multiplicative factor which makes the stream more or less loud according to its distance from the listener. An attenuation of 0 will produce a non-attenuated stream, i.e. its volume will always be the same whether it is heard from near or from far. On the other hand, an attenuation value such as 100 will make the stream fade out very quickly as it gets further from the listener. The default value of the attenuation is 1.

Parameters

  soundStream | Sound stream object
  attenuation | New attenuation factor of the stream

CSFML_AUDIO_API void sfSoundStream_setLoop | ( | sfSoundStream * | soundStream,
|  | sfBool | loop
| ) |  |

Set whether or not a sound stream should loop after reaching the end.

If set, the stream will restart from beginning after reaching the end and so on, until it is stopped or sfSoundStream_setLoop(stream, sfFalse) is called. The default looping state for sound streams is false.

Parameters

  soundStream | Sound stream object
  loop | sfTrue to play in loop, sfFalse to play once

CSFML_AUDIO_API void sfSoundStream_setMinDistance | ( | sfSoundStream * | soundStream,
|  | float | distance
| ) |  |

Set the minimum distance of a sound stream.

The "minimum distance" of a stream is the maximum distance at which it is heard at its maximum volume. Further than the minimum distance, it will start to fade out according to its attenuation factor. A value of 0 ("inside the head of the listener") is an invalid value and is forbidden. The default value of the minimum distance is 1.

Parameters

  soundStream | Sound stream object
  distance | New minimum distance of the stream

CSFML_AUDIO_API void sfSoundStream_setPitch | ( | sfSoundStream * | soundStream,
|  | float | pitch
| ) |  |

Set the pitch of a sound stream.

The pitch represents the perceived fundamental frequency of a sound; thus you can make a stream more acute or grave by changing its pitch. A side effect of changing the pitch is to modify the playing speed of the stream as well. The default value for the pitch is 1.

Parameters

  soundStream | Sound stream object
  pitch | New pitch to apply to the stream

CSFML_AUDIO_API void sfSoundStream_setPlayingOffset | ( | sfSoundStream * | soundStream,
|  | sfTime | timeOffset
| ) |  |

Change the current playing position of a sound stream.

The playing position can be changed when the stream is either paused or playing.

Parameters

  soundStream | Sound stream object
  timeOffset | New playing position

CSFML_AUDIO_API void sfSoundStream_setPosition | ( | sfSoundStream * | soundStream,
|  | sfVector3f | position
| ) |  |

Set the 3D position of a sound stream in the audio scene.

Only streams with one channel (mono streams) can be spatialized. The default position of a stream is (0, 0, 0).

Parameters

  soundStream | Sound stream object
  position | Position of the stream in the scene

CSFML_AUDIO_API void sfSoundStream_setRelativeToListener | ( | sfSoundStream * | soundStream,
|  | sfBool | relative
| ) |  |

Make a sound stream's position relative to the listener or absolute.

Making a stream relative to the listener will ensure that it will always be played the same way regardless the position of the listener. This can be useful for non-spatialized streams, streams that are produced by the listener, or streams attached to it. The default value is false (position is absolute).

Parameters

  soundStream | Sound stream object
  relative | sfTrue to set the position relative, sfFalse to set it absolute

CSFML_AUDIO_API void sfSoundStream_setVolume | ( | sfSoundStream * | soundStream,
|  | float | volume
| ) |  |

Set the volume of a sound stream.

The volume is a value between 0 (mute) and 100 (full volume). The default value for the volume is 100.

Parameters

  soundStream | Sound stream object
  volume | Volume of the stream

CSFML_AUDIO_API void sfSoundStream_stop | ( | sfSoundStream * | soundStream) |  |

Stop playing a sound stream.

This function stops the stream if it was playing or paused, and does nothing if it was already stopped. It also resets the playing position (unlike sfSoundStream_pause).

Parameters

  soundStream | Sound stream object