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 ?
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:
A quick look at the content of the files confirms that the actual score data is contained in the
$ unzip score.gp
$ cat VERSION
$ cd Content
$ file *
LayoutConfiguration: X11 SNF font data, MSB first
Preferences.json: ASCII text, with no line terminators
score.gpif: XML 1.0 document text, UTF-8 Unicode text, with very long lines
Ahah... so it's an XML document with a
$ tidy -q -xml -indent score.gpif | head -20
<?xml version="1.0" encoding="utf-8"?>
<GPRevision required="12021" recommended="12023">
GPIFtop-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.
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
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.