HISE Logo Forum
    • Categories
    • Register
    • Login

    Gain Reduction Meter on a Faust compressor

    Scheduled Pinned Locked Moved Unsolved General Questions
    scriptnodefaustmeters
    15 Posts 7 Posters 619 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.
    • A
      aaronventure @Mighty23
      last edited by

      @Mighty23 when you make a graph, it creates an output cable like that? what does the faust code for that look like?

      M Christoph HartC 2 Replies Last reply Reply Quote 0
      • M
        Mighty23 @aaronventure
        last edited by

        @aaronventure
        the full code is in the snippet in the main post. inside Script FX1 there is the faust node.

            // Add gain reduction meters to the UI
            gainReductionLeft = gain_reduction(l) : vbargraph("Gain Reduction Left", -60, 0);   // Left channel
            gainReductionRight = gain_reduction(r) : vbargraph("Gain Reduction Right", -60, 0);  // Right channel
        };
        

        Free Party, Free Tekno & Free Software too

        U 1 Reply Last reply Reply Quote 1
        • U
          udalilprofile @Mighty23
          last edited by

          @Mighty23
          Hello. Were you able to solve the problem? What compressor are you using?

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

            @aaronventure the vbargraph UI element in Faust translates to a mod output.

            T 1 Reply Last reply Reply Quote 0
            • M
              Mighty23
              last edited by

              @udalilprofile @aaronventure

              import("stdfaust.lib");
              
              /* Controls */
              comp_group(x) = hgroup("1-compression", x);
              env_group(x)  = vgroup("2-envelop", x);
              gain_group(x) = vgroup("3-gain", x);
              link_group(x) = vgroup("4-channel linking", x);
              
              // Controls
              ratio     = comp_group(nentry("ratio", 2, 1, 20, 0.1));
              threshold = comp_group(nentry("threshold", -20, -96, 10, 0.1));
              knee      = comp_group(nentry("knee", 3, 0, 20, 0.1));
              attack    = env_group(hslider("attack [unit:ms]", 2, 0, 1000, 0.1) : /(1000)) : max(1/ma.SR);
              release   = env_group(hslider("release [unit:ms]", 500, 0, 10000, 1) : /(1000)) : max(1/ma.SR);
              makeup_gain = gain_group(hslider("makeup gain", 0, -96, 96, 0.1));
              
              // Control for channel linking  - stereo vs dual mono.
              channel_link = link_group(hslider("channel link", 100, 0, 100, 1) : /(100));
              
              // Envelope detector
              t = 0.1;
              g = exp(-1/(ma.SR*t));
              env = abs : *(1-g) : + ~ *(g);
              
              // Compression function 
              compress(env) = level*(1-r)/r
              with {
                  level = env : h ~ _ : ba.linear2db : (_-threshold+knee) : max(0)
                  with {
                      h(x,y) = f*x+(1-f)*y with { f = (x<y)*ga+(x>=y)*gr; };
                      ga = exp(-1/(ma.SR*attack));
                      gr = exp(-1/(ma.SR*release));
                  };
                  p = level/(knee+0.001) : max(0) : min(1);
                  r = 1-p+p*ratio;
              };
              
              // Gain computer for a single channel
              gain_computer(x) = env(x) : compress : gain : +(makeup_gain) : ba.db2linear
              with {
                  gain(x) = attach(x, x : gain_group(hbargraph("gain", -96, 0)));
              };
              
              // Gain reduction calculation (in dB)
              gain_reduction(env) = env : ba.linear2db : (_ - compress(env)) : min(0);
              
              // Main process
              process(l,r) = (gl*l, gr*r)
              with {
                  g_left = gain_computer(l);
                  g_right = gain_computer(r);
                  g_linked = max(g_left, g_right);
                  
                  gl = g_left*(1-channel_link) + g_linked*channel_link;
                  gr = g_right*(1-channel_link) + g_linked*channel_link;
                  
                  
                  gainReductionLeft = gain_reduction(l) : hbargraph("[5]Gain Reduction Left[style:numerical]", -60, 0);
                  gainReductionRight = gain_reduction(r) : hbargraph("[6]Gain Reduction Right[style:numerical]", -60, 0);
              };
              

              @udalilprofile said in Gain Reduction Meter on a Faust compressor:

              Hello. Were you able to solve the problem? What compressor are you using?

              I'm still trying, as soon as I can get a decent version I'll post a snippet.

              Free Party, Free Tekno & Free Software too

              U 1 Reply Last reply Reply Quote 0
              • M Mighty23 marked this topic as a question on
              • U
                udalilprofile @Mighty23
                last edited by

                @Mighty23 thnx)

                1 Reply Last reply Reply Quote 0
                • T
                  trummerschlunk @Christoph Hart
                  last edited by

                  @Christoph-Hart How exactly would I access the 'mod output' of a vbargraph UI element?
                  My goal is to simply put a meter from my faust code on the interface.

                  A 1 Reply Last reply Reply Quote 0
                  • A
                    aaronventure @trummerschlunk
                    last edited by aaronventure

                    @trummerschlunk Right now you can't because the mod output goes away once you compile the node and you can only use a compiled Faust node within ScriptNode.

                    Link Preview Image
                    [Engine/ScriptNode/Faust] Compiling a Faust node with vbargraph outputs doesn't preserve them in the compiled node · Issue #619 · christophhart/HISE

                    If you use vbargraph in Faust, it will create a cable output in the node, but the cable outputs will not be present on the compiled node. something = 0.3; somethingElse = 0.5; intermediary = something * somethingElse : vbargraph("[0]Cabl...

                    favicon

                    GitHub (github.com)

                    But to answer your question, you would just pass your GR through vbargraph.

                    Let's say you're calculating it separately so

                    gainReduction = gain reduction math here : vbargraph("GainReduction",0,1);
                    

                    Link Preview Image
                    Faust Syntax - Faust Documentation

                    favicon

                    (faustdoc.grame.fr)

                    T 1 Reply Last reply Reply Quote 0
                    • T
                      trummerschlunk @aaronventure
                      last edited by

                      @aaronventure so I understand correctly: no workaround?

                      A 1 Reply Last reply Reply Quote 0
                      • A
                        aaronventure @trummerschlunk
                        last edited by

                        @trummerschlunk depends on what you're metering. If it's just the gain reduction, you can have a peak node before the faust node and another right after, subtract these to get the difference (do it in the modchain so that it doesn't affect your audio signal) and there's your gain reduction.

                        If you're metering something else, you can do one of two things:

                        • run a multichannel scriptnode (4 channels for example) with a 4 channel faust effect and simply output whatever you're metering to the other two channels, get them specifically with a multi node (to separate the channels) and use that in your interface
                        • create another version of your faust effect where you're outputting whatever your metering and just connect it to the same parameters as your main faust effect (keep in mind that, since you're gonna be doing this in modchain, you only need one channel out of faust as modchain is a single channel node
                        T 1 Reply Last reply Reply Quote 0
                        • T
                          trummerschlunk @aaronventure
                          last edited by

                          @aaronventure ok, thanks...
                          For me it's not about gain reduction, so I hope the first option for 'metering something else' will work. I have a lot of meters though... 20 to be precise...

                          S 1 Reply Last reply Reply Quote 0
                          • S
                            sletz @trummerschlunk
                            last edited by

                            @trummerschlunk see my answer here: https://faustdoc.grame.fr/manual/syntax/#attach-primitive

                            T 1 Reply Last reply Reply Quote 0
                            • T
                              trummerschlunk @sletz
                              last edited by

                              Thanks, @sletz, I am aware of the attach primitive. The problem is that no metering signals are available in HISE when the dsp network is compiled.

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

                              11

                              Online

                              1.7k

                              Users

                              11.8k

                              Topics

                              102.7k

                              Posts