Tip of the day: how to compare Guitar Pro files
Tags: music, guitar, guitarpro, xml
Published: 2020-10-02 07:43:57

---
title: Tip of the day: how to compare Guitar Pro files
published: true
date: 2018-10-07 09:21:56 UTC
tags: ["music", "guitar", "guitarpro", "xml"]
canonical_url: https://blog.riff.org/2018_10_07_tip_of_the_day_how_to_compare_guitar_pro_files
---

[Music](https://blog.riff.org/topic/music)

- [GuitarPro](https://blog.riff.org/taxonomy/term/240)
- [GP7](https://blog.riff.org/taxonomy/term/241)
- [XML](https://blog.riff.org/tags/xml)

## The problem

When working on compositions in a multi-member band (currently 5 in [AnotherDay](https://www.facebook.com/AnotherDay78)), each member tends to create their own Guitar Pro files to avoid overwriting the previous versions created by other band members. And `.gp` files tend to accumulate for the same song. At which point I start to wonder: "I know there's this riff in one of the versions, but which one ?" or "Are these two files really different or could I just merge them by editing a few notes, or remove one altogether ?"

The problem, of course, is that [Guitar Pro](https://www.guitar-pro.com/en/index.php?pg=guitar-pro), even in version 7.5, has no builtin file comparison tool. How can one compare these files ?

## Diagnostic

If GP7 doesn't have a buitin solution, how about comparing the files themselves ? Problem: the file format is not documented. But a `file score.gp` command returns `Zip archive data, at least v2.0 to extract`. So let's unzip the file to see what it looks like:

```
$ unzip score.gp
Archive:  score.gp   
creating: Content/  
  inflating: Content/BinaryStylesheet
  inflating: Content/LayoutConfiguration
  inflating: Content/PartConfiguration
  inflating: Content/Preferences.json  
  inflating: Content/score.gpif
  inflating: VERSION
$ cat VERSION
7.0
$ cd Content
$ file *
BinaryStylesheet:    data
LayoutConfiguration: X11 SNF font data, MSB
firstPartConfiguration:   data
Preferences.json:    ASCII text, with no line terminators
score.gpif:          XML 1.0 document text, UTF-8 Unicode text, with very long lines$`
```
A quick look at the content of the files confirms that the actual score data is contained in the `score.gpif` file.
```
$ tidy -q -xml -indent score.gpif | head -20  
<?xml version="1.0" encoding="utf-8"?>
<GPIF>
  <GPVersion>7</GPVersion>
  <GPRevision required="12021" recommended="12023">
  12024</GPRevision>
  <Encoding>
    <EncodingDescription>GP7</EncodingDescription>
  </Encoding>
  <Score>
    <Title>
      <![CDATA[]]>
</Title>
    <SubTitle>
      <![CDATA[]]>
</SubTitle>
    <Artist>
      <![CDATA[]]>
</Artist>
    <Album>
      <![CDATA[]]>
```
Ahah... so it's an XML document with a `GPIF` top-level element. A quick search with that keyword lands us on a file called "The Guitarpro 7 (".GP") file format" by the [MuseScore](https://musescore.org/) developers, currently available at [https://musescore.org/sites/musescore.org/files/2017-08/the\_guitarpro\_7\_file%20format.doc](https://musescore.org/sites/musescore.org/files/2017-08/the_guitarpro_7_file%20format.doc). And its content allows one to understand the contents of these scores. I bet it would even come in handy to manually edit/repair a file corrupted by the frequent crashes of Guitar Pro.

But that's not the goal for today, we can now compare these scores more or less easily.

## The solutions

First solution is to use the process described above and compare the `score.gpif` files using your [favorite text comparison software](http://meldmerge.org/). Works well, but can we do it with less command-line manipulation ?

Turns out, most of the process can be replicated in Guitar Pro itself, by using the new (?) MusicXML export: just navigate to `File` / `Export` / `MusicXML...` to export the scores to compare, and you directly get a pair of XML files which you can directly compare in your visual text comparison tool. Problem solved.

<section></section>