I am writing a program in Java for searching through a set of melodies. The imported data consists of a modified MusicXML file. For each melody, one whole branch is pure MusicXML. Another contains a set of abstractions. The program searches these abstractions, and will display (notate) the melodies that match certain search criteria. In order to display correctly, it has to line up the graphic representation of each abstracted segment with the proper note. To do this, I need to find the nth note in the melody a few times for each incipit.
I am using XPaths (org.apache.xpath.XPathAPI;) which is good for grabbing the notes once I have the root node of a melody. However since the notes are all nested within measures, this is not so elegant: I have to get a nodelist of the measures, than iterate over each measure.
In my original representation, I represented measures by giving each note a relative metric weight. The weight of each first beat is 1, the weights for eighth-notes in 6/8 would be 134256, for 2/4: 1324, etc. I can know where a barline occurs by looking at these values.
I could transform the notation so that I would have a straightforward notelist, however, I would like to keep this branch pure MusicXML. There is an object called NodeIterator, which is an alternative to NodeList. Can this be used? Is there some more elegant way to solve this "problem"?
Thanks for any suggestions. Jane