SDL_GetAudioDeviceGain(3)
π SDL_GetAudioDeviceGain(3) π
okay bestie, welcome to the SDL3 FUNCTIONS corner of the man pages, where we're talking about SDL_GetAudioDeviceGain β yes, the whole page is literally about asking an audio device "hey girl, how loud are you rn?" π
β¨ NAME β¨
SDL_GetAudioDeviceGain β Get the gain of an audio device. π§
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_audio.h>
float SDL_GetAudioDeviceGain(SDL_AudioDeviceID devid);
like. it's one function. it takes one id. it gives you back a float. slay. π
π¦ DESCRIPTION π¦
so the gain of a device is literally just its volume β that's it, that's the vibe. a bigger gain means a louder output, and a gain of zero means silence. like, actual silence. not a whisper, not a vibe, just nothing. π€«
audio devices default to a gain of 1.0f, which is the "no change in output" setting β the main character neutral state, no notes, the audio equivalent of wearing your hair natural. π
and here's the tea bestie, because this part matters: physical devices may not have their gain changed, only logical devices, and this function will always return -1.0f when used on physical devices. so if you're poking at a physical device expecting a cute little number back, you're gonna get that -1.0f instead. not a bug, that's just the rules. π
π FUNCTION PARAMETERS π
devidβ the audio device to query. that's the one you're asking about. the subject of your inquiry. the girl in question. π«Ά
β RETURN VALUE β
returns the gain of the device, or -1.0f on failure. and if it fails? call SDL_GetError() for more information, because she will tell you what went wrong. π£
π THREAD SAFETY π
it is safe to call this function from any thread. yes bestie, ANY thread. go wild. no locks, no drama, no waiting your turn. π
π₯ AVAILABILITY π₯
this function is available since SDL 3.2.0. if you're on something older, sorry babe, no gain for you. π
π SEE ALSO π
SDL_SetAudioDeviceGain(3)β the other half of the duo, the one that actually changes the gain. get you a function that can do both. π
ngl the whole "physical devices always give you -1.0f" thing is the one gotcha to remember here. write it on your hand. put it in your notes app. it's giving character development. β¨
and that's the page!! brought to you by Simple Directmedia Layer, SDL 3.4.18, and this exact SDL_GetAudioDeviceGain(3) moment. stay loud, stay caffeinated, and go query your audio devices responsibly. 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