Making Sense of Kawai K5000 Patch Data Files
Dragging a 20-year-old C-language command-line utility to list Kawai K5000 patches kicking and screaming into the 21st century, or actually rewriting it in Python.
Back in 1998 or so the Kawai K5000 was the mightiest synth of all, only to be discontinued soon after (apparently due to poor sales), with Kawai shutting down their whole synth lineup to focus on pianos...
There was a message board for K5000 enthusiasts called Eat at Joe's (archived on Jens Groh's website), and later a Yahoo group (which was shut down in 2019 along with others like it). People helped each other make sense of this wonderful digital synth, which was not helped by the rather matter-of-fact user manual of the K5000. The seminal book Introduction to Additive Synthesis, Advanced Sound Design, Tips and Tricks by Dave Bellingham and Peter Gorges (the latter responsible for the factory presets) was and is known in the K5000 community as "The Wizoo Book" (after its publisher). It did smooth the road a bit, but ultimately additive synthesis remained a mostly hidden motherlode to be mined in the 2000s by Camel Audio with Chameleon 5000 and later Alchemy (now part of Apple's Logic Pro).
The message board was frequented by folks who also knew about computer programming, and there appeared some utilities written by folks like Jens Groh, Yasuhiro Iwamoto, and later also Jeremy Bernstein, in many cases building on the work of each other. Some of the utilities they developed were:
Utility | Original author | Purpose |
---|---|---|
kaanalyz | Jens Groh | "KAA analyzer": Provides information about a KAA bank file. |
kaatoka1 | Jens Groh | KAA to KA1: Converts the patches in a KAA file to individual KA1 files. |
kaatosyx | Jeremy Bernstein | KAA to SYX: Converts a KAA bank file to MIDI System Exclusive format. |
ka1tokaa | Yasuhiro Iwamoto | Combines several KA1 files into one KAA bank file. |
ka1tosyx | unknown, no source code available | Converts a single KA1 file to MIDI System exclusive format. |
There may be others, but these are the ones I have found floating on the web.
The trouble with these utilities is that they can be a little difficult (or even impossible) to run on modern
computers, being originally written from 1998 to 2006. For example, I tried to run the KAANALYZ.EXE
program in DOSBox, but got "This program cannot be run in DOS mode.", which gave me a hint that
it might actually be a Windows executable. And indeed, running the file
command on it gives the result:
PE32 executable (console) Intel 80386, for MS Windows
The original authors have in most cases included the source code with their programs, even though open source was not nearly as common then as it is now. So, because I had my trusty old Borland C++ 3.1 installed in DOSBox, I first tried to compile the program from the C source code for MS-DOS. That attempt failed miserably, because the program wants to allocate 132 kilobytes of static memory, which is double the size of what is allowed in a 16-bit MS-DOS (or Windows) program. I got the error message "Structure size too large", and that was all she wrote.
Next I tried compiling kaanalyz.c
with the GNU C Compiler. After some trial and error I managed to weed out
all the Windows-specific API calls, making it kind of POSIX compatible,
and got it to compile on macOS (yes, there were warnings, and yes, I ignored them). So at least now
I have a 64-bit executable version of kaanalyz
I can run on my Mac, for reference purposes.
Interlude: The Kawai K5000 data file types
There are several kinds of "native" data files for the Kawai K5000. The list can be found in the user manual (page 119), but here is a quick recap:
File extension | Purpose of file |
---|---|
.KAA | A full bank of single patches. |
.KA1 | A file with one single patch. |
.KCA | A full bank of multi/combi patches. |
.KC1 | A file with one multi/combi patch. |
.KRA | Arpeggiator settings |
Note that the "1" in the file extensions is the number one, not the letter i.
You don't see combi files or arpeggiator settings in the wild that much, and single patches (either individuals or banks of them) are much more common. For example, you can download several .KAA and .KA1 files from the Kawai USA downloads section.
Rewriting kaanalyz
in Python 3
Staring hard at the C code by Jens Groh (it's very rich with pointers, as is endemic to 1990s C code), I slowly got the picture of how a Kawai K5000 KAA file is constructed. There is a pointer table that determines the locations of the patches inside the file, but otherwise they are the same format as the K5000 System Executable files. So, it's probably a good idea to convert all the KAA files into the System Exclusive format, and then deal with them using SysEx Librarian on the Mac or MIDI-OX in Windows.
Working with SysEx files can be a good idea also if you don't like to, or can't work, with floppy disks. You can't send KAA or KA1 files to the K5000 over MIDI, so you may want to work exclusively (pun intended) with SysEx. I use a USB floppy disk on my Mac, and I don't particularly enjoy it, but I'm not going to replace the floppy disk on my K5000S with a USB stick reader, either.
Just to provide the current K5000 a modern way to deal with KAA files (and later maybe also KA1 files)
I decided to rewrite kaanalyz
in Python 3, for maximal reuse value. If you can program, and if
you know Python, it gives you an opportunity to extend the program with any features you want or need.
In itself, kaanalyz
is not really the most important utility in the bunch listed earlier, but
it's a start, and parts of it can be reused in other rewrites, just as the original authors did.
The Python version of kaanalyz
still doesn't have all the features of the original: for example,
it can't sort the patches in the bank by size or other attributes, only the patch number. Also, it can't split
the KAA file into individual KA1 files, which feels kind of redundant anyway, because that is handled by the
kaatoka1
utility, which is also a good candidate for a modern rewrite.
Still, if you invoke kaanalyz.py
from the command line, you get a listing of patches that is exactly
like to original would produce with the -lp
switch. For example, here is the KAA bank file included with the
book by Bellingham and Gorges mentioned earlier:
% python3 kaanalyz.py ~/tmp/WIZOO.KAA "/Users/me/tmp/WIZOO.KAA" contains 66 patches using 87424 bytes (66.70% of memory). 43648 bytes (33.30% of memory) free. Base address = 0x00344E74. Patches: number name sources size pointer padding 1 WizooIni AP---- 1060 0x001CFC 0 2 Angelvox PAA--- 1952 0x002120 0 3 StageMKI AAA--- 2758 0x0028C0 0 4 Engage AA---- 1866 0x003386 0 5 @Clustaz AAP--- 1952 0x003AD0 0 6 Magnetic PP---- 254 0x004270 0 7 Bronx AAP--- 1952 0x00436E 0 8 Hormonic AAPP-- 2038 0x004B0E 0 9 Protonic PAA--- 1952 0x005304 0 10 Melmaker AAA--- 2758 0x005AA4 0 11 SmthWssn APPP-- 1232 0x00656A 0 12 SAWTOOTH AP---- 1060 0x006A3A 0 13 SQUARE AP---- 1060 0x006E5E 0 14 BRIGHT AP---- 1060 0x007282 0 15 DARK AP---- 1060 0x0076A6 0 16 ODD AP---- 1060 0x007ACA 0 17 EVEN AP---- 1060 0x007EEE 0 18 5THS AP---- 1060 0x008312 0 19 OCTAVES AP---- 1060 0x008736 0 20 VELCURVE AP---- 1060 0x008B5A 0 21 DHE WAVE AP---- 1060 0x008F7E 0 22 DHE LOOP AP---- 1060 0x0093A2 0 23 LFO FADE AP---- 1060 0x0097C6 0 24 DCF LOPA PP---- 254 0x009BEA 0 25 DCF HIPA PP---- 254 0x015482 0 26 DCF RESO PP---- 254 0x015384 0 27 FF AP---- 1060 0x014F60 0 28 FILTER AP---- 1060 0x009CE8 0 29 PITCHENV PP---- 254 0x00A10C 0 30 CONTROL AP---- 1060 0x00A20A 0 31 GosplOrg AAA--- 2758 0x00A62E 0 32 Sphaera AAPP-- 2038 0x00B0F4 0 33 DynoSaur AAA--- 2758 0x00B8EA 0 34 TB5005 AA---- 1866 0x00C3B0 0 35 Gorgizmo AAPP-- 2038 0x00CAFA 0 36 Creaturz AAAP-- 2844 0x00D2F0 0 37 @IsCream AA---- 1866 0x00DE0C 0 38 Myst2006 APP--- 1146 0x00E556 0 39 Cyber@FX APPAP- 2124 0x00E9D0 0 40 @Vocodor AP---- 1060 0x00F21C 0 41 StTRAMP AA---- 1866 0x00F640 0 42 ORGAN FO AAA--- 2758 0x00FD8A 0 43 FF FLANG AP---- 1060 0x010850 0 44 FF RESO AP---- 1060 0x010C74 0 45 BELL LIK AP---- 1060 0x011098 0 46 MANHATTA AP---- 1060 0x0114BC 0 47 SPLIT/ZO PP---- 254 0x0118E0 0 48 BEST EQ AP---- 1060 0x0119DE 0 49 ALIAS AP---- 1060 0x011E02 0 50 DISTORT AP---- 1060 0x012226 0 51 Copyrigh AAPP-- 2038 0x01264A 0 52 WIZOO AP---- 1060 0x012E40 0 53 1998 AP---- 1060 0x013264 0 54 WizooIni AP---- 1060 0x013688 0 55 WizooIni AP---- 1060 0x000C6C 0 56 WizooIni AP---- 1060 0x001090 0 57 WizooIni AP---- 1060 0x0014B4 0 58 WizooIni AP---- 1060 0x000424 0 59 WizooIni AP---- 1060 0x000848 0 60 WizooIni AP---- 1060 0x000000 0 61 WizooIni AP---- 1060 0x0018D8 0 65 WizooIni AP---- 1060 0x013AAC 0 66 WizooIni AP---- 1060 0x013ED0 0 67 WizooIni AP---- 1060 0x0142F4 0 68 WizooIni AP---- 1060 0x014718 0 69 WizooIni AP---- 1060 0x014B3C 0
It should be fairly easy to interpret this information, but just in case you are not familiar with the
original kaanalyz
, see the
write-up Using the "kaanalyz" program
by Michael Hester from 2003. (Note that the Python 3 version of kaanalyz
does not implement
the sorting options or the KA1 file extraction.)
You can find the Python 3 version of kaanalyz
on GitHub.
If interest warrants, I may start work
on similar rewrites of the other utilities. Hope you find it useful. Please send any feedback by e-mail, or
file issues on GitHub if you are a developer.
Thanks to all the Eat at Joe's enthusiasts for their hard work in figuring out how to deal with these file formats, and for thoughtfully including the source code. I'm much more versed with the actual data model for patches, having developed a utility library for that (see GitHub for that, too).