MIX_CreateSineWaveAudio(3)

πŸ“¦
version 3.2.4 Β· 2 versions
, in fedora 44

πŸ’– MIX_CreateSineWaveAudio(3) πŸ’–

okay bestie, welcome to the SDL_mixer3 FUNCTIONS section of the manual, and today's main character is MIX_CreateSineWaveAudio. yes she makes beeps. no she is not boring. let's go πŸŽ€


✨ NAME ✨

MIX_CreateSineWaveAudio β€” create a MIX_Audio that generates a sinewave πŸ¦‹


✨ SYNOPSIS ✨

#include <SDL3_mixer/SDL_mixer.h>

MIX_Audio * MIX_CreateSineWaveAudio(MIX_Mixer *mixer, int hz, float amplitude, Sint64 ms);

like, that's the whole vibe right there πŸ’…


✨ DESCRIPTION ✨

so the tea is: this function is genuinely useful just to have something to play. maybe you're testing, maybe you're debugging, maybe you just want a little beep in your life. no judgement 🫢

you tell it the frequency in Hz (that's what decides the pitch of the sinewave's audio) and the amplitude (that's what decides the volume: 1.0f is very loud, 0.0f is silent, no in-between drama required).

you can also say how many milliseconds of audio to generate. and listen β€” if you specify a value less than zero, it will generate infinite audio ✨ which means when it's assigned to a MIX_Track, the sinewave will play forever. iconic. possibly chaotic. both.

one more thing, and it's important: MIX_Audio objects can be shared between multiple mixers πŸ’– the mixer parameter just suggests the most likely mixer to use this audio, in case some optimization might be applied β€” but that's not required, and you can totally pass a NULL mixer. no cap.


✨ FUNCTION PARAMETERS ✨

  • mixer β€” a mixer this audio is intended to be used with. May be NULL. (yes really, she's chill like that 😌)
  • hz β€” the sinewave's frequency in Hz. this is the pitch, bestie 🎡
  • amplitude β€” the sinewave's amplitude from 0.0f to 1.0f. this is the volume, so go loud or go silent 🌸
  • ms β€” the maximum number of milliseconds of audio to generate, or less than zero to generate infinite audio. forever-girl behavior πŸ’€

✨ RETURN VALUE ✨

returns an audio object that can be used to make sound on a mixer 🎢 β€” or NULL on failure. and if you get that NULL, don't panic, just call SDL_GetError() for more information. she'll tell you what went wrong πŸ₯Ί


✨ THREAD SAFETY ✨

it is safe to call this function from any thread. periodt. 🧚


✨ AVAILABILITY ✨

this function is available since SDL_mixer 3.0.0. so if you're on anything older... girly, upgrade 😭


✨ SEE ALSO ✨


and that's the whole page!! this one comes to you straight from the SDL_mixer docs, version 3.2.4, the MIX_CreateSineWaveAudio(3) era πŸ’œ go make some beeps, you absolute icon. mwah πŸŽ€βœ¨

πŸ“¦ where this page comes from