# Guitar Pro 4 file format
I have found years ago a file description for Guitar Pro version 4.06 files only.
## General
Values of type "integer" and "byte" presented in this document are written from left to right of the the LSB (least significant byte) to the MSB (most significant byte).
| Type | Number of bytes |
|----------------|:---------------:|
| **integer** | 4 |
| **short** | 4 |
| **short int** | 2 |
| **byte** | 1 |
The **colors** are stored in 4 bytes in the following way, the data is written from left to right of the LSB (least significant byte) to the MSB (most significant byte):
| Bit 3 | Bit 2 | Bit 1 | Bit 0 |
|-----------------------------------------|-------|-------|-------|
| White byte, it always evaluates to 0x00 | Blue | Green | Red |
When this document uses the expression "character string," it means a couple of a first byte encoding the number 'n' of characters in the string (consequently limited to 255 characters), followed by the 'n' characters themselves.
The musical notes are stored as integers. The value of the C(0) is 0, and each incrementation of the variable represents a half tone:
| Note | Value |
|--------|------:|
| C#(0) | 1 |
| C (1) | 12 |
| E (2) | 28 |
| ... | ... |
## File structure
* Headers
* Version
* Tablature
* Lyrics
* Other Tablature Information
* [Body](FILE-STRUCTURE-BODY.md)
* Measures
* Tracks
* Measure-track pairs
* Beat 1 : note 1..i
* Beat 2 : note 1..i
* Beat i : note 1..i
* [Chord diagrams](FILE-STRUCTURE-CHORD-DIAGRAMS.md)
## Headers
### Version
30 character string (not counting the byte announcing the real length of the string as explained in GENERAL) representing the version number. Only the first n characters (n being given by the value described previously) characters are considered.
Possible values are:
| **Extension** | **Header values** |
|:-------------:|-------------------|
| **GP1** | FICHIER GUITARE PRO v1
FICHIER GUITARE PRO v1.01
FICHIER GUITARE PRO v1.02
FICHIER GUITARE PRO v1.03
FICHIER GUITARE PRO v1.04 |
| **GP2** | FICHIER GUITAR PRO v2.20
FICHIER GUITAR PRO v2.21 |
| **GP3** | FICHIER GUITAR PRO v3.00 |
| **GP4** | FICHIER GUITAR PRO v4.00
FICHIER GUITAR PRO v4.06
FICHIER GUITAR PRO L4.06 |
| **GP5** | FICHIER GUITAR PRO v5.00
FICHIER GUITAR PRO v5.10 |
*__Translator's Note__: "Fichier" is French for "File". It is left untranslated above, as the program expects the string in French.*
Only the specifications relating to version "FICHIER GUITAR PRO v4.06" are described here.
After this point (0x0000001F), the data is written sequentially without a precise address.
### Information about the piece
The follollowing information is presented in the form of a block of data containing:
* an `integer` representing the size of the stored information + 1;
* the `string` of characters representing the data
This structure requires that a null `string` be written `01 00 00 00 00` in the file.
The information concerned is, in order of reading within the file:
| Field name | Guitar Pro versions |
|--------------------------------------------|---------------------|
| **title** | 3, 4 |
| **subtitle** | 3, 4 |
| **interpret** | 4 |
| **album** from which the piece was taken | 3, 4 |
| **author** | 4 |
| **copyright** | 3, 4 |
| **tablature author** | 3, 4 |
| **instructional** line about the tablature | 3, 4 |
The following section contains information regarding the 'notice' (note) field in the piece's properties.
It begins with an integer containing the number of lines of Nb_Notice notes, then Nb_Notice instances of the structure previously described, each containing lines of notes.
The file then contains a byte determining the '**TripletFeel**' attribute of the piece.
If TripletFeel is activated, the value is 1. If not, the integer value is 0.
### Lyrics
The next section of the file contains the **lyrics** associated with the piece.
*__WARNING__: The strings presented in this section and in this section only do not conform to the format presented in "General", but are written directly.*
The lyrics section begins with an integer giving the number of the track with which the lyrics are associated.
Then, for each of the 5 lines of lyrics generated by Guitar Pro 4, the file contains an integer representing the number of characters in the string followed by the character string itself.
### Other information about the piece
The next data are:
* **tempo**: `integer`
* **key**: `byte`. This value encodes the key (signature) at the beginning of the piece. It is encoded as: `0: C`, `1: G(#)`, `2: D (##)`, `-1: F (b)` ...
* **octave**: `byte`. The standard value is 0. It becomes 8 if the sheet is to be played one octave higher (8va). This functionality is not yet used, but is presented as a preview of a revision of the GP4 format.
* **MIDI channels**: Table of midi channels. There are 4 ports and 16 channels, the channels are stored in this order: `port1/channel1`, `port1/channel2`, ..., `port1/channel16`, `port2/channel1`, ... Each element of the table has the following form:
| Element | Data type |
|----------------|----------------------------------------------------|
| **instrument** | `integer` |
| **Volume** | `byte` |
| **Balance** | `byte` |
| **Chorus** | `byte` |
| **Reverb** | `byte` |
| **Phaser** | `byte` |
| **Tremolo** | `byte` |
| **blank1** | `byte` => Backward compatibility with version 3.0 |
| **blank2** | `byte` => Backward compatibility with version 3.0 |
* **number of measures**: `integer`
* **number of tracks**: `integer`