Kawai triple sensor conversion

I came across a plugin that I happened to like but ran into some problems. It’s the free Roland MKS20 emulation from giulioz. The plugin did just not understand the note messages from my Kawai VPC1 so good - at all. Retriggered Note On messages kept ringing forever. I came up with this script to use in a scriplet. Quite simple but as a newbie to scripting it took me some hours. :slight_smile:

var 
tracker1 : NoteTracker

On NoteEvent(m : NoteMessage)

    If IsNoteOff(m) then                                                            // If note message is a Note Off
        if NoteTracker_IsNoteOffPending(tracker1,GetNoteNumber(m)) == True Then     // If note has been pressed earlier - send note Off.
            SendNow(m)                                                              // Send the Note Off message one time
            NoteTracker_GotNoteOff(tracker1, GetNoteNumber(m))                      // Register the note as Off in NoteTracker
        end                                                                         
    else                                                                            // If note message is Note On
    
        if NoteTracker_IsNoteOffPending(tracker1,GetNoteNumber(m)) == False Then    // If note is Off when key is pressed
            SendNow(m)    
            NoteTracker_GotNoteOn(tracker1, GetNoteNumber(m))                       // Register the note as On in NoteTracker and send note On

        else                                                                        // If note is on and retriggering 
            SendNow(MakeNoteOffMessage(GetNoteNumber(m), 25))                       // Send Note Off followed by a Note On
            SendNow(m)        
        end
    end
end 

Info on Kawai triple sensor midi handling

Link to MKS20 plugin

What it does is to always send a Note Off along with the Note On each time the note is retriggeret without key being fully released (Off).
When key is released one Note Off message is sent.

Fun to explore the NoteTracker function with all help from earlier posts here. Thanks!