Purple Hearts hpmusic
Main Menu
Good Links
Who's Online
We have 63 guests online
About the Structure of Style-Files
Wednesday, 03 November 2004
The task of a YAMAHA Style is to lead all informations to a keyboard needed to play an automatic accompaniment. The musician has to enter notes of the melody with the right and suitable chords with his left hand only. A complex function of the keyboard identifies the chords and transforms the notes of the style to get an good sound. Furtheron a style includes a style name, a standard tempo and data, which define the method how to fit the chords.

A style is divided in several parts which can be manually switched by the musician. At PSR-8000 we have the parts "Intro A", "Main A", "Ending A", "Intro B", "Main B", "Ending B", "Fill In AA", "Fill In BB", "Fill In AB" and "Fill In BA". Elder PSR's have less, newer more parts. Each part is assigned to a sequence of notes for several channels and voices with a duration of at least one measure. These notes are the material to be transformed. There is a lot of build-in styles inside the keyboards, the so called internal styles. On the other side there is the possibility, to create or buy a style-file which can be stored into a special bank of custom styles and to use it like an internal style.

Look into the manual of your keyboard, if you want to get information how to use the styles and style-files. With this paper you will get an overview of the internal structure of style-files only. You should have a little knowledge about MIDI-events and the structure of MIDI-files to understand all of it. There are many articles in the internet, for example:

The global Structure of a Style-File

A style-file is a SMF0-file with special conventions. The file-extension is .sty. You can hear the parts one after another, if you rename the extension to .mid and play it using a MIDI-player with the PC.

A style file is divided into four sections:

  1. The Style Header
  2. The Style Parts
  3. The CASM Chunk
  4. The MHhd Chunk

The Style Header

The style-header starts with the MThd Chunk header and a MTrk header as found in all SMF0-files. The SysEx F0 05 7E 7F 09 01 F7 :"Turn General Midi System On" is one of the first events, mostly followed by the SysEx F0 43 10 4C 00 00 7E 00 F7: "XG System On". To declare the file to be a style, there have to be inserted two marker-events with the texts SFF1 and SInt at time 1:00:000. The time-, tempo-, song-name- and copyright-events are included as usual. After this we find controller-events and static SysEx as in most SMF0-files.

The Style Parts

Each part starts with a marker with the name of the part and ends with the next marker.

For example a beginning of the part "Fill In AA" with the first note of the part:

4:01:000 Marker: Fill In AA
4:01:000 Note On: chan. 10, note B2 velocity 78

The sequence of the style parts ends with the meta-event "End of Track" (ff 2f 00).

The CASM Chunk

The CASM Chunk Header is an 8 bytes block and follow the "End of Track" meta-event immediately. The first 4 bytes are the ascii's "CASM", the next 4 bytes define the length of of all data of the CASM chunk as an 32 bit number of bytes.

The CASM chunk is divided in several CSEG blocks, each of them starts with a 8 byte CSEG block header.

The CSEG header starts with the 4 ascii's "CSEG", followed by a 32 bit number, the length of the data of the CSEG block. The end of the last CSEG block is the end of the CASM chunk.

The CSEG block is divided in several Sdec blocks. It is started by the 8 byte Sdec header: 4 ascii's "Sdec", followed by a 32 bit length of the Sdec data. The Sdec data is a sequence of ascii's, defining the parts specified in following Ctab blocks.

An example of a Sdec block: "Sdec" 00 00 00 1C "Fill In AA,Fill In AB,MAIN A"

The Sdec block is followed immediately by a sequence of Ctab blocks. Each Ctab block contains informations about a concrete channel of the parts included in the preceding Sdec block. The Ctab block starts with a 8 byte Ctab block header: 4 ascii's "Ctab", followed by a 32 bit number, which is the length of the data of the Ctab block.

The first byte of the Ctab data is the channel number of the range 0,1,...0f. After this there are 8 ascii's, the voice-name. You will find special strings like "CC-Crash" or "Pad-Root" instead of the well-known voice-names of the GM or XG banks. The following bytes are the information data, how to fit the the chords.

The MHhd/MHtr Chunk

The MHhd Chunk is omitted mostly. The Chunk starts with two header of 8 bytes. The MHhd header with the 4 ascii's "MHhd", followed by a 32 bit number with value 8. After this we find the MHtr header with the 4 asccii's "MHtr", followed by a 32 bit number which is the length of the next data up to the end of the MHhd/MHtr Chunk. The data are divided by marker meta-events with the well known names "Main A", "Fill In AA",... There are new markers with names "Break AA" and Break BB". The sections between the markers are filled with YAMAHA SysEx-events f0 nn 43 76 .. .. f7. Do not ask me about the function of these.

The Structure of a Style-File

Style Header

Style Parts

Part 1
Part 2
Part n

CASM Chunk









End of CASM =
End of last CSEG =
End of last Ctab

MHhd/MHtr Chunk (optional)

Related Software and Articles

Jørgen Sørensen's CasmEdit is an excellent program to edit CASM-chunks of style-files.

The elder CASM-Editor of Osenenko CasmEdit can be found at

Another program midi2style from Jørgen Sørensen allows to create style-files with sequences of notes from usual MIDI-files. You also can insert effects and other nice things.

Jørgen publishes a more detailled article about the structure of styles and you will find a lot of links to answer questions of styles.

You can get the freeware program Visual Styler from the internet. The task is to convert styles from one keyboard-model to use it with another, normal an elder model. The user has to select parts of a source style and copies only these into a destination file. The Sdec’s are slightly modified, but all other data of the CASM will not be changed. The program can be downloaded from

I have programmed a MIDI- and style-file analyzer to get interpretations of all events and an insight into the structure of style-files. This program PSRMIDI is freeware and can be downloaded from my homepage.

After we have changed the style-file extension of a style from .sty to .mid, we can load the file in Cakewalk. We can look at the notes and other events, but we cannot see anything of the CASM chunk. We can play it one part after another. But if we change events and store the modified style, Cakewalk has deleted the CASM chunk completely.