KSP Kontakt scripting issues with custom knob and velocity value to mirror on play note (visual FX)

Discussion in 'Kontakt' started by MarcoB, Mar 21, 2023.

  1. MarcoB

    MarcoB Newbie

    Joined:
    Mar 21, 2023
    Messages:
    2
    Likes Received:
    0
    Hi, I'm a KSP newbie and probably I'm doing something really stupid... I'm using Kontakt 5.8 engine, full version, trying to develope a simple instrument.

    Every time I play a note (on note event) I'd like to have a custom knob that can visually display the current velocity value in order to give the user a visual feedback of the intensity of the played note (just for fun and aesthetics :))

    It might be a custom knob that represents a speaker, so by playing a keystroke hard (high velocity) I could show a beautiful kind of animated speaker icon with different image size and aspect in accordance with the velocity value. It should be nice effect to look at, especially when you play along with rhythm, IMO.

    what I can't understand is why I can make it work if I write

    $VelocityStandardKnob := $EVENT_VELOCITY where $VelocityStadardKnob is the simple built-in standard knob that Kontakt offers, in that scenario when I play a note I can see the knob reflect the velocity value but if I switch from the built-in knob type and use a custom knob with custom graphics instead (you know, it's a slider in reality), then that custom knob does not reflect the velocity value when I play a note.

    I have put a message instruction after the assignment and I can see that the $VElocityCustomKnob value contains the same current value of the $VelocityStandardKnob value so I am really stucked ... what I am doing wrong ?

    Thanks a lot guys, for you support.
     
    • Interesting Interesting x 1
    • List
  2.  
  3. 5teezo

    5teezo Audiosexual

    Joined:
    Feb 2, 2012
    Messages:
    2,062
    Likes Received:
    1,175
    Users already have an integrated sensor for detecting velocity… it's called ears… focus on sound, not on gimmicks!
     
    • Like Like x 1
    • Disagree Disagree x 1
    • List
  4. xorome

    xorome Audiosexual

    Joined:
    Sep 28, 2021
    Messages:
    1,122
    Likes Received:
    836
    Example code for a three-state slider:

    File structure:
    Code:
    Instrument.nki
    res.nkc
    res.nkr
    Resources\pictures\button0.png
    Resources\pictures\button0.txt
    
    button0.txt (notice the empty line at the end, the file should be 10 lines exactly):
    Code:
    Has Alpha Channel: no
    Number of Animations: 3
    Horizontal Animation:  yes
    Vertical Resizable: no
    Horizontal Resizable: no
    Fixed Top: 0
    Fixed Bottom: 0
    Fixed Left: 0
    Fixed Right:  0
    
    
    KSP:
    Code:
    on init
        set_ui_height_px(150)
    
        declare ui_slider $slider0(1, 127)
        set_control_par_str(get_ui_id($slider0), $CONTROL_PAR_PICTURE, "button0")
        move_control_px($slider0, 250, 0)
    
        declare $vel
        message (" ")
    end on
    
    on note
        ignore_event ($EVENT_ID)
        $vel := $EVENT_VELOCITY
    
        if ($vel >= 100)
            $slider0 := 100
        else
            if ($vel >= 50)
                $slider0 := 50
            else
                $slider0 := 1
            end if
        end if
    end on
    
    preview.gif

    edit: fixed preview
     
    Last edited: Mar 22, 2023

    Attached Files:

  5. Xupito

    Xupito Audiosexual

    Joined:
    Jan 21, 2012
    Messages:
    7,231
    Likes Received:
    3,995
    Location:
    Europe
    Dude, relax. He's not a user in this, he's the developer, a beginner one. His question is totally legit. At least read what the thread is about.

    Edited:
    Almost forgot: great answer. Bravo :wink::shalom:
     
    Last edited: Mar 22, 2023
Loading...
Similar Threads - Kontakt scripting issues Forum Date
Kontakt Scripting Kontakt Jul 27, 2017
Tutorials for Kontakt Scripting? Kontakt Jun 26, 2017
Kontakt Scripting - Building an Instrument From Scratch AudioSex Academy Aug 5, 2015
Scripting Tools For Kontakt 5 Kontakt Jul 26, 2015
Kontakt Scripting - Kontakt Custom Script Collection AudioSex Academy Nov 7, 2014
Loading...