Welcome to the new and improved Native Instruments online community. Join our active forum of 40,000+ members for discussions and much more.

More than 16 custom event parameters

Reid115 Member Posts: 47 Member
edited August 2022 in Scripting Workshop

Currently, you can have only up to 16 values stored with $EVENT_PAR_CUSTOM. Unfortunately, my program is really complicated and needs probably double that for most events. I need the parameters so that I can communicate a lot of information between the NCB and the LCB (a lot of weird per-voice modulation stuff). I'm essentially trying to create a C struct for events... I can't do something with polyphonic variables (which are only visible in NCB/RCB anyways) because there will be many independent events fired within a single NCB call. The best solution I can come up with is as follows:

on init
    declare polyphonic $new_id
    declare polyphonic $tmp_idx
    define MAX_VOICES := 500
    declare %EVENT_PAR_CUSTOM_16[MAX_VOICES] := (0)
    declare %EVENT_PAR_CUSTOM_17[MAX_VOICES] := (0)
    declare %EVENT_PAR_CUSTOM_18[MAX_VOICES] := (0)
    declare %EVENT_PAR_CUSTOM_50[MAX_VOICES] := (0)
end on

on note
    new_id := play_note(...)

    // Note that next available spot will be the same in all arrays, so im just using CUSTOM_16.
    tmp_idx := next available spot in %EVENT_PAR_CUSTOM_16
    set_event_par_arr(new_id, EVENT_PAR_CUSTOM, tmp_idx, 0)
    EVENT_PAR_CUSTOM_16[tmp_idx] := something
    EVENT_PAR_CUSTOM_17[tmp_idx] := something
    EVENT_PAR_CUSTOM_18[tmp_idx] := something
    EVENT_PAR_CUSTOM_50[tmp_idx] := something
end on

on listener
    if EVENT_PAR_CUSTOM_35[get_event_par_arr(some_event_id, EVENT_PAR_CUSTOM, 0)] = something
        // do something
    end if
end on

Has anyone ever done this before? Any ideas for a more elegant/efficient solution? Thanks 😵


  • EvilDragon
    EvilDragon Moderator Posts: 858 mod

    Yeah the only way to do this if 16 event pars is not enough is to have your own data structures to handle additional parameters with.

Back To Top