HISE Logo Forum
    • Categories
    • Register
    • Login

    Calling functions in midi processors...

    Scheduled Pinned Locked Moved General Questions
    31 Posts 4 Posters 2.3k 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 @d.healey
      last edited by Lindon

      @d-healey thanks, yes I have the igonereEvent process working now - its just that I dynamically want to set the (replacement) note to be played. So I assign a variable to my Sampler or I'm trying to - mybe my OO background is getting in the way _ I think that there should be some level of encapsulation in a Sampler - it should have its own variables and functions - and I should be able ot call these functions from somewhere else... how is that bad practice?

      and..
      So far it just appears you want to trigger a specific note in the onNote callback.

      yes lets start with that.

      HISE Development for hire.
      www.channelrobot.com

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

        @Lindon

        I think that there should be some level of encapsulation in a Sampler - it should have its own variables and functions - and I should be able ot call these functions from somewhere else... how is that bad practice?

        Samplers don't have variables. MIDI processors have variables which are encapsulated, and Samplers can have MIDI processors. If you want several MIDI processors to share a bunch of variables you could use a global object (I think) and just use it for those samplers (in reality any script could access it but in practice you would be able to treat it like a namespace for specific MIDI processors).

        So far it just appears you want to trigger a specific note in the onNote callback.

        Why does the UI script need to be involved in this?

        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 Lindon

          @d-healey
          "Why does the UI script need to be involved in this?"

          -- Because the end user will decide which note gets played....the sampler will hold a set of "enhancement sounds" that get played alongside the melodic/tonal component. So the UI will need to "tell" the sampler which note the play.

          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...:

            -- Because the end user will decide which note gets played....the sampler will hold a set of "enhancement sounds" that get played alongside the melodic/tonal component. So the UI will need to "tell" the sampler which note the play.

            This is like my early KSP influenced thinking ;) You need to seperate the user's interaction with the UI from the MIDI logic. Your user will change a setting on the UI script and your UI script needs to change the same setting on the sampler's MIDI processor so it can do it's job, and you can probably connect this up using parameter IDs in the interface designer rather than scripting it.

            So you have to think of everything as a module and then you link those modules together. It does mean that in some instances you'll be duplicating GUI controls but it's not really any different to duplicating variables and it's much faster to implement.

            Here's a little demo

            HiseSnippet 1268.3oc4X8zaaaCEmJNJs1KqXsKG1kAHTrAjhkUXmljtggg3Dm+.iVmXXkVraELRz1DQhTfhJKtE61tsuKC69NrcaeG1s8MneC1djRxhNSH0JnqqqyGBHe78H+w2e36mReA2iDGyEHq5mLIhfrV11cBSNtyXLkg5tGx5V18vwRhvIUztShvwwDejkUsCUBrpuHR+6kauKN.y7HEhPnmxodjGSCoxBo8a+HZPvAXexIzPCs2ncWONqCOfm.3olcSTD16L7HxQXkZKXirVZeepjKbkXIIFYs3tb+Iti4eKKU+mRiomFPTSZgbgMJU7A7.eEhUiQcFSC76meuiQHK69EdgZodgUr6Q8oSkW3M9.8BNEVX5OrV3pfWqqI7rLf2hov611tdBZjrXEE1dO6tLHPMDCg.SXkpKx5ms6vAEXx6GhOibf.lL0fU2pYy0b1rYy68UCSXdRJm4vYGwkjiYqduFunQ8FeWiKuxvgksj5PD7f.hnrUUgbwUX1prjvSIh0bNGGjPx0Ct4y5ZWZ9bsdoWXCE4rtLp73HR17BmeqRb9nLOlJLjAPPUoNHbqrffa.0mHPTXStg8iX7SagzX2rL.8jt6gk37sA1Q3ThHBIUcYr1ibNTljFaqauGI9LIORqaXDmoNeqkdkG5EPlr0uCm0D0fe.FDkeS5Bp8gYVVj61BpuDPoEjBz0XeP+87MHqm6mDfkyVJnp+yV.hgyjyoRrXwT4Dy2GpP8QyRqOJMDMmv8118oRuwki2EJAuPv5eZ7l8Zy6au+vgDOYAXWz9fu459zx0CJebJTtisqTPvgT1HWbXDTDqwSC6rYsdcz.HZta.zWPB3XeW5yMT6WauaB3uDyJ8mZqOpcB4IrYNqLjOfDQvRH7aXyMaOXvgBdRzks5kaqSVNQ.Mf.Wg4BGyHfeWZdG6H3wwCgqiduhMWpehXjxWUHY.4bhHdVYGkDBwdFiDDqpcsTOXDSTwZpWOrTPuvTa8oz7DrNd+o1quw8m824GC+Y3moF9kczySMoU0MY8paxCptIaTcS1r5lrU0M4gUxjzDsd3HUEihsxk5Yci4isBrA8wPpfQ08tzQS27TIy9zqgpSyE0P23zJgYwRuiP7orVakQ.52rgmWhk.0BgitWmyW6jSIB66qDs5c0Kb20b.5P+WgLTiWWjgxuj4RZhld4LEUboLkpuLknVgn2l4Ws77wuBkyuRMHVNQ4kWRq.Jj56GP5yAVDJ1EEsL9E3ymhxaV8hU9wC+im+8aGZ14DgBwWX1jIFZvodzGdEYHMHLFZAD0MD9THUGZn0fiOYHNIP5DCsmPAT1YD+S3Z8eyQeq17wA4UTYWOGitT0Kb6yNGZ4CRTX7NPrReOykNaccONiGMlyndy1fE7ViFQDlXuzKzNRIzeuPxJsGPBH3XiTqOo8ioLBVLKugJ4KZM+9hqJd8Q1ov0QUm47tAs6Z+um18U45tUFoaG3zEx2xiyKaqYL4nX0+uETGvSj.a8bFy1.sZW3SI7HljqWP00Icdy7GxcILe8j+D9ksXqbl3pEakuHxKeqf6V1XcmGqZDlhwk9qIC.N9AlozFum+FAkgXOA+YdocTUX8lZI.JY5+WZ0s6ol6LsUpx6BMvnOyySUF74sPnxsX8JawCprEaTYK1rxVrUks3gU1hu3JrPwldmDIOL8QQPP+8SSjr1eZhTMzeAbjOzNO
            

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

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

              This is back from my early days with HISE when I wasn't familiar with the modular paradigm and was asking a similar question. Also seems like you were around then too - https://forum.hise.audio/topic/46/calling-child-functions

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

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

                You could store all required info for the samplers in global variables and act on that information in the specific samplers midiprocessors.

                LindonL d.healeyD 2 Replies Last reply Reply Quote 0
                • LindonL
                  Lindon @d.healey
                  last edited by

                  @d-healey said in Calling functions in midi processors...:

                  It does mean that in some instances you'll be duplicating GUI controls

                  OK so in the end you are saying I should include the View/Controller with the Model....Ok, but now I have a dynamically loadable set of (say) 30 fx's - now we are saying every one of these effects MUST have its own set of widgets? - ugly ugly ugly.

                  HISE Development for hire.
                  www.channelrobot.com

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

                    @Stroggan OK.. so can you demonstate that then.

                    HISE Development for hire.
                    www.channelrobot.com

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

                      @Lindon

                      OK so in the end you are saying I should include the View/Controller with the Model....Ok, but now I have a dynamically loadable set of (say) 30 fx's - now we are saying every one of these effects MUST have its own set of widgets? - ugly ugly ugly.

                      I haven't worked with adding/removing effects dynamically so I might be missing something but effects don't have MIDI processors so I'm not sure why the number of effects you add will affect the number of widgets. Widgets are no different to having a script full of variables, a widget is just a holder for a value.

                      I think you need to give a more full explanation of what you are trying to achieve so that I can see the bigger picture and how HISE's way of working can be used for your project.

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

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

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

                        You could store all required info for the samplers in global variables and act on that information in the specific samplers midiprocessors.

                        That's what I suggested earlier, but things will get messy and it's really not the "best" way to do it if you can avoid it.

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

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

                          @Lindon Well what i wanted was perfect control over which note ID got played by which sampler so I set a constant variable identifier in each sampler's midiprocessor:

                          const var identifier = 0;
                          

                          And when I trigger a note I store it's ID in a multi dimensional array [sampler ID][noteID].
                          which then gets ignored or played in the sampler midiprocessor:

                          function onNoteOn()
                          {
                              input_id = Message.getEventId();
                              
                              local i;
                          	for(i = 0; i < 8; i++){
                          	    if(Globals.SamplerNoteIds[identifier][i] === input_id){   
                          	        Globals.SamplerNoteIds[identifier][i] = -1;
                          	        return;
                          	    }
                          	}
                          	// if loop doesn't find id, ignore event
                          	Message.ignoreEvent(true);
                          }
                          

                          This is indeed a bit messy as @d-healey said, but plain midimuters did not provide that amount of control.

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

                            @d-healey OK here it is: (but this is just one instance of a problem....)

                            An instrument has 4 samplers, 3 play chromatically assigned notes (drum sounds)

                            1 plays an enhancement sound.

                            Th user selects an enhancement sound from a drop down list of 40 potentail sounds. - Lets say they select sound "sub001" which we know is assigned to midi note number 60 in Sampler4

                            The user press midi note number 45 on their keyboard:

                            Sampler 1 plays the close-mic-ed snare sound (which is "under" note 45)
                            Sampler 2 plays the over-head mic-ed snare sound
                            Sampler 3 plays the room -mic snare sound
                            Sampler 4 plays sub001

                            -- it doesnt matter which "sound"/note the user plays - the instrument ALWAYS plays Sub001 along with the other midi-mapped sound, until the user selects another "enhancment" sound

                            HISE Development for hire.
                            www.channelrobot.com

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

                              Meanwhile the level of frustration just gets higher and higher. I loaded your snippet Dave... OK I can work with that (except I cant as we will see).

                              I add a knob01 to my samplers on init midiprocessor:

                              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.

                              HISE Development for hire.
                              www.channelrobot.com

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

                                @Lindon that could be solved easily with Globals.subNote = 60;

                                and in Sampler 4 use:

                                Message.setNoteNumber(Globals.subNote);
                                
                                LindonL 1 Reply Last reply Reply Quote 0
                                • 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.FbhEy2pZ0ErZVs5M91JkqTdPDyVP4LKN69bAYG172nR4mUorE7K9e3UExcIK5GPYh4mixr4dT1AyIse1Wx8psnuKd31CkuJXgVnV7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VKknsbxZoShrSeUPrk7rpCjQIBSx1RceQWfBu6HcJxpmiBUfpGPbC5fGO.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
                                            • First post
                                              Last post

                                            11

                                            Online

                                            1.8k

                                            Users

                                            12.0k

                                            Topics

                                            104.5k

                                            Posts