1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

K3 Mod Wheel Script

Discussion in 'Scripting Workshop' started by robindeandotcom, Jan 23, 2008.

Thread Status:
Not open for further replies.
  1. robindeandotcom

    robindeandotcom Forum Member

    Messages:
    26
    I need a script that does something like ...

    if note is equal to 25, 26, 27 or 28 ... set mod wheel position to 100 percent (up) and play the note down 2 octaves ...

    else set mod wheel to 0 percent (down).

    Can I get some help with this?

    That is to say, if the note is in an array (25, 26, 27, 28) maximize the mod wheel position and play the note one 2 octaves below the orignal pitch. Otherwise, be sure that the mod wheel is minimized and play the note as-is.

    Any help would be great.
     
  2. g.h.

    g.h. NI Product Owner

    Messages:
    73
    Hi!

    Try this one!

    gh
     

    Attached Files:

  3. robindeandotcom

    robindeandotcom Forum Member

    Messages:
    26
    I fear that this is far more than what I need.

    Is there a method that is more simple and efficient?
     
  4. Patrick@Denman

    Patrick@Denman NI Product Owner

    Messages:
    103
    Looks to me like g.h. delivered exactly what you were asking for. (Good job, g.h.) What is it about the script that you think is not simple?
     
  5. robindeandotcom

    robindeandotcom Forum Member

    Messages:
    26
    Oh I just don't know what I'm looking at, really. I'm new to scripting and anxcious to play. I'll try and make sense of it but if anyone is up for giving an explaination / comments on what is happening in the code I'd be very grateful. Don't bother with it if you don't have time though. Thanks for the script :)
     
  6. Thonex

    Thonex NI Product Owner

    Messages:
    208
    If you want to get into scripting, may I suggest you got to this forum:

    http://vi-control.net/forum/viewforum.php?f=65

    People there are very helpful... and there are a lot of resources there.

    Cheers,

    T

    PS. I'm not at my studio so I can't check it, but I think this code will also do what you want... and is a little simpler. Just copy/paste the code below into your Scripting editor and hit the Apply button:

    Code:
    
    on note
      if (in_range($EVENT_NOTE,25,28)
        set_controller (1,127)
        change_note($EVENT_ID,$EVENT_NOTE-24)
      else
        set_controller (1,0)
        exit    
      end if
    end on
    
     
    Last edited: Feb 9, 2008
  7. kotori

    kotori NI Product Owner

    Messages:
    1,153
    Here's a simpler script (please change the 25-28 values yourself if needed):
    Code:
    on init
      declare const $LOWEST_NOTE  := 25
      declare const $HIGHEST_NOTE := 28
    end on
    
    on note
      if (in_range($EVENT_NOTE, $LOWEST_NOTE, $HIGHEST_NOTE))
        set_controller(1, 127)
        change_note($EVENT_ID, $EVENT_NOTE-24)
      else
        set_controller(1, 0)
      end if
    end on
    You can view it syntax highlighted (easier to read) here.
     
  8. Thonex

    Thonex NI Product Owner

    Messages:
    208
    beat you Kotori :))))))))))
     
  9. kotori

    kotori NI Product Owner

    Messages:
    1,153
    :D
     
  10. Patrick@Denman

    Patrick@Denman NI Product Owner

    Messages:
    103
    Great contributions, guys. Robin, being new to scripting I'm sure this stuff can be a bit intimidating. Some of us "code monkeys" tend to take it for granted, so don't be shy about asking what is going on.

    When you look at some of the scripts that NI has created - like for the Akkord guitar - it's pretty hairy. (The Akkord script is close to 1800 lines of code.) So my take is that anything under 50 lines is usually pretty lean stuff.

    I'm a software developer myself, but haven't really done any scripting in KONTAKT yet, so I'm using this as an incentive to get into it as well...:)
     
  11. robindeandotcom

    robindeandotcom Forum Member

    Messages:
    26
    Intimidating yes and intimidating no. I do php and cgi web dev myself. The simplified renderings behave more adequately thus far. However, My new problem is that the controller change isn't sounding until after the note being played initiates it.

    That is to say, "note is played and then note after it reflects the controller change"

    Any solutions?
     
  12. Thonex

    Thonex NI Product Owner

    Messages:
    208
    I'm not sure I'm following you. Are you saying that when you play midi note 25 (C#1) followed by (say) midi note 60 (C3) that the CC1 is not being set to 0 when you play C3 the first time?

    T
     
  13. kotori

    kotori NI Product Owner

    Messages:
    1,153
    After any line saying "set_controller (1,[...])" try to insert a new line saying "cc_delivery_request(1)" (without the quotes). Don't forget to press the Apply button in the Kontakt Script Editor for the changes to take effect.
     
  14. Thonex

    Thonex NI Product Owner

    Messages:
    208
    Where did you find that command Nils ? :)
     
  15. kotori

    kotori NI Product Owner

    Messages:
    1,153
  16. Thonex

    Thonex NI Product Owner

    Messages:
    208
  17. robindeandotcom

    robindeandotcom Forum Member

    Messages:
    26
    Thanks for the response. adding "cc_delivery_request(1)" to a line AFTER the set_controller line didn't work either, though.

    @Thonex - I'm suggesting that when I play midi note 25 (actually it's an array of other note options), the CC1 data is not INSTANTLY heard. Rather, it's heard in the note that is played afterwards.

    I want to change the CC1 data and hear the change within the sample on a per note basis. i.e. I play a note which then changes the CC1 and plays the sample which reflects the change.

    Here's my code thus far:

    Code:
    on init
    declare $alternate
    end on
    on note
    if (in_range($EVENT_NOTE,67,72))
    set_controller (1,127)
    cc_delivery_request(1)
    change_note($EVENT_ID, $EVENT_NOTE - 24)
    else set_controller (1,0)
    cc_delivery_request(1)
    end if
    if ($alternate = 0)
    $alternate := 1
    else if ($alternate = 1)
    change_note($EVENT_ID, $EVENT_NOTE - 24)
    $alternate := 0
    end if
    end if
    end on
     
  18. robindeandotcom

    robindeandotcom Forum Member

    Messages:
    26
  19. Thonex

    Thonex NI Product Owner

    Messages:
    208
    Try substituting the change_delivery_request line with:

    wait (1)

    if that doesn't work, try wait (10).... I'm not sure why it's not working... again I haven't tried this in my studio, but it should work.

    Let us know.

    T
     
  20. robindeandotcom

    robindeandotcom Forum Member

    Messages:
    26
    Thanks T,

    I'll try that and if it doesn't work, I'll move it over to the VI forum.
     
Thread Status:
Not open for further replies.