Convolution gain louder at higher sample rates
-
@dustbro said in Convolution gain louder at higher sample rates:
uch for this! I think I have it (mostly) working.
Any words of advice on how to deal with a user changing sample rates while the plugin is loaded?
I tried this in the preparedToPlay callback with no luckWas this ever solved or do I need to monitor the sample rates and change gain accordingly ?
-
@lalalandsynth ittybittybump. :)
-
@lalalandsynth I believe you still have to self monitor these changes
-
Actually I'm not sure whether this is a bug in the convolution engine or a physical /mathematical law that you need to counteract manually. I'd love to encorporate a automatic fix for this into the convolution module directly, but it's not so easy, so maybe something can help me out here.
Let's assume we have a impulse response at 48 kHz with a single dirac at 0dB at sample position 512. And we're convoluting a signal with the same samplerate, then it would be a simple static delay of 512 samples without modification of the gain. Now If we switch to 96kHz, the impulse response needs to be resampled to match the 96kHz signal input. However this means that the upsampling will duplicate the dirac impulse (so that in the 96k response, we'll have a dirac at sampleposition 1024 and 1025, both at 0dB. If we now convolute the 96k signal, we'll get two delays short after each other which basically causes a +6db gain.
In this simple example, the solution would be a 6dB attenuation when we double the samplerate (+12db if we quadruple it, etc), but this is only working for this extremely simple test case - as soon as you have a "real" impulse response the upsampling will not be in this linear relation.
I'm not sure how other convolution reverbs take this into account (or if they don't), so if anybody has a clue about this, let me know.
-
@Christoph-Hart Might be of interest - https://github.com/juce-framework/JUCE/commit/68d30f9c8d8571acf43a39caffc7d5b64ed9f253
And here's the forum post - https://forum.juce.com/t/dsp-convolution-changing-level-depending-on-the-host-sample-rate/
-
@d-healey Well the comment below the commit is correct, the problem is that you can't expect the linearity between resample factor and output gain - you even can't expect the gain change to be the same for each input signal, so it's a highly imprecise thing after all.
-
@christoph-hart I guess it would be helpful to have an approximation at least, I guess not many users are switching sample rates mid project?
-
Or getting a tool that tests different samplerates for an impulse and spits out a compensation table (why not an API we can directly use in script? but execution time might be a problem, or not with the new background thread...)
As @Christoph-Hart said it also depends on the input, but this is a lesser problem since users need to compensate for the signal they put in (as it's always been the case in any audio processing)
-
What about providing several impulses at different sample rates and loading the one based on the "current" sample rate?
-
@d-healey I'm not sure this erases the gain problem, because you have to resample them somewhere anyway, but I might be mistaken...
-
Here's an interesting consideration in the last post:
https://dsp.stackexchange.com/questions/78354/is-it-ok-to-resample-impulse-response
My opinion would be to record them at different samplerates from the start, so you never resample, and load them as @d-healey mentioned
Although this might not fix the fact that regarding the frequency domain, you'll have additional energy in the upper frequencies at higher SR and so have to deal with (a filter might be enough though) -
Could someone provide me with an IR at two different SR for which you approximately know the gain difference?
I'd like to make some tests... -
This is from two years ago, was there any change in Hise? I have this same problem.
Is it possible to decrease the volume of the Convolution Reverb samples with some configuration? So I could decrease the volume of the samples according to the sample rate.
-
@bendurso I ended up doing some calculations for the gain differences and threw it in a script.
-
@Dan-Korneff said in Convolution gain louder at higher sample rates:
I ended up doing some calculations for the gain differences and threw it in a script.
Did you put a "Simple Gain" and modify it based on the currentSampleRate?
Because only the Wet signal is increased by the sample rate change. The Dry stays the same, and if I put a Simple Gain it will also impact the Dry signal.
-
@bendurso I did. I leave the convolution node set to full wet and mange the blend separately.
-
@Dan-Korneff Cool thanks, I was learning scriptnode these days and I was able to do that. But how did you monitor the Sample Rate changes? In your last code post you were asking about that.
Making a timer to monitor the current sample rate would be another option to constantly output the values. Wouldn't there be any problem with this?