[Flac] Assistance with an encoding plugin

B. Ryan Newberry brnewber at gmail.com
Sat Jun 17 10:08:34 PDT 2006


Hi,

I'm working on writing a FLAC encoding plugin for a personal cd ripping
project of mine which uses paranoia for the raw audio extraction. My
basic setup which follows gets me oddly high pitched audio with lots of
noise (although the music IS somewhat recognizable).

#include <FLAC/stream_encoder.h>

FLAC__StreamEncoder *encoder;
FILE *output_file_descriptor;

encoder = FLAC__stream_encoder_new();

FLAC__stream_encoder_set_write_callback(plugin->encoder, write_callback);
FLAC__stream_encoder_set_metadata_callback(plugin->encoder,
metadata_callback);
FLAC__stream_encoder_set_client_data(plugin->encoder,
output_file_descriptor);
FLAC__stream_encoder_init(plugin->encoder);

while(/* audio data left to extract */)
{
  /* audio buffer is an int16_t buffer that paranoia dumps interleaved
audio into */
      FLAC__stream_encoder_process_interleaved(       encoder,
                                                     audio_buffer,
                                                      CD_FRAMESIZE_RAW /
4);

}

      FLAC__stream_encoder_finish(encoder);
      FLAC__stream_encoder_delete(encoder);

write_callback simply writes the encoded data out to a file stream, and
metadata_callback isn't doing anything at the moment (one thing at a
time :-) ).

Now one thing that I see which may be causing my issue is the fact that
paranoia is extracting to an int16_t buffer whereas the FLAC functions
are expecting an int32_t buffer. I've tried doing the following to convert

int16_t *paranoia_buffer
int32_t *flac_buffer

for(j = 0; j < n; ++j)
flac_buffer[j] = paranoia_buffer[j];

and then using flac_buffer for the encoding, to no avail.  Other than
that, I have no idea what I may be doing wrong.

Thanks,

-- 
Ryan Newberry
http://ripoffc.sourceforge.net
"All mankind is divided into three classes: those that are immovable, those that are movable, and those that move." - Benjamin Franklin



More information about the Flac mailing list