[sdlsound] pcm data from sample.buffer
skruedims at yahoo.dk
Wed Oct 26 09:06:39 EDT 2011
I'm trying to get the raw PCM data, from a decoded mp3 file.
I'm only interested in the raw pcm data, and not to output it to eg. sdl-audio.But if try to look into the sample.buffer after decoding, the buffer seems empty. (See below).
But if i modify eg. playsound_simple.c, in the audio callback function there are data in the buffer.
It looks like SDL_OpenAudio does something to the data?
Is it possible to somehow get the raw pcm data without using eg. SDL_OpenAudio?
cout << "\nFailed init" << endl;
Sound_Sample *sample = Sound_NewSampleFromFile("data/musik.mp3", NULL, 65536);
cout << "Error opening file:" << Sound_GetError();
Uint32 br = Sound_DecodeAll(sample);
Uint8 *decoded = (Uint8*)sample->buffer;
if ((sample->flags & SOUND_SAMPLEFLAG_EOF))
cout << "\nDecoded number of bytes:" << br << endl;
for (Uint32 i=0; i<br; i++)
Uint8 f = decoded[i];
cout << (float)f << ",";
More information about the sdlsound