Sample Code that uses Sound_NewSample() and Sound_Decode()

Hi everyone,
I would like to know where there is some source code that tells you how
to use SDL_Sound. I am having trouble figuring how to write a program
that gets waveform information from a .wav or .mp3 file. Either that,
or retrieves specific Decibel Levels of .wav or .mp3 files.

Thank you.

-John

I would like to know where there is some source code that tells you how
to use SDL_Sound. I am having trouble figuring how to write a program
that gets waveform information from a .wav or .mp3 file. Either that,
or retrieves specific Decibel Levels of .wav or .mp3 files.

(without error checks, and assuming you’ve got tons of memory…)

Sound_Sample *sample;

SDL_Init(SDL_INIT_AUDIO);
Sound_Init();
sample = Sound_NewSampleFromFile(“myfile.ogg”, NULL, 32767);
Sound_DecodeAll(sample);

// sample->buffer will now have sample->buffer_size bytes in the format
// specified by sample->actual. DecodeAll can be replaced by Decode to
// get waveform data in 32767 byte blocks if memory is a concern.

–ryan.