Skip to content
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

Compressor improvement #63

Merged
merged 9 commits into from
Jul 27, 2020

Conversation

AvAars
Copy link
Contributor

@AvAars AvAars commented Jul 26, 2020

Improved the compressor a lot, as this was one of the modules I currently use most. Would appreciate any feedback 👍

Some changes I made:

  • pulled gain calculation and reduction apart for monitoring and multichannel support (now has an Apply() function to apply gain reduction to a signal without calculating the reduction, and GetGain() to get the gain reduction in dB)
  • improved readability by moving away from the faust internal names
  • improved makeup-gain calculations (I think this is correct, at least it sounds like that and this is based on another faust implementation, but I'm not completely sure)
  • changing parameters now costs a lot less (only calculating the affected internals on parameter changes)
  • a lot less expensive, eliminating useless variables, more inlining and using pow10f and fastlog10f, which I have included in dsp.h
  • added methods to disable automatic makeup gain and set your own makeup gain
  • added getters for all parameters

And, as mentioned in #59 , added block processing (for single- and multichannel). The single sample process methods inside these block processing methods get fully inlined, so there's a performance gain for those using these methods.

General compressor improvements:
- pulled gain apart for monitoring and multichannel support
- improved readability
- improved makeup-gain calculations
- added block processing
Renamed some more faust internals and removed an unnecessary variable, with the added bonus of improving inlining as well when looking at the assembly.
Reduced the cost of parameter changes by only recalculating the affected internals, inlined all calculations to reduce method calls.
Fixed recalculating release on SetRelease and resetting makeup gain when disabling auto makeup
Some additional documentation (unfinished)
Added fast pow10f and approximations for log2f and log10f
Cleaning up some documentation, added getters for the parameters (for monitoring the state of the compressor, when desired), using the faster pow10f and log10f from my additions to dsp.h
@AvAars
Copy link
Contributor Author

AvAars commented Jul 26, 2020

Maybe have to check up on best practices of inline functions, the recalculation of the internals might be better off outside the header file.

inline directive in class definition is superfluous
@stephenhensley
Copy link
Collaborator

Looks great! I'll be able to test it today or tomorrow and get it merged.

I had actually just starting to make a lot of similar (some identical) changes while working on a project that needed several of compressors.

Thanks for the contribution!

@stephenhensley
Copy link
Collaborator

This tests well. I haven't checked with too many input sources yet, but the auto makeup gain is nice. One thing that would be nice (maybe for the entire library) is to be able to set a 0dB value.

I imagine this won't be much of an issue on the Daisy Pod, etc. where the maximum output is a reasonable line level, but with the Daisy patch there's an extra 6dB of headroom so with Auto Makeup Gain the output gets close to 20Vpp.

That said, maybe that should be something that can be set for the whole library via a DaisySPConfig struct or something because everything is based on nominal 0dB==1.0 right now.

Overall, this is most likely good to go. I'm going to run a few more tests in a little and then I'll get it merged.

@stephenhensley stephenhensley merged commit 832164c into electro-smith:master Jul 27, 2020
@AvAars
Copy link
Contributor Author

AvAars commented Jul 28, 2020

Great 👍 I'm using it on my Patch as well, but running the output straight into a performance mixer with 20dB headroom so I didn't experience any issues. For other modules it might be too hot indeed.

The auto makeup gain is based on this topic where the auto makeup gain of TASCAM products is explained:

  • Calculate the amount of gain reduction would be applied to a 0dBFS signal.
  • Halve that.
  • Add it.

It would be easy enough to implement a 0dB = -6dB correction (adding it to the threshold in the processing stage, but not in the calculation of the makeup gain), so that's easily fixed when there a library-wide configuration option is available. It would be a nuisance to use if it would be implemented as a regular option for the compressor.

@AvAars AvAars deleted the compressor-improvement branch July 28, 2020 19:33
@AvAars AvAars restored the compressor-improvement branch July 28, 2020 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants