-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New dynamic limiter for very wide dynamic ranges #935
Conversation
I found another track.
All sounds good. I like it. Thank you. |
Great to hear. One more report would be great for me to merge this with confidence. |
I will give it a test. There are a couple tracks that I know of that distort. |
So far so good. The entire Bush, Sixteen Stones album was pretty bad with the old limiter |
I do notice that it uses a little bit more CPU though. Maybe 2%-ish more on my Raspberry Pi 4. That should still be fine on a Pi Zero I would think though. It should still be under 30%. |
Oh man that's definitely a throwback! Can't remember much often I played that album back in the days. A lot. However with the default pregain of 0.0 I don't think the dynamic limiter kicks in at all? The tracks indeed suffer from very low dynamic range. The average ReplayGain for these tracks is around -10 dB. The peaks then all stay under threshold.
Yeah, that's quite possible. Though the code is short and sweet, there are more things going on now that the CPU has no intrinsics for. Like linear <> logarithmic conversions, twice for every sample. |
Now that you mentioned it I do have some ideas to optimize this when we aren’t attacking or releasing a peak. |
dce7944 is a little more efficient and hasn't broken anything right? |
I didn't read the logs but I want to say that Glycerine in track mode distorts?
I will give it a go and report back. |
Yep, that cut it from about 2% to about 1%,lol!!! LGTM After you merge this and your |
I don't think so -- it's down -5.6 dB. If you mean that guitar, I do think that it clips but already in the recording and possibly even on the guitar amp. This is "Glycerine - Remastered" on "Sixsteen Stone (Remastered)": https://open.spotify.com/track/5buITai6eMzU8rJonMEI6e?si=962443be52484f34
Well, like it said on the tin 😆 I'll take it.
For a final check maybe you can compare what Glycerine sounds like in an official Spotify client. On macOS, the official app sounds a little lower in volume, but the guitar no better.
👍 |
Testing on my Pi Zero shows CPU usage in the high teens to low 20's. So it's about what I expected. 1% increase on the Pi 4 and 5-10% on the Pi Zero. Not great but not a deal breaker. Still plenty of headroom. When the new API work becomes more complete I will test that on the Zero. |
Wow! Thank you for this! I could never use the old dynamic limiter, because this song was always crackling:
Now the limiter is finally useful! |
Glad to hear it’s appreciated ❤️ |
* spotty-dev: (76 commits) Quantum-realm level normalisation optimization (librespot-org#965) Only log runtime argument if it starts with a dash "-" Improved error handling when fetching tokens or track data. update changelog Prevent shuffle crash Remove basic normalisation deprecation warning Fix Alsa softvol linear mapping (librespot-org#950) simplify get_factor (librespot-org#942) Update LMS integration to Remove unsafe code (librespot-org#940) Save some more CPU cycles in the limiter (librespot-org#939) New dynamic limiter for very wide dynamic ranges (librespot-org#935) Fix `--device` argument to various backends (librespot-org#938) examples/playlist_tracks: Use normal URI parser Fix clippy lint warning Clean up list_compatible_devices Sink: pass ownership of the packet on write() Restore giving feedback about auth success. The plugin is checking for this. Remove that last couple unwraps from main Fix auto fallback for --alsa-mixer-device and --alsa-mixer-index ...
Well that was a fun exercise! This time I actually think I know what I'm doing.
The current dynamic limiter was an amateur attempt that worked within a limited range and first Rust code I ever wrote. This time I took a article from the Journal of the Audio Engineering Society [1] and wrote a fresh implementation of the most recommended variant (feed-forward in the log domain with a smooth, decoupled peak detector).
So far it seems to work beautifully, including the tracks with wide dynamic range in the linked issue. Would be nice if some of you could give this a spin on various genres and let me know how it goes.
I purposely changed the field names to signal developers downstream that some of these fields now hold values in a different unit. Before in
0.2.0
this caused distorted audio for some other applications and I'd like to prevent that this time.Closes: #934
[1] Giannoulis, D., Massberg, M., & Reiss, J.D. (2012). Digital Dynamic Range Compressor Design—A Tutorial and Analysis. Journal of The Audio Engineering Society, 60, 399-408