Hi all, I'm trying to use the FLAC C libraries to encode audio. I'm doing something like: FLAC__seekable_stream_encoder_set_channels(pflac->fse, 1); FLAC__seekable_stream_encoder_set_sample_rate(pflac->fse, 11025); FLAC__seekable_stream_encoder_set_bits_per_sample(pflac->fse, 8); if ((bps = FLAC__seekable_stream_encoder_init(pflac->fse)) != FLAC__SEEKABLE_STREAM_DECODER_OK) { printf ("Error : FLAC encoder init returned error : %s\n", FLAC__SeekableStreamEncoderStateString [bps]); exit (1); } and I'm triggering the error message, but the most information I can get from the FLAC__SeekableStreamEncoderStateString method is FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR. SOmeone else has dug through the FLAC libraries and came to the conclusion that FLAC doesn't accept the given sample rate (11025). I therefore tried to test the error return value of the set_sample_rate() method, but found that it always returns TRUE (ie no error). Is there someway of figuring out if a sample rate is valid? Cheers, Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ "Linux everywhere pretty much eliminates the need for Java everywhere" -- Bruce Ide in letter to LWN editors
--- Erik de Castro Lopo <erikd-flac@mega-nerd.com> wrote:> Hi all, > > I'm trying to use the FLAC C libraries to encode audio. > > I'm doing something like: > > FLAC__seekable_stream_encoder_set_channels(pflac->fse, 1); > FLAC__seekable_stream_encoder_set_sample_rate(pflac->fse, 11025); > FLAC__seekable_stream_encoder_set_bits_per_sample(pflac->fse, 8); > > if ((bps = FLAC__seekable_stream_encoder_init(pflac->fse)) !> FLAC__SEEKABLE_STREAM_DECODER_OK) > { printf ("Error : FLAC encoder init returned error : %s\n", > FLAC__SeekableStreamEncoderStateString [bps]); > exit (1); > } > > and I'm triggering the error message, but the most information I > can get from the FLAC__SeekableStreamEncoderStateString method is > FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR. > > SOmeone else has dug through the FLAC libraries and came to the > conclusion that FLAC doesn't accept the given sample rate (11025). > I therefore tried to test the error return value of the > set_sample_rate() > method, but found that it always returns TRUE (ie no error). > > Is there someway of figuring out if a sample rate is valid?that's the right way. the reason it's being rejected is the encoder is configured to obey the subset: http://flac.sourceforge.net/format.html#subset to encode 11.025 kHz you need to call FLAC__seekable_stream_encoder_set_streamable_subset() http://flac.sourceforge.net/api/group__flac__seekable__stream__encoder.html#a9 you can get error messages in string form with FLAC__seekable_stream_encoder_get_resolved_state_string() http://flac.sourceforge.net/api/group__flac__seekable__stream__encoder.html#a33 this will drill down into the underlying layers if necessary. Josh __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com
On Wed, 10 Nov 2004 16:08:21 -0800 (PST) Josh Coalson <xflac@yahoo.com> wrote:> > Is there someway of figuring out if a sample rate is valid? > > that's the right way.But it doesn't tell me that the sample rate is invalid it tells me FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR or FLAC__STREAM_ENCODER_NOT_STREAMABLE.> the reason it's being rejected is the encoder is configured to > obey the subset: > > http://flac.sourceforge.net/format.html#subset > > to encode 11.025 kHz you need to call > FLAC__seekable_stream_encoder_set_streamable_subset()OK, from reading the documentation, FLAC is limited to 8 channels and sample rates other than 11025. However, if I try to create a file with too many channels I get an error of FLAC__STREAM_ENCODER_INVALID_NUMBER_OF_CHANNELS which is fine. If I try to create a file at a sample rate of 11025 I get an error of FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR or FLAC__STREAM_ENCODER_NOT_STREAMABLE which says nothing about the sample rate. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ "Using Java as a general purpose application development language is like going big game hunting armed with Nerf weapons." -- Author Unknown
On Wed, 10 Nov 2004 16:08:21 -0800 (PST) Josh Coalson <xflac@yahoo.com> wrote:> > Is there someway of figuring out if a sample rate is valid? > > that's the right way.But it doesn't tell me that the sample rate is invalid it tells me FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR or FLAC__STREAM_ENCODER_NOT_STREAMABLE.> the reason it's being rejected is the encoder is configured to > obey the subset: > > http://flac.sourceforge.net/format.html#subset > > to encode 11.025 kHz you need to call > FLAC__seekable_stream_encoder_set_streamable_subset()OK, from reading the documentation, FLAC is limited to 8 channels and sample rates other than 11025. However, if I try to create a file with too many channels I get an error of FLAC__STREAM_ENCODER_INVALID_NUMBER_OF_CHANNELS which is fine. If I try to create a file at a sample rate of 11025 I get an error of FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR or FLAC__STREAM_ENCODER_NOT_STREAMABLE which says nothing about the sample rate. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ "Using Java as a general purpose application development language is like going big game hunting armed with Nerf weapons." -- Author Unknown
On Wed, 10 Nov 2004 16:08:21 -0800 (PST) Josh Coalson <xflac@yahoo.com> wrote:> > Is there someway of figuring out if a sample rate is valid? > > that's the right way.But it doesn't tell me that the sample rate is invalid it tells me FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR or FLAC__STREAM_ENCODER_NOT_STREAMABLE.> the reason it's being rejected is the encoder is configured to > obey the subset: > > http://flac.sourceforge.net/format.html#subset > > to encode 11.025 kHz you need to call > FLAC__seekable_stream_encoder_set_streamable_subset()OK, from reading the documentation, FLAC is limited to 8 channels and sample rates other than 11025. However, if I try to create a file with too many channels I get an error of FLAC__STREAM_ENCODER_INVALID_NUMBER_OF_CHANNELS which is fine. If I try to create a file at a sample rate of 11025 I get an error of FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR or FLAC__STREAM_ENCODER_NOT_STREAMABLE which says nothing about the sample rate. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ "Using Java as a general purpose application development language is like going big game hunting armed with Nerf weapons." -- Author Unknown