HISE Logo Forum
    • Categories
    • Register
    • Login

    Switching stereo field.

    Scheduled Pinned Locked Moved General Questions
    21 Posts 4 Posters 1.2k 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.
    • marcLabM
      marcLab @d.healey
      last edited by

      @d-healey

      inline function stereo(component,value)
      { 
         var inv = 1-value;
         
         m1.addConnection(value, value); // L
         m1.addConnection(inv, inv); // R
         
         if (!value)
         {
                m1.addConnection(value, inv); // L
                m1.addConnection(inv, value); // R
         }
      
      
      }
      

      How about this for optimization :) ?

      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @marcLab
        last edited by

        @marcLab I think you can do better. I don't think you need the if statement at all.

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

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

          Making inv local will be the best optimisation.

          1 Reply Last reply Reply Quote 3
          • marcLabM
            marcLab @d.healey
            last edited by

            @d-healey damn, my brain hurts a little bit..

            ustkU 1 Reply Last reply Reply Quote 1
            • d.healeyD
              d.healey
              last edited by

              Don't you still need to remove the old connection?

              Libre Wave - Freedom respecting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              marcLabM 1 Reply Last reply Reply Quote 0
              • ustkU
                ustk @marcLab
                last edited by

                @marcLab something is telling me that inv and !value might be equivalent 😉

                Can't help pressing F5 in the forum...

                1 Reply Last reply Reply Quote 4
                • marcLabM
                  marcLab @d.healey
                  last edited by

                  @d-healey did the test, they seem to change when only calling .addConnection

                  1 Reply Last reply Reply Quote 0
                  • marcLabM
                    marcLab @d.healey
                    last edited by marcLab

                    @d-healey just can't figure out how to arrive at only 2 lines of code

                    .addConnection(0,0) // L -> L
                    .addConnection(1,1) // R -> R

                    OR

                    .addConnection(0,1) // L -> R
                    .addConnection(1,0) // R -> L

                    With juggling with my value (0 or 1) without the if statement.

                    inline function onstereoFieldControl(component,value)
                        { 
                            local index = btnStereo.indexOf(component);
                            
                            // L->L R->R
                            samplerMatrix[index].addConnection(value, value); 
                            samplerMatrix[index].addConnection(!value, !value); 
                        
                            // L->R R->L
                            if (!value)
                            {
                                samplerMatrix[index].addConnection(value, !value); 
                                samplerMatrix[index].addConnection(!value, value); 
                            }
                            
                        }
                    
                    d.healeyD 1 Reply Last reply Reply Quote 0
                    • d.healeyD
                      d.healey @marcLab
                      last edited by d.healey

                      @marcLab Index has magically appeared, do you have more than one stereo button? And do you have a snippet?

                      Libre Wave - Freedom respecting instruments and effects
                      My Patreon - HISE tutorials
                      YouTube Channel - Public HISE tutorials

                      marcLabM 1 Reply Last reply Reply Quote 0
                      • marcLabM
                        marcLab @d.healey
                        last edited by marcLab

                        @d-healey yeah index because I have 6 btn for 6 different samplers :p, but this part is working :)

                        I'm just trying to reduce the number of lines. For being full optimal.

                        d.healeyD 1 Reply Last reply Reply Quote 0
                        • d.healeyD
                          d.healey @marcLab
                          last edited by

                          @marcLab

                          I'm just trying to reduce the number of lines. For being full optimal.

                          Give me a simple snippet with a single sampler and routing matrix etc and I'll see what I can do.

                          The number of lines doesn't always make much difference to the performance but it can make a different to maintenance, reuse, and debugging.

                          Libre Wave - Freedom respecting instruments and effects
                          My Patreon - HISE tutorials
                          YouTube Channel - Public HISE tutorials

                          marcLabM 2 Replies Last reply Reply Quote 0
                          • marcLabM
                            marcLab @d.healey
                            last edited by

                            @d-healey

                            HiseSnippet 1598.3oc6b1saaaCEGWJNpKwqoXsnWraFfZ1tvAoNUNwNc.Ys0INIEAKNwvJsX.EcELRz1DUlTPhJqYE898nrK2dC16wdI5av1gRxVeT2TGk90Vnunv7PdN7O+PmyOkfzNdLKruOySQc9iN0EqndUMySo7AsFfHTk81VQcNMeN1CyT15TWjuO1VQUszCE8pN+rJged8C1B4fnV3DSJJOlQrv6SFR3IV6z7GINN6hrwGQFlZz0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WiGRwv9d5wpzxi462CVNgwxOcWcB75K1qRrzEeB1yOqsCBFBm8.MfinJpp3gvG4iEm0DqHrgziNbVLNBEddCutQX6Z4ZuZt1qkqc8bsajq854Ze2j1QansQthaFeq1lcasYUCiZU217npPdEOXCq5QdDV08Yv2Zu6avI7ESGm.LCcPvdRpQtEo+3YOxR5a3iOGB0ZpW3ZButxU9r9so93kCtzzI22wK7M+HMZRDmN6POAdtErHz3MfB+8PAN7QVylCoMixbGvnDqrOk.2i52G6kV6SbAsImCOjlX4lM6hcvH+TOl+cM2GdeGjW1G9OW6E0l98hy575q0hjqtHwm9+OpcV5ResyyZq6ZwUN0gY2i+Y947U0By0qKJM+oRpY9wm.UCgZil.OfENcExYDUciZaLphoIlZG13efOwcVSIBoMryZi5TwZTnf0V72CeMF0RXpnzQHRnCTn1I8UZef5PHInDXAHmVURNIImjjSRxoK.4zpRxII4jjbRRNcohbZsKGjSu9ARxooibR7qXOGXzbuGAixBFjZnuUJo2wuZbIwzmLho0jDSRhIIwjjX5REwTcIwjjXRRLIIlJ.wTcIwjjXRRLIIltTQL0PRLIIljDSRhoBPL0PRLIIljDSRhoKUDSqKIljDSRhIIwTAHlVWRLIIljDSRho+CSLUHUpbVpT8MT4PjkG6YVQ+U5Jz5bgV.URC++Zh40ZKZqO9uPYMMiULTFB0pdlkk3AgpvN7j8Y0B3yZEvm5EvmFEvm0KfO2s.978moOBLgMC3rgQIIACc1I5hk5NiuXUR4eA.erEXN
                            
                            1 Reply Last reply Reply Quote 1
                            • marcLabM
                              marcLab @d.healey
                              last edited by

                              @d-healey said in Switching stereo field.:

                              The number of lines doesn't always make much difference to the performance but it can make a different to maintenance, reuse, and debugging.

                              Trying to be PROFESSIONAL :P

                              1 Reply Last reply Reply Quote 1
                              • d.healeyD
                                d.healey
                                last edited by d.healey

                                inline function onstereoFieldControl(component, value)
                                {
                                    local index = btnStereo.indexOf(component);
                                
                                    samplerMatrix[index].addConnection(value, value - 1 * value);
                                    samplerMatrix[index].addConnection(!value, !value + 1 * value);
                                }
                                

                                Libre Wave - Freedom respecting instruments and effects
                                My Patreon - HISE tutorials
                                YouTube Channel - Public HISE tutorials

                                marcLabM ustkU 2 Replies Last reply Reply Quote 3
                                • marcLabM
                                  marcLab @d.healey
                                  last edited by

                                  @d-healey damn..let me try this!

                                  1 Reply Last reply Reply Quote 0
                                  • ustkU
                                    ustk @d.healey
                                    last edited by

                                    @d-healey You little jokester 🤣

                                    Can't help pressing F5 in the forum...

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

                                      @d-healey said in Switching stereo field.:

                                      The number of lines doesn't always make much difference to the performance but it can make a different to maintenance, reuse, and debugging.

                                      In my experience it also doesn‘t make sense going into full-riddle mode and condensing the functionality down to the least amount of characters because you will come back in a few months and think „what lunatic has written this“.

                                      But it‘s a fun excercise...

                                      d.healeyD 1 Reply Last reply Reply Quote 2
                                      • d.healeyD
                                        d.healey @Christoph Hart
                                        last edited by

                                        @Christoph-Hart I agree, you have to find a balance and should always aim to make the code readable, even if that means it's more verbose. In this case I'd go with the two line version, but I'm used to reading code like this so my vision might be skewed :)

                                        Libre Wave - Freedom respecting instruments and effects
                                        My Patreon - HISE tutorials
                                        YouTube Channel - Public HISE tutorials

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

                                        26

                                        Online

                                        1.7k

                                        Users

                                        11.8k

                                        Topics

                                        102.7k

                                        Posts