Q: Performance friendly way for triggering note to specific child synth



  • Here's my problem:

    I'm writing a guitar library, and the hierarchy of my project goes something like this:
    Root
    ..Each String:
    ....Articulations
    ......Downstroke
    ......Upstroke

    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.

    1. 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.
    2. 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?



  • Using a script in every sampler is a good approach. You can use a single external script so you don't end up with lots of tiny individual scripts.

    You can delay events with delayEvent().

    For my strumming system I had everything in a single sampler, each string and up/down was mapped into a different area of the mapping editor. This idea isn't original with me, I've seen it used by a few guitar libaries. I created the strum using a timer to play the strings one after another.

    24eef671-6b1f-4b68-bb17-2a4e06797108-image.png


Log in to reply
 

16
Online

1.5k
Users

4.6k
Topics

42.1k
Posts