K2000 System Exclusive Documentation

Introduction
This document discusses some of the issues and details involved in K2000 System Exclusive editor/librarian development. This information is provided to assist those wishing to develop software that communicates with the K2000 via MIDI.
While the K2000 manual documents the "sysex" protocol, it does not contain the data structure internals. This documentation contains "C" include files which explain the structure of the various K2000 objects.

Generic Object Structure
Objects all start with an "Object Header" which contains the object type, ID, size, offset to start of object data, and name. Following this is the data for the object. The C include files do not account for the header, they specify only the data portion of each object. The header format is explained below and is common to all objects. The data portion of the object is defined by the include files.

 ----------------
|  Object Header |   <-- same for all object types
 ----------------
|  Object Data   |   <-- specific to object type
|                |
|                |
|                |
|                |
 ----------------

Object Header Format
Each object contains a standard object header, with fields arranged in the following order.
type/ID - two bytes, encoded specially, see below
size      - two bytes, unsigned quantity 0-65535, size includes header
offset to start of data - two bytes, unsigned
name - null terminated  C string padded to an even number of bytes, maximum 18 bytes (max 16 characters + null termination + pad byte). Minimum 2 bytes (1 char + null).

|XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX|
[    type/ID     ][      size      ][ offset to data ][      name

|XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX|
          more name

|XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX|
          more name                                  ][  Null ][Word Pad]

The offset to object data is used to get quickly past the name which can be variable length. It is equal to the length of the name (including pad byte if any) + 2. When an object is renamed, you need to update the object's size in the header as well as the offset to data.

Type/ID encoding - Big vs. small ID's
Objects have a type and ID, combined in a single two byte word. Sometimes
this is simply one byte of type, and one byte of ID. Many objects (most noteably programs, keymaps, samples, and setups) use a variation with a  6 bit type and 10 bits of ID.

This document does not contain enough information to read or create .KRZ files, but it will allow you to edit from your computer. Currently we are not providing the disk format.


Description of the include files
Note: include files provided are named DOS style (8 char max, all caps).

- misc include files -
types.h		- aliases for variable types
objtypes.h	- types of objects in our system, and their numbers
tableids.h	- enumeration of different kinds of table objects
ObjectStructs.h - (OBJECTS&.H) includes the files below 
Alias.h		- more aliases, may not be needed
segtag.h	- segment tags, identifies parts of objects
Compiler.h - (COMPILE&.HV) compiler specific

- master parameters data structure -
mastb.h		- master parameters overall structure
mdb.h		- master parameters misc data structure
cdb.h		- master parameters per channel data structure
zdb.h		- master parameters zone data (transmit control) structure

- program data structure -
progb.h		- program object overall structure
pgmb.h		- program object, program (common) parameters
asrb.h		- program object, asr parameter structure
fcnb.h		- p.o., fun structure
lfob.h		- lfo structure
efxb.h		- effects control structure
layerb.h	- layer overall structure
lyrb.h		- misc layer parameter structure
encb.h		- envelope control structure
envb.h		- envelope structure
csegb.h		- pitch control parameter structure
hsegb.h         - dsp control parameter structure (amp, filter, etc.)

- other objects -
psetup.h	- performance setup object overall structure, see zdb.h for "per zone" params
keymap.h	- keymap object stucture
sblock.h	- sample object structure
itbl.h		- intonation table object structure 
vmap.h		- velocity map
pmap.h		- pressure map
blist.h		- quick access bank




