Non Repeating Round Robin Help
-
@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.
-
@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.
-
@aaronventure All good points!