HISE Logo Forum
    • Categories
    • Register
    • Login

    Is there any way to disable routing matrix reset behaviour when loading a sample-map or when creating a multi-mic set of samples?

    Scheduled Pinned Locked Moved General Questions
    23 Posts 4 Posters 889 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.
    • O
      Orvillain
      last edited by

      Routing matrix configuration before loading any samples:
      66fb5c48-7da9-4675-bfe8-92b2e1706c78-image.png

      Routing matrix configuration after dragging and dropping samples in and using a token to create multi-mic matches:
      48ce33ef-d542-4cf4-883f-9b20df589b28-image.png

      The sampler has completely reconfigured its outputs. Which I don't want.

      I am guessing the suggesting is going to be to write a callback or two, to retrigger the creation of my routings post load operation. But I'm really hoping there is some sort of flag to disable this behaviour???

      1 Reply Last reply Reply Quote 0
      • Dan KorneffD
        Dan Korneff
        last edited by

        There's a function called "use static matrix" or something like that.

        Dan Korneff - Producer / Mixer / Audio Nerd

        O 1 Reply Last reply Reply Quote 0
        • O
          Orvillain @Dan Korneff
          last edited by

          @Dan-Korneff said in Is there any way to disable routing matrix reset behaviour when loading a sample-map or when creating a multi-mic set of samples?:

          There's a function called "use static matrix" or something like that.

          Hmmm. If I do this:

          const var Kick_sampler = Synth.getChildSynth("Kick_sampler");
          kick_sampler.UseStaticMatrix(true);
          

          I get an error:

          master:! Line 9, column 29: Unknown function 'UseStaticMatrix' {SW50ZXJmYWNlfG9uSW5pdCgpfDI3M3w5fDI5}
          

          I'm 99.9% confident that Kick_sampler is indeed a sampler object.

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

            @Orvillain

            @Orvillain said in Is there any way to disable routing matrix reset behaviour when loading a sample-map or when creating a multi-mic set of samples?:

            Kick_sampler is indeed a sampler object.

            In your case it's a childSynth Synth.getChildSynth("Kick_sampler");

            You need to either use Synth.getSampler() or Kick_sampler.asSampler()

            Also there is a slight typo, the function is setUseStaticMatrix()

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

            O 1 Reply Last reply Reply Quote 0
            • A
              aaronventure
              last edited by

              Also you can hardcode your matrix in the script if it helps.

              O 1 Reply Last reply Reply Quote 0
              • O
                Orvillain @aaronventure
                last edited by

                @aaronventure said in Is there any way to disable routing matrix reset behaviour when loading a sample-map or when creating a multi-mic set of samples?:

                Also you can hardcode your matrix in the script if it helps.

                That's what I am doing. I've built an extremely elaborate module tree using a script. As soon as I load a sample map, a bunch of it is reset. Booooo hisss.

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

                  @d-healey

                  Hmmmm. I'll take a look. The typo is indeed a typo, but it came from the autocomplete! Most strange.

                  BTW, my code already does:

                  slot_data['sampler'] = builder.get(sampler, builder.InterfaceTypes.ChildSynth);
                  

                  And that also returned the same error. So I guess I need to try a few of these suggestions out.

                  O 1 Reply Last reply Reply Quote 0
                  • O
                    Orvillain @Orvillain
                    last edited by

                    Right, yes... you were totally spot on. This worked:

                    	// Creates the sampler
                    	var sampler_name = slot_name + "_sampler";
                    	var sampler = builder.create(
                    								builder.SoundGenerators.StreamingSampler,
                    								sampler_name,
                    								slot_data['module_index'],
                    								builder.ChainIndexes.Direct);
                    	
                    	// Gets the sampler routing matrix and sets up the slot_data references
                    	var sampler_routing_matrix = Synth.getRoutingMatrix(sampler_name);
                    	slot_data['sampler_index'] = sampler;
                    	slot_data['sampler'] = builder.get(sampler, builder.InterfaceTypes.ChildSynth);
                    	var as_sampler = Synth.getSampler(sampler_name);
                    	as_sampler.setUseStaticMatrix(true);
                    

                    The key lines being the last two.

                    O d.healeyD 2 Replies Last reply Reply Quote 0
                    • O
                      Orvillain @Orvillain
                      last edited by

                      @Orvillain

                      Ah spoke too soon. It works, as in... when I load the sample map, it doesn't reconfigure the output mappings.... but I stop hearing all of the channels. I'll dig into it, but it may be that I have to bite the bullet and write a function to load the sample map and then re-create the routing for me immediately after.

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

                        @Orvillain said in Is there any way to disable routing matrix reset behaviour when loading a sample-map or when creating a multi-mic set of samples?:

                        var as_sampler = Synth.getSampler(sampler_name);
                        as_sampler.setUseStaticMatrix(true);

                        You can use the childSynth reference with asSampler()

                        For example

                        const mySampler = Synth.getChildSynth("mySamplerId");
                        mySampler.asSampler().doSamplerThing();
                        

                        You should use const instead of var - avoid var in general unless you have no other option.

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

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

                          @d-healey said in Is there any way to disable routing matrix reset behaviour when loading a sample-map or when creating a multi-mic set of samples?:

                          You should use const instead of var - avoid var in general unless you have no other option.

                          All this code is in a set of functions, and whenever I try to use const it says const can only be declared on a global level, so I was holding off optimizing it for now. I'm assuming it is going to be a case of putting all my functions into some namespaces and then using 'reg' ?

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

                            @Orvillain

                            You should use inline functions rather than functions where possible.

                            Within inline functions variables need to be declared as local

                            You should declare component and module references within on init as const. Generally you shouldn't declare them within functions - the only time I think you would is when using a widget factory which returns the reference to be stored in a const.

                            I recommend reading this post from Christoph about best scripting practices, if you haven't already.

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

                            O 2 Replies Last reply Reply Quote 0
                            • O
                              Orvillain @d.healey
                              last edited by

                              @d-healey

                              I'd clean forgotten about inline functions! haha. Silly me.

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

                                @d-healey said in Is there any way to disable routing matrix reset behaviour when loading a sample-map or when creating a multi-mic set of samples?:

                                You should declare component and module references within on init as const. Generally you shouldn't declare them within functions - the only time I think you would is when using a widget factory which returns the reference to be stored in a const.

                                What about in cases where you're doing the following?

                                1. Helper functions to create a sub-tree for your main module tree. Necessitates declaration of components within a function.

                                2. Helper functions to modify elements of a tree. Necessitates creating a reference to an object; either using the built in get methods, or by storing your declarations from step 1 in a global const tree, and then parsing that tree in step 2 helper functions.

                                ???

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

                                  @Orvillain said in Is there any way to disable routing matrix reset behaviour when loading a sample-map or when creating a multi-mic set of samples?:

                                  Helper functions to create a sub-tree for your main module tree. Necessitates declaration of components within a function.

                                  This is what I meant by widget factory. At the end of the function you can return the widget to store it in a const if you need to refer to it in other parts of your script. If you don't need to refer to it outside the function then no need to return it.

                                  @Orvillain said in Is there any way to disable routing matrix reset behaviour when loading a sample-map or when creating a multi-mic set of samples?:

                                  modify elements of a tree.

                                  I'm not sure what you mean by tree.

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

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

                                    @d-healey said in Is there any way to disable routing matrix reset behaviour when loading a sample-map or when creating a multi-mic set of samples?:

                                    This is what I meant by widget factory. At the end of the function you can return the widget to store it in a const if you need to refer to it in other parts of your script. If you don't need to refer to it outside the function then no need to return it.

                                    Right, yes. That's basically what I'm doing. I'm inserting data into a global const, and not returning anything from the function.

                                    @d-healey said in Is there any way to disable routing matrix reset behaviour when loading a sample-map or when creating a multi-mic set of samples?:

                                    I'm not sure what you mean by tree.

                                    I just mean a sub-section of the main module tree; a container and all of its sub modules.

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

                                      @Orvillain said in Is there any way to disable routing matrix reset behaviour when loading a sample-map or when creating a multi-mic set of samples?:

                                      global const

                                      Do you mean an actual global variable, or just a const that you declared in on init?

                                      @Orvillain said in Is there any way to disable routing matrix reset behaviour when loading a sample-map or when creating a multi-mic set of samples?:

                                      I just mean a sub-section of the main module tree; a container and all of its sub modules.

                                      Ah I haven't done anything with adding modules via scripting yet so I'm not sure of the best practices there. But in general if you have a reference to a module or component that you are using throughout your script you should get it into a const - the widget factory method might be suitable here, I'm not sure.

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

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

                                        @d-healey said in Is there any way to disable routing matrix reset behaviour when loading a sample-map or when creating a multi-mic set of samples?:

                                        Do you mean an actual global variable, or just a const that you declared in on init?

                                        Yeah, sorry. That is what I mean. I tend to think of anything setup in on init as being global.

                                        @d-healey said in Is there any way to disable routing matrix reset behaviour when loading a sample-map or when creating a multi-mic set of samples?:

                                        Ah I haven't done anything with adding modules via scripting yet so I'm not sure of the best practices there. But in general if you have a reference to a module or component that you are using throughout your script you should get it into a const - the widget factory method might be suitable here, I'm not sure.

                                        I'll have a sweep through my code and have a think how/if some of it could be modularized and refactored to follow this suggestion. Not seeing any detrimental effects right now, and none of this code will be running at runtime anyway once the plugin is built, because the builder isn't accessible in the VST plugin, iirc.

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

                                          So back to the core issue.

                                          I have a Sampler with 10 outputs. The sampler sits in a container with 20 channels.
                                          I send each of the 10 outputs to channels:
                                          0, 2, 4, 6, 8, 10, 12, 14, 16, 18
                                          I then insert 5 send effects into the sampler FX block. These are setup to route 1+2, 3+4, 5+6, 7+8, 9+10 to a send container.
                                          The routing for the send container takes the signals and routes them to:
                                          1, 3, 5, 7, 9, 11, 13, 15, 17, 19.

                                          In this way, I get the mono multi-mic signals from my sampler, duplicated and turned into dual-mono signals.

                                          This all works fine and I have sanity checked it to death. At the container I have 0+1, +2+3, 4+5, 6+7, 8+9, 10+11, 12+13, 14+15, 16+17, 18+19 ... and each pair is essentially exactly the same signal.

                                          I won't belabour the point as to why I'm doing this, just that I need to. And it works fine.

                                          The problem is, when I load a sample map, the sampler configuration is completely reset. I want to preserve the routing I have setup.

                                          However when I do this:

                                          var as_sampler = Synth.getSampler(sampler_name);
                                          	as_sampler.setUseStaticMatrix(true);
                                          

                                          If I do it the other way, I get the same thing:

                                          	var this_sampler = Synth.getChildSynth(sampler_name);
                                          	this_sampler.asSampler().setUseStaticMatrix(1);
                                          

                                          I'm only getting the first two channels from the multi-mic samples in the Sampler. I'm not getting the full range of samples.

                                          It does not seem to matter if I declare setUseStaticMatrix(true) before or after the routing config. It simply seems to lock me to the first two outputs.

                                          Anyone got any ideas?

                                          O 1 Reply Last reply Reply Quote 0
                                          • O
                                            Orvillain @Orvillain
                                            last edited by

                                            Right, I guess what I'm gonna do is learn broadcasters, then use the attachToSampleMap function, and use that to rebuild the routing matrix for the sample after a sample map loads.

                                            Wish me luck!

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

                                            49

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            102.1k

                                            Posts