| KeyKit :: Frequently Asked Questions |
Please send suggestions for additions to me@timthompson.com.
KeyKit is both a programming language and a complete graphical environment containing a large variety of tools for both normal "sequencing" tasks as well as "algorithmic composition" tasks. The KeyKit download site can be found here.
The graphical environment is complete enough to be easily used without doing any programming at all, and can be used to do a large variety of manipulations in a MIDI environment. The system, however, is designed very much from a programmer's perspective. It is designed to make it easy to add new tools and features, often with only a few lines of KeyKit code. For example, adding a new editing operation to the Group tool (the multi-track sequencer) can be done with 4 lines of code. See below for how to do this.
Just register again with your same email address, and the new password you will be sent will override the old one.
You should read the HTML documentation that comes with the system.
The Mouse Matrix tool is the simplest tool that you can have immediate (though perhaps brief) fun with. The Kboom tool is a drum pattern editor that is both a lot of fun and *very* deep in capability.
Snarf is a single global variable that many tools can set and/or get, much like the clipboard on Windows. If you see a "Snarf" menu item in a tool, selecting that menu item will save the current contents of the tool in the Snarf variable. You can then go to another tool, and use "Load->Snarf" (or whatever menu item the tool provides for reading the Snarf). For example, the Group tool has a "File->Read->Snarf" menu item.
Besides being able to Snarf midi phrases and use them between tools, you can also Snarf an entire tool and its contents (with Window->Snarf Tool) and then create any number of copies of that tool (with Window->Paste Tool). Besides the obvious use, this can be useful to copy a tool to a new page.
The Group tool has a "File->Write->Standard MIDI File" menu item. So, typically, you copy things to a Group tool in order to write them out as a MIDI file. However, you can also write a MIDI file from the console, or in a script, using the writemf function like this: writemf(Snarf,"file.mid");
After starting KeyKit, you can type statements in the "console", but this is typically only used for:
The usual way of writing KeyKit code is to use the text editor of your choice on a file in the liblocal directory (say, "foo.k"), and when you want to execute that code (or load the function it defines) you type
#include foo.k
in the KeyKit console. Typically such a file will just
define a function, and you can then execute it
interactively from the console. For example,
if the foo.k file defines functions foo1() and
foo2(), you could then type statements like this at
the console:
foo1()
Snarf = foo1()
Snarf = foo2() + foo1()
The first statement will actually schedule and play the return value of foo1(), assuming that the return value of foo1() is a phrase. The second and third statements will assign values to the global Snarf variable, which is used as a conventional mechanism for transferring values between the GUI tools. For example, you could use "File->Read->Snarf" in the Group tool (the multi-track editor) to view and play the results of your foo1() function.
There is no GUI tool for this, but sample code for this can be found in lib/realutil.k - the getsysexdump() function is well-commented. The txpatches() and txperfs() functions use getsysexdump() for getting patch and performance dumps from a Yamaha TX81Z.
Let's say you want to add an editing operation that will shift the currently-picked notes up one octave in pitch. You would add 1 line to the lib/mkmenus.k file, in the mkmenu_edit() function, like this:
o.menucmd("Octave Up ->",po,"edit","cmd_octaveup")
and then add a cmd_octaveup() function to the lib/cmds.k
file like this:
function cmd_octaveup(p) {
p.pitch += 12
}
That's it!
And you can do this while KeyKit is running!. Just
make the additions described above, then type these statements in the
console:
#include cmds.k
#include mkmenus.k
The Group tools on your screen will immediately have access to the
new editing operation.
Obviously if you want sub-menus and other things, it isn't
quite that simple, but you can use the existing commands as samples of
what to do for more complex new commands.
KeyKit works on Linux, but only with external MIDI devices (using the /dev/midi device driver). Internal sound devices are not supported. If Linux developers write better support for MIDI, this might change.
"lowkey" is a version of the KeyKit interpreter that does not have graphics support, suitable for use from CGI and other scripts. Here's an example of using lowkey in a CGI script. Write the KeyKit code you want to execute, and put it into a file, defined as a function. For example, put this in "foo.k":
function foogen(n) {
# Repeat C chord n times, as an example
p = repeat('c e g',n)
# Write the result as a standard midi file, in foo.mid
writemf(p,"foo.mid")
}
Then execute lowkey like this:
lowkey foo.k -c "foogen(4)"
This lets you write the function once and call it in different ways
from your CGI script. When you invoke lowkey, you either need
to be in the bin directory, or you need to set the KEYROOT
environment variable to the directory in which you've
installed keykit.
Questions can be mailed to the KeyKit mailing list - keykit@nosuch.com - and answers will usually be provided.