CSFML 3.0.0
Loading...
Searching...
No Matches
SoundStream.h
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#pragma once
26
28// Headers
30#include <CSFML/Audio/Export.h>
31
32#include <CSFML/Audio/EffectProcessor.h>
33#include <CSFML/Audio/SoundChannel.h>
34#include <CSFML/Audio/SoundSourceCone.h>
35#include <CSFML/Audio/SoundStatus.h>
36#include <CSFML/Audio/Types.h>
37#include <CSFML/System/Time.h>
38#include <CSFML/System/Vector3.h>
39
40#include <stddef.h>
41
42
47 typedef struct
48{
49 int16_t* samples;
50 unsigned int sampleCount;
51} sfSoundStreamChunk;
52
53 typedef bool (*sfSoundStreamGetDataCallback)(sfSoundStreamChunk*, void*);
54 typedef void (*sfSoundStreamSeekCallback)(sfTime, void*);
55
56
71 CSFML_AUDIO_API sfSoundStream* sfSoundStream_create(
72 sfSoundStreamGetDataCallback onGetData,
73 sfSoundStreamSeekCallback onSeek,
74 unsigned int channelCount,
75 unsigned int sampleRate,
76 sfSoundChannel* channelMapData,
77 size_t channelMapSize,
78 void* userData);
79
86 CSFML_AUDIO_API void sfSoundStream_destroy(const sfSoundStream* soundStream);
87
100 CSFML_AUDIO_API void sfSoundStream_play(sfSoundStream* soundStream);
101
111 CSFML_AUDIO_API void sfSoundStream_pause(sfSoundStream* soundStream);
112
123 CSFML_AUDIO_API void sfSoundStream_stop(sfSoundStream* soundStream);
124
133 CSFML_AUDIO_API sfSoundStatus sfSoundStream_getStatus(const sfSoundStream* soundStream);
134
145 CSFML_AUDIO_API unsigned int sfSoundStream_getChannelCount(const sfSoundStream* soundStream);
146
158 CSFML_AUDIO_API unsigned int sfSoundStream_getSampleRate(const sfSoundStream* soundStream);
159
172 CSFML_AUDIO_API sfSoundChannel* sfSoundStream_getChannelMap(const sfSoundStream* soundStream, size_t* count);
173
187 CSFML_AUDIO_API void sfSoundStream_setPitch(sfSoundStream* soundStream, float pitch);
188
201 CSFML_AUDIO_API void sfSoundStream_setPan(sfSoundStream* soundStream, float pan);
202
213 CSFML_AUDIO_API void sfSoundStream_setVolume(sfSoundStream* soundStream, float volume);
214
227 CSFML_AUDIO_API void sfSoundStream_setSpatializationEnabled(sfSoundStream* soundStream, bool enabled);
228
240 CSFML_AUDIO_API void sfSoundStream_setPosition(sfSoundStream* soundStream, sfVector3f position);
241
254 CSFML_AUDIO_API void sfSoundStream_setDirection(sfSoundStream* soundStream, sfVector3f direction);
255
266 CSFML_AUDIO_API void sfSoundStream_setCone(sfSoundStream* soundStream, sfSoundSourceCone cone);
267
280 CSFML_AUDIO_API void sfSoundStream_setVelocity(sfSoundStream* soundStream, sfVector3f velocity);
281
292 CSFML_AUDIO_API void sfSoundStream_setDopplerFactor(sfSoundStream* soundStream, float factor);
293
308 CSFML_AUDIO_API void sfSoundStream_setDirectionalAttenuationFactor(sfSoundStream* soundStream, float factor);
309
323 CSFML_AUDIO_API void sfSoundStream_setRelativeToListener(sfSoundStream* soundStream, bool relative);
324
339 CSFML_AUDIO_API void sfSoundStream_setMinDistance(sfSoundStream* soundStream, float distance);
340
355 CSFML_AUDIO_API void sfSoundStream_setMaxDistance(sfSoundStream* soundStream, float distance);
356
368 CSFML_AUDIO_API void sfSoundStream_setMinGain(sfSoundStream* soundStream, float gain);
369
381 CSFML_AUDIO_API void sfSoundStream_setMaxGain(sfSoundStream* soundStream, float gain);
382
399 CSFML_AUDIO_API void sfSoundStream_setAttenuation(sfSoundStream* soundStream, float attenuation);
400
411 CSFML_AUDIO_API void sfSoundStream_setPlayingOffset(sfSoundStream* soundStream, sfTime timeOffset);
412
425 CSFML_AUDIO_API void sfSoundStream_setLooping(sfSoundStream* soundStream, bool loop);
426
435 CSFML_AUDIO_API float sfSoundStream_getPitch(const sfSoundStream* soundStream);
436
445 CSFML_AUDIO_API float sfSoundStream_getPan(const sfSoundStream* soundStream);
446
455 CSFML_AUDIO_API float sfSoundStream_getVolume(const sfSoundStream* soundStream);
456
465 CSFML_AUDIO_API bool sfSoundStream_isSpatializationEnabled(const sfSoundStream* soundStream);
466
475 CSFML_AUDIO_API sfVector3f sfSoundStream_getPosition(const sfSoundStream* soundStream);
476
485 CSFML_AUDIO_API sfVector3f sfSoundStream_getDirection(const sfSoundStream* soundStream);
486
495 CSFML_AUDIO_API sfSoundSourceCone sfSoundStream_getCone(const sfSoundStream* soundStream);
496
505 CSFML_AUDIO_API sfVector3f sfSoundStream_getVelocity(const sfSoundStream* soundStream);
506
515 CSFML_AUDIO_API float sfSoundStream_getDopplerFactor(const sfSoundStream* soundStream);
516
525 CSFML_AUDIO_API float sfSoundStream_getDirectionalAttenuationFactor(const sfSoundStream* soundStream);
526
536 CSFML_AUDIO_API bool sfSoundStream_isRelativeToListener(const sfSoundStream* soundStream);
537
546 CSFML_AUDIO_API float sfSoundStream_getMinDistance(const sfSoundStream* soundStream);
547
556 CSFML_AUDIO_API float sfSoundStream_getMaxDistance(const sfSoundStream* soundStream);
557
566 CSFML_AUDIO_API float sfSoundStream_getMinGain(const sfSoundStream* soundStream);
567
576 CSFML_AUDIO_API float sfSoundStream_getMaxGain(const sfSoundStream* soundStream);
577
586 CSFML_AUDIO_API float sfSoundStream_getAttenuation(const sfSoundStream* soundStream);
587
596 CSFML_AUDIO_API bool sfSoundStream_isLooping(const sfSoundStream* soundStream);
597
608 CSFML_AUDIO_API void sfSoundStream_setEffectProcessor(sfSoundStream* soundStream, sfEffectProcessor effectProcessor);
609
618 CSFML_AUDIO_API sfTime sfSoundStream_getPlayingOffset(const sfSoundStream* soundStream);
Export.h
CSFML_AUDIO_API
#define CSFML_AUDIO_API
Definition Audio/Export.h:42
Types.h
sfSoundStream
struct sfSoundStream sfSoundStream
Definition Audio/Types.h:32
EffectProcessor.h
sfEffectProcessor
void(* sfEffectProcessor)(const float *inputFrames, unsigned int *inputFrameCount, float *outputFrames, unsigned int *outputFrameCount, unsigned int frameChannelCount)
Callable that is provided with sound data for processing.
Definition EffectProcessor.h:102
SoundChannel.h
sfSoundChannel
sfSoundChannel
Types of sound channels that can be read/written from sound buffers/files.
Definition SoundChannel.h:39
SoundSourceCone.h
SoundStatus.h
sfSoundStatus
sfSoundStatus
Enumeration of statuses for sounds and musics.
Definition SoundStatus.h:38
sfSoundStream_setSpatializationEnabled
void sfSoundStream_setSpatializationEnabled(sfSoundStream *soundStream, bool enabled)
Set whether spatialization of the sound is enabled.
sfSoundStream_getCone
sfSoundSourceCone sfSoundStream_getCone(const sfSoundStream *soundStream)
Get the cone properties of the sound in the audio scene.
sfSoundStream_setVelocity
void sfSoundStream_setVelocity(sfSoundStream *soundStream, sfVector3f velocity)
Set the 3D velocity of the sound in the audio scene.
sfSoundStreamGetDataCallback
bool(* sfSoundStreamGetDataCallback)(sfSoundStreamChunk *, void *)
Type of the callback used to get a sound stream data.
Definition SoundStream.h:53
sfSoundStream_setMinGain
void sfSoundStream_setMinGain(sfSoundStream *soundStream, float gain)
Set the minimum gain of the sound.
sfSoundStream_setPan
void sfSoundStream_setPan(sfSoundStream *soundStream, float pan)
Set the pan of the sound.
sfSoundStream_setMinDistance
void sfSoundStream_setMinDistance(sfSoundStream *soundStream, float distance)
Set the minimum distance of a sound stream.
sfSoundStream_getVelocity
sfVector3f sfSoundStream_getVelocity(const sfSoundStream *soundStream)
Get the 3D velocity of the sound in the audio scene.
sfSoundStream_setDirection
void sfSoundStream_setDirection(sfSoundStream *soundStream, sfVector3f direction)
Set the 3D direction of the sound in the audio scene.
sfSoundStream_setRelativeToListener
void sfSoundStream_setRelativeToListener(sfSoundStream *soundStream, bool relative)
Make a sound stream's position relative to the listener or absolute.
sfSoundStream_getVolume
float sfSoundStream_getVolume(const sfSoundStream *soundStream)
Get the volume of a sound stream.
sfSoundStream_getMinGain
float sfSoundStream_getMinGain(const sfSoundStream *soundStream)
Get the minimum gain of the sound.
sfSoundStream_getDopplerFactor
float sfSoundStream_getDopplerFactor(const sfSoundStream *soundStream)
Get the doppler factor of the sound.
sfSoundStream_setPlayingOffset
void sfSoundStream_setPlayingOffset(sfSoundStream *soundStream, sfTime timeOffset)
Change the current playing position of a sound stream.
sfSoundStream_setDopplerFactor
void sfSoundStream_setDopplerFactor(sfSoundStream *soundStream, float factor)
Set the doppler factor of the sound.
sfSoundStream_getStatus
sfSoundStatus sfSoundStream_getStatus(const sfSoundStream *soundStream)
Get the current status of a sound stream (stopped, paused, playing).
sfSoundStream_create
sfSoundStream * sfSoundStream_create(sfSoundStreamGetDataCallback onGetData, sfSoundStreamSeekCallback onSeek, unsigned int channelCount, unsigned int sampleRate, sfSoundChannel *channelMapData, size_t channelMapSize, void *userData)
Create a new sound stream.
sfSoundStream_pause
void sfSoundStream_pause(sfSoundStream *soundStream)
Pause a sound stream.
sfSoundStream_getChannelCount
unsigned int sfSoundStream_getChannelCount(const sfSoundStream *soundStream)
Return the number of channels of a sound stream.
sfSoundStream_setPosition
void sfSoundStream_setPosition(sfSoundStream *soundStream, sfVector3f position)
Set the 3D position of a sound stream in the audio scene.
sfSoundStream_getMaxDistance
float sfSoundStream_getMaxDistance(const sfSoundStream *soundStream)
Get the maximum distance of the sound.
sfSoundStream_setCone
void sfSoundStream_setCone(sfSoundStream *soundStream, sfSoundSourceCone cone)
Set the cone properties of the sound in the audio scene.
sfSoundStream_isLooping
bool sfSoundStream_isLooping(const sfSoundStream *soundStream)
Tell whether or not a sound stream is in loop mode.
sfSoundStream_getChannelMap
sfSoundChannel * sfSoundStream_getChannelMap(const sfSoundStream *soundStream, size_t *count)
Get the map of position in sample frame to sound channel.
sfSoundStream_isRelativeToListener
bool sfSoundStream_isRelativeToListener(const sfSoundStream *soundStream)
Tell whether a sound stream's position is relative to the listener or is absolute.
sfSoundStream_setLooping
void sfSoundStream_setLooping(sfSoundStream *soundStream, bool loop)
Set whether or not a sound stream should loop after reaching the end.
sfSoundStream_setDirectionalAttenuationFactor
void sfSoundStream_setDirectionalAttenuationFactor(sfSoundStream *soundStream, float factor)
Set the directional attenuation factor of the sound.
sfSoundStream_stop
void sfSoundStream_stop(sfSoundStream *soundStream)
Stop playing a sound stream.
sfSoundStream_destroy
void sfSoundStream_destroy(const sfSoundStream *soundStream)
Destroy a sound stream.
sfSoundStream_isSpatializationEnabled
bool sfSoundStream_isSpatializationEnabled(const sfSoundStream *soundStream)
Tell whether spatialization of the sound is enabled.
sfSoundStream_getMinDistance
float sfSoundStream_getMinDistance(const sfSoundStream *soundStream)
Get the minimum distance of a sound stream.
sfSoundStream_getDirectionalAttenuationFactor
float sfSoundStream_getDirectionalAttenuationFactor(const sfSoundStream *soundStream)
Get the directional attenuation factor of the sound.
sfSoundStream_setAttenuation
void sfSoundStream_setAttenuation(sfSoundStream *soundStream, float attenuation)
Set the attenuation factor of a sound stream.
sfSoundStreamSeekCallback
void(* sfSoundStreamSeekCallback)(sfTime, void *)
Type of the callback used to seek in a sound stream.
Definition SoundStream.h:54
sfSoundStream_play
void sfSoundStream_play(sfSoundStream *soundStream)
Start or resume playing a sound stream.
sfSoundStream_setPitch
void sfSoundStream_setPitch(sfSoundStream *soundStream, float pitch)
Set the pitch of a sound stream.
sfSoundStream_getPosition
sfVector3f sfSoundStream_getPosition(const sfSoundStream *soundStream)
Get the 3D position of a sound stream in the audio scene.
sfSoundStream_setVolume
void sfSoundStream_setVolume(sfSoundStream *soundStream, float volume)
Set the volume of a sound stream.
sfSoundStream_getSampleRate
unsigned int sfSoundStream_getSampleRate(const sfSoundStream *soundStream)
Get the sample rate of a sound stream.
sfSoundStream_setMaxGain
void sfSoundStream_setMaxGain(sfSoundStream *soundStream, float gain)
Set the maximum gain of the sound.
sfSoundStream_getPitch
float sfSoundStream_getPitch(const sfSoundStream *soundStream)
Get the pitch of a sound stream.
sfSoundStream_getPan
float sfSoundStream_getPan(const sfSoundStream *soundStream)
Get the pan of the sound.
sfSoundStream_getDirection
sfVector3f sfSoundStream_getDirection(const sfSoundStream *soundStream)
Get the 3D direction of the sound in the audio scene.
sfSoundStream_setEffectProcessor
void sfSoundStream_setEffectProcessor(sfSoundStream *soundStream, sfEffectProcessor effectProcessor)
Set the effect processor to be applied to the sound.
sfSoundStream_setMaxDistance
void sfSoundStream_setMaxDistance(sfSoundStream *soundStream, float distance)
Set the maximum distance of the sound.
sfSoundStream_getPlayingOffset
sfTime sfSoundStream_getPlayingOffset(const sfSoundStream *soundStream)
Get the current playing position of a sound stream.
sfSoundStream_getAttenuation
float sfSoundStream_getAttenuation(const sfSoundStream *soundStream)
Get the attenuation factor of a sound stream.
sfSoundStream_getMaxGain
float sfSoundStream_getMaxGain(const sfSoundStream *soundStream)
Get the maximum gain of the sound.
Time.h
Vector3.h
sfSoundSourceCone
Structure defining the properties of a directional cone.
Definition SoundSourceCone.h:39
sfSoundStreamChunk
defines the data to fill by the OnGetData callback
Definition SoundStream.h:48
sfSoundStreamChunk::samples
int16_t * samples
Pointer to the audio samples.
Definition SoundStream.h:49
sfSoundStreamChunk::sampleCount
unsigned int sampleCount
Number of samples pointed by Samples.
Definition SoundStream.h:50
sfTime
Represents a time value.
Definition Time.h:38
sfVector3f
3-component vector of floats
Definition Vector3.h:38