[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)) !=
>   {	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
> 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:


to encode 11.025 kHz you need to call


you can get error messages in string form with


this will drill down into the underlying layers if necessary.


Do you Yahoo!? 
Check out the new Yahoo! Front Page. 

More information about the Flac-dev mailing list