|
From: Andrew C <cou...@gm...> - 2019-06-27 09:37:05
|
Hi all, Been reading through the NKSP documentation again and trying to undeerstand how to trigger keyswitches from a script. All I can find are play_note, change_note and set_par_event play_note says: almost like generating a new MIDI note-on event programmatically, with the difference though ... no MIDI specific note-on handling be done (i.e. it will have no effect on key switching or on the status of built-in array variable %KEY_DOWN[]). change_note says: MIDI processing tasks of the sampler like exclusive groups (a.k.a. key groups), key based round robin and all other common MIDI processing tasks are not affected by this function at all. and set_par_event's midi note function says (I think?) that it's functionally identical to change_note Am I SOL on scripting MIDI notes that can affect keyswitch areas of the keyboard? While I thought set_gig_dimension would point me in the right direction, but it does not seem to have any bearing on the keyswitch dimension. Thanks, Andrew. |
|
From: Christian S. <sch...@li...> - 2019-06-27 10:34:53
|
On Donnerstag, 27. Juni 2019 10:36:54 CEST Andrew C wrote: > Am I SOL on scripting MIDI notes that can affect keyswitch areas of the > keyboard? > While I thought set_gig_dimension would point me in the right direction, > but it does not seem to have any bearing on the keyswitch dimension. These are two different things: The keyswitch dimension is the standard solution that requires no scripting at all. So with that solution you just a) add a "keyboard" dimension with gigedit and b) define the keyswitching range with gigedit (low and high note of the keyswitching range. That's it. If you want to implement keyswitchting by script instead, i.e. because you want a more fine graded keyswitching behaviour than the standard built-in one described above, then don't use the "keyboard" dimension. In fact when doing such things by script then I recommend you to pick a dimension type which would not trigger implied actions by the sampler. Because if you pick e.g. the "modulation wheel" dimension, then of course the sampler would switch dimensions if you rotate the modulation wheel, likewise if you pick the "keyboard" dimension the sampler would switch dimension when the keys of the instrument's keyswitch range are triggered. In the NKSP instrument scripting examples that you find online, e.g. on the old LS 2.0 release notes: http://doc.linuxsampler.org/Release_Notes/LinuxSampler_2_0_0/ I commonly used the "smartmidi" dimension instead for the purpose of switching the dimension regions by scripts, because that dimension type is not switched automatically by the sampler unless you have created iMIDI rules. [ Probably a more cleaner solution would be if we introduce some dedicated, new dimension type in the gig format for scripting purposes instead. ]. So with scripting you would e.g.. use if (%KEY_DOWN[28]) to check for a certain key currently being pressed down and then switch to the desired dimension zone of the smart midi dimension: gig_set_dim_zone($newNote, $GIG_DIM_SMART_MIDI, 2) where the last argument stands for the precise dimension region zone you want to switch to. About change_note() and set_event_par() not having any affect on the built-in "keyboard" dimension: that is not a bug, that's intended behaviour. These functions are intended to modify voice parameters, they are not really intended as MIDI filters. For MIDI event filtering KSP has a separate event handler which is currently not implemented in LS yet. What you could also do though in the "on note" event handler you could use the ignore_event() function to drop the respective MIDI note on event, and then immediately call play_note() instead and pass the return value of the latter to git_set_dim_zone() and switch to the desired dimension zone. CU Christian |
|
From: Christian S. <sch...@li...> - 2019-06-27 10:45:59
|
On Donnerstag, 27. Juni 2019 12:34:52 CEST Christian Schoenebeck wrote: > to check for a certain key currently being pressed down and then switch to > the desired dimension zone of the smart midi dimension: > > gig_set_dim_zone($newNote, $GIG_DIM_SMART_MIDI, 2) > > where the last argument stands for the precise dimension region zone you > want to switch to. Actually when I thought more about it, the following should actually be sufficient for your case: on note ... gig_set_dim_zone($EVENT_ID, $GIG_DIM_KEYBOARD, 2) end note Because gig_set_dim_zone() should actually always override the sampler's built-in dimension region selection. So the script's selection should always have precedence. $EVENT_ID is a built-in variable for the current event type, in the note event handler that's the note-on event. CU Christian |
|
From: Andrew C <cou...@gm...> - 2019-06-27 11:25:45
|
Hi Christian, Many thanks for that indepth explanation. gig_set_dim_zone was my next area to investigate, but I had forgotten you could do things like $newnote := play_note. My test script looks like this now and it works, selecting the specific dimension (i'm not sure if "ignore_event" is necessary): on init declare $newnote end on on note ignore_event $newnote := play_note($EVENT_NOTE, $EVENT_VELOCITY, -1, -2) gig_set_dim_zone($newnote, $GIG_DIM_SMARTMIDI, 6) end on Originally I was doing the following and not understanding why it didn't work: gig_set_dim_zone($newnote, $GIG_DIM_SMARTMIDI, 6) play_note($EVENT_NOTE, $EVENT_VELOCITY, -1, -2) Thanks again, Andrew. |
|
From: Christian S. <sch...@li...> - 2019-06-27 11:59:40
|
On Donnerstag, 27. Juni 2019 12:25:36 CEST Andrew C wrote: > My test script looks like this now and it works, selecting the specific > dimension (i'm not sure if "ignore_event" is necessary): > > on init > declare $newnote > end on > > on note > > ignore_event > > $newnote := play_note($EVENT_NOTE, $EVENT_VELOCITY, -1, -2) > gig_set_dim_zone($newnote, $GIG_DIM_SMARTMIDI, 6) > > end on ignore_event is necessary, otherwise you get 2 notes playing on each MIDI note-on event: one note playing the smart midi dimension zone 0 and one note playing the smart midi dimension zone 6. So that's probably not what you want. CU Christian |