On Wednesday, May 24, 2017 22:13:38 Andrew C wrote:
> Just updated to the latest and it works (ignoring event_id ignores input).
> Just having a logic problem in my script (My issue, not the sampler)
> 
> When I put in the full parameters for play_note and tell it to keep the
> same note_off value for the original note, in 'case 0', the $event_note is
> played correctly, but in 'case 1', the $event_note and $event_note + 5 get
> played the same time. I thought I had told ignore_event to ignore the
> initial note?
[snip]
> on init
> declare polyphonic $alt
> end on
> 
> on note
> ignore_event($EVENT_NOTE)
> 
> message("Alt is: " & $alt)
> 
> select $alt
> 
> case 0
> play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, -1)
> message("Root note")
> $alt := 1
> case 1
> play_note($EVENT_NOTE+5, $EVENT_VELOCITY, 0, -1)
> message("Transposed")
> $alt := 0
> end select
> 
> end on

Your variable $alt is declared "polyphonic". That means each time your note 
event handler is executed, it is using a completely separate instance of your 
variable $alt (which is always initialized with 0 by the way). Hence $alt is 
always 0 and thus your case 1 is never executed.

Just remove keyword "polyphonic" and it will probably behave as you intended 
it to do.

http://doc.linuxsampler.org/Instrument_Scripts/NKSP_Language/#polyphonic_variables

The value of polyphonic variables is only preserved from a note handler to its 
(own) release handler. So you can use polyphonic variables to "stick" your own 
custom values to one specific note if your will.

> On a related note, it seems that 'change_note' in ksp could achieve the
> desired effect of transposing incoming notes:
> 
> "The values of $EVENT_NOTE and $EVENT_VELOCITY can be changed by using the
> following functions:
> 
> change_note(<ID-number>,<new-note-number>)
> 
> change the note value of a specific note event
> 
> change_velo(<ID-number>,<new-velocity-number>)
> change the velocity value of a specific note event"

Correct, that's what you rather wanted to do in your example instead. Right 
now your can use set_event_par() instead:

http://doc.linuxsampler.org/Instrument_Scripts/NKSP_Language/Reference/set_event_par_function/

I will certainly also add change_vol() and change_note() just for sake of 
completeness. The behavior is absolutely identical though.

ATM you can even do that:

        $EVENT_NOTE := 40
        $EVENT_VELOCITY := 127

But I am not sure yet whether that will change in future, maybe those will 
become read-only variables one day, so writing to those built-in variables is 
currently not a documented behavior, and probably you are not allowed to do 
that with KSP at all.

CU
Christian

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxsampler-devel mailing list
Linuxsampler-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxsampler-devel

Reply via email to