KeyKit - A viewgraph-style description
What is it?
- Programming language - interpreted, multi-tasking, graphics,
object-oriented
- Specialized for MIDI algorithmic and realtime manipulation,
"phrase" data type, realtime scheduling
- Multi-window graphical user interface, pull-off menus
and buttons, tools include multi-track editor, drum pattern editor
- Entire user interface and all tools written in KeyKit
and provided as source code in library, easily customized and extended
Reason for Being
- Hacking - fun, programming, normal music composition,
algorithmic music
- learning - OS's, device drivers, graphics, user interface
design, OO
- personal and programmer-centric, not commercial, although
current version is complete enough for non-programmers
Development History
- 1.0 - BASIC-like
- 2.0 - realtime
- 3.0 - grammer, rewrite, fast enough to avoid built-ins
- 4.0 - graphics
- 5.0 - first multi-window attempts, multi-tasking, fifos,
tools using tasks/fifos
- 6.0 - object-oriented, multi-window interface rewritten,
pull-off menus/buttons
Development machines
- Atari ST, PC (286), UNIX (386, X11), Windows NT, Win95
- Ported at various times to: Atari ST, DOS, UNIX PC, Mac,
Amiga, SVR3, SVR4, SunOS, NeXT, X Windows, SGI, Amdahl, VAX, 5620, Plan
9, Windows 3.1/NT/95
Language Features
- Inspired by awk
- Variables need not be declared
- No semicolons
- #define, #include
- The usual control structures and expressions
Phrase data type
- Time-ordered list of MIDI "notes" - can be
system-exclusives, isolated note-on, isolated note-off, or full note with
duration
- Constant value syntax
ph
= 'c e g' # ph is a c major triad
ph
= 'dc2,e,f' # ph is an arpeggio, channel 2
- Structure-like manipulation of attributes :
ph.dur
= 1b # all note durations = 1 beat
ph.pitch
+= 12 # transposed up an octave
Phrase and Note Attributes
- pitch (0-127)
- vol(0-127)
- chan (1-16)
- dur (in clicks)
- time (in clicks, relative to beginning of phrase)
- type (NOTE, NOTEON, NOTEOFF, MIDIBYTES, PROGRAM, PRESSURE,
etc.)
- length (of phrase, independent of notes in it)
- attrib (string, arbitrary meaning)
- flags (integer, arbitrary meaning, bit 1 == picked)
Phrase Operations
- Serial concatenation
ph = ph1 + ph2
- Parallel merging
ph = ph1 | ph2
- Removing notes
ph = ph1 - ph2
- Matching notes
ph = ph1 & ph2
- Nth note
ph = ph1 % n
Phrase Operations - the "select"
ph = ph1 { ??.pitch > 60 }
ph = ph1 { ??.dur > 1b }
ph = ph1 { isonbeat(??,4b) }
ph = ph1 { ??.number < 4 }
ph = ph1 { rand(3)==0 }
ph = ph1 { isinscale(??,scale) }
ph = ph - ph { ??.type == MIDIBYTES }
Phrase Operations - Looping
- # randomize volume
of each note and
- # construct a new
phrase with the result
- r = ''
- for ( nt in ph )
{
-
nt.vol += rand(10)
-
r = r | nt # or r |= nt
- }
- # randomize volume
of each note, in-place
- for ( n=0; n<sizeof(ph);
n++ )
- ph%n.vol += rand(10)
Function values, In-line Functions
function
major(k) {return(k|transpose(k,4)|transpose(k,7));}
function
minor(k) { return(k|transpose(k,3)|transpose(k,7));}
function
randchord() {
if ( rand(2) == 0 ) return(major) else return(minor)
}
f =
randchordtype()
f('c')
randchordtype()('c')
Instead of return(major), you could use an in-line function:
return
(function ? (k){return(k|transpose(k,4)|transpose(k,7));})
Other Language Features
- Variable arguments -
… , nargs(), argv(), varg()
- Fifos
- Objects
- Graphics - primitive elements are:
lines, rectangles, text, windows,
phrase windows, menus
Tasks and I/O
- All tasks are time-shared evenly, interleaved at the
interpreted instruction level
- Scheduled MIDI output events are tasks as well, but performance
can't be degraded by other tasks
- MIDI input is always being recorded, available in a global
variable for easy and immediate processing
- MIDI, mouse, and console input events can be read from
special fifos
- Reading a fifo (with no data waiting) blocks a task
- lock() and unlock() used for exclusion and synchronization
KeyKit - the GUI
- Completely implemented with KeyKit code, even pull-off
menus, dragging of windows, etc.
- Tools framework allows all tools to be manipulated consistently
for resizing, saving/restoring state, copying
The GUI Tools
Bang, Blocks, Bounce, Chord Palette, Console, Controller,
Echo, Group, Kboom, Loopy, Markov Maker, Mouse Matrix, Parameters, Peer,
Prog Change, Riff, RiffRaff, Sectionalize, Tempo, Volume
Documentation
- Tutorial
- Tools reference manual
- Hacking the user interface
- Language reference manual
Copyright 1996 AT&T Corp. All rights reserved.