MUtility - Expression Panel code - help needed

Official support for: meldaproduction.com
RELATED
PRODUCTS

Post

I've invested plenty of hours on this yesterday, and then pretty much gave up because I could get nothing to run.


I did some digging on MUtility. The "Expression Panel" allows for C/C++ type code to do specific mathematical taks. And I hope somebody can help me either write up a line of code, or just tell me how to do this right.


What I want to do:

Quite simple actually - and to some maybe stupid, but I have my reasons for this. I want MUtility to listen on the input of the plugin, and then instantly (sample accurately) normalize everything to -1dBFS on the output side of things.

Example:
First Input sample signal is at -60dBFS, I want to instantly bring it up to -1dBFS
Second Input sample signal then drops down to -80dBFS; I want to instantly bring it up to -1dBFS
Third input sample then shoots up to -30dBFS, I still want to bring it up to -1dBFS


I've tried to dip my toe into the code, and thought of an if/then/else solution. Or just if/then. And then I tried stuff like:

Code: Select all

x <= max ? y == max
Nothing. I tried and tried various combinations, nothing worked. In fact, the only thing that worked for me was x < 0. And then the signal shot up to like +30dB beyond the 0dBFS ceiling, completely out of control. Then i tried the Math Panel again, and even just nudging the Log function let things go instantly out of control.


So what am I doing wrong?
How do I pull off this endeavor?
Can I even create something like that with one simple line of code?



Before anybody says "just use MAutoVolume or MAGC or similar"

I am not(!) after an auto gain as in "loudness normalization" (vocals, stereo mix, etc), or something that is controlled with an external signal. For this I have like 10 different tools already. So I am not after that.



Any help in a timely manner would be greatly appreciated.
Thanks
[ Mix Challenge ] | [ Studio Page / Twitter ] | [ KVRmarks (see: metering tools) ]

Post

Looking at your code statement

Code: Select all

x <= max ? y == max
<= is a binary logical operator
== is a binary logical operator
max is a binary arithmetic operator
So the statement is probably just ignored.

Perhaps use something like (but I am only guessing ;))

Code: Select all

max(x, 0.90) 
But instead of 0.90 you'll need to use whatever -1 dBFS is when converted to amplitude.

Edit: oops, that works on samples with 0 amplitude (silence) too, so it needs some sort of guard condition.
DarkStar, ... Interesting, if true
Inspired by ...

Post

This is getting closer:

Code: Select all

x>0.1?max(x,0.89):x
Image

Edit: 0.1 should be smaller. And it needs to deal with negative amplitudes too. Maybe nested 'if' tests? Something like this (but I have not tried it):

Code: Select all

x>0.001?max(x,0.89):x<-0.001?min(x,0.89):x
There are some handy calculators here:
http://www.sengpielaudio.com/calculator-levelchange.htm
DarkStar, ... Interesting, if true
Inspired by ...

Post

First and foremost - thank you for investing the time. Definitely appreciated.

I've just tried the code, and I can only the the positive wave to "glue" to 0dB - and not even fully (i still need to activate the Limiter Function - which still lets signal through on occasion).

I've also tried the second code (as in - the nested if), and nothing happens. The results are also not really what I'm looking after. It... sounds distorted (well - duh!), even with a pure sine wave (duh again). Maybe this is not what I've expected to happen.


So I tried MCompressor and used a custom shape, plus the "Normalize to 0dB" function, attack at 2ms and release 2ms. Still slightly distorted, but definitely more what I'm after.

The problem here is: the signal still exceeds 0dBFS, and the limiter doesn't catch that. Oh well.


Still - was worth a shot. And for the time being, I might go with this route for experimental purposes (MCompressor/custom shape).

Thank you for the help/input.
[ Mix Challenge ] | [ Studio Page / Twitter ] | [ KVRmarks (see: metering tools) ]

Post

Purely out of curiosity, what are you doing that for? And what does it sound like?

Post

What that's for: Sound experiments
What it should sound like: clean, undistorted
What does it sound like (if it works): just loud signals (loud ones being loud, quiet ones being "sucked up")
[ Mix Challenge ] | [ Studio Page / Twitter ] | [ KVRmarks (see: metering tools) ]

Post

Why not use a wave shaper with custom graph and a very heavy S curve that makes loud things very loud and quiet things very quiet. Melda added a second S curve that is much more exaggerated for this sort of purpose. I think I'm missing something maybe? Sorry if I'm being dumb

Post

Compyfox wrote: Wed May 13, 2020 10:35 pm I've also tried the second code (as in - the nested if), and nothing happens.
I only guessed that nested ifs might work in MUtility. Maybe it's too much for the expression evaluator. :)
DarkStar, ... Interesting, if true
Inspired by ...

Post

What happens if you use MTransformer for this? Look at 10:45 in this video:

Post

I can look into it, but I don't own a MTransformer license.

Do not expect that people are on the "Subscription Plan" or the MTotalBundle. Hence me asking for MUtility specifically.
[ Mix Challenge ] | [ Studio Page / Twitter ] | [ KVRmarks (see: metering tools) ]

Post

Don't get exactly what you want to do, but here's a formula with a "?" that might help

Code: Select all

abs(x)>0.1?0.25*x/abs(x):x
What it does:
1.) abs(x) transfrorms the negative half wave into positive, so we only have x values in range [0,1]
2.) "abs(x) > 0.1?" check whether the value is bigger than 0.1. Keep in mind we used abs - this actually means values of x large then 0.1 AND values of x smaller than -0.1 will be detected.
3.) 0.25*x/abs(x) - sets the output value to 0.25. The x/abs(x) factor will have only the values 1 or -1 and is there to put the output into the positive half wave if x is positive or in the negative half wave if its negative ... little trick because the sign(x) function is missing.
4.) Everything put together means: if the value of x is > 0.1 then set it to fixed value 0.25 or -0.25 respectively. Otherwise output x.

Check out the screenshot: Input is a sawtooth waveform. You can clearly see that levels above 10% (0.1 in formula) in Oscilloscope Window are set to 25% (0.25 in formula) in both half waves.
You do not have the required permissions to view the files attached to this post.
Last edited by ] Peter:H [ on Sat May 16, 2020 3:33 pm, edited 4 times in total.

Post

And here's it with changed "<" to ">" in the formula of my previous post. Check out the difference in the screenshot. Input is again a sawtooth.

Code: Select all

abs(x)<0.1?0.25*x/abs(x):x
@CompyFox - I carefully re-read your initial post. if any sample regardless of what the input is is leveled up to the same level then this will result actually in a Square Wave... But may be that is not what you want. May be you can add a "drawing" to help me understand your problem and then I might find the formula for you.
You do not have the required permissions to view the files attached to this post.
Last edited by ] Peter:H [ on Sat May 16, 2020 3:33 pm, edited 1 time in total.

Post

Another idea: Use MCompressor, which is free, and has a drawable transfer curve. I tried this, putting all nodes at -1 (The leftmost node being as close to silence as possible for the input level axis, and putting it at -1 for the output. ). At first, it just sounded louder, until I turned the attack and release down to 0 ms. Then was was some weirdness that I got out of the sound.
* I'm still blown away that a free compressor does this- upward & downward compression & expansion.
And you can draw any crazy curve that you want, with as many nodes as you want. :borg:

Post

Please see the Peter:H's ideas above. BUT what you are trying to do is VERY VERY wrong. What you are basically doing is a module, that would only produce -1, 0 or 1, and the 0 is nearly impossible. What normalization does usually is that it analyzes THE ENTIRE audio and gains the whole think based on the highest (abs) sample. In your case you are essentially doing the same thing is using nearly infinite gain and clipping the output. Well, maybe you want that :D, I wouldn't :D.
Vojtech
MeldaProduction MSoundFactory MDrummer MCompleteBundle The best plugins in the world :D

Post

I don't.

In fact, I'd use MCompressor with a custom curve, but funny enough... The "Maximize to 0dBFS" feature somewhat works, but Limiter doesn't limit to 0dBFS. And the Oversampling changes the sound too much.

I guess the Melda Production tools just can't help me with what I'm after experimentation wise.
[ Mix Challenge ] | [ Studio Page / Twitter ] | [ KVRmarks (see: metering tools) ]

Locked

Return to “MeldaProduction”