Solved Triggering of Different RR Groups, With Different Amounts of Samples, Without Triggering Dead Notes
-
Hello, I am very new to HISE/scripting and had a question about triggering certain notes within a RR group. I am building a piano sampler instrument but some of my RR groups don't have samples for some notes, while other groups have samples for those same notes. I am trying to figure out a way to maintain my random RR while also eliminating any dead notes. As it currently stands, the code seems to cause the RR's to stop working and just remain on one RR group.
onInit
const var NoteSamples = Synth.getSampler("NoteSamples"); NoteSamples.enableRoundRobin(false); reg counter = 0; reg lastCount = 0;
onNoteOn
function onNoteOn() { counter = (lastCount - 1 + Math.randInt(2, 5)) % 5 ; NoteSamples.setActiveGroup(counter + 1); lastCount = counter; Message.getNoteNumber(); if (NoteSamples.isNoteNumberMapped(number)); Function.NoteSamples.setActiveGroup(1); }
The code seems to compile okay, but when I play a note I get this error:
Round Robin 1:! onNoteOn() - Line 8, column 37: API call with undefined parameter 0 {Um91bmQgUm9iaW4gMXxvbk5vdGVPbigpfDIwOHw4fDM3}
I would still like to trigger the RR groups with less samples, but ONLY for the samples that they DO have, and not for the ones that they don't.
Thank you in advance, I apologize if this is a silly question, I am still very new to scripting and HISE in general.
-
ok lets start with this:
function onNoteOn() { counter = (lastCount - 1 + Math.randInt(2, 5)) % 5 ; NoteSamples.setActiveGroup(counter + 1); lastCount = counter; Message.getNoteNumber(); <--and put it where? if (NoteSamples.isNoteNumberMapped(number)); <-- whats "number" here? Function.NoteSamples.setActiveGroup(1); }
did you mean this?
function onNoteOn() { counter = (lastCount - 1 + Math.randInt(2, 5)) % 5 ; NoteSamples.setActiveGroup(counter + 1); lastCount = counter; local Nnumber = Message.getNoteNumber(); if (NoteSamples.isNoteNumberMapped(Nnumber)); Function.NoteSamples.setActiveGroup(1); }
-
Just duplicate the samples for the groups with missing notes.
-
@d-healey Ahhhhh such a simple solution, thank you!
-