[Flac-dev] Legal sample rates
Josh Coalson
xflac at yahoo.com
Wed Nov 10 16:08:21 PST 2004
--- Erik de Castro Lopo <erikd-flac at 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
More information about the Flac-dev
mailing list