SDL_LoadWAV -- Load a WAVE file



function SDL_LoadWAV( filename : PChar; spec : PSDL_AudioSpec; audio_buf :  PUInt8; audiolen : PUInt32 ) : PSDL_AudioSpec;


SDL_LoadWAV This function loads a WAVE file into memory.

If this function succeeds, it returns the given  TSDL_AudioSpec,  filled with the audio data format of the wave data, and sets  audio_buf to a malloc'd  buffer containing the audio data, and sets audio_len  to the length of that audio buffer, in bytes.  You need to free the audio  buffer with SDL_FreeWAV when you are done with it.

This function returns NULL and sets the SDL error message if the wave file cannot be opened, uses an unknown data format, or is corrupt. Currently raw, MS-ADPCM and IMA-ADPCM WAVE files are supported.


wav_spec : TSDL_AudioSpec;
wav_length : UInt32;
wav_buffer : PUInt8;

// Load the WAV
if( SDL_LoadWAV( 'test.wav', @wav_spec, @wav_buffer, @wav_length) = nil ) then
MessageBox( 0, PChar( Format( 'Couldn''t Open test.wav : %s', [SDL_GetError] ) ), 'Error', MB_OK or MB_ICONHAND );
halt( -1 );
// Do stuff with the WAV
// Free It
SDL_FreeWAV( wav_buffer );

See Also

TSDL_AudioSpec , SDL_OpenAudio , SDL_FreeWAV