SDL_SetAudioStreamGain(3)
π SDL_SetAudioStreamGain π
okay bestie, gather round, we're doing SDL3 audio today and honestly? it's giving volume knob energy. this one lives in the SDL3 FUNCTIONS lineup and its whole personality is changing the gain of an audio stream. that's it. that's the job. and it eats. β¨
π NAME π
SDL_SetAudioStreamGain β change the gain of an audio stream. no cap, that's literally the whole thing.
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_audio.h>
bool SDL_SetAudioStreamGain(SDL_AudioStream *stream, float gain);
π¦ DESCRIPTION π¦
so like. the gain of a stream is its volume, periodt. bigger gain = louder output, and a gain of zero means silence, like the sound went to sleep. π€
audio streams default to a gain of 1.0f, which is the "no change in output" vibe β you're not touching anything, you're just existing. iconic.
and here's the fun part: this gets applied during SDL_GetAudioStreamData, which means you can continuously change it to cook up all kinds of effects. fades, dips, dramatic swells... the whole main character arc. π₯
π FUNCTION PARAMETERS π
streamβ the stream whose gain is getting changed. the glow-up target. πgainβ the gain itself.1.0fis no change,0.0fis silence. pick your fighter.
β RETURN VALUE β
returns true on success or false on failure. and if it fails? call SDL_GetError() for more info, she'll tell you what went wrong. π«Ά
π₯ THREAD SAFETY π₯
fr fr, you can call this from any thread and it's safe β it holds a stream-specific mutex the whole time it's running. so go ahead and be chaotic, it's protected. πͺ
π AVAILABILITY π
this function has been available since SDL 3.2.0. she's been here, she's been serving. π
π SEE ALSO π
SDL_GetAudioStreamGain(3)β the other half of the duo, go read her too.
β οΈ heads up bestie: 0.0f gain is full silence, not "a little quiet." don't be surprised when the vibes go completely quiet. π
okay that's the whole page!! this was brought to you by Simple Directmedia Layer (the source, the icon, the legend π) running SDL 3.4.18. now go make something loud. mwah. πβ¨π
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms