HISE Logo Forum
    • Categories
    • Register
    • Login

    Non Repeating Round Robin Help

    Scheduled Pinned Locked Moved Scripting
    23 Posts 4 Posters 855 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.
    • d.healeyD
      d.healey @Casmat
      last edited by

      @Casmat Yes, try it and see.

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

      CasmatC 1 Reply Last reply Reply Quote 0
      • CasmatC
        Casmat @d.healey
        last edited by

        @d-healey
        the sampler still has no chamging rr groups, i changed Message.setVelocity to Sampler.setActiveGroups

        i make music

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

          @Casmat said in Non Repeating Round Robin Help:

          the sampler still has no chamging rr groups, i changed Message.setVelocity to Sampler.setActiveGroups

          Sampler.setActiveGroups won't work. You need to replace Sampler with the reference to the specific sampler you want to affect.

          Are you wanting all samplers to changes to the same group at the same time, or do you want each one to change to a different random group?

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

          CasmatC 1 Reply Last reply Reply Quote 0
          • CasmatC
            Casmat @d.healey
            last edited by

            @d-healey
            i would like each sampler to change to a different group

            i make music

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

              @Casmat In that case you should use one RR script per sampler. Of course you don't want to re-write the same code 3 times, so this is where a reusable module is perfect.

              This is what we did in the Hackspace course (I think it was in part 3).

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

              CasmatC 1 Reply Last reply Reply Quote 0
              • CasmatC
                Casmat
                last edited by

                got it! thanks for clarifying!

                i make music

                1 Reply Last reply Reply Quote 0
                • CasmatC
                  Casmat @d.healey
                  last edited by Casmat

                  @d-healey
                  Just tried testing it and it seems to not work still. the RR groups in the sampler view don't seem to change number. this is what I have so far:

                  oninit:

                  const var sampler0 = Synth.getSampler("sampler0");
                  sampler0.enableRoundRobin(false);
                  
                  reg counter = 0;
                  reg lastCount = 0;
                  

                  onnoteon:

                  function onNoteOn()
                  {
                  	counter = (lastCount - 1 + Math.randInt(2, 5)) % 5 ;
                  	sampler0.setActiveGroup(counter + 1);
                  	lastCount = counter;
                  }
                  
                  

                  Here's the hise snippet as well:

                  HiseSnippet 2257.3oc6b0sbabaEdWIgXQFKYmLIcZm1NyVOsyPkXqvkxVoynoiV8aBqsjnIUTSuHiCzRPRDsDXCVrxVMiq0zIOB8lbWdD5ifeDZmoO.9pNSuKuAs.6tjKVJJEJpehnDzUBXW.78c.1y4fymkqvntnf.JyvL21G3iLLuMn1ADdqUZAwDixqZX9yAa2BY8Y9LbyVbqkgAAVUvPB0X4C7EMP0MLMG+SjusYtILh94GVbYnGj3hR6xvXGJ1E8DbaLOs2JNOF64sNrNZabak29gNkcojUndzPAxFGTzvG5tGrIZSn70FCXX9VqUGyorZbHGEXXNwxz5GTqE84j32eGb.dWOjrgsQMwDE285Tu5RDK60XkVXu5U5XABLLLAURsGiGaOdOvF353t8mZWtazCrRGgp8vbrrva7LvyVEdEUfWefjoBjlHFRuCnlKC6ySehDOuMnLgiXMfBytJTheWCyWCVgJdABe11v8PqyDM5NfByWr38slqXwYVnQHwkioDKJYSJGsEovL4+l74x+x7V89nFM56yjKCi54gX88wxcZ1IMvBjv16hX22ZenWHp6KJneVaJ33sopa4twrV4EojxDLeKeD43NHXjXpD1+oSPk3U4QV+oSr907v0QLCrvHmGrGYW4m.EMhvr5wdiSy3sOiiuzvM9Ikie8WT7LM5gD62MZzXOwIwkpGvJdtLKmOXoz4xrL2vMKua1YYo17gadlRNOK01+LXbUmB6y9TT5rOE8yl9YkWExgROlIe7J9f1Gw3XouByUQ6KB+D6+LGXUTvdbpuHRxJz19Th7ScyIiW5oRV5xsEwahV46.vsatrH.TSFMjT23Epq6ApMdN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4GA
                  

                  i make music

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

                    @Casmat Your snippet works here, the groups change with each key press.

                    Peek 2023-04-10 11-05.gif

                    I noticed you are hardcoding the sampler reference which means you need three separate scripts. Try to avoid this. Instead, reuse the same script as I demonstrate in the Hackspace course.

                    The problem with writing 3 scripts that all do the same thing is it doesn't scale well and you give yourself additional code maintenance. Imagine you have a project with 10 samplers, now you have 10 separate RR scripts that all do the same thing except one line is different. Then you find a bug in the script, now you have to go through 10 scripts to fix the bug 10 times. It makes no sense to do that when you can write and maintain one script instead.

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

                    CasmatC 1 Reply Last reply Reply Quote 0
                    • CasmatC
                      Casmat @d.healey
                      last edited by

                      @d-healey

                      Hmm, that’s weird, it doesn’t seem to change on my end, I’ll try fiddling with it in the meantime and yes, I had the scripts all connected, I had just disconnected them to see if that would’ve fixed the problem. Thanks again for your help!

                      i make music

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

                        Hey, sorry for the necro bump. But if you've got say 7 RR groups... and for a particular velocity range there are only 6 samples..... is it possible to avoid the sampler triggering silence when it cycles around to the 7th group.

                        So for example:

                        RR1 - vel-range 60-70 - sample mapped
                        RR2 - vel-range 60-70 - sample mapped
                        RR3 - vel-range 60-70 - sample mapped
                        RR4 - vel-range 60-70 - sample mapped
                        RR5 - vel-range 60-70 - sample mapped
                        RR6 - vel-range 60-70 - sample mapped
                        RR7 - vel-range 60-70 - NO SAMPLE MAPPED

                        Currently you hit a note to trigger the sample 6 times in a row... you'll trigger RR1, 2, 3, 4, 5, 6... and then on the 7th it will attempt to trigger RR7.... and produce silence, because there isn't a sample there.

                        Any way around this?

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

                          @Orvillain said in Non Repeating Round Robin Help:

                          Any way around this?

                          Put some samples there - copy them from another group

                          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 Orvillain

                            @d-healey said in Non Repeating Round Robin Help:

                            @Orvillain said in Non Repeating Round Robin Help:

                            Any way around this?

                            Put some samples there - copy them from another group

                            Ahhh, I think I figured it out.

                            In the init script:

                            Content.makeFrontInterface(600, 600);
                            const var Sampler1 = Synth.getSampler("Sampler1");
                            Sampler1.enableRoundRobin(false);
                            Sampler1.refreshRRMap();
                            var last_group = 0;
                            

                            In the onNoteOn function:

                            function onNoteOn()
                            {
                            	var note = Message.getNoteNumber();
                            	var vel = Message.getVelocity();
                            	var rrGroups = Sampler1.getRRGroupsForMessage(note, vel);
                            	
                            	Console.print('For this note and vel we have a max of - ' + rrGroups + ' rrGroups');
                            	if (last_group >= rrGroups)
                            	{
                            		last_group = 0;
                            	}
                            	Console.print(last_group);
                            	Sampler1.setActiveGroup(last_group+1);
                            	
                            	last_group += 1;
                            	
                            }
                            

                            This will ensure that for a given note and velocity, the active group can never be one that is empty - assuming that it is always the later groups that are empty, and not the ealier ones.

                            IE: For all samples group 0, 1, 2, 3 should be populated. If you have groups 0, 1, 3 populated, then group 2 will still fire off silence. Not too bad. There is at least a way.

                            The will cycle around the groups in a forwards RR style. If you wanted it to be random, you'd have to adjust the logic.

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

                              @Orvillain yes, just don't ever declare variables in realtime callbacks and use reg whenever possible for realtime callbacks. You get 32 slots by default, but if you ever need more, create a namespace (each namespace gets its own 32 regs).

                              var in your case creates a scoped variable that will be killed once the function is executed. Memory allocation and deallocation is a bad idea for realtime. That's also why for any arrays you use in realtime callbacks, even reg, need to have reserved slots by calling array.reserve().

                              Objects cannot have dynamic access in realtime callbacks. Any object properties you want to use, you need to assign/initialize beforehand in on init.

                              So in your case, you need to declare these variables as reg in on init and then store whatever in on note on.

                              I suggest you build HISE with the audio thread guard (find it in the JUCE_CORE module in Projucer) and enable it in project settings. It should then scream at you whenever you try something like this.

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

                                @aaronventure All good points!

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

                                38

                                Online

                                1.7k

                                Users

                                11.7k

                                Topics

                                102.1k

                                Posts