SYNTH ZONE
Visit The Bar For Casual Discussion
Topic Options
#219175 - 11/20/03 01:58 AM How a Pa80 STY file looks inside
RicFreak Offline
Member

Registered: 08/07/02
Posts: 135
Loc: Italy
This message is mainly for programmers.

There have been many people asking me how a STY file is made inside.

Well, here it is:

File len is stored in bytes 5 to 8 (add 8 bytes to the computed len)

File tag (KORF) is stored in bytes 25 to 28

Index len in byes 33 to 36. Each index entry is 24 bytes long, so you can easily compute how many entries are in the index. Index entries may (or may not) be duplicated because a Pa80 style is made of two pieces: the style itself (midi data) and its performance (volume, programs, effects ... ), but the performance sometimes is missing; there is a flag in each index entry (byte 19) for distinguish styles (2) from performances (7). Style index (that is its position inside the bank) is at byte 21.

Styles begin immediately after the index. For each style, bytes 5 to 8 store the style length (again, add 8 to this value), then the style data follow.

After the styles there is another index. So read 8 more bytes and compute this index length using bytes 5 to 8 (and adding 8 to the result). Each entry simply point to the start of the data of each index entry.

Ok, this should be enough for understanding style file structure.

Now the bad new: style contents is compressed, so you cannot understand how things are inside. I asked KORG for this compression algorithmn months ago (almost 2 years ago), but they always refused to share this with me.

Please note that all the informations about style file structure come from me only, with the help of a couple of fellow users: KORG never helped in this task.

Top
#219176 - 11/20/03 02:08 AM Re: How a Pa80 STY file looks inside
RicFreak Offline
Member

Registered: 08/07/02
Posts: 135
Loc: Italy
A little example (excerpt from first style bank of korg musical resources):


00000000 01 00 01 14 00 02 68 77 02 00 00 18 00 00 00 0C . . . . . . h w . . . . . . . .
00000010 0B 00 00 00 00 00 00 4B 4F 52 46 00 05 00 00 18 . . . . . . . K O R F . . . . .
00000020 00 00 03 00 53 6F 66 74 20 42 65 61 74 00 00 00 . . . . S o f t B e a t . . .
00000030 00 00 00 00 00 00 02 00 00 00 00 00 50 6F 70 20 . . . . . . . . . . . . P o p
00000040 42 65 61 74 00 00 00 00 00 00 00 00 00 00 02 00 B e a t . . . . . . . . . . . .
00000050 01 00 00 00 53 74 6E 64 72 64 38 42 65 61 74 00 . . . . S t n d r d 8 B e a t .
00000060 00 00 00 00 00 00 02 00 02 00 00 00 55 6E 70 6C . . . . . . . . . . . . U n p l
00000070 75 67 38 42 74 20 31 00 00 00 00 00 00 00 02 00 u g 8 B t 1 . . . . . . . . .
00000080 03 00 00 00 4C 6F 76 65 20 38 20 42 65 61 74 00 . . . . L o v e 8 B e a t .
00000090 00 00 00 00 00 00 02 00 04 00 00 00 48 61 6C 66 . . . . . . . . . . . . H a l f
000000A0 20 42 65 61 74 00 00 00 00 00 00 00 00 00 02 00 B e a t . . . . . . . . . . .
000000B0 05 00 00 00 55 4B 20 38 20 42 65 61 74 00 00 00 . . . . U K 8 B e a t . . .
000000C0 00 00 00 00 00 00 02 00 06 00 00 00 38 42 65 61 . . . . . . . . . . . . 8 B e a
000000D0 74 47 72 6F 6F 76 65 00 00 00 00 00 00 00 02 00 t G r o o v e . . . . . . . . .
000000E0 07 00 00 00 55 4B 20 52 26 42 00 00 00 00 00 00 . . . . U K R & B . . . . . .
000000F0 00 00 00 00 00 00 02 00 08 00 00 00 50 6F 70 42 . . . . . . . . . . . . P o p B
00000100 61 6C 6C 61 64 20 31 00 00 00 00 00 00 00 02 00 a l l a d 1 . . . . . . . . .
00000110 09 00 00 00 48 69 70 48 6F 70 20 42 65 61 74 00 . . . . H i p H o p B e a t .
00000120 00 00 00 00 00 00 02 00 0A 00 00 00 4C 69 67 68 . . . . . . . . . . . . L i g h
00000130 74 52 6F 63 6B 20 31 00 00 00 00 00 00 00 02 00 t R o c k 1 . . . . . . . . .
00000140 0B 00 00 00 4C 69 67 68 74 52 6F 63 6B 20 32 00 . . . . L i g h t R o c k 2 .
00000150 00 00 00 00 00 00 02 00 0C 00 00 00 4D 69 61 6D . . . . . . . . . . . . M i a m
00000160 69 20 42 65 61 74 00 00 00 00 00 00 00 00 02 00 i B e a t . . . . . . . . . .
00000170 0D 00 00 00 43 6C 61 73 73 69 63 42 65 61 74 00 . . . . C l a s s i c B e a t .
00000180 00 00 00 00 00 00 02 00 0E 00 00 00 55 6E 70 6C . . . . . . . . . . . . U n p l
00000190 75 67 38 42 74 20 32 00 00 00 00 00 00 00 02 00 u g 8 B t 2 . . . . . . . . .
000001A0 0F 00 00 00 53 6F 66 74 20 42 65 61 74 00 00 00 . . . . S o f t B e a t . . .
000001B0 00 00 00 00 00 00 07 00 00 00 02 00 50 6F 70 20 . . . . . . . . . . . . P o p
000001C0 42 65 61 74 00 00 00 00 00 00 00 00 00 00 07 00 B e a t . . . . . . . . . . . .
000001D0 01 00 02 00 53 74 6E 64 72 64 38 42 65 61 74 00 . . . . S t n d r d 8 B e a t .
000001E0 00 00 00 00 00 00 07 00 02 00 02 00 55 6E 70 6C . . . . . . . . . . . . U n p l
000001F0 75 67 38 42 74 20 31 00 00 00 00 00 00 00 07 00 u g 8 B t 1 . . . . . . . . .
00000200 03 00 02 00 4C 6F 76 65 20 38 20 42 65 61 74 00 . . . . L o v e 8 B e a t .
00000210 00 00 00 00 00 00 07 00 04 00 02 00 48 61 6C 66 . . . . . . . . . . . . H a l f
00000220 20 42 65 61 74 00 00 00 00 00 00 00 00 00 07 00 B e a t . . . . . . . . . . .
00000230 05 00 02 00 55 4B 20 38 20 42 65 61 74 00 00 00 . . . . U K 8 B e a t . . .
00000240 00 00 00 00 00 00 07 00 06 00 02 00 38 42 65 61 . . . . . . . . . . . . 8 B e a
00000250 74 47 72 6F 6F 76 65 00 00 00 00 00 00 00 07 00 t G r o o v e . . . . . . . . .
00000260 07 00 02 00 55 4B 20 52 26 42 00 00 00 00 00 00 . . . . U K R & B . . . . . .
00000270 00 00 00 00 00 00 07 00 08 00 02 00 50 6F 70 42 . . . . . . . . . . . . P o p B
00000280 61 6C 6C 61 64 20 31 00 00 00 00 00 00 00 07 00 a l l a d 1 . . . . . . . . .
00000290 09 00 02 00 48 69 70 48 6F 70 20 42 65 61 74 00 . . . . H i p H o p B e a t .
000002A0 00 00 00 00 00 00 07 00 0A 00 02 00 4C 69 67 68 . . . . . . . . . . . . L i g h
000002B0 74 52 6F 63 6B 20 31 00 00 00 00 00 00 00 07 00 t R o c k 1 . . . . . . . . .
000002C0 0B 00 02 00 4C 69 67 68 74 52 6F 63 6B 20 32 00 . . . . L i g h t R o c k 2 .
000002D0 00 00 00 00 00 00 07 00 0C 00 02 00 4D 69 61 6D . . . . . . . . . . . . M i a m
000002E0 69 20 42 65 61 74 00 00 00 00 00 00 00 00 07 00 i B e a t . . . . . . . . . .
000002F0 0D 00 02 00 43 6C 61 73 73 69 63 42 65 61 74 00 . . . . C l a s s i c B e a t .
00000300 00 00 00 00 00 00 07 00 0E 00 02 00 55 6E 70 6C . . . . . . . . . . . . U n p l
00000310 75 67 38 42 74 20 32 00 00 00 00 00 00 00 07 00 u g 8 B t 2 . . . . . . . . .
00000320 0F 00 02 00 06 00 00 30 00 00 30 8E 4F 43 33 32 . . . . . . . 0 . . 0 O C 3 2
00000330 0F 50 00 00 06 01 00 00 00 00 00 50 07 40 1D 08 . P . . . . . . . . . P . @ . .
00000340 40 20 0E 0E 08 38 42 65 61 74 4D 61 78 96 60 F8 @ . . . 8 B e a t M a x `
00000350 03 FF 02 80 76 47 21 C0 74 00 01 B0 00 47 00 56 . . v G ! t . . . G . V
00000360 00 01 00 02 00 03 00 04 00 05 00 06 00 07 40 5D . . . . . . . . . . . . . . @ ]
00000370 09 40 24 05 0A 00 0B 00 0C 00 0D 40 27 0E 00 0F . @ $ . . . . . . . . @ ' . . .
00000380 40 37 10 00 11 40 34 60 65 12 40 34 00 01 13 00 @ 7 . . . @ 4 ` e . @ 4 . . . .
00000390 14 00 15 00 16 00 17 00 18 00 19 00 1A 00 1B 00 . . . . . . . . . . . . . . . .
000003A0 1C C0 4C 00 17 1D 00 1E 00 1F 00 20 00 21 00 22 . L . . . . . . . . . ! . "



File len is 00 02 68 77 that is 157.815. Add 8 to this and you'll get the file length (157.823)

Index len is 00 00 03 00 that is 768. Each index entry is 24 bytes long, so there are 768 / 24 = 16 entries in this index

First index entry is:
53 6F 66 74 20 42 65 61 74 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00
Style name is stored inside first 11 bytes (Soft Beat)
Style type is at byte 19 (02 = style)
Style index is at byte 21 (00 = first style of the bank)

This same style comes again later (see 000001A0 position) but style type at byte 19 turns to 07 (performance)

This means that Soft beat style is made up of two parts: first is the style (midi data) while second is the "performance" (volume, programs, effects....)

Index ends at byte 3 of line 00000320; first style starts at byte 4 of that same line, and its length is 00 00 30 8E that is 12430 bytes. Then comes 12430 bytes of data, then comes another style and so on until the end:


000073E0 AB CD EF 01 00 00 BB FE 00 00 18 00 00 00 90 4B . . . . . . . . . K
000073F0 42 45 47 00 00 00 1C 00 00 03 24 00 00 33 BA 00 B E G . . . . . . . $ . . 3 .
00007400 00 4C BB 00 00 70 72 00 00 9B BF 00 00 BD 96 00 . L . . p r . . . . .
00007410 00 D0 71 00 00 EA FE 00 01 28 31 00 01 4F 82 00 . q . . . . ( 1 . . O .
00007420 01 67 C6 00 01 7A 56 00 01 9C C0 00 01 C8 61 00 . g . . z V . . . . a .
00007430 01 E4 1A 00 02 03 BA 00 02 44 82 00 02 46 C6 00 . . . . . . . D . . F .
00007440 02 48 8B 00 02 4A BE 00 02 4C F3 00 02 4F 19 00 . H . . J . . L . . O . .
00007450 02 51 06 00 02 53 2C 00 02 55 CA 00 02 57 DD 00 . Q . . . S , . . U . . W .
00007460 02 59 ED 00 02 5C 4D 00 02 5E C6 00 02 61 02 00 . Y . . \ M . . ^ . . a . .
00007470 02 63 5D 00 02 65 9C 4B 45 4E 44 00 00 00 21 00 . c ] . . e K E N D . . . !


Last index starts at last byte of line 000073E0 with the KBEG tag. Note the following address: 00 00 00 1C, exactly where the KORF tag ends in the first header.
Second address is 00 00 03 24 (as I said before, first style begins at byte 4 of line 00000320). Repeat this for all entries, then add a KEND tag with 4 more bytes for last index length.


[This message has been edited by RicFreak (edited 11-20-2003).]

Top
#219177 - 11/20/03 07:06 PM Re: How a Pa80 STY file looks inside
S0C9 Offline
Member

Registered: 09/23/02
Posts: 109
Loc: NRH, TX, USA
Yeah Ric,
and they still don't support Styles or Performance in the OPOSRF.dll do they !!

After almost 2yrs (like you) I've given up waiting on Mr. Schmidt and Korg Italy to release (even with the NDA) anything public, even with the release of the new PA1X..
Bummer....
Regards,
STeve

Top

Moderator:  Admin 



Help keep Synth Zone Online