• Register
  • Help
Results 1 to 4 of 4

Topic: Welcome!!!

Share/Bookmark
  1. #1
    Moderator/Developer Brian2112's Avatar
    Join Date
    Nov 2003
    Location
    Out of my Mind
    Posts
    1,858

    Thumbs up Welcome!!!

    Welcome to the Midi Programming Section!

    This section of the forum is dedicated to the discussion of midi files, Imidi programming, and scripting. Attachments are enabled in this section to so that Imidi, midi, and all scripting can be discussed and uploaded in this section.

    *With regard to midi files, you must own the copyright or have proper permissions in order to post them. Furthermore, please have a care as to not inadvertently post commercial scripts or programs.


    Just to get the ball rolling, here's a little bit about Kontakt 2 scripting:

    The introduction of scripting in Kontakt 2 was a bold stroke. In the past, many sample developers used their own “in-house” tools to create legato, repetition, and other articulation management in orchestra libraries (in particular). Most of these things can now be practically constructed in Kontakt 2’s internal environment – eliminating the need for many external applications to be developed. Almost anything that can be imagined can be done. Legato, vibrato, advanced arpeggios, piano string resonance, harmonics, sequencers, and many other applications already exist. The possibilities for interpreting and manipulating incoming midi data are almost limitless (as well as generating new midi data).

    Users benefit whether they ever open the script editor or not. Some scripts are very simple and work “behind the scenes” so to speak. Others are sophisticated enough to require their own manual, and have a lot of knobs and buttons in the GUI.

    Perhaps, the majority of users have no interest in developing their own scripts. Many just want to open the box and make music. The whole point of scripting is to make what comes out of the box even better. Most developers for the K2 platform are now including their own scripts in their libraries (which can also be used (but not edited) in the new Kontakt 2 player).

    It is my hope that this forum will encourage some people to get their feet wet with a little scripting. The more users who are writing scripts, the better our sample libraries can be. There are many great resources for scripting all over the net – I hope this will be another.

    I. Learning a New Language

    Someone completely new to any kind of programming might be freaked out if they open the script editor and look at a script. Believe me; it is not as difficult as it looks. Learning to program (in any language) has just two main requirements.

    The first is learning the language’s “syntax” which is the vocabulary and structure of the language. Unlike an American learning to speak French or Chinese, the vocabulary of words in most programming languages is usually quite small (usually 60 or less!). I bet you had vocabulary tests in high school that were worse than that!

    Second (and perhaps most important) is logic and flow. Most programming errors occur in this realm, yet this concept applies to any language – even modular synth manipulation. This is a skill that is developed over time. But once you have this concept down, then you can easily translate your knowledge to any language.

    II. Getting our Hands Dirty

    Most programs in any high level language contain three main parts in this order:

    1)Initialization and declaration of variables.

    2)The program body or the “Main Loop”

    3)Subroutines and/or functions

    Here is a small example of an initialization routine using English, the programming language "BASIC", and the Kontakt2 Script Processor (KSP):

    English:

    (Very simply): I want to draw a table with 20 sliding bars on it. I want the default value of each bar to be set at 64.

    (Detail): I want to refer to the value of each bar as a variable called “vbar”. I want to select any of the 20 individual bars (which I will call “bar”) and change its value.
    SO: the value of a given bar is stored in a variable called “vbar”. And the given bar itself is called “bar”.


    Kontakt 2 KSP:
    on init {means “On initialization of the program….”}
    declare $bar {Tells KSP that I will be using “bar” as a variable}
    declare ui_table %vbar[20] (4,4,127) {Draws a table with 20 bars on it, places it where I want, and sets the max value of each bar to 127 and tells KSP that the value of each bar will be stored in an array variable called vbar! Smoking man!}
    $bar := 0 {“bar” has an initial value of 0}

    Ok. An array variable simply means that rather than having one value at a time, it has as many you define it to have. In this case, vbar has been defined to have 20 values - hence “%vbar[20]”. The percent symbol lets the KSP know that this will be an array variable (- as opposed to $bar which can only have one value at a time – hence the “$” symbol).
    So now that we want to set the value of each of the 20 bars on the table initially to 64, we could do this:

    %vbar[0] : = 64
    %vbar[1] : = 64
    %vbar[2] : = 64
    Etc…..20 times!

    But that would be silly, take a lot of time to type it all in, and waste system resources. So let’s make a loop that does the work for us.

    In the programming language BASIC, it might look something like this:

    10 For loop = 0 to 19 {step 1}
    20 %vbar[loop] = 64
    30 Next loop

    That’s it!
    Another way in BASIC (not using a {for…next} loop:

    10 x=0
    20 if x=20 then goto 60
    30 vbar[x] = 64
    40 x=x+1
    50 goto 20
    60 Do_Other_Stuff

    But Brian! You ignorant fool! It goes on before it reaches the value 20 and we have 20 bars to define!
    True. But the array for the table in KSP begins at 0 – not at 1. So our 20 bars are 0-19 instead of 1-20. Think about a Midi CC. It can have 128 values but the values range from 0-127 – same deal.

    Now our KSP loop (very similar to the last examples in BASIC):

    while ($bar < 20)
    %vbar[$bar] := 64
    inc ($bar) {increment bar variable – same as bar=bar+1}
    end while

    Oh, and one last thing...
    end on {end of initialization routine}
    Done!



    In the example above, we have our table with all the bars having a default value of 64 (the white sliders are halfway up - which is what we wanted), but I adjusted 3 of the bars after the script was written in real time just by dragging the bars. The new values are 0 (for bar 7), 127 (for bar 8), and 31 (for bar 9). Each one of these bars can be a midi CC value, a pitch value, or whatever we want!

    More to come...

    ...2112
    "So what if some parts of life are a crap shoot? Get out there and shoot the crap." -- Neil Peart
    Hint:1.6180339887498948482 Φ

  2. #2

    Thumbs up Re: Welcome!!!

    Let me be the first to congradulate you guys.

    ...But i didn't understant i thing tho.

    edit: I was mostly kidding... thanks for posting this Brian.

  3. #3

  4. #4
    Senior Member
    Join Date
    Jan 2002
    Location
    UK- teeming with life....
    Posts
    2,567

    Re: Welcome!!!

    Quote Originally Posted by Brian2112
    Welcome to the Midi Programming Section!



    This section of the forum is dedicated to the discussion of midi files, Imidi programming, and scripting. Attachments are enabled in this section to so that Imidi, midi, and all scripting can be discussed and .....................ar 7), 127 (for bar 8), and 31 (for bar 9). Each one of these bars can be a midi CC value, a pitch value, or whatever we want!

    More to come...

    ...2112
    Thanks for the generous introduction Brian; I feel that I can programme anything now! In all seriousness, though, the initiation was very clearly presented. Thanks for taking the time to initiate the, nearly, uninitiated!

    Good job

    Frank

Go Back to forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •