[Flac-dev] trying to write encoder - need help!

Matt Funk mfunk at telus.net
Fri Jun 11 14:19:16 PDT 2004

Hi all,

I'm attempting to encode raw audio data using libFLAC++. My audio data
is 16 bit, mono, 16000Hz. I set all the appropriate parameters on the
encoder and then call init().  Everything appears to be ok.

I don't know how to properly convert from char *data to the FLAC__int32
*[] requested by the process function. I think this is where my problem

If I call process() like this: 

FLAC__int32 *samplesArray[1] = { (FLAC__int32 *)data };

// data size if 4096 bytes
if (!process(samplesArray, 1024))
	die("return false");

it appears to encode ok, but when I play the flac file, it plays at
twice the normal speed. I can cheat and tell the encoder that the sample
rate is really 8000 Hz when in reality its 16KHz and it plays ok. 

So my question is how to convert from char *data to FLAC__int32* data?
I've been looking at encode.c but I'm confused by it (my c skills aren't

Thanks in advance. I can supply more code if necessary.


More information about the Flac-dev mailing list