Akai S5000 / S6000 Sampler AKP file specification & misc SCSI problems
======================================================================

Reverse engineered by Seb Francis (akp@burnit.co.uk)

The Akai S5000 and S6000 samplers use PC format floppy disks and
hard drives to store their data.  Great I thought: now both my
PC and my sampler can share the same hard drives and interchange
information easily without disk swapping!  Unfortunately, it just
doesn't work as Akai promised.  And in fact in their later
documentation they are now recommending that you don't connect
your PC/Mac to the sampler via SCSI at all.

Basically SCSI is just not designed to have two SCSI controllers
on the same bus.  There is a very high risk of a SCSI bus crash
(both your PC and sampler will crash) if do this.  Additionally
with one particular PC SCSI controller I tried, the SCSI cable
became really hot after only a few minutes of being connected
.. not good!

Even if SCSI did work as Akai originally promised, Windows does
not update its disk cache when the sampler writes to the disk,
so you can't see any changes to the filesystem until you reboot
the PC.  And the fact that Windows thinks the contents of the disk
is different to what it actually is, is highly likely to cause
disk corruption.

Luckily, Akai have now brought out a USB card for the S5000/6000
samplers which allows you to transfer and edit your sampler data
on PC or Mac using a piece of software called "ak.Sys"
(http://www.akaipro.com/int/products/archive/s56k/s56aks.html).
It was about time they did something about the lack of PC editing
software!  It's a shame their SCSI hardware design was done so
badly that you have to buy a USB card to get connection to your PC.
The older S series samples connect ok to the PC via SCSI, but I
assume the difference here is that the internal sampler HD bus
seems separated from the external SCSI bus which connects to the
PC.

Anyway, this filespec was worked out before the USB cards and
ak.Sys software was around, in an attempt to facilitate some
kind of PC-based editing of Akai program files.

Luckily there are now several programs which can convert to and
from AKP format files:

(i) AKAIDISK - a program to make AKP files automatically for a
load of drum sounds, etc. (I don't think this prog is on the web,
but if you want a copy you could mail the author
paul.kellett@maxim.abel.co.uk).

(ii) The newer versions of Awave Studio can read and write
AKP files (http://www.fmjsoft.com/).  This is a handy piece of
software which allows conversion between many different formats.

(iii) CDXtract (http://www.cdxtract.com/) can convert to and from
many different sampler formats, including AKP.

(iv) I also saw some other AKP related progs here:
http://members.aol.com/cutrateone/akaibugs/page_util.html



Notes on the file specification
-------------------------------

This file spec was worked out using an S6000 running OS v1.11.
An S5000 or an older OS may not support everything in this
format, but the structure should be identical.  The newer OSs
probably use some of the spare bytes .. but they are backwards
compatible with this spec.

The AKP file is basically in the standard RIFF file format,
however there are a couple of non-standard things:

The 4 bytes after the 'RIFF' header should indicate the number of
bytes remaining in the file.  Instead they are always set to 0.
It probably doesn't matter if they are not - I expect the sampler
just ignores them.

A RIFF file is made up of chunks: each one starting with a 4 byte
ASCII header and a 4 byte (double word) number representing the
length of the chunk.  Only two types of chunk are allowed to have
subchunks, the 'RIFF' chunk (the whole file) and any 'LIST' chunks.
In an AKP file, the 'kgrp' chunk contains 9 subchunks.  The kgrp
header is also slightly non-standard.

In a RIFF file, the name of each chunk should be unique.  In an
AKP file, this is not the case (e.g. the 2 'lfo ' chunks and the
3 'env ' chunks).  This doesn't matter as the chunks are always
written in the same order (which makes it nice and easy to write
software which reads AKP files).

Anyway, the upshot of these incompatibilities is: you will probably
not be able to use any of the standard libraries for reading RIFF
files.  You will have to write your own.


Where there is no description for a byte, it is recommended that
you use the hex value listed.  Certainly, the first and the last
bytes of a chunk's data are almost always 1 and 0 respectively.
The sampler may just ignore these, but who knows!

The default value for a byte is given in (parenthesis) and the
range of values is given afterwards.  These values are in decimal.
All values to the left are in hex.

Enjoy!


0000 - 0003:	'RIFF'
0004 - 0007:	00 00 00 00 (0)
0008 - 000B:	'APRG'


000C - 000F:	'prg '
0010 - 0013:	06 00 00 00 (6)

0014:	01	.
0015:	00	MIDI program number (0) 0 = OFF
0016:	01	number of keygroups (1) 1 -> 99
0017:	00	.
0018:	02	.
0019:	00	.


001A - 001D:	'out '
001E - 0021:	08 00 00 00 (8)

0022:	01	.
0023:	55	Loudness (85) 0 -> 100
0024:	00	Amp Mod 1 (0) 0 -> 100
0025:	00	Amp Mod 2 (0) 0 -> 100
0026:	00	Pan Mod 1 (0) 0 -> 100
0027:	00	Pan Mod 2 (0) 0 -> 100
0028:	00	Pan Mod 3 (0) 0 -> 100
0029:	19	Velocity Sens (+025) -100 -> 100


002A - 002D:	'tune'
002E - 0031:	16 00 00 00 (22)

0032:	01	.
0033:	00	Semitone Tune (0) -36 -> 36
0034:	00	Fine Tune (0) -50 -> 50
0035:	00	C detune (0) -50 -> 50
0036:	00	C# detune (0) -50 -> 50
0037:	00	D detune (0) -50 -> 50
0038:	00	Eb detune (0) -50 -> 50
0039:	00	E detune (0) -50 -> 50
003A:	00	F detune (0) -50 -> 50
003B:	00	F# detune (0) -50 -> 50
003C:	00	G detune (0) -50 -> 50
003D:	00	G# detune (0) -50 -> 50
003E:	00	A detune (0) -50 -> 50
003F:	00	Bb detune (0) -50 -> 50
0040:	00	B detune (0) -50 -> 50
0041:	02	Pitchbend Up (2) 0 -> 24
0042:	02	Pitchbend Down (2) 0 -> 24
0043:	00	Bend Mode (0) 0 = NORMAL, 1 = HELD
0044:	00	Aftertouch (0) -12 -> 12
0045:	00	.
0046:	00	.
0047:	00	.


0048 - 004B:	'lfo ' (LFO 1)
004C - 004F:	0C 00 00 00 (12)

0050h:	01	.
0051h:	01	Waveform (1) 0 = SINE, 1 = TRIANGLE, 2 = SQUARE, 3 = SQUARE+,
		4 = SQUARE-, 5 = SAW BI, 6 = SAW UP, 7 = SAW DOWN, 8 = RANDOM
0052h:	2B	Rate (43) 0 -> 100
0053h:	00	Delay (0) 0 -> 100
0054h:	00	Depth (0) 0 -> 100
0055h:	00	LFO Sync (0) 0 = OFF, 1 = ON
0056h:	01	.
0057h:	0F	Modwheel (15) 0 -> 100
0058h:	00	Aftertouch (0) 0 -> 100
0059h:	00	Rate Mod (0) -100 -> 100
005Ah:	00	Delay Mod (0) -100 -> 100
005Bh:	00	Depth Mod (0) -100 -> 100


005C - 005F:	'lfo ' (LFO 2)
0060 - 0063:	0C 00 00 00 (12)

0064h:	01	.
0065h:	00	Waveform (0) 0 = SINE, 1 = TRIANGLE, 2 = SQUARE, 3 = SQUARE+,
		4 = SQUARE-, 5 = SAW BI, 6 = SAW UP, 7 = SAW DOWN, 8 = RANDOM
0066h:	00	Rate (0) 0 -> 100
0067h:	00	Delay (0) 0 -> 100
0068h:	00	Depth (0) 0 -> 100
0069h:	01	.
006Ah:	00	LFO Re-trigger (0) 0 = OFF, 1 = ON
006Bh:	00	.
006Ch:	00	.
006Dh:	00	Rate Mod (0) -100 -> 100
006Eh:	00	Delay Mod (0) -100 -> 100
006Fh:	00	Depth Mod (0) -100 -> 100


0070 - 0073:	'mods'
0074 - 0077:	26 00 00 00 (38)

0078h:	01	.
0079h:	00	.
007Ah:	11	.
007Bh:	00	.
007Ch:	02	.
007Dh:	06	Amp Mod 1 Src (6) 0 = NO SOURCE, 1 = MODWHEEL, 2 = BEND,
		3 = AFT'TOUCH, 4 = EXTERNAL, 5 = VELOCITY, 6 = KEYBOARD,
		7 = LFO1, 8 = LFO2, 9 = AMP ENV, 10 = FILT ENV, 11 = AUX ENV,
		12 = dMODWHEEL, 13 = dBEND, 14 = dEXTERNAL
007Eh:	02	.
007Fh:	03	Amp Mod 2 Src (3) 0 = NO SOURCE, 1 = MODWHEEL, 2 = BEND,
		3 = AFT'TOUCH, 4 = EXTERNAL, 5 = VELOCITY, 6 = KEYBOARD,
		7 = LFO1, 8 = LFO2, 9 = AMP ENV, 10 = FILT ENV, 11 = AUX ENV,
		12 = dMODWHEEL, 13 = dBEND, 14 = dEXTERNAL
0080h:	01	.
0081h:	08	Pan Mod 1 Src (8) 0 = NO SOURCE, 1 = MODWHEEL, 2 = BEND,
		3 = AFT'TOUCH, 4 = EXTERNAL, 5 = VELOCITY, 6 = KEYBOARD,
		7 = LFO1, 8 = LFO2, 9 = AMP ENV, 10 = FILT ENV, 11 = AUX ENV,
		12 = dMODWHEEL, 13 = dBEND, 14 = dEXTERNAL
0082h:	01	.
0083h:	06	Pan Mod 2 Src (6) 0 = NO SOURCE, 1 = MODWHEEL, 2 = BEND,
		3 = AFT'TOUCH, 4 = EXTERNAL, 5 = VELOCITY, 6 = KEYBOARD,
		7 = LFO1, 8 = LFO2, 9 = AMP ENV, 10 = FILT ENV, 11 = AUX ENV,
		12 = dMODWHEEL, 13 = dBEND, 14 = dEXTERNAL
0084h:	01	.
0085h:	01	Pan Mod 3 Src (1) 0 = NO SOURCE, 1 = MODWHEEL, 2 = BEND,
		3 = AFT'TOUCH, 4 = EXTERNAL, 5 = VELOCITY, 6 = KEYBOARD,
		7 = LFO1, 8 = LFO2, 9 = AMP ENV, 10 = FILT ENV, 11 = AUX ENV,
		12 = dMODWHEEL, 13 = dBEND, 14 = dEXTERNAL
0086h:	04	.
0087h:	06	LFO 1 Rate Mod Src (6) 0 = NO SOURCE, 1 = MODWHEEL, 2 = BEND,
		3 = AFT'TOUCH, 4 = EXTERNAL, 5 = VELOCITY, 6 = KEYBOARD,
		7 = LFO1, 8 = LFO2, 9 = AMP ENV, 10 = FILT ENV, 11 = AUX ENV,
		12 = dMODWHEEL, 13 = dBEND, 14 = dEXTERNAL
0088h:	05	.
0089h:	06	LFO 1 Delay Mod Src (6) 0 = NO SOURCE, 1 = MODWHEEL, 2 = BEND,
		3 = AFT'TOUCH, 4 = EXTERNAL, 5 = VELOCITY, 6 = KEYBOARD,
		7 = LFO1, 8 = LFO2, 9 = AMP ENV, 10 = FILT ENV, 11 = AUX ENV,
		12 = dMODWHEEL, 13 = dBEND, 14 = dEXTERNAL
008Ah:	03	.
008Bh:	06	LFO 1 Depth Mod Src (6) 0 = NO SOURCE, 1 = MODWHEEL, 2 = BEND,
		3 = AFT'TOUCH, 4 = EXTERNAL, 5 = VELOCITY, 6 = KEYBOARD,
		7 = LFO1, 8 = LFO2, 9 = AMP ENV, 10 = FILT ENV, 11 = AUX ENV,
		12 = dMODWHEEL, 13 = dBEND, 14 = dEXTERNAL
008Ch:	07	.
008Dh:	00	LFO 2 Rate Mod Src (0) 0 = NO SOURCE, 1 = MODWHEEL, 2 = BEND,
		3 = AFT'TOUCH, 4 = EXTERNAL, 5 = VELOCITY, 6 = KEYBOARD,
		7 = LFO1, 8 = LFO2, 9 = AMP ENV, 10 = FILT ENV, 11 = AUX ENV,
		12 = dMODWHEEL, 13 = dBEND, 14 = dEXTERNAL
008Eh:	08	.
008Fh:	00	LFO 2 Delay Mod Src (0) 0 = NO SOURCE, 1 = MODWHEEL, 2 = BEND,
		3 = AFT'TOUCH, 4 = EXTERNAL, 5 = VELOCITY, 6 = KEYBOARD,
		7 = LFO1, 8 = LFO2, 9 = AMP ENV, 10 = FILT ENV, 11 = AUX ENV,
		12 = dMODWHEEL, 13 = dBEND, 14 = dEXTERNAL
0090h:	06	.
0091h:	00	LFO 2 Depth Mod Src (0) 0 = NO SOURCE, 1 = MODWHEEL, 2 = BEND,
		3 = AFT'TOUCH, 4 = EXTERNAL, 5 = VELOCITY, 6 = KEYBOARD,
		7 = LFO1, 8 = LFO2, 9 = AMP ENV, 10 = FILT ENV, 11 = AUX ENV,
		12 = dMODWHEEL, 13 = dBEND, 14 = dEXTERNAL
0092h:	00	.
--- Keygroup Mod Sources: ---
0093h:	07	Pitch Mod 1 Src (7) 0 = NO SOURCE, 1 = MODWHEEL, 2 = BEND,
		3 = AFT'TOUCH, 4 = EXTERNAL, 5 = VELOCITY, 6 = KEYBOARD,
		7 = LFO1, 8 = LFO2, 9 = AMP ENV, 10 = FILT ENV, 11 = AUX ENV,
		12 = dMODWHEEL, 13 = dBEND, 14 = dEXTERNAL
0094h:	00	.
0095h:	0B	Pitch Mod 2 Src (11) 0 = NO SOURCE, 1 = MODWHEEL, 2 = BEND,
		3 = AFT'TOUCH, 4 = EXTERNAL, 5 = VELOCITY, 6 = KEYBOARD,
		7 = LFO1, 8 = LFO2, 9 = AMP ENV, 10 = FILT ENV, 11 = AUX ENV,
		12 = dMODWHEEL, 13 = dBEND, 14 = dEXTERNAL
0096h:	02	.
0097h:	05	Amp Mod Src (5) 0 = NO SOURCE, 1 = MODWHEEL, 2 = BEND,
		3 = AFT'TOUCH, 4 = EXTERNAL, 5 = VELOCITY, 6 = KEYBOARD,
		7 = LFO1, 8 = LFO2, 9 = AMP ENV, 10 = FILT ENV, 11 = AUX ENV,
		12 = dMODWHEEL, 13 = dBEND, 14 = dEXTERNAL
0098h:	09	.
0099h:	05	Filter Mod Input 1 (5) 0 = NO SOURCE, 1 = MODWHEEL, 2 = BEND,
		3 = AFT'TOUCH, 4 = EXTERNAL, 5 = VELOCITY, 6 = KEYBOARD,
		7 = LFO1, 8 = LFO2, 9 = AMP ENV, 10 = FILT ENV, 11 = AUX ENV,
		12 = dMODWHEEL, 13 = dBEND, 14 = dEXTERNAL
009Ah:	09	.
009Bh:	08	Filter Mod Input 2 (8) 0 = NO SOURCE, 1 = MODWHEEL, 2 = BEND,
		3 = AFT'TOUCH, 4 = EXTERNAL, 5 = VELOCITY, 6 = KEYBOARD,
		7 = LFO1, 8 = LFO2, 9 = AMP ENV, 10 = FILT ENV, 11 = AUX ENV,
		12 = dMODWHEEL, 13 = dBEND, 14 = dEXTERNAL
009Ch:	09	.
009Dh:	09	Filter Mod Input 3 (9) 0 = NO SOURCE, 1 = MODWHEEL, 2 = BEND,
		3 = AFT'TOUCH, 4 = EXTERNAL, 5 = VELOCITY, 6 = KEYBOARD,
		7 = LFO1, 8 = LFO2, 9 = AMP ENV, 10 = FILT ENV, 11 = AUX ENV,
		12 = dMODWHEEL, 13 = dBEND, 14 = dEXTERNAL


------- First keygroup starts ------

009E - 00A1:	'kgrp'
00A2 - 00A5:	50 01 00 00 (336)

	00A6 - 00A9:	'kloc'
	00AA - 00AD:	10 00 00 00 (16)
	
	00AE:	01	.
	00AF:	03	.
	00B0:	01	.
	00B1:	04	.
	00B2:	15	low note (21) 21 -> 127
	00B3:	7F	high note (127) 21 -> 127
	00B4:	00	Semitone Tune (0) -36 -> 36
	00B5:	00	Fine Tune (0) -50 -> 50
	00B6:	00	Overide FX (0) 0 = OFF, 1 = FX1, 2 = FX2, 3 = RV3, 4 = RV4
	00B7:	00	FX Send Level (0) 0 -> 100
	00B8:	64	Pitch Mod 1 (100) -100 -> 100
	00B9:	00	Pitch Mod 2 (0) -100 -> 100
	00BA:	00	Amp Mod (0) -100 -> 100
	00BB:	00	Zone Xfade (0) 0 = OFF, 1 = ON
	00BC:	00	Mute Group
	00BD:	00	.
	
	
	00BE - 00C1:	'env ' (Amp Env)
	00C2 - 00C5:	12 00 00 00 (18)
	
	00C6:	01	.
	00C7:	00	Attack (0) 0 -> 100
	00C8:	00	.
	00C9:	32	Decay (50) 0 -> 100
	00CA:	0F	Release (15) 0 -> 100
	00CB:	00	.
	00CC:	00	.
	00CD:	64	Sustain (100) 0 -> 100
	00CE:	00	.
	00CF:	00	.
	00D0:	00	Velo->Attack (0) -100 -> 100
	00D1:	00	.
	00D2:	00	Keyscale (0) -100 -> 100
	00D3:	00	.
	00D4:	00	On Vel->Rel (0) -100 -> 100
	00D5:	00	Off Vel->Rel (0) -100 -> 100
	00D6:	00	.
	00D7:	00	.
	
	
	00D8 - 00DB:	'env ' (Filter Env)
	00DC - 00DF:	12 00 00 00 (18)
	
	00E0:	01	.
	00E1:	00	Attack (0) 0 -> 100
	00E2:	00	.
	00E3:	32	Decay (50) 0 -> 100
	00E4:	0F	Release (15) 0 -> 100
	00E5:	00	.
	00E6:	00	.
	00E7:	64	Sustain (100) 0 -> 100
	00E8:	00	.
	00E9:	00	Filt Env Depth (0) -100 -> 100
	00EA:	00	Velocity->Attack (0) -100 -> 100
	00EB:	00	.
	00EC:	00	Keyscale (0) -100 -> 100
	00ED:	00	.
	00EE:	00	On Vel->Rel (0) -100 -> 100
	00EF:	00	Off Vel->Rel (0) -100 -> 100
	00F0:	00	.
	00F1:	00	.
	
	
	00F2 - 00F5:	'env ' (Aux Env)
	00F6 - 00F9:	12 00 00 00 (18)
	
	00FA:	01	.
	00FB:	00	Rate 1 (0) 0 -> 100
	00FC:	32	Rate 2 (50) 0 -> 100
	00FD:	32	Rate 3 (50) 0 -> 100
	00FE:	0F	Rate 4 (15) 0 -> 100
	00FF:	64	Level 1 (100) 0 -> 100
	0100:	64	Level 2 (100) 0 -> 100
	0101:	64	Level 3 (100) 0 -> 100
	0102:	00	Level 4 (0) 0 -> 100
	0103:	00	.
	0104:	00	Vel->Rate 1 (0) -100 -> 100
	0105:	00	.
	0106:	00	Keyboard->R2/R4 (0) -100 -> 100
	0107:	00	.
	0108:	00	Vel->Rate 4 (0) -100 -> 100
	0109:	00	Off Vel->Rate 4 (0) -100 -> 100
	010A:	00	Vel->Out Level (0) -100 -> 100
	010B:	85	.
	
	
	010C - 010F:	'filt'
	0110 - 0113:	0A 00 00 00 (10)
	
	0114:	01	.
	0115:	00	Filter Mode (0) 0 = 2-POLE LP, 1 = 4-POLE LP,
			2 = 2-POLE LP+, 3 = 2-POLE BP, 4 = 4-POLE BP,
			5 = 2-POLE BP+, 6 = 1-POLE HP, 7 = 2-POLE HP,
			8 = 1-POLE HP+, 9 = LO<>HI, 10 = LO<>BAND, 11 = BAND<>HI,
			12 = NOTCH 1, 13 = NOTCH 2, 14 = NOTCH 3, 15 = WIDE NOTCH,
			16 = BI-NOTCH, 17 = PEAK 1, 18 = PEAK 2, 19 = PEAK 3,
			20 = WIDE PEAK, 21 = BI-PEAK, 22 = PHASER 1, 23 = PHASER 2,
			24 = BI-PHASE, 25 = VOWELISER
	0116:	64	Cutoff Freq (100) 0 -> 100
	0117:	00	Resonance (0) 0 -> 12
	0118:	00	Keyboard Track (0) -36 -> 36
	0119:	00	Mod Input 1 (0) -100 -> 100
	011A:	00	Mod Input 2 (0) -100 -> 100
	011B:	00	Mod Input 3 (0) -100 -> 100
	011C:	00	Headroom (0) 0 = 0db, 1 = 6db, 2 = 12db, 3 = 18db,
			4 = 24db, 5 = 30db
	011D:	00	.
	
	
	011E - 0121:	'zone' (Zone 1)
	0122 - 0125:	2E 00 00 00 (46)
	
	0126:	01	.
	0127:	nn	number of chars in Sample Name
	0128 - 013B:	Sample Name (pad with 00h)
			(if first character = 00h then no sample assigned)
	013C:	00	.
	013D:	00	.
	013E:	00	.
	013F:	00	.
	0140:	00	.
	0141:	00	.
	0142:	00	.
	0143:	00	.
	0144:	00	.
	0145:	00	.
	0146:	00	.
	0147:	00	.
	0148:	00	Low Velocity (0) 0 -> 127
	0149:	7F	High Velocity (127) 0 -> 127
	014A:	00	Fine Tune (0) -50 -> 50
	014B:	00	Semitone Tune (0) -36 -> 36
	014C:	00	Filter (0) -100 -> 100
	014D:	00	Pan/Balance (0) -50 -> 50 = L50 -> R50
	014E:	04	Playback (4) 0 = NO LOOPING, 1 = ONE SHOT, 2 = LOOP IN REL,
			3 = LOOP UNTIL REL, 4 = AS SAMPLE
	014F:	00	Output (0) 0 = MULTI, 1 = 1/2, 2 = 3/4, 3 = 5/6, 4 = 7/8,
			5 = 9/10, 6 = 11/12, 7 = 13/14, 8 = 15/16,
			9 = 1, 10 = 2, 11 = 3, 12 = 4, 13 = 5, 14 = 6, 15 = 7,
			16 = 8, 17 = 9, 18 = 10, 19 = 11, 20 = 12, 21 = 13,
			22 = 14, 23 = 15, 24 = 16
	0150:	00	Zone Level (0) -100 -> 100
	0151:	01	Keyboard Track (1) 0 = OFF, 1 = ON
	0152:	00	Velocity->Start LSB (0) }
	0153:	00	Velocity->Start MSB (0) } -9999 -> 9999
	
	
	0154 - 0157:	'zone' (Zone 2)
	0158 - 015B:	2E 00 00 00 (46)
	
	015C - 0189:	Zone 2 data
	
	
	018A - 018D:	'zone' (Zone 3)
	018E - 0191:	2E 00 00 00 (46)
	
	0192 - 01BF:	Zone 3 data
	
	
	01C0 - 01C3:	'zone' (Zone 4)
	01C4 - 01C7:	2E 00 00 00 (46)
	
	01C8 - 01F5:	Zone 4 data


------- Next keygroup starts ------