Due to the float-to-int conversion in libsndfile, any float sample above 1.0 will get converted to an invalid value, which may produce cracks when the music is played.
We can avoid that by normalizing the values when opening the file, but it is incredibly slow for long musics (can take many seconds).
See this issue on the libsndfile tracker: erikd/libsndfile#16
Possible solutions are:
Or just have a applyClip() function that performs a min(1.0, x) on each sample frame. Normalizing can cause greatly affect how a song sounds, which may upset some people.
Clamping would not work, see this: erikd/libsndfile#16 (comment)
Aha, I see, that's annoying. I wasn't aware OGG files supported float values <> 1.0.
Just a future idea...
A possible fix might be to petition the xiph foundation, in order to modify the ogg standard. The new standard would include the maximum sample values +/- inside of every ogg audio stream.
We might have other options once #604 is completed.
Laurent's just mentioned this in the last post, but it would be great to have this considered along with the new audio implementation
Actually, I don't think that the new implementation makes anything easier regarding this problem. We just have more control, so we could try other strategies (like normalizing on the fly, using the current maximum).