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
--- Erik de Castro Lopo <erikd-flac@mega-nerd.com> wrote:> 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.oh, I meant FLAC__format_sample_rate_is_valid() is the right way to check.> > 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.11025 is a valid sample rate, but 9 channels is not a valid # of channels. the FLAC__STREAM_ENCODER_NOT_STREAMABLE error means you are violating the "set streamable subset" setting that is in effect. I guess FLAC__STREAM_ENCODER_NOT_STREAMABLE could be expanded to FLAC__STREAM_ENCODER_NOT_STREAMABLE_BAD_SAMPLE_RATE, FLAC__STREAM_ENCODER_NOT_STREAMABLE_BAD_BITS_PER_SAMPLE etc but it doesn't seem worth changing the API for. Josh __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com
On Thu, 11 Nov 2004 13:33:42 -0800 (PST) Josh Coalson <xflac@yahoo.com> wrote:> --- Erik de Castro Lopo <erikd-flac@mega-nerd.com> wrote: > > 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. > > oh, I meant FLAC__format_sample_rate_is_valid() is the right way > to check.Ok, I tried that, but this: printf ("\n\n%u -> %d\n%u -> %d\n%u -> %d\n", 112, FLAC__format_sample_rate_is_valid(112), 11025, FLAC__format_sample_rate_is_valid(11025), 44100, FLAC__format_sample_rate_is_valid(44100)); prints out this: 112 -> 1 11025 -> 1 44100 -> 1 which suggests that both 112 and 11025 are valid samplerates, but when I use 11025, I get a FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR.> 11025 is a valid sample rate, but 9 channels is not a valid > # of channels. > > the FLAC__STREAM_ENCODER_NOT_STREAMABLE error means you are > violating the "set streamable subset" setting that is in effect. > > I guess FLAC__STREAM_ENCODER_NOT_STREAMABLE could be expanded > to FLAC__STREAM_ENCODER_NOT_STREAMABLE_BAD_SAMPLE_RATE, > FLAC__STREAM_ENCODER_NOT_STREAMABLE_BAD_BITS_PER_SAMPLE etc > but it doesn't seem worth changing the API for.Without valid feedback fro libflac about why I am getting FLAC__STREAM_ENCODER_NOT_STREAMABLE I am completely up the creek without a paddle. The current state of affairs prevents me from supplying the user with accurate information about what they have done wrong. It means that if I release what I have now users are going to have something go wrong and not know why. That means they will end up sending me emails. Erik PS: I seem to be having a great deal of trouble with the xiph.org mail server. It seems to be silently deleting some of my emails. I sometimes need to resend my emails 2 or 3 times before it gets through to the list. -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ "Python is the most efficient language I've ever used. It's 10 times better than any of the other tools I have used. It's free, it's object-oriented, it adapts to everything, it runs on everything. There is almost an indescribable 'quality without a name' attraction on my part." --Bruce Eckel, Author of Thinking in Java
On Thu, 11 Nov 2004 13:33:42 -0800 (PST) Josh Coalson <xflac@yahoo.com> wrote:> I guess FLAC__STREAM_ENCODER_NOT_STREAMABLE could be expanded > to FLAC__STREAM_ENCODER_NOT_STREAMABLE_BAD_SAMPLE_RATE, > FLAC__STREAM_ENCODER_NOT_STREAMABLE_BAD_BITS_PER_SAMPLE etc > but it doesn't seem worth changing the API for.Here's what I do in libsndfile: - Errors are integers from 0 (SFE_NO_ERROR) through to some maximum error number (which can change from release to release). - API functions can return an error number. - The API supplies a function (rather than a string array) to convert the error number into a "const char *" string after checking that the error number is in the valid range. - Using a function means that error messages can be added and removed from release to release without breaking the API. Hope this helps, Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ "If POSIX threads are a good thing, perhaps I don't want to know what they're better than." -- Rob Pike