6

I've been modifying some drum tabs on Guitar Pro. The problem is, for a specific section I want to remove all the cabasa notes. (Instrument 69)

Now of course, I can do it one note at a time. But I'll have to do this for one at a time for a loooong time.

I understand that Export the current GP file as an XML file from: File > Export > MusicXML and replacing certain chunks of text relevant before importing again would work.

But, I can't figure out which chunk of text to remove. Could anyone familiar with the MusicXML help me out?

  • 2
    I don't know, but here's how I'd find out: 1. make a toy project for testing, like a single bar standard rock groove with a single cabasa hit in the middle 2. export as test.xml 3. delete the cabasa note (normally in the Guitar Pro GUI; don't touch anything else though) 4. export as test-c.xml 5. look at the diff between the two files. On Linux, OSX or probably also in Windows PowerShell, this can be done simply with the command diff test.xml test-c.xml. – leftaroundabout Jul 23 '18 at 13:07
  • 1
    Have you opened the MusicXML export in a text editor and looked for the relevant section where one of the notes is? MusicXML is pretty intuitive, in my personal opinion. Once you figure out the text that defines the note, a search and replace should fix the problem. – Todd Wilcox Jul 23 '18 at 13:33
  • XML transformation (and filtering out elements falls into this category) is done either using a XML access library or XSL. I'm afraid that Music is probably not the most appropriate SO section for the question, since MusicXml is just a special scheme of generic XML. – guidot Jul 23 '18 at 14:49
  • 2
    @guidot Oh I don't know, I've done several search and replace operations in MusicXML files to correct issues just like this. Also, MusicXML has specific tags that users here are more likely to know about than someone with generic XML expertise. And as I have said, you don't need any special libraries or whatever "XSL" is, any text editor can be used to make large-scale changes to a MusicXML file. – Todd Wilcox Jul 23 '18 at 15:08
  • 1
    @guidot what, do you mean I shouldn't use regex for parsing XML? – leftaroundabout Jul 23 '18 at 16:53
2

I was able to do this using search and replace in the MacOS TextEdit app. One thing you have to be able to do for this to work is be able to include wildcards in the search field, which I believe most text editors can (not sure about Notepad on Windows).

First I created the following in Musescore and then exported the score to MusicXML:

Before

For the test, I wanted to be able to remove all the notes on the line, which in this score represent tom hits, while leaving the snare and kick hits intact.

I opened up the MusicXML document and looked until I found this snippet:

  <note default-x="101.58" default-y="-565.00">
    <unpitched>
      <display-step>D</display-step>
      <display-octave>5</display-octave>
      </unpitched>
    <duration>2</duration>
    <instrument id="P6-I46"/>
    <voice>1</voice>
    <type>quarter</type>
    <stem>up</stem>
    </note>

I determined that the above text was one instance of the tom hits I wanted to delete because the tom hit is displayed on the line that normally represents D in octave 5 when there is a treble clef sign at the beginning of the staff. This was corroborated by the fact that the other <note> entries were referred to C and F, which means they represented the kick and snare (on the F and C spaces of the treble clef, respectively).

So that means that searching for all such note definitions and replacing them with nothing would delete all of the tom hits. There is one catch: each note definition has a different x position in its definition. In this example we see it here:

  <note default-x="101.58" default-y="-565.00">

In order to find all the notes in one search, you have to put a wildcard in for the x value in the quotes, like this:

  <note default-x="<wildcard>" default-y="-565.00">

The wildcard text you use depends on the text editor you are using. In TextEdit on macOS, you don't actually replace that with text, but with a special "Any" object from the Pattern Insert dialog.

After searching for the entire note definition with the wildcard (and getting 36 hits) and replacing all of them with nothing (deleting them), I saved the MusicXML file and opened it in MuseScore again and it now looks like this:

After

So you'll need a text editor that can search and replace multiline text with wildcards in the search, and you'll have to go through the MusicXML document first to find the relevant <note> definition tag that specifies the cabasa.

To find it, you'll first need to find the <part> tag that is for the drum kit. It should have a part number corresponding to its position in the score. For instance, if it's the first one listed, it should be part 1. In my case, it was the sixth and last one, so it's part 6:

<part id="P6">

Another way to find the right part is look for a percussion clef definition, which looks like this:

    <clef>
      <sign>percussion</sign>
      <line>2</line>
      </clef>

Once you find the part, you have to figure out which note represents the cabasa. I suggest looking at the <display-step> tags for the note the cabasa note head would represent if it were on the treble clef instead of the percussion clef.

Also, save backups and double check you've removed the right notes before deleting the backups.

| improve this answer | |
  • @AdamTan Great! I'm happy to hear that. If you click the green check mark next to this answer, it will confirm for future users who have the same problem that this method works. – Todd Wilcox Jul 24 '18 at 13:17
  • 1
    You can't do regular expressions replacements on Notepad, but you can with Notepad++ which is a very lightweight and free program to download, in case someone needs this with Windows. – EzLo Jul 24 '18 at 13:31
  • Mine was: <note> <unpitched> <display-step>C</display-step> <display-octave>0</display-octave> </unpitched> <duration>1</duration> <instrument id="P7-I68"/> <voice>1</voice> <type>16th</type> <stem>up</stem> <beam number="1">continue</beam> <beam number="2">continue</beam> <notations> <dynamics><fff></fff> </dynamics> <?GP7 <root></root>?> </notations> <?GP7 <root></root>?> </note> However, when I remove it, the formatting screws up severely. Any ideas? – Adam Tan Jul 26 '18 at 11:01
  • The score in particular is: songsterr.com/a/wsa/radiohead-airbag-tab-s51299t7 – Adam Tan Jul 26 '18 at 11:01
0

If unsatisfied with the manual approach given in an other answer, the XML transformation script looks (use appropriate XSLT transformation tool of your OS) like this:

<?xml version="1.0"?>
<!-- Filter all note elements, which have a given instrument attribute -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes"/>

    <xsl:template match="note">
        <xsl:choose>
            <xsl:when test="instrument/@id='P2-I3'">
                <!-- such elements are filtered, adjust id above -->
            </xsl:when>
            <xsl:otherwise>
                <xsl:copy>
                    <xsl:apply-templates />
                </xsl:copy>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="@*|node()">
        <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>
| improve this answer | |
  • Wouldn't that delete all the notes in the specified part, not just the cabasa notes? – Todd Wilcox Jul 25 '18 at 19:37
  • @ToddWilcox: It removes all notes with the given instrument specification, here P2-I3, in your example P6-I46. I assumed, that this corresponds to instrument 69 from the question. While it would be easy to change that to default-y, I don't see how you prevent false positives in a non-interactive process. – guidot Jul 26 '18 at 7:32
  • I interpreted the question differently I think. I read it as being about removing one note from a part. The thing about a percussion part is that it’s one “part” (the MusicXML term) that has multiple instruments (the real world term) on it. I thought the asker wanted to just remove one kind of percussion note, the cabasa, from the percussion part. If I read your answer correctly, it will remove all of the percussion notes, which I didn’t think was desired. – Todd Wilcox Jul 26 '18 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.