CSFML - C binding of the Simple and Fast Multimedia Library

CSFML 2.6.1

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

Loading...
Searching...
No Matches
Classes | 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.

## Classes
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.
typedef void(* | sfSoundStreamSeekCallback) (sfTime, void *)
| Type of the callback used to seek in a sound stream.

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

## Typedef Documentation

## ◆ sfSoundStreamGetDataCallback

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

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

Definition at line 48 of file SoundStream.h.

## ◆ sfSoundStreamSeekCallback

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

## ◆ sfSoundStream_create()

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

## ◆ sfSoundStream_destroy()

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

Destroy a sound stream.

Parameters

  soundStream | Sound stream to destroy

## ◆ sfSoundStream_getAttenuation()

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

## ◆ sfSoundStream_getChannelCount()

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

## ◆ sfSoundStream_getLoop()

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

## ◆ sfSoundStream_getMinDistance()

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

## ◆ sfSoundStream_getPitch()

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

Get the pitch of a sound stream.

Parameters

  soundStream | Sound stream object

Returns
  Pitch of the stream

## ◆ sfSoundStream_getPlayingOffset()

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

Get the current playing position of a sound stream.

Parameters

  soundStream | Sound stream object

Returns
  Current playing position

## ◆ sfSoundStream_getPosition()

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

## ◆ sfSoundStream_getSampleRate()

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

## ◆ sfSoundStream_getStatus()

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

## ◆ sfSoundStream_getVolume()

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]

## ◆ sfSoundStream_isRelativeToListener()

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

## ◆ sfSoundStream_pause()

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

## ◆ sfSoundStream_play()

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

## ◆ sfSoundStream_setAttenuation()

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

## ◆ sfSoundStream_setLoop()

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

## ◆ sfSoundStream_setMinDistance()

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

## ◆ sfSoundStream_setPitch()

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

## ◆ sfSoundStream_setPlayingOffset()

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

## ◆ sfSoundStream_setPosition()

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

## ◆ sfSoundStream_setRelativeToListener()

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

## ◆ sfSoundStream_setVolume()

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

## ◆ sfSoundStream_stop()

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