Save last played note on a specific key

moosmahna
moosmahna Member Posts: 6 Member

Hy,

Is it possible that the last note that I played is "stored" on another key? For example: I press C3 and the note is saved on C2 (but sounding C3). When I press Bb4 it is also "stored" on C2 (sounding Bb4).

I tried some codes I found but I can not get it to work. I hope you can help me.

Thanks a lot

Kind Regards Roman

Comments

  • Lovechld2000
    Lovechld2000 Member Posts: 29 Member
    edited February 2023
    { Compiled on Thu Feb 16 19:38:54 2023 }
    on init
      declare const $SPECIALKEY := 24 { 24 is C0 if you want C2 use 48 }
      declare $note_track
      set_key_color($SPECIALKEY,$KEY_COLOR_LIME)
    end on
    
    
    on note
      message("")
      if ($EVENT_NOTE=$SPECIALKEY)
        ignore_event($EVENT_ID)
        play_note($note_track,$EVENT_VELOCITY,0,-1)
        message($note_track)
      else
        $note_track := $EVENT_NOTE
      end if
    end on
    
    
    
    
    
    
    
  • moosmahna
    moosmahna Member Posts: 6 Member

    Hy,

    thank you very much! Perfect.

  • moosmahna
    moosmahna Member Posts: 6 Member

    Hy,

    I have tried to copy your code to my groups.

    When I activate group 1 it works perfect. But when I activate group 2 then it doesnt. When I press a key the sample from group 1 is played and when I release the key the right sample from group 2 is played.

    What have I missed?

    on note

    if ($Gruppe1=1)

    disallow_group($ALL_GROUPS)

    allow_group(0)


    set_key_color($SPECIALKEY,$KEY_COLOR_LIME)


    message("")

     if ($EVENT_NOTE=$SPECIALKEY)

       ignore_event($EVENT_ID)

       play_note($note_track,$EVENT_VELOCITY,0,-1)

       message($note_track)

     else

       $note_track := $EVENT_NOTE

     end if


    {----- O N  N O T E GROUP 2 -----}

    if ($Gruppe2=1)

    disallow_group($ALL_GROUPS)

    allow_group(1)


    set_key_color($SPECIALKEY,$KEY_COLOR_LIME)


    message("")

     if ($EVENT_NOTE=$SPECIALKEY)

       ignore_event($EVENT_ID)

       play_note($note_track,$EVENT_VELOCITY,0,-1)

       message($note_track)

     else

       $note_track := $EVENT_NOTE

     end if

    Thanks again

  • Lovechld2000
    Lovechld2000 Member Posts: 29 Member

    If you write code in here, click on the symbol that appears to the left of where you type and choose the inverted commas - toggle special formats and choose code block. I recommend reading the ksp manual, books about kontakt scripting and xtant kontakt video courses to learn how to do this more effectively.


    on init
      declare const $SPECIALKEY := 24 { 24 is C0 if you want C2 use 48 }
      declare $note_track
      set_key_color($SPECIALKEY,$KEY_COLOR_LIME)
      declare ui_button $Gruppe1
      declare ui_button $Gruppe2
    end on
    
    
    
    
    
    
    on note
        disallow_group($ALL_GROUPS) 
        message("")
        if($Gruppe1=1)
            allow_group(0)
        end if
        if ($Gruppe2=1)
            allow_group(1)
        end if
        
        if ($EVENT_NOTE=$SPECIALKEY)  
            ignore_event($EVENT_ID) 
            play_note($note_track,$EVENT_VELOCITY,0,-1)
            message($note_track)
        else
            $note_track := $EVENT_NOTE
        end if
         
    end on
    
Back To Top