Skip to content

Conversation

roderickvd
Copy link
Member

Provides a new LimitSettings API and limiter filter to prevent audio peaks from exceeding a threshold. Supports soft-knee limiting, per-channel detection, configurable attack/release, and efficient processing for mono, stereo, and multi-channel audio. Includes comprehensive tests and usage examples.

}

/// Internal function that converts decibels to linear
pub(super) fn to_linear(decibels: f32) -> f32 {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move these methods to mod.rs or some utility module?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have src/math it could fit there. Feel free to move it and rename it to decibels_to_linear(). But its also fine where it is right? this is always amplifying, sometimes a number sometimes a source.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved and renamed them to src/math.rs in b1497f8. It doesn't feel right to me that we were adding a utility function to_db to a module that didn't use it. I also made them public, because they are useful as general-purpose audio functions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are useful as general-purpose audio functions

I don't follow exactly. We have different amplify methods on source for the different scales. How does converting a single float to another float help audio? Do you mean they are useful as parts for custom sources?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a user of this library, I frequently run into the need to convert one into the other and display it to the end user. For example: Deezer, Qobuz and Spotify all send linear values and I want to print their dB equivalents on screen. Easy peasy when Rodio has them public.

@roderickvd roderickvd requested a review from dvdsk June 8, 2025 22:25
@dvdsk
Copy link
Member

dvdsk commented Jun 9, 2025

I love the settings example showing some analysis! It shows a different application of rodio then playback with effects.

Could we augment that example with 2 of the examples from #750? I would say the "compressor_wav" and "compressor_wav_alternate.rs". We could rename those to "compressor_basic" and "compressor_changing".

Copy link
Member

@dvdsk dvdsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation is spot on, its a nice balance between explaining audio and being to the point.

I fear we need to talk about our nemesis spans again. Specifically what happens when the channel count changes. Do we need to switch from limit::Mono to Limit::Stereo then?

The rest is minor stuff: language preference (you can ignore if you disagree), a test that's not needed, comments that are superfluous etc.

@roderickvd roderickvd requested a review from dvdsk June 9, 2025 19:20
@roderickvd
Copy link
Member Author

Thank you for your review.

Could we augment that example with 2 of the examples from #750? I would say the "compressor_wav" and "compressor_wav_alternate.rs". We could rename those to "compressor_basic" and "compressor_changing".

I did not add anything like _changing. There currently is no way to change the limiter settings after it was created, and I don't really see a reason to do so.

Provides a new LimitSettings API and limiter filter to prevent audio
peaks from exceeding a threshold. Supports soft-knee limiting,
per-channel detection, configurable attack/release, and efficient
processing for mono, stereo, and multi-channel audio. Includes
comprehensive tests and usage examples.
…dule

- Add LimitSettings presets for common use cases (dynamic_content, broadcast, mastering, gaming, live_performance)
- Expand and clarify LimitSettings documentation and dBFS reference
- Move dB/linear conversion functions and tests from amplify.rs to new math.rs module
- Refactor limiter implementation for clearer internal structure and documentation
- Add new example (limit_wav) and integration tests for limiter behavior
- Clean up and modernize limit_settings.rs example
- Update module imports to use new math API
@roderickvd roderickvd force-pushed the feat/feedforward-limiter branch from e47684a to e61dce9 Compare June 9, 2025 19:38
@dvdsk
Copy link
Member

dvdsk commented Jun 9, 2025

There currently is no way to change the limiter settings after it was created, and I don't really see a reason to do so

Then lets not do that 👍

@dvdsk
Copy link
Member

dvdsk commented Jun 9, 2025

ready to merge now right?

@roderickvd
Copy link
Member Author

👍 I will squash merge now.

@roderickvd roderickvd merged commit 2c9e6b9 into master Jun 9, 2025
9 checks passed
@PetrGlad
Copy link
Collaborator

I may have some confusion regarding terminology, how such limiter is different to a compressor? Compressor also has attack/release time parameters, with perhaps only difference that below-the-knee-threshold samples are also affected.
Is the difference that limiter works with amplitudes, not loudness?

@roderickvd roderickvd deleted the feat/feedforward-limiter branch June 14, 2025 21:55
@roderickvd
Copy link
Member Author

A limiter is also a compressor, a particular type of it. Any compressor has a threshold (amplitude) beyond which it starts reducing dynamic range with a certain ratio. For a limiter, that ratio is very high or infinite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants