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

Add support for stereo/multichannel input #4

Open
iver56 opened this issue Aug 18, 2022 · 7 comments
Open

Add support for stereo/multichannel input #4

iver56 opened this issue Aug 18, 2022 · 7 comments

Comments

@iver56
Copy link
Contributor

iver56 commented Aug 18, 2022

I'd love to add a wrapper for this limiter in audiomentations. In that context it would be nice to have support for stereo, so e.g. the music source separation community can enjoy the transform.

For now I will set supports_multichannel = False

@pzelasko
Copy link
Owner

Thanks, I’d love to help here. How do you envision stereo support? Do you think that the limiter needs to process 2-channel information together to estimate the gain, or is it sufficient to create a limiter instance per each channel? In the latter case you could probably use it as is.

@iver56
Copy link
Contributor Author

iver56 commented Aug 18, 2022

Hmm, I haven't thought so much about the details, but here are two quick cents

cent 1:
Applying it to each channel individually could sound bad because inconsistencies between left and right can be quite noticeable to the human ear

cent 2 (alternative approach):

  • Perform any loudness analysis on a monofied signal
  • Apply the same gain to both/all channels

What do professional limiters, like Waves L2 do with stereo audio?

@iver56
Copy link
Contributor Author

iver56 commented Aug 18, 2022

Some limiters offer stereo linking controls, the manipulation of which can have an effect on the width of your mix. Left totally unlinked, both channels will be limited independently, causing each channel or the other to dip in level on its own. This can create an interesting sense of width, because each side of the stereo image is reacting differently to the limiter, drawing the ear in different directions. When pushed too far, unlinked limiting can cause the stereo image to wander in distracting, unpleasant ways.

https://www.izotope.com/en/learn/an-introduction-to-limiters-and-how-to-use-them.html

Ok, so applying the limiter to each channel individually could actually be an option

@iver56
Copy link
Contributor Author

iver56 commented Aug 18, 2022

https://gearspace.com/board/mastering-forum/592906-stereo-link-mastering-limiter.html

It seems some audio engineers like their limiter stereo-linked, some like it unlinked, others prefer something in-between (e.g. 70% linked). If we want to cater to everyone, we need a parameter that controls how "linked" the channel gains should be if the input is multichannel. In other words, a float in the range [0.0, 1.0]

@pzelasko
Copy link
Owner

OK, I'll try to look into it in the following days.

@Fretless14
Copy link

Hey guys, professional audio mix engineer here 🙂

Yeah usually there is a "stereo link" option that you can turn on and off, and in advanced cases you can mix them together with a mix knob keeping the gain (or power?) the same.

I'm looking at adding a limiter to one of my apps and at first glance this seems like a great fit :) let me know if you have any questions or want any input from a professional in the audio industry! I can also maybe contribute some if I have time, though I primarily work in Python and somewhat limited experience in C++.

@pzelasko
Copy link
Owner

Hi there! Sorry for a long time to reply, I was traveling. If you'd like to contribute the stereo link feature that would be awesome! If I understand it right, you'd basically need to modify the code to:

  • accept stereo input (or multi-channel in a more general case); can be done by adding an optional argument num_channels in the C++ code and interpreting channel_idx * num_samples as stride into the samples array / pointer
  • to determine whether the limiter is active, modify this line to look at each channel's samples:
    envelope_ = max(abs(sample), envelope_ * release_);
  • apply the gain to each channel in place of:
    audio[idx] = delay_line_[delay_index_] * gain_;

Let me know if you'd be picking it up.

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

No branches or pull requests

3 participants