HISE Logo Forum
    • Categories
    • Register
    • Login

    Convolution gain louder at higher sample rates

    Scheduled Pinned Locked Moved Bug Reports
    samplerateconvolution
    37 Posts 7 Posters 2.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Dan KorneffD
      Dan Korneff @Christoph Hart
      last edited by

      @Christoph-Hart I have about 2-3 seconds of tail in the impulse.
      I'm gonna do some proper testing today and report back with my findings.

      Dan Korneff - Producer / Mixer / Audio Nerd

      1 Reply Last reply Reply Quote 0
      • Dan KorneffD
        Dan Korneff
        last edited by

        Working on a project with the Convolution reverb and ran into this problem again.
        I made a simple convolution as a test, and here's what I found:

        file used in convolution =
        6789tyhgy67878s1.wav

        and here are the processed results at different sample rates:
        processed files.png

        processed files are louder at higher sample rates

        Dan Korneff - Producer / Mixer / Audio Nerd

        1 Reply Last reply Reply Quote 0
        • Christoph HartC
          Christoph Hart
          last edited by

          Wow, that's a weird one. I've tracked it down to something deep inside the convolution library I am using, but I can't fix it inside the library (also I really don't understand what's causing the gain increase on a theoretical DSP level, the convolution algorithm should not be affected by the amount of samples that you feed it into, all it does is basically shifting the signal into lower FFT bins).

          My empirical tests show that there is a logarithmic correlation between samplerate and gain across different IRs (the actual gain increase varies a little bit, but these are the average numbers:

          44,1kHz: -1dB
          48kHz: 0dB (reference)
          96kHz: +3.5dB
          192kHz: +6.6dB

          I've tested it with the 4-5 IRs I had on my laptop and the noise generator (this signal might be the best candidate for checking the overall gain on an IR). Can you verify this with a few other IRs? Because my gut feeling tells me that we just need to bake in this gain change of the average IR as constant multiplier based on the resample factor and then live with the small inconsistencies (there will always some kind of inconsistency caused by the IR resampling so it will never be mathematically perfect anyway).

          1 Reply Last reply Reply Quote 0
          • Dan KorneffD
            Dan Korneff
            last edited by

            Here's what I'm seeing on my end
            Reference is White Noise @ -20

            conv ref chart.png

            Dan Korneff - Producer / Mixer / Audio Nerd

            1 Reply Last reply Reply Quote 0
            • Dan KorneffD
              Dan Korneff
              last edited by

              Also noticing that the AudioWaveform panel is affected by files at different sample rates as well.
              Check out these images.
              Same IR at different sample rates.

              44.1k
              WAVE 44.png

              96k
              WAVE 96.png

              There also seems to be a center offset for mono files as well?

              Dan Korneff - Producer / Mixer / Audio Nerd

              1 Reply Last reply Reply Quote 0
              • Dan KorneffD
                Dan Korneff
                last edited by

                @Christoph-Hart I was going to use Simple Gain to compensate for the level difference, but I'm getting an error.

                var SR = Engine.getSampleRate();
                const var Label1 = Content.getComponent("Label1");
                Label1.set("text", SR);
                

                Within HISE, this code works. But in a DAW, Engine.getSampleRate() returns -1

                Dan Korneff - Producer / Mixer / Audio Nerd

                1 Reply Last reply Reply Quote 0
                • Christoph HartC
                  Christoph Hart
                  last edited by

                  The onInit callback will be executed before the samplerate is known in a plugin so you need to make sure to defer that - you're safest bet would be a script FX and its preparedToPlay callback because this is where you usually setup the processing stuff.

                  But just out of curiosity because your numbers differ vastly from my ones: what did you measure for the file you've uploaded? I am still not sure if this is a constant gain factor and how much does it depend on the impulse response type.

                  Dan KorneffD 1 Reply Last reply Reply Quote 1
                  • Dan KorneffD
                    Dan Korneff @Christoph Hart
                    last edited by

                    @Christoph-Hart I'll measure those impulses asap

                    Dan Korneff - Producer / Mixer / Audio Nerd

                    1 Reply Last reply Reply Quote 0
                    • Dan KorneffD
                      Dan Korneff
                      last edited by

                      for the file I uploaded
                      44 = -18
                      48 = -17.6
                      88 = -14.9
                      96 = -12.6
                      174 = -11.7
                      192 = -11.9

                      Dan Korneff - Producer / Mixer / Audio Nerd

                      1 Reply Last reply Reply Quote 0
                      • Dan KorneffD
                        Dan Korneff
                        last edited by

                        I'm just noticing that the first IR I uploaded was a stereo file, and the rest were mono. That appears to make a difference on the output level as well.

                        Dan Korneff - Producer / Mixer / Audio Nerd

                        1 Reply Last reply Reply Quote 0
                        • Christoph HartC
                          Christoph Hart
                          last edited by

                          Yeah sure, let's add that to the number of weird reasons why the gain goes up. What else? The length of the filename? :)

                          Dan KorneffD 1 Reply Last reply Reply Quote 1
                          • Dan KorneffD
                            Dan Korneff @Christoph Hart
                            last edited by

                            @Christoph-Hart 🤣

                            Dan Korneff - Producer / Mixer / Audio Nerd

                            1 Reply Last reply Reply Quote 0
                            • M
                              mwplugs
                              last edited by

                              convolution is producing a distorted digital noise at sample rates 44.1 and 48khz anything above the behave perfect. but with every one tested there is a distortion below 88.2

                              Dan KorneffD 1 Reply Last reply Reply Quote 0
                              • Dan KorneffD
                                Dan Korneff @mwplugs
                                last edited by

                                @mwplugs I'm about to add convolution to a project. I'll report what happens on my end.

                                Dan Korneff - Producer / Mixer / Audio Nerd

                                M 1 Reply Last reply Reply Quote 0
                                • M
                                  mwplugs @Dan Korneff
                                  last edited by

                                  @dustbro ok yeah i cant figure it out for the life of me

                                  1 Reply Last reply Reply Quote 0
                                  • Dan KorneffD
                                    Dan Korneff
                                    last edited by Dan Korneff

                                    @Christoph-Hart I could use a little help getting Engine.getSampleRate() to work properly.
                                    I would like to use the sample rate as a variable to compensate for the gain difference with different sample rates.
                                    I've added a global variable with Engine.getSampleRate() to the preparedToPlay callback, which works in HISE, but the exported plugin shows "undefined" for the sample rate. 🤷

                                    here's a snippit:

                                    HiseSnippet 1224.3oc0X8+SabCE2GvMQRajZq1e.V7SAsD5EZfRWU0nDftnUfnFFqSUnNm6bRrvw9zYGFYUU6Os8ezz9OX6YeG4tKbvXYZnQ9g.98M+487yedF5DI8oJkLB4T53IgTjyCc6NQnG1ZHgIPs2E47DWEYTHmhiHZJVSUZzNSBIJEM.43r3aL14TZIj8ye7M6P3DgOMUDBchj4SeKaDSmJsy1eGiy2mDPOlMJi0M2tsuTzRxkiALsnqGJj3eFY.8PhwrEbQNewdALsLpqFviBrYGYvjtCk+rH19SXJVON0rnApKDnXwnVCY7fNWluJDxYoNoY+hwY+W5d.KfMUdZU3QVE3TOxVCbVHOjVJGjZbcPZeIOvDfqAdNYf2Rwv6wtc8iXg5TMF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b+AvOxsC4+CMD2E7I2E6wHhej7i9wrolqlKak.4sv9mLWx8.yZbCjk1G7y0aMOzH3Om8i99lwx0g5Sw9r9b3yylCeZNG9rwb3ylygOOeN7YqazGy+IgWOVKGE2+CB5rmcZiiydBBzIauJf9KvoIPOm
                                    

                                    Dan Korneff - Producer / Mixer / Audio Nerd

                                    1 Reply Last reply Reply Quote 1
                                    • Christoph HartC
                                      Christoph Hart
                                      last edited by

                                      You're declaring the global variable in the prepareCallback itself (I wasn't aware that this is possible, might have to add a safe check to prevent this at some point).

                                      This means that the variable will be initialised long after the interface script has run, so undefined is exactly what's happening...

                                      BTW, the safest way to use global variables is to define them in the first script (most likely the interface script) and also tuck them behind a condition so that it just gets initialised if it doesn't exist:

                                      if(!isDefined(myGlobalVariable))
                                      {
                                         global myVariable = 90;
                                      }
                                      

                                      If you don't do this, the variable will get reinitialised everytime you compile the interface script which is not a problem in your case, but might lead to annoying issues when using more complex data (because the other scripts might use a reference to the old object).

                                      Dan KorneffD 1 Reply Last reply Reply Quote 2
                                      • Dan KorneffD
                                        Dan Korneff @Christoph Hart
                                        last edited by

                                        @Christoph-Hart Thanks so much 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 luck

                                        if (HostSampleRate != Engine.getSampleRate())
                                        {
                                             ..... some function to update HostSampleRate
                                        }

                                        Dan Korneff - Producer / Mixer / Audio Nerd

                                        lalalandsynthL 1 Reply Last reply Reply Quote 0
                                        • lalalandsynthL
                                          lalalandsynth @Dan Korneff
                                          last edited by

                                          @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 luck

                                          Was this ever solved or do I need to monitor the sample rates and change gain accordingly ?

                                          https://lalalandaudio.com/

                                          https://lalalandsynth.com/

                                          https://www.facebook.com/lalalandsynth

                                          https://www.facebook.com/lalalandsynth

                                          lalalandsynthL Dan KorneffD 2 Replies Last reply Reply Quote 0
                                          • lalalandsynthL
                                            lalalandsynth @lalalandsynth
                                            last edited by

                                            @lalalandsynth ittybittybump. :)

                                            https://lalalandaudio.com/

                                            https://lalalandsynth.com/

                                            https://www.facebook.com/lalalandsynth

                                            https://www.facebook.com/lalalandsynth

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            53

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            101.8k

                                            Posts