SDL_LoadWAV(3)

NAME
SDL_LoadWAV - Loads a WAV from a file path.

HEADER FILE
Defined in SDL3/SDL_audio.h

SYNOPSIS
#include "SDL3/SDL.h"

int SDL_LoadWAV(const char *path, SDL_AudioSpec * spec,
                Uint8 ** audio_buf, Uint32 * audio_len);

DESCRIPTION
This is a convenience function that is effectively the same as: c SDL_LoadWAV_IO(SDL_IOFromFile(path, "rb"), 1, spec, audio_buf, audio_len);

FUNCTION PARAMETERS

path
    The file path of the WAV file to open.

spec
    A pointer to an SDL_AudioSpec
     that will be set to the WAVE data's format details on successful return.

audio_buf
    A pointer filled with the audio data, allocated by the function.

audio_len
    A pointer filled with the length of the audio data buffer in bytes

RETURN VALUE
Returns 0 on success. audio_buf will be filled with a pointer to an allocated buffer containing the audio data, and audio_len is filled with the length of that audio buffer in bytes. This function returns -1 if the .WAV file cannot be opened, uses an unknown data format, or is corrupt; call SDL_GetError () for more information. When the application is done with the data returned in audio_buf , it should call SDL_free () to dispose of it.

THREAD SAFETY
It is safe to call this function from any thread.

AVAILABILITY
This function is available since SDL 3.0.0.

SEE ALSO
SDL_free(3), SDL_LoadWAV_IO(3)