HISE Logo Forum
    • Categories
    • Register
    • Login

    Calling functions in midi processors...

    Scheduled Pinned Locked Moved General Questions
    31 Posts 4 Posters 2.1k 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.
    • LindonL
      Lindon @Stroggan
      last edited by

      @Stroggan yes I'm sure and thanks for that but Dave and I (I think) are trying to work out the Correct way to do this....

      HISE Development for hire.
      www.channelrobot.com

      1 Reply Last reply Reply Quote 0
      • S
        Stroggan
        last edited by

        I'm looking forward to learn the correct way as well then ☺

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

          I cant even get the "interface" to show up any more - all I get is Canvas:ScriptProcessor1

          HISE Development for hire.
          www.channelrobot.com

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

            @Lindon said in Calling functions in midi processors...:

            const var Knob1 = Content.addKnob("Knob1", 0, 0);

            heres the snippet now.... it all seems broken to me

            HiseSnippet 1581.3oc6X0raaaDDdokYhsZTQSZNzC8.gQKfCpqgj0eIsnHx+GiDGqJ4DzCFHcM4J6ElbWVxkNQIH25ySQQeAZu0mi9Fj2f1YWRZtJV1gLINQso5f.2Ymg6Ly2ty7sra.2lDFxCPFyt6PeBx3Jl8GxDGt5gXJCs0ZHiOxTPBE83QBBZkg93vPhCxvnzlRELlcZj52Kt8JXWLyljIBgdHmZStG0iJxj1sycottafcH6R8zztQmsr4rU4t7HvYJYVE4isOBe.49XoZSYhLtz5NTAOnu.CdDxX5U3NC6eH+wrX8eHMjtuKQNnFpO7hhEuA20Q5wRonUOj55zMMnCQHCytYofRwofqatM0gdh7rTwmnlvJyB87gwTmm6US28ple2yPy8lN18tpYe6.puHalXXZKlfDL.aOJLEqKZpJFlqxAMXhE8vGQ1H.FbhEy2pZ0ErZVs5M91JkqTdPDyVP4LKN69bAYG172nR4mUorE7K9e3UExcIK5GPYh4mixr4dT1AyIse1Wx8psnuKd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NTeByQM3ugeISVKknsbxZoShrSeUPrk7rpCjQIBSx1RceQWfBu6HcJxpmiBUfpGPbC5fGO.YLSOt7JCSa1nE5d76RFpdtA5NzzmuIH+gx2pLQbGp5QSyZK0FkbEkDdfT2juMrq4ZeydKG4P46kDR836yE6IKkEvngh81zkaeD.N9ThalXKKc4Vw6ACylWMKTUzA3TYUsQqEeL9XzZQ9tTa.LkgO5TQUyZZQ0sxhpl0mLipl0xUTogUM0vplSnXUybgUszvplZXUqITrpUtvpVZXUKMrp0DJV0JWXUaMrpkFV0dBEqZmKrpsFV0VCqZOghUsyEVUWCqVRCqpOghU0yEVUWCqpqgU0mPwp54BqZngU00vpFSnXUiwgUuKnC8tXM7v1A7GYG+YBjDulQIAxzLUJdVyskisN46CHwF313zGYaKAsutFBMdKVpvVTuvVznvVzrvVzpvVztvVbyywB4mEb4HA2K9FdfftqGyJ1X8SXEWB8O.k21wZ
            

            HISE Development for hire.
            www.channelrobot.com

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

              @Lindon

              const var Knob1 = Content.addKnob("Knob1", 0, 0);

              --- but of course when I go to my interface its nowhere to be seen....how do I make it show up in my interface? how do I even edit it.

              Controls should only be added this way to MIDI processors that aren't the user interface script. Is that the interface you are talking about? If so did you click the interface button (the one to the left of the callback buttons)?

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

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

                @Lindon

                heres the snippet now.... it all seems broken to me

                There are no controls on the main interface. Did you add any in the interface designer? Or did I lead you to believe they were added by the other script?

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

                LindonL 1 Reply Last reply Reply Quote 0
                • LindonL
                  Lindon @d.healey
                  last edited by

                  @d-healey yes thats what you led me to belive I think...

                  OK what is the process of adding a slider to the midi processor of a sampler and have it show up in the main interface?

                  HISE Development for hire.
                  www.channelrobot.com

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

                    @Lindon You have to add them to each separately.

                    For example I have an instrument and it has a sampler with a MIDI processor for handling legato, and another MIDI processor for handling round robin (nice and modular).

                    On my user interface I want to give the user a control to bypass the round robin script and to adjust the xfade time of the legato. But I don't want them to have access to the other controls of those scripts such as setting the playable range or the legato volume etc. So on my user interface I add a button and I connect this via parameter ID in the interface designer to the bypass button of my RR script, I also add a knob which is connected to the xfade knob of my legato script.

                    It seems like more work duplicating controls and I was put off at first, but actually it's very fast to do and allows me to easily create scripted modules that can be used in different projects and with entirely different interfaces.

                    I have a load of modules here you can play with - https://github.com/davidhealey/HISE-Scripting-Framework/tree/master/modules - I use the Connect to external script option from the context menu that appears when right-clicking on a MIDI processor's header.

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

                    LindonL 1 Reply Last reply Reply Quote 0
                    • LindonL
                      Lindon @d.healey
                      last edited by

                      @d-healey OK, thanks.

                      HISE Development for hire.
                      www.channelrobot.com

                      1 Reply Last reply Reply Quote 1
                      • LindonL
                        Lindon
                        last edited by Lindon

                        So then just the one outstanding question:

                        why oh why cant I say this in my main interface script:

                        const var myScriptProcessor = Synth.getMidiProcessor("myScriptProcessor");
                        
                        myScriptProcessor.myFunction(param,param);
                        

                        instead of this I have to create a set of interface widgets in myScriptProcessor, one for each param of myFunction then call another widget to execute the logic in myFunction

                        What is wrong with exposing the method(sorry Function) and allowing me to call it from somewhere else?

                        Surely we can all agree the current approach (if it is all we have) is a bit broken?

                        HISE Development for hire.
                        www.channelrobot.com

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

                          @Lindon said in Calling functions in midi processors...:

                          So then just the one outstanding question:

                          why oh why cant I say this in my main interface script:

                          Because scripts can't talk to each other directly. You can do that using Global variables but it really isn't necessary.

                          instead of this I have to create a set of interface widgets in myScriptProcessor, one for each param of myFunction then call another widget to execute the logic in myFunction

                          Create your module and get it to work exactly how you want (makes it really easy to test the code is working) then add the controls to your UI that you want the user to have access to and link them together in the interface designer. It's a 10 minute job...

                          What is wrong with exposing the method(sorry Function) and allowing me to call it from somewhere else?

                          I can see this being useful and can't see a downside to it (maybe Christoph will see a pitfall) but it will kind of collapse the tree paradigm.

                          Surely we can all agree the current approach (if it is all we have) is a bit broken?

                          I haven't encountered any problems with it so far. Just requires a different way of thinking about problems.

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

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

                            It‘s definitely not broken, it enforces encapsulation and moves the responsibilty to operate on data to where it belongs.

                            If you want to avoid multiple controls, store them in a global data object (or multiple variables) and use a single button in your target script that fetches all values and do the appropriate thing.

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

                              @Christoph-Hart there is nothing about callable functions that breaks encapsulation, so thats not a fair assessment I think. The responsibility to operate on data remains in exactly the same place, in the object where the function resides. All in the end we are talking about is a parameter passing paradigm, function call vs filling in (otherwise unused) widget values.

                              in fact this

                              myScriptProcessor.setAttribute(0,12);
                              

                              breaks encapsulation - so I can set an attribute in a midiProcessor but I cant call a function.

                              You may have to excuse me I'm a SmallTalk programmer by training - so I have a bit of a purist view...

                              HISE Development for hire.
                              www.channelrobot.com

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

                                Yes there is - if you recompile the target script without recompiling the caller script, the function will point to a invalid root object and it will crash badly as soon as you call any API method. The lifetime of a compiled function must never exceed the lifetime of its root and this would make it very easy to violate that rule.

                                Worst case in the current approach is calling setAttribute with an invalid ID.

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

                                38

                                Online

                                1.7k

                                Users

                                11.7k

                                Topics

                                102.1k

                                Posts