[flac-dev] Commonly getting FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA on valid audio

Johnny Rosenberg gurus.knugum at gmail.com
Sat Feb 9 13:44:48 PST 2013

2013/2/9 Erik de Castro Lopo <mle+la at mega-nerd.com>:
> Johnny Rosenberg wrote:
>> For example, when loading an audiofile with libsndfile, all the
>> samples are converted to floating point numbers,
> With libsndfile, converting to float is optional. You can just as
> easily read int or short.
>> which is what I want
>> anyway, but the conversion is done by dividing the integers from the
>> file with pow(2,bps-1), but when converting back, they multiply with
>> pow(2,bps-1)-1, so if you just read and then write, you end up with a
>> slightly lower volume (not that you can hear any difference if you do
>> it only a few times, but still, it isn't right, AND it is very easy to
>> do it right, so why don't they?)…
> Firstly, you do realise that I am the main author and maintainer of
> libsndfile, don't you?

Yes I do, now that you mentioned it. I'm not sure why that matters in
a FLAC-dev mailing list, though.
I didn't know there was a maintainer anyway these days, since I didn't
get a reply when emailing about this a couple of years ago (or maybe
it was last year, I don't remember – I sent it from one of my other
email addresses, since I use this one for mailing lists only).

> Secondly, the scaling can be switched off don't you? See:
>     http://www.mega-nerd.com/libsndfile/command.html#SFC_SET_NORM_DOUBLE

Thanks, I don't think I saw that page before, for some strange reason.
The sentence ”setting normalisation to SF_FALSE means that no scaling
will take place”, does this mean, for instance for a 24-bit file, that
the values will be doubles in the interval -8388608 to +8388607?
That information should probably be added to question 10 in your FAQ, I suppose.

For my purpose, not ”normalising” at all seems to be a good enough
idea, I think. I will calculate the levels from dB anyway, so I just
need to know how many bits per sample there is, which libsndfile
easily lets me know.
But I will try to do my thing with libflac first. If I fail making my
code clean, simple and readable (and working…), I might give
libsndfile another try.

> Finally, there are about 700 different way so convert between int
> and float. I chose the one that I thought had provided the best
> trade off. I stand by that decision.

Well, the good thing is that this SFC_SET_NORM_DOUBLE thing allows me
to do it the 701th way… Maybe I should convert to % or ‰…

Anyway, if I'm allowed to ask a libsndfile question here, is there a
special reason why you read sound files into one-dimensional arrays
instead of two-dimensional ones (such as AudioData[Channel][Sample])?
If so, what is that reason?


Kind regards

Johnny Rosenberg

> Erik
> --
> ----------------------------------------------------------------------
> Erik de Castro Lopo
> http://www.mega-nerd.com/
> _______________________________________________
> flac-dev mailing list
> flac-dev at xiph.org
> http://lists.xiph.org/mailman/listinfo/flac-dev

More information about the flac-dev mailing list