HISE Logo Forum
    • Categories
    • Register
    • Login

    [bug] SlotFX.setBypassed no worky

    Scheduled Pinned Locked Moved Bug Reports
    21 Posts 3 Posters 198 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.
    • OrvillainO
      Orvillain @HISEnberg
      last edited by

      @HISEnberg said in [bug] SlotFX.setBypassed no worky:

      @d-healey I believe this is how the HardcodedMaster Fx is meant to be used, referencing it both as a SlotFx and as an Effect, then using whichever API is necessary for your use case. I typically try to do this and stick to a particular naming convention (ex. SlotDelay, EffectDelay)....

      I have a namespace called ModuleManager. At instantiation of the plugin, it collects all references to all required modules, and stores them in a SharedData namespace reg variable. The reason I do that is because I noticed early on that a lot of Synth.xxxx calls would complain about being run outside of the init function. Okay. Cool. Fair enough. That all works, and I get my references and the plugin works.

      It just seems really kooky that I'd have to do a getCurrentEffect() on a slotFX reference that already exists. The documentation does state that setBypassed can be run on a slotFX object. So I spent quite a bit of time trying to solve this before coming to the forum and being shown Dave's snippet.

      Is all just a bit inconsistent is all.

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

        @Orvillain said in [bug] SlotFX.setBypassed no worky:

        reg variable

        Use const

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

        OrvillainO 1 Reply Last reply Reply Quote 0
        • OrvillainO
          Orvillain @d.healey
          last edited by Orvillain

          @d-healey said in [bug] SlotFX.setBypassed no worky:

          @Orvillain said in [bug] SlotFX.setBypassed no worky:

          reg variable

          Use const

          As I understand it, regs are more performant and are mutable. Perfect for tracking modes or current effects or effect orders, etc etc.

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

            @Orvillain
            reg should be used for variables declared in onInit whose data needs to be editable.

            const should be used for all fixed data - arrays, objects, component references, module references, etc.

            reg is more performant in real time callbacks than var but you should avoid using var anyway.

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

            OrvillainO 1 Reply Last reply Reply Quote 0
            • OrvillainO
              Orvillain @d.healey
              last edited by Orvillain

              @d-healey said in [bug] SlotFX.setBypassed no worky:

              @Orvillain
              reg should be used for variables declared in onInit whose data needs to be editable.

              const should be used for all fixed data - arrays, objects, component references, module references, etc.

              reg is more performant in real time callbacks than var but you should avoid using var any way.

              All of the data inside my custom SharedData namespace needs to be editable.

              I don't use var anywhere.

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

                @Orvillain said in [bug] SlotFX.setBypassed no worky:

                All of the data inside my custom SharedData namespace needs to be editable.

                If you're using Synth.getEffect() or similar they should be const and shouldn't change.

                Checkout this post by Christoph - https://forum.hise.audio/topic/79/scripting-best-practices/2

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

                OrvillainO 1 Reply Last reply Reply Quote 0
                • OrvillainO
                  Orvillain @d.healey
                  last edited by Orvillain

                  This post is deleted!
                  d.healeyD 1 Reply Last reply Reply Quote 0
                  • d.healeyD
                    d.healey @Orvillain
                    last edited by d.healey

                    @Orvillain said in [bug] SlotFX.setBypassed no worky:

                    Inside that is reg engines = {blahblahblah}

                    It's an object so should be const engines = {}

                    You can still add to the object and change the data within it, you just can't change the variable itself.

                    For example this would give an error

                    const engines = {};
                    
                    engines = 10;
                    

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

                    1 Reply Last reply Reply Quote 0
                    • OrvillainO
                      Orvillain
                      last edited by Orvillain

                      @d-healey said in [bug] SlotFX.setBypassed no worky:

                      @Orvillain said in [bug] SlotFX.setBypassed no worky:

                      Inside that is reg engines = {blahblahblah}

                      It's an object so should be const engines = {}

                      You can still add to the object and change the data within it, you just can't change the variable itself.

                      Yes I'm aware of that.

                      For example this would give an error

                      const engines = {};
                      
                      engines = 10;
                      

                      I'm aware of that too.

                      What is the benefit of using const, in my situation? The only thing I can come up with is it gives me a guard against overwriting engines. But nothing is attempting to do that anyway. Nor will it.

                      To my mind, reg gives me access performance benefits. Maybe that is wrong.

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

                        @Orvillain said in [bug] SlotFX.setBypassed no worky:

                        What is the benefit of using const, in my situation?

                        I think the best answer is from Christoph

                        it yields a huge performance boost (because it can resolve the function call on compile time).
                        There is absolutely no reason to not declare UI widgets, references to modules (via Synth.getModulator() etc.) not as const

                        reg is good for accessing script level variables in midi callbacks and anywhere else where you would have had to use a script level var. But the more reg you have (and you only get 32 per namespace) the worse the performance gets. Internally reg is like a predefined array that HISE is keeping track of. So the more values you add the more data it needs to go through each time to you access it.

                        Another addition to Javascript: Use reg instead of var when declaring temporary variables which are accessed in the MIDI (or audio) callbacks. It tells the interpreter to store this in a fixed size container with faster access times:
                        If you have a script with lots of variables, the interpreter must search the entire array for every variable access (so the 23 - 40 ms are depending on how many other variables are defined in the script while the access time to reg slots stay the same).

                        It's also possible since you're storing them in an object rather than as direct references that const gives no performance benefit. But it's still good practice to use a const here. It makes it clear to other developers who might see your code (or your future self) that this variable is not meant to be reassigned, and it also prevents it being reassigned accidentality.

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

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

                        49

                        Online

                        2.0k

                        Users

                        12.9k

                        Topics

                        111.9k

                        Posts