-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 effect #12523
Compressor effect #12523
Conversation
Welcome at Mixxx! |
Done! |
The Ubuntu builds and the pre-commit check are failing. All these CI checks needs to be pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple comments, thank you very much so far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I have left some comments. Not yet tested.
autoMakeUp->setName(QObject::tr("Auto Makeup Gain")); | ||
autoMakeUp->setShortName(QObject::tr("Makeup")); | ||
autoMakeUp->setDescription(QObject::tr( | ||
"The AutoMakeup button enables automatic makeup gain to 0 db level")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The AutoMakeup button enables automatic makeup gain to 0 db level")); | |
"The Auto Makeup button enables automatic gain adjustment so that the perceived volume does not change. ")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact this description isn't true, because this algorithm adjusts volume to 0 dBFS (actually around -3 dBFS) in anyways. So it doesn't matter, what was the original level, output will be almost 0 dBFS (even if original input was -30 dBFS for example).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, than you may add a true description?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think originally it was true, however your suggestion changes the meaning. If you don't like the original one, I can try to reformulate it. In fact it just adjusts volume to almost 0 dBFS level for any input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about it and it's just come to my mind that maybe it's better to call it "AGC (Auto Gain Coontrol)"? What do you think?
double makeUpStateDB = pState->previousMakeUpGain; | ||
CSAMPLE maxSample = SampleUtil::maxAbsAmplitude(pOutput, numSamples); | ||
if (maxSample > 0) { | ||
double maxSampleDB = ratio2db(maxSample); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a warning here:
/home/daniel/workspace/mixxx2/src/effects/backends/builtin/compressoreffect.cpp:165:48: required from here
/home/daniel/workspace/mixxx2/src/util/math.h:78:21: warning: conversion from ‘double’ to ‘float’ may change value [-Wfloat-conversion]
78 | return log10(a) * 20;
| ~~~~~~~~~^~~~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I have no clue, why this warning is still here. I think I have convertion from float to double, but not double to float.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ratio2db is a template type. It uses the float implementation because of CSAMPLE maxSample
But log10() is double. So it looks like a static cast to T is missing.
return static_cast<T>(log10(a)) * 20;
Not you fault, but please fix it.
The other question is if we need double precision for maxSampleDB, nd can we avoid the DB round trip and instead use the ratio values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's a good question. I managed to avoid this DB round trip, so now I don't use ratio2db() and db2ratio() for applying make up.
constexpr CSAMPLE_GAIN kMakeUpAttackCoeff = 0.03f; | ||
constexpr CSAMPLE_GAIN kMakeUpTarget = -3.0f; | ||
|
||
double calculateBallistics(double paramMs, const mixxx::EngineParameters& engineParameters) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I use it on these lines: 117,119,193,201 in compressoreffect.cpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, the issue is that it is unused in very cpp file that includes the h file. Can we move the whole namespace to the CPP file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. sure. I've moved it to CPP file.
I have tested this briefly and it works good. Thank you.
|
Thank you for testing and for the good points.
Yes, I've added line breaks.
Actually I'm not sure, that it could be useful. Compressor it's not a sound effect, it's more about sound tuning. Usually you find the best settings for you and use it all the time. So it will be strange if someone tries to increase and decrease attack or release knob for example dureing the perfomance, because it just mess up the sound.
Personally I think it should be "Gain", because it's the same in meaning as "Main Output Gain" knob in the main mixer for example.
I guess you are talking about using "Auto Makeup Gain". So as it says in the description, it tries to adjust volume level to 0dBFS. So if someone wants to decrease it, they definetely can do it via gain knob.
I think it's a good idea, but I don't know how to introduce some "listener" to the Makeup switch button. Do you know how to do it?
I believe it's because of the same bug as #12451. So if we apply compressor effect to the Deck 1 for example, then it should be applied before fade out (volume control). But in reallity it is applied after volume control and so completely comprensate it.
I'm not sure, that I understand what you mean. However compressor is a powerful tool, it's always possible to mess everything up with the wrong settings. So it's kind of "by design". |
First of all, I am very happy with your work looking forward to integrate it into Mixxx. I am sorry for the delays in review. Sometimes a written review sounds hard and does not transport the precognition your work deserves.
An issue is that we have pre-fader and postfader effects. Currently the compressor works only for as prefader, which is the Quick effect where only on knob is available. My use case is to use it to adjust 70th tracks or classic tracks with modern pop songs.
The "Main Output Gain" is the input Gain of you PA. So we should not judge from that. I have found more instances where it is called level without make-up the context. On the other hand it is usually called "make-up gain" which is quite long, when it controls the "make-up gain" stage which finally controls the "Level". You currently describe the knob as plain Output Gain which is the "Level". So I suggest to use the label "Level" then. But we may adjust this all altogether with the "makeup" button.
make-up is used to turn the output level of the compressed signal up to compensate the compressor effect. It should ideal match the input gain. The default Input gain is NOT 0 dBFs, as deck effect, because you don't have room for Mixing. In the main stage, you should also not compensate for 0 dBFs, because a digital signal of 0dBFs ma have high frequency parts between the samples which will than clip. 0 dBFs is not recommended for broadcast. This means we should not default to a problematic high value. Can we pick a default that matches the default level of Mixxx?
Ah I see, this is an issue, we can do this easy. We may adjust the two gain knob scales that they match each other for the default Mixxx levels. This should lower the level jump we experience with the "Make-up" button.
We don't have on other solution to put the effect to the quick effect rack. Maybe the auto-make-up is a bit to fast? Can we slow it down or even make it adjustable? For my understanding it needs a time "learn" the input level.
You hear it clearly if you put a reverb before the compressor. All gain changes must be ramped to not have the noise from the resulting rectangular wave. |
Thank you for the review!
I'm not sure, that I completely understand you. But I agree that we need to find good default values. I thought that I found those, but I will try to do it better.
Ok, I will rename it to "Level".
Yes, I will decrease the default value. But I agree with you, that strictly speaking it's not a make-up, it's kind of AGC (Auto gain control).
Yes, I will do it too.
The problem is that if we even don't use the make-up, compressor will compensate fade out until the level becomes lower than compressor threshold. After that the level will drop dramatically, so it will looks like just stopping without fading out. Therefore I think we have to apply fader only after all effects, not before. So may be we need to create an issue for that? Because as I understand most of the other mixxing software do it in such order: firstly effects, secondly fader (or crossfade, microphone ducking and all other stuff).
Thank you, now I hear it. I think I need some time to investigate into it, maybe we need to use another algorithm for make-up or just delete this part. |
Eventually I decided to change the auto make up algorithm, so for now it tries to match the input loudness level (compensate decreasing gain effect from compressor) - as it usually works. Also I fixed crackling (I believe), and renamed "Gain" knob to "Level". As I said before, the auto make up algorithm which I used before was a kind of AGC effect, so I decided to split it to a separate effect. But I can't find any existing issue about AGC. Does anyone know if it's ever been requested? Is it okay if I try to create separate PR with AGC effect later? |
AFAIK, the AGC compressor would be very helpful for the NI stem support feature as the DSP compressor setup embedded in the stem metadata. seem to be relying on such a compressor. SO it would be very useful to have this feature as well!
I think that makes sense yes Also, is it worth targeting |
I just did a brief test, but I was not able to make it work again. Is something broken now? |
continue; | ||
} | ||
|
||
double maxSampleDB = ratio2db(maxSample); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ratio2db() is slow. It would be better to do the calculation in ratio and to the db2ratio() conversion of the parameters outside this busy loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I have to do it? I understand your point, but it's not easy to transform such calculations. I'm sure that it's possible in theory, but the final code will be unreadable. All examples of compressor that I saw before were written in DB values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that was just a suggestion. You may add TODO comment instead, that someone else may pick it up.
No, it's not broken. It should work. As you can see, all checks have passed in GitHub. Maybe the problem is that it's already too old branch? Do I need to rebase it on new master? I see that the 2.4 version is already released, so maybe I need to rebase on 2.5? |
OK, I will test again maybe there was something wrong in my setup. |
Yes, it looks like this PR has been move to the |
Ok, I've rebased to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, works good now.
In my first test I have tested with long attack and release times which was compensated by the auto markup gain. The kMakeUpAttackCoeff fits to the defaults.
Did you consider to adjust it with the buffer size and the attack and the release times?
It is good enough for beta I will file an issue for the final release. I would be happy if you could pick it up.
This is a simple implementation of general single-band compressor, which was requested in this feature request #6453 years ago.
I'm not an expert of compressors, so I've just used general information about it from the Internet, mainly from this readme: https://github.com/p-hlp/CTAGDRC
It's the simpliest solution with gain computer and ballistics, without parameters automation. However in most cases it will be enough, for example, for radio broadcasting.
The only automation I did is the Auto makeup. I haven't found some good example of it, so I tried to introduce some "homemade" algorithm.
I've been using custom build with this effect for radio broadcasting for 2 weeks and it looks good. However, due to this bug #12451 I have some limitations of using this compressor.
Also I'm not a C++ developer, I've been working with Java for years, so there may be some stupid mistakes which I apologize for in advance :)