Conversation
|
Wow, I wasn't aware of that! Using SFC_SET_CLIPPING (see also #23) should solve the problem. Interestingly, the same thing was discussed repeatedly over the years: It seems that this also changes the scaling behavior discussed in #20. I'm not a fan of raising an error in this case (and I'm not a fan of warnings at all). |
|
This is probably also a sign that we shouldn't rush 1.0 (see #102). |
|
Whatever solution we choose, I am a big fan of saving floating point data outside the [-1, 1) range, so this should definitely be preserved. This, might rule out using the sndfile flag. As for integer normalization, I think that raising an error is the cleanest solution. In face of ambiguity, resist the temptation to guess. This thing is, I discovered this when I wrote some float data and expected it to just work. Only much later did I find out that I had written garbage to disk. If it had raised an error, I would have discovered the problem right away instead of hours too late. My files would have been useless with clipped or scaled data as well. |
The documentation states: "Turn on/off automatic clipping when doing floating point to integer conversion." So this shouldn't be a problem. What I find a bit annoying is that it also silently changes the scaling behavior. I would like to control the clipping behavior and the scaling behavior separately, but there seems to be no separate option for that in libsndfile. Anyway, there is no "right" solution for scaling, so we might as well choose the second one as default, even if I personally prefer the first one.
Sure, that sounds reasonable. |
We can easily measure this. For very short signals, If we can't find a faster solution than In light of this, I am in favor of enabling clipping for integer formats by default. |
|
Thanks for the measurements, I guess that's settled, then! The remaining question is if we should hard-code |
|
I don't see much utility in not clipping integer data. If unclipped, it's just garbage anyway. |
|
I added a commit which enables clipping (7724a09). |
What happens when the data written is bigger than [-1, 1)?
|
Awesome! |
The second point is unpleasant. We could