Using hard coded velocity as "sample selector" across multiple groups

Options
pegboard_alex
pegboard_alex Member Posts: 1 Newcomer
edited November 2023 in Kontakt

Hey all! I'm trying to build something based on the Roland JD-990, where you have 4 "tones", or layers if you will. I'm using the velocity layers across two groups (as there are more than 127 waveforms) to hold the various waveforms for one layer.

I was able to set up a waveform selector that allows/disallows group 0 and 1 based on whether or not the value, which I'm storing in a variable, is over 127. All is well so far.

I'm now trying to extend this into a second layer, so I duplicated group 0 and 1, into 2 and 3, with a second variable to hold the waveform number. Similar to how the JD800/990 works, I have switches that either write to waveform variables A, B or both, to choose a certain waveform.

On "note on", I set the volume based on the velocity first

    $vol_amount := (($EVENT_VELOCITY - 1) * 24000 / 126) - 24000 
    change_vol($EVENT_ID, $vol_amount, 1) 

then I set the note velocity to whatever waveform is selected to access that "velocity layer"


    if ($toneA_WF < 127)
        allow_group( 0 )
        disallow_group(1)

        change_velo($EVENT_ID, $toneA_WF + 1)
        else if ($toneA_WF > 127)
            disallow_group(0)
            allow_group(1)

            change_velo($EVENT_ID, $toneA_WF - 129) 
        end if
    end if

The problem comes when I want to access a different velocity layer for "Tone B" (and further down the line more groups), group 2/3 at the same time.. I cannot for the life of me figure out how to change the velocity for groups individually. I've read the KSP Reference Manual over and over, as well as searched the various forums. I have some basic programming experience, but I'm new to Kontakt scripting, so I feel like I'm just missing something obvious, haha. I've played around/have a suspicion the solution might have something to do with set_event_par_arr, but have not been able to make it work so far.

I've been down some very deep "if...else" rabbitholes, but I reverted back to something simpler (that still doesn't work), so this is just currently where I'm at with "note on":


on note
    disallow_group(0)
    disallow_group(1)
    disallow_group(2)
    disallow_group(3)
    { change volume based on velocity }
    $vol_amount := (($EVENT_VELOCITY - 1) * 24000 / 126) - 24000 
    change_vol($EVENT_ID, $vol_amount, 1) 
    
    if ($toneA_WF < 127)
        allow_group(0)
        disallow_group(1)

        change_velo($EVENT_ID, $toneA_WF + 1)
        else if ($toneA_WF > 127)
            disallow_group(0)
            allow_group(1)

            change_velo($EVENT_ID, $toneA_WF - 129) 
        end if
    end if

     if ($toneB_WF < 127)
        allow_group(2)
        disallow_group(3)

        change_velo($EVENT_ID, $toneB_WF + 1)
        else if ($toneB_WF > 127)
            disallow_group(2)
            allow_group(3)

            change_velo($EVENT_ID, $toneB_WF - 129) 
        end if
    end if 
end on


Cheers!

Answers

  • EvilDragon
    EvilDragon Moderator Posts: 1,023 mod
    Options

    Moving to scripting subforum.


    As to your question: you need to play_note() for each group you want to play separately, and use set_event_par_arr() to disallow or allow the group(s) you want to trigger for each such event.

Back To Top