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