DEV Community

Frédéric G. MARAND
Frédéric G. MARAND

Posted on • Originally published at blog.riff.org on

Tip of the day: how to compare Guitar Pro files

Music

The problem

When working on compositions in a multi-member band (currently 5 in AnotherDay), 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, 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$`
Enter fullscreen mode Exit fullscreen mode

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[]]>
Enter fullscreen mode Exit fullscreen mode

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 developers, currently available at 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. 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.

Top comments (0)