Here's my problem:
I'm writing a guitar library, and the hierarchy of my project goes something like this:
On NoteOn, I need to trigger multiple (but not all) articulations at once, each delayed by a different amount, but whether each articulation is triggered as downstroke or upstroke depends on a global variable.
How should I approach this?
I thought about and experimented with two approaches.
- Modular approach.
Using a script in EVERY sampler, which loads many global namespaces to determine the current articulation and whether or not to ignore the midi event. This approaches creates a complex web of tiny scripts, a bit less manageable, and I don't know how performant it would be if every sampler needs to have a MIDI script handling every note on with many conditional branches.
- Grouped approach.
I tried writing a bigger script at level of each string. Upon receiving a NoteOn message, it creates a NoteOn message for each involved articulation, differentiated by midi channels, and handles the attributes of samplers (such as down/up strokes and round robin) directly as parent synth. This way, I don't need to add a script for each sampler so it MIGHT be more performant?
The problem is that I can't find a way to send a MIDI event to a specific child synth. There's only Synth.playNote() and Synth.addNoteOn(), and both can't be delayed.
Although as I am writing this I just came up with the idea of using a local variable to record the eventid generated by addNoteOn(), then check for equivalent event in onNoteOn() and set timestamp and channel in a if branch.
However it would be nice to know which approach would be more performance friendly. Is A, numerous NoteOn callbacks from multiple MIDI processors to check whether an event should be ignored, better than B, generating many specific NoteOns and setting attributes of multiple child processors from one parent MIDI processor?
PS. another question, is hardcoded script better than hand written script for filtering events in terms of performance?