**Describe the bug**
Though it ideally should never happen, clipping is sometimes unavoidable. 
However, unlike other encoders which let the signal "stay" at the clipping 
boundary while it clips, the FLAC encoder does weird things.

When I produce FLAC contained in OGG, the signal overflows or underflows. At 
least when I run it through a conversion using http://soundconverter.org/ 
(which uses GStreamer under the hood) and import it into Audacity. See the 
visualization below.
![screenshot from 2019-01-28 
12-35-16](https://user-images.githubusercontent.com/9883897/51835163-d4467100-22fc-11e9-8c67-9b477876978e.png)

When I produce raw FLAC files, the signal seems to go out of the boundaries 
(beyond what Audacity displays). But after 186ms the signal is at max, later 
it's back to how it first was, then it produces garbage, then it's at min, 
before returning to how it first was after a total of 650ms. The cycle then 
continues. See the visualization below.
![screenshot from 2019-01-28 
13-05-58](https://user-images.githubusercontent.com/9883897/51835359-7d8d6700-22fd-11e9-9ff0-273a13e4e44f.png)

I have seen the comments around here about how the FLAC encoder is not really 
fit for the purpose of streaming, and that it is pretty experimental. We are 
therefore transitioning to high-quality Ogg Vorbis instead. But I thought you 
might want to know about this problem either way.


**To Reproduce**
```liquidsoap
set("log.file", false)
set("log.stdout", true)

sound = sine(amplitude=1.2)

output.file(
    %flac(samplerate=44100, channels=1, compression=5, bits_per_sample=16),
    "clipping.flac",
    sound
)

output.file(
    %ogg(%flac(samplerate=44100, channels=1, compression=5, 
bits_per_sample=16)),
    "clipping.flac.ogg",
    sound
)
```
Hit CTRL-C when a couple seconds have passed. This probably goes without 
saying, but don't ever listen to files produced. To check how it looked, I used 
Audacity. To open the FLAC contained in OGG file, I had to convert it to 
another format first (in my case Ogg Vorbis, using GStreamer/SoundConverter) 
before opening it in Audacity. 

**Expected behavior**
I expect the signal to stay at the clipping boundary while it clips, discarding 
information about what value it has beyond the boundary. See the visualization 
below of how the Ogg Vorbis encoder handles this:
![screenshot from 2019-01-28 
13-15-50](https://user-images.githubusercontent.com/9883897/51835873-fa6d1080-22fe-11e9-8963-13a7424eb8fe.png)


**Version details**
 - OS: Ubuntu 18.04.1
 - Version: `1.3.6`, but we have also encountered this in earlier versions.

**Install method**
Installed from sources

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/savonet/liquidsoap/issues/700
_______________________________________________
Savonet-users mailing list
Savonet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to