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
At 01:08 PM 6/17/2006, B. Ryan Newberry wrote:>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.Have you actually checked that the data from the CD (before compression) is actually correct? If that's off, then the FLAC compression won't matter. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.394 / Virus Database: 268.9.0/368 - Release Date: 6/16/2006
yahoo2 wrote:> At 01:08 PM 6/17/2006, B. Ryan Newberry wrote: > >> 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. > > > Have you actually checked that the data from the CD (before > compression) is actually correct? If that's off, then the FLAC > compression won't matter. >I've got 3 other working plugins (Vorbis, Mp3, and Wav) that all get their input data from cd paranoia the same way as my FLAC plugin so I know my input data is good. -- 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
--- "B. Ryan Newberry" <brnewber@gmail.com> wrote:> 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).you get this when playing back the flac stream with something else? does the generated file pass 'flac -t'?> #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);BTW with the stream encoder you will not get all the metadata written back at the end of processing, like the seekpoints and total sample count (which will make seeking slower) and the md5 sum. if you can seek your output you should use the file or seekable stream encoder instead. see http://flac.sourceforge.net/api/group__flac__encoder.html just to cover everything, there could be a problem in the initialization (not enough code here to tell). you have to make calls to set the #channels etc. are you checking the return value of FLAC__stream_encoder_init()?> 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); > > }that looks right assuming the count matches the audio_buffer size, i.e. for stereo, audio_buffer should have 2*CD_FRAMESIZE_RAW/4 samples in it. also audio_buffer should be int32_t's, converted as you show below.> 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 :-) ).that's fine.> 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.that looks fine (assuming again that the count is right). it's hard to tell without seeing all the code. Josh __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com