liquidsoap icon indicating copy to clipboard operation
liquidsoap copied to clipboard

Can i feed the crossfade RMS level calculation with a filtered version of its original input source?

Open Groschi opened this issue 3 years ago • 2 comments

I've been wondering about this recently. I think it would improve the (smart) crossfade in some cases if it was possible to do the RMS level detection based on a filtered version of the input source, thus crudely/lazily adding a weighting to the level detection like the ones described here: https://en.wikipedia.org/wiki/Weighting_filter

I regularly encounter song transitions in my stream were a song starts or ends with with a deep, sustained bass note or a very high shriek (guitar feedback, for example). These sounds actually are quite loud (in terms of pure sound pressure) but they don't sound quite as loud to human ears at healthy/moderate playback volumes.

In such cases, liquidsoap is like "This song ending still has a quite high level, so i better not overlap the tracks", while the human being in front of the speakers is like: "This sounds pretty quiet to me. Why hasn't the next song started yet?". Thus, applying some kind of weighting before the RMS calculation would in many cases lead to a better-suited transition choice.

Is there a straightforward way to do this in a script or by adapting fades.liq? Kind of a "sidechaining" of the RMS level calc?

Groschi avatar Apr 24 '21 20:04 Groschi

Unfortunately, this is not easy to achieve right now because the RMS computation is quite hardcoded in the cross operator.

However, it would be possible to hardcode possible RMS weighting in the cross operator, which you could enable through some parameter. My problem now is: how to implement weighting (say A-weighting)? The definitions are given in the frequency domain, which is not convenient. I guess one could come up with some good IIR filter implementation, but I don't have the time really dig this right now... If you can sort this out, it could be implemented without much difficulty.

smimram avatar Apr 25 '21 07:04 smimram

We could allow the user to pass their own RMS function with a nullable parameter. This would also play well with the ffmpeg astats filter: https://github.com/savonet/liquidsoap/pull/1812

toots avatar Aug 25 '21 17:08 toots