Download GpPlayer_1_0_src.zip - 1.22 MB
Download GpPlayer_1_0_bin.zip - 497.76 KB
Introduction
First of all I want to say that this is my first article on CodeProject. Therefore excuse if it has not the same quality as other articles have. Let’s answer some questions before we start.
Updates / Project Website
To keep in touch with the most current infos and releases head to our project repository on Google Code:
http://code.google.com/p/gpplayer/
Background
What is this project about?
"Guitar Pro is a multitrack tablature editor for guitar, banjo and bass. Besides writing scores, Guitar Pro is a useful resource for guitarists from beginner to experienced levels toprogress, compose, or simply accompany themselves." (http://www.guitar-pro.com/en/, 15.11.2009). The target of this Project is to develop an Application which can open these Tablature-Files, display the Tablature and give the possibility to play those through Midi.
What were my targets of this project?
I wanted to learn about the structure of this file format and improve my control development skills. In future I want to make a Java Swing Port of this Application to provide an online player to tablature-file hoster.
What was my main information source?
There is an open-source application (LGPL) called TuxGuitar (http://tuxguitar.herac.com.ar/) which is written in Java. My sources are based on this Java Code and are mainly only a C# port. (But how could it be another way if there is a strict file format?).
Under which license is this project published?
GPL v3 (http://www.gnu.org/licenses/gpl-3.0.html). In future I plan to switch to LGPL for some parts (especially the io and player parts).
Song Model
The Song Model describes the structure of a song, stored in a GuitarPro file. It is a quite simple hierarchy with the Song as root-node:
File Format
Points of interest
The File-Read-Algorithms I used are based on the Java Source of TuxGuitar. One of the well known differences between Java and C# are the byte types. C# uses byte as an unsigned byte and sbyte as a signed one. Java uses byte as a signed byte and ubyte as an unsigned. Therefore I had to write an own Stream wrapper which uses sbyte as main type for reading and implement an own “SignedByteFileStream”.
The only special part in GuitarPro files is how strings are stored. First you have to read one ubyte or integer (depending on the string) which determines the length of the string which follows. After that you read the amount of bytes given by the first ubyte. These bytes can be used to decode a UTF-8 encoded text.
Guitar Pro File version 5
Not all bytes are determined to their usage but the most important for playing and displaying songs is known.

The file starts with a version identifier. The first byte 18Hex (24Decimal) indicates 24bytes for the text "FICHIER GUITAR PRO v5.10". 30 Bytes are reserved for this version identifier.

The Song Information starts at byte 31: 9 "int-strings" containing title, subtitle, artist, album, author, music, copyright, tab writer, instructions. An integer (4Bytes) indicates how many int-strings have to be read as additional notes.
After the information we have to read lyrics, page setup, and 64 (midi) channel definitions.
Finally we can start to read our tracks and measures. I don’t explain all parts because this would make the article to long. But you can read all about it in the source code.
Special Thanks
First of all I want to give props to all developers of TuxGuitar who can be found here: http://tuxguitar.herac.com.ar/authors.html. You made it possible for me to understand how to read GuitarPro files and how to render the tablature.
Also thanks to Leslie Sanford who has developed the C# Midi Toolkit (MIDIToolkit.aspx) which allowed me to access the midi interface for playing the songs.
History
1.0 - Initial Release (Translated file reading algorithms from Java to C#, Song Player, Tablature and Fretboard Controls)
Future Plans / TODOs:
- Java Applet Port
- Identify missing bytes and complete song model
- Styleguide Renaming and Documentation
- Directly build midi sequence for sequencer (No temp-file export)
- Analyze GuitarPro and FMOD Ex to build an own RSE (http://www.fmod.org/index.php/products/fmodex)
- More Layouts for the tablature control
- WPF Port (not sure)