All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_wave.c File Reference
#include "SDL_config.h"
#include "SDL_audio.h"
#include "SDL_wave.h"

Go to the source code of this file.


static void Fill_IMA_ADPCM_block (Uint8 *decoded, Uint8 *encoded, int channel, int numchannels, struct IMA_ADPCM_decodestate *state)
static int IMA_ADPCM_decode (Uint8 **audio_buf, Uint32 *audio_len)
static Sint32 IMA_ADPCM_nibble (struct IMA_ADPCM_decodestate *state, Uint8 nybble)
static int InitIMA_ADPCM (WaveFMT *format)
static int InitMS_ADPCM (WaveFMT *format)
static int MS_ADPCM_decode (Uint8 **audio_buf, Uint32 *audio_len)
static Sint32 MS_ADPCM_nibble (struct MS_ADPCM_decodestate *state, Uint8 nybble, Sint16 *coeff)
static int ReadChunk (SDL_RWops *src, Chunk *chunk)
void SDL_FreeWAV (Uint8 *audio_buf)
SDL_AudioSpecSDL_LoadWAV_RW (SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)


static struct IMA_ADPCM_decoder IMA_ADPCM_state
static struct MS_ADPCM_decoder MS_ADPCM_state

Function Documentation

static void Fill_IMA_ADPCM_block ( Uint8 decoded,
Uint8 encoded,
int  channel,
int  numchannels,
struct IMA_ADPCM_decodestate *  state 

Definition at line 307 of file SDL_wave.c.

References i, and IMA_ADPCM_nibble().

Referenced by IMA_ADPCM_decode().

static int IMA_ADPCM_decode ( Uint8 **  audio_buf,
Uint32 audio_len 
static Sint32 IMA_ADPCM_nibble ( struct IMA_ADPCM_decodestate *  state,
Uint8  nybble 

Definition at line 253 of file SDL_wave.c.

Referenced by Fill_IMA_ADPCM_block().

static int MS_ADPCM_decode ( Uint8 **  audio_buf,
Uint32 audio_len 

Definition at line 119 of file SDL_wave.c.

References MS_ADPCM_nibble(), MS_ADPCM_state, NULL, SDL_free(), SDL_malloc(), SDL_OutOfMemory, and while().

Referenced by SDL_LoadWAV_RW().

static Sint32 MS_ADPCM_nibble ( struct MS_ADPCM_decodestate *  state,
Uint8  nybble,
Sint16 coeff 

Definition at line 85 of file SDL_wave.c.

Referenced by MS_ADPCM_decode().

static int ReadChunk ( SDL_RWops src,
Chunk chunk 
void SDL_FreeWAV ( Uint8 audio_buf)

This function frees data previously allocated with SDL_LoadWAV_RW()

Definition at line 601 of file SDL_wave.c.

References SDL_free().

SDL_AudioSpec* SDL_LoadWAV_RW ( SDL_RWops src,
int  freesrc,
SDL_AudioSpec spec,
Uint8 **  audio_buf,
Uint32 audio_len 

This function loads a WAVE from the data source, automatically freeing that source if freesrc is non-zero. For example, to load a WAVE file, you could do:

* SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...);

If this function succeeds, it returns the given SDL_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 and MS-ADPCM WAVE files are supported.

Definition at line 405 of file SDL_wave.c.

References AUDIO_F32, AUDIO_S16, AUDIO_S32, AUDIO_U8, WaveFMT::bitspersample, WaveFMT::channels, SDL_AudioSpec::channels, chunk, DATA, Chunk::data, WaveFMT::encoding, FACT, FMT, SDL_AudioSpec::format, SDL_AudioSpec::freq, WaveFMT::frequency, IEEE_FLOAT_CODE, if(), IMA_ADPCM_CODE, IMA_ADPCM_decode(), InitIMA_ADPCM(), InitMS_ADPCM(), Chunk::length, LIST, Chunk::magic, MP3_CODE, MS_ADPCM_CODE, MS_ADPCM_decode(), NULL, PCM_CODE, ReadChunk(), RIFF, RW_SEEK_CUR, SDL_AudioSpec::samples, SDL_AUDIO_BITSIZE, SDL_free(), SDL_memset(), SDL_ReadLE32(), SDL_RWclose, SDL_RWseek, SDL_SetError(), SDL_SwapLE16, SDL_SwapLE32, SDL_zero, and WAVE.

Variable Documentation

struct IMA_ADPCM_decoder IMA_ADPCM_state

Referenced by IMA_ADPCM_decode(), and InitIMA_ADPCM().

struct MS_ADPCM_decoder MS_ADPCM_state

Referenced by InitMS_ADPCM(), and MS_ADPCM_decode().