Open Riebeck-one opened 5 months ago
The total volume could only be the same over the blend scale when you use two identical models. There may be phase differences with some models which lead to the impression of a volume drop. That means, not all models working nicely together when blend them. But, that could on the other hand be a nice effect. To make a blind test you need to load two times the same model. The formula I use for the blend is the good old faust wet/dry control
wet_dry = vslider("wet_dry", 50, 0, 100, 1) : /(100);
dry = 1 - wet_dry;
process = (*(dry),*(wet_dry):>_), (*(dry),*(wet_dry):>_);
In Ratatouille the Blend is done here: https://github.com/brummer10/Ratatouille.lv2/blob/main/Ratatouille/Ratatouille.cpp#L755 when mix aida-x with NAM, otherwise, when mix two NAM files it is done here: https://github.com/brummer10/Ratatouille.lv2/blob/main/Ratatouille/Ratatouille.cpp#L755 when mix to aida-x files it is done here: https://github.com/brummer10/Ratatouille.lv2/blob/main/Ratatouille/RtNeuralMulti.cc#L195
It's always the same process. You may play with the formula, when you found a better approve, let me know.
I've added a small delay to allow to fix phasing issues (if the arrive). Additional it could be used to color the sound. The delay will be applied to the second model.
It seems like the blend knob does not keep the volume constant across its range. What I mean is that having the blend set to 0 or 1 gives approximately the same output volume, but setting it to a value in between, like 0.5, results in a much lower volume.
I tried to look into your code to see what is really happening with the blend option. I'm very rusty with my C++, and I do not know exactly how LV2 plugins work internally, so I might be saying something irrelevant, but hey, you never know.
I made some calculations to find how you could add the volumes of the two channels corresponding to each neural network. Let $L_1$ be the volume of the first one, $L2$ the volume of the second one, $L{\text{tot}}$ the total volume when the two are combined, and $x$ the value of the blend setting (which ranges from 0 to 1). I supposed all volumes are in dB.
My assumption is that:
$L{\text{tot}} = 10 \log{10} \left( x \cdot 10^{L_1/10} + (1-x) \cdot 10^{L_2/10} \right)$
Maybe you're already using this kind of formula, but if you don't (and if I didn't make a mistake in my reasoning and calculations), it should make the volume constant across the range of the blend knob.