SDL_ConvertAudioSamples(3)

πŸ’– SDL_ConvertAudioSamples πŸ’–

okay bestie, welcome to the SDL_ConvertAudioSamples(3) page, living in the SDL3 FUNCTIONS collection ✨

πŸŽ€ NAME πŸŽ€

SDL_ConvertAudioSamples β€” converts some audio data from one format to another format. glow up for your audio, literally πŸ’…


✨ SYNOPSIS ✨

#include <SDL3/SDL_audio.h>

bool SDL_ConvertAudioSamples(const SDL_AudioSpec *src_spec, const Uint8 *src_data, int src_len, const SDL_AudioSpec *dst_spec, Uint8 **dst_data, int *dst_len);

🌸 DESCRIPTION 🌸

okay so real talk first, bestie: this function is a convenience queen, but you should NOT use it to resample audio in blocks, because it will introduce audio artifacts on the boundaries 😭 like, the seams will show. fr fr. Only use this one if you're converting your audio data in its entirety in one single call. If you wanna convert audio in smaller chunks, use an SDL_AudioStream instead β€” that's literally what it was designed for, it's giving purpose πŸ’œ

and internally? not me creating and destroying an SDL_AudioStream on every single use πŸ™ˆ so yeah, it's also less efficient than just using one directly, if you need to convert multiple times. main character energy costs a lil extra, that's just the vibe.


πŸ¦‹ FUNCTION PARAMETERS πŸ¦‹

  • src_spec β€” the format details of the input audio ✨
  • src_data β€” the audio data to be converted πŸ’«
  • src_len β€” the len of src_data πŸ“
  • dst_spec β€” the format details of the output audio 🌈
  • dst_data β€” will be filled with a pointer to the converted audio data, which should be freed with SDL_free(). On error, it will be NULL πŸ’€ (so like, check it, okay?)
  • dst_len β€” will be filled with the len of dst_data πŸ“

⭐ RETURN VALUE ⭐

Returns true on success or false on failure πŸ₯² β€” and if it fails, call SDL_GetError() for more info, she will tell you everything πŸ‘‘


🧚 THREAD SAFETY 🧚

It is safe to call this function from any thread πŸ’– multithreaded baddie behavior, we love to see it.


πŸ‘‘ AVAILABILITY πŸ‘‘

This function is available since SDL 3.2.0 πŸŽ€


mwah, that's the whole page bestie, go convert something gorgeous πŸ’–βœ¨πŸ¦‹πŸŒΈπŸ’…

sign-off szn: brought to you by Simple Directmedia Layer πŸ’œ version SDL 3.4.18 β€” yeah, that's the whole footer vibe, no cap 🫢
πŸ“¦ where this page comes from