Forum
    • Categories
    • Register
    • Login

    Rms type or Cosine type Crossfade Curves

    Scheduled Pinned Locked Moved Scripting
    15 Posts 4 Posters 88 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.
    • J
      Jeetender @Lindon
      last edited by Jeetender

      @Lindon How

      const var wetdryknob = Content.getComponent("wetdryknob");
      const var FX_WET = Synth.getEffect("WET");
      const var FX_DRY = Synth.getEffect("DRY");
      
      inline function onWetDryControl(component, value)
      {
          local wetMix = value / 127.0;
          local dryMix = 1.0 - wetMix;
      
          local wetGain = Math.sin(wetMix * Math.PI * 0.5);
          local dryGain = Math.cos(dryMix * Math.PI * 0.5);
      
           wetGain = Math.max(wetGain, 0.0001);
          dryGain = Math.max(dryGain, 0.0001);
      
          local wetDb = Engine.getDecibelsForGainFactor(wetGain);
          local dryDb = Engine.getDecibelsForGainFactor(dryGain);
      
           FX_WET.setAttribute(FX_WET.Gain, wetDb);
          FX_DRY.setAttribute(FX_DRY.Gain, dryDb);
      }
      
      wetdryknob.setControlCallback(onWetDryControl);```
      LindonL 1 Reply Last reply Reply Quote 0
      • David HealeyD
        David Healey @Jeetender
        last edited by

        @Jeetender said in Rms type or Cosine type Crossfade Curves:

        i have a wet and and dry module in HISE

        Can you tell me more about what you are doing because there might be an easier way to achieve what you want.

        Free HISE Bootcamp Full Course for beginners.
        YouTube Channel - Public HISE tutorials
        My Patreon - HISE tutorials

        J 1 Reply Last reply Reply Quote 0
        • J
          Jeetender @David Healey
          last edited by

          @David-Healey iam just trying to create a wet dry balance between the two gain modules. iam not using scriptfx node. the earlier script moved the knobs in opposite direction but it was checking the peak volume, so at 50% the overall gain would just goo silent..

          err.jpg

          David HealeyD 1 Reply Last reply Reply Quote 0
          • David HealeyD
            David Healey @Jeetender
            last edited by

            @Jeetender Have you tried using the send container and send effect for this instead?

            Free HISE Bootcamp Full Course for beginners.
            YouTube Channel - Public HISE tutorials
            My Patreon - HISE tutorials

            J 1 Reply Last reply Reply Quote 0
            • J
              Jeetender @David Healey
              last edited by

              @David-Healey no i did not, but the thing is there, i still have to balance between the send or wet with Dry. there is no direct wet dry balance in the modules...

              David HealeyD griffinboyG 2 Replies Last reply Reply Quote 0
              • David HealeyD
                David Healey @Jeetender
                last edited by

                @Jeetender What about setting the Gain of the SimpleGain where you want it and using a CC modulator to control the actual value (you can connect the Default value knob to a UI knob, you don't actually need to use a CC). Then you could set any shape you want using the modulation tables.

                611b63e8-5067-43ea-baa5-1cd17ee08750-image.png

                Free HISE Bootcamp Full Course for beginners.
                YouTube Channel - Public HISE tutorials
                My Patreon - HISE tutorials

                J 1 Reply Last reply Reply Quote 0
                • griffinboyG
                  griffinboy @Jeetender
                  last edited by

                  @Jeetender

                  Wet / Dry balance is done using a sin / cosine curve usually.
                  You don't need to do any RMS calculations for an equal power curve.

                  1 Reply Last reply Reply Quote 0
                  • griffinboyG
                    griffinboy @Jeetender
                    last edited by griffinboy

                    @Jeetender

                    This is pseudo code.
                    It's something like this

                    // Equal-power wet/dry crossfade (pseudocode)
                    
                    // knob range
                    value = 0 to 127
                    
                    // normalize
                    t = value / 127.0
                    
                    
                    // equal-power law
                    // sin/cos keep total power constant
                    wet_lin = sin(t * PI * 0.5)
                    dry_lin = cos(t * PI * 0.5)
                    
                    
                    // linear → dB
                    // dB = 20 * log10(gain)
                    // log10(x) = ln(x) / ln(10)
                    
                    wet_db = 20 * ln(wet_lin) / ln(10)
                    dry_db = 20 * ln(dry_lin) / ln(10)
                    
                    
                    // clamp near zero (avoid -inf)
                    if (wet_lin < 0.00001) wet_db = -100
                    if (dry_lin < 0.00001) dry_db = -100
                    
                    
                    // apply
                    WET.Gain = wet_db
                    DRY.Gain = dry_db
                    
                    
                    
                    /*
                    Behaviour:
                    
                    t=0
                    dry=1.0  (0 dB)
                    wet=0.0  (-inf)
                    
                    t=0.5
                    dry≈0.707 (-3 dB)
                    wet≈0.707 (-3 dB)
                    
                    Summed signal power stays constant across the crossfade,
                    so the centre position does not sound quieter.
                    
                    

                    This is the kind of question that AI can help you understand.
                    Ask chat gpt about it until you get why it works!

                    J 1 Reply Last reply Reply Quote 0
                    • J
                      Jeetender @David Healey
                      last edited by

                      @David-Healey this works good but still the same issue, at 50% the volume is not constant.

                      said in Rms type or Cosine type Crossfade Curves:

                      @Jeetender What about setting the Gain of the SimpleGain where you want it and using a CC modulator to control the actual value (you can connect the Default value knob to a UI knob, you don't actually need to use a CC). Then you could set any shape you want using the modulation tables.

                      611b63e8-5067-43ea-baa5-1cd17ee08750-image.png

                      David HealeyD 1 Reply Last reply Reply Quote 0
                      • David HealeyD
                        David Healey @Jeetender
                        last edited by

                        @Jeetender said in Rms type or Cosine type Crossfade Curves:

                        this works good but still the same issue, at 50% the volume is not constant.

                        Have you used an equal power curve?

                        Free HISE Bootcamp Full Course for beginners.
                        YouTube Channel - Public HISE tutorials
                        My Patreon - HISE tutorials

                        1 Reply Last reply Reply Quote 0
                        • J
                          Jeetender @griffinboy
                          last edited by

                          @griffinboy chatgpt or other bots aren't familiar with HISE coding yet i believe.. they just get confused with parameters.

                          said in Rms type or Cosine type Crossfade Curves:

                          @Jeetender

                          This is pseudo code.
                          It's something like this

                          // Equal-power wet/dry crossfade (pseudocode)
                          
                          // knob range
                          value = 0 to 127
                          
                          // normalize
                          t = value / 127.0
                          
                          
                          // equal-power law
                          // sin/cos keep total power constant
                          wet_lin = sin(t * PI * 0.5)
                          dry_lin = cos(t * PI * 0.5)
                          
                          
                          // linear → dB
                          // dB = 20 * log10(gain)
                          // log10(x) = ln(x) / ln(10)
                          
                          wet_db = 20 * ln(wet_lin) / ln(10)
                          dry_db = 20 * ln(dry_lin) / ln(10)
                          
                          
                          // clamp near zero (avoid -inf)
                          if (wet_lin < 0.00001) wet_db = -100
                          if (dry_lin < 0.00001) dry_db = -100
                          
                          
                          // apply
                          WET.Gain = wet_db
                          DRY.Gain = dry_db
                          
                          
                          
                          /*
                          Behaviour:
                          
                          t=0
                          dry=1.0  (0 dB)
                          wet=0.0  (-inf)
                          
                          t=0.5
                          dry≈0.707 (-3 dB)
                          wet≈0.707 (-3 dB)
                          
                          Summed signal power stays constant across the crossfade,
                          so the centre position does not sound quieter.
                          
                          

                          This is the kind of question that AI can help you understand.
                          Ask chat gpt about it until you get why it works!

                          griffinboyG 1 Reply Last reply Reply Quote 0
                          • griffinboyG
                            griffinboy @Jeetender
                            last edited by

                            @Jeetender

                            Right but the math works the same way.
                            All you need to do is find the right hise functions in the API for the math calls.

                            1 Reply Last reply Reply Quote 0
                            • LindonL
                              Lindon @Jeetender
                              last edited by Lindon

                              @Jeetender eaiest way is ro use a scriptnode network and a xfade module...

                              HISE Development for hire.
                              www.channelrobot.com

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

                              29

                              Online

                              2.2k

                              Users

                              13.5k

                              Topics

                              117.4k

                              Posts