MIX_CreateSineWaveAudio(3)
π 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 beNULL. (yes really, she's chill like that π)hzβ the sinewave's frequency in Hz. this is the pitch, bestie π΅amplitudeβ the sinewave's amplitude from0.0fto1.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 β¨
MIX_DestroyAudio(3)β gotta clean up after yourself, bestie π§ΉMIX_SetTrackAudio(3)β put that audio on a track πMIX_LoadAudio_IO(3)β for when you want actual files and not just vibes π
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
- fedora 44: SDL3_mixer-doc 3.2.4-3.fc44 Β· Zlib AND (GPL-2.0-or-later OR LGPL-2.0-or-later)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms