AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Native instruments kontakt scripting9/7/2023 ![]() ![]() And to do this, we need to define another callback, called on init.Īs you might already have guessed, the on init callback is triggered when KSP initialises a script, just as the on note callback is triggered when a note is played. Instead, variables should be declared once when KSP first initialises the script. The reason for this is that if variables could be declared in the on note callback, they would end up being declared every time a note was played, which could create a number of issues. However, to make matters a little more complicated, KSP doesn't allow you to declare variables in the on note callback. So to declare our $interval variable, we need to write the following instruction in our script. It's bit like bringing a really expensive bottle of Scotch through customs: you need to declare it before you can start drinking it. ![]() And if you look at the Script Editor's Status Line, KSP reports "ERROR (line 2): variable $interval was not declared”. The reason for the error is that when we use a variable of our own - as opposed to a built‑in variable like $EVENT_NOTE - we have to first tell KSP of its existence before we can actually start using it. But in this case, the highlighted line is indeed to blame. It's worth noting that there are cases where the highlighted line isn't always the one that contains the error (see the 'Debugging' box for more on script troubleshooting), so it's often worth checking the line before or after as well when tracking down a problem. The line containing our play_note command will be highlighted in red, and this means that KSP found an error in our script. If you click Apply right now, you'll notion the Change Indicator doesn't turn black. So if $interval stores the value ‑3 and $EVENT_NOTE is 60, the pitch of the note to play would be 60 plus ‑3, which is the same as 60 – 3 = 57. The reason for this - and now for a flashback to school maths lessons - is that adding a negative value results in that value being subtracted from the sum. In the above instruction, we now get the pitch of the harmony note by adding $interval to the built‑in $EVENT_NOTE variable. Play_note($EVENT_NOTE + $interval, $EVENT_VELOCITY, 0, ‑1) To do this, we'll substitute the ‑3 constant for a variable that's called $interval. ![]() In order to make our harmoniser adjustable without needing to edit the script, we need to define the interval of the harmony note as a variable - a value that can change - instead of defining it as a constant. So if we wanted this particular script to produce a different harmony note instead, we would need to edit this constant value. We refer to a value such as ‑3 as a constant because its value will never change: ‑3 will always be ‑3. Play_note($EVENT_NOTE - 3, $EVENT_VELOCITY, 0, ‑1)īecause the interval of the harmony note is written into the script with the constant ‑3, the script is, in essence, a fixed harmoniser. It should have looked something like this: Last month, we looked at creating the simplest harmoniser, and finished with a script that would play a harmony note a minor third below the original note. Alternatively, if you are looking for a specific command you can use the search bar.Building on last month's introduction to the basics of scripting in Native Instruments' Kontakt soft sampler, we explain how to make your scripted functions adjustable via a simple user interface. You can navigate this manual through the menu on the left, which groups elements of the KSP language in functions. To learn more about KONTAKT, refer to the KONTAKT User Manual. Where applicable, it also includes examples and short code snippets that demonstrate how a given function can be used. This resource is a reference manual that covers every function, command, variable, callback and other element of the KONTAKT scripting language. From simple sequencers to large orchestral clusters with thousands of samples, KSP makes it all work. Its underlying scripting language defines how samples are being played, how MIDI information is used for interacting with the instrument, how the instrument looks and much more. KSP is the technology that powers thousands of instruments in our industry leading sampling platform - KONTAKT. ![]() Welcome to the KONTAKT Script Processor (KSP) reference manual.
0 Comments
Read More
Leave a Reply. |