I finally got on the Wordle bandwandwagon and ran the Discovering XQuery Blog through their clever wordcloud generator thingy. Actually, I ran it more than a couple of times since it's a lot of fun to let it create random patterns (warning: time suck!).
Here is what the most recent posts (it uses the RSS feed) produced:
(click here to see in on Wordle)
What a shocker! Yup, XQuery is front and center here at Discovering XQuery and with XML to base it on you have all you need to create and work with content (of course using MarkLogic Server). I also like the accidental sentence 'XQuery can script'. Youbetcha!
A good example of this is this paper from the upcoming International Conference on Music Information Retrieval (ISMIR2008). In between the sessions on music recognition and automated transcription (my favorite: Multiple-Feature Fusion Based Onset Detection for Solo Singing Voice) is this session on working with MusicML: Using XQuery on MusicXML Databases for Musicological Analysis. The authors got some MusicXML from wikifonia (a free site that collects MusicXML and provides a nice rendering of the music) and used XQuery like a buzzsaw to slice up the content sorting out duplicate titles, listing key signatures and time signatures and even trying to find motives (sequences of chords or rhythms) in the corpus. Pretty cool stuff!
I thought I'd give it a try myself and add maybe add to their collection of queries.
The first step is to get some content. Lloading XML from an external source looks like this in MarkLogic:
for $i in (1 to 200)
let $song-source := concat("http://static.wikifonia.org/" ,$i , "/musicxml.xml")
let $database-uri := concat("/songs/" ,$i , "/music.xml")
return
xdmp:document-load($song-source,
xmlns="xdmp:document-load">
<uri>{$database-uri}uri>) xml
This grabs the first 200 songs and inserts them into a database.
The XML is pretty neat and, like all good XML, nicely self-describing:
partwise version="2.0">
<movement-title>What's New</movement-title>
<identification>
<creator type="composer">Bob Haggard</creator>
...
</identification>
<part-list>
<score-part id="P1">
<part-name>Voice</part-name>
<score-instrument id="P1-I1">
<instrument-name>Voice</instrument-name><!-- Then the actual music in measures -->
<measure number="1">
<note>
<pitch>
<step>D</step>
<octave>4</octave>
</pitch>
<duration>384</duration>
<voice>1</voice>
<type>eighth</type>
<lyric number="1" name="verse">
<syllabic>end</syllabic>
<text>You</text>
</lyric>
</note>
....
</measure>
....
</score>
Having loaded some MusicXML, it's time to run use some XQuery to explore the music. You can run the ones in the paper like this one that lists the titles that have no rests:
for $i in //score-partwise
return
$i[count($i//rest) eq 0]//movement-title
This gives us a sequence of titles:
Zachtjes gaan de paardenvoetjes
Sinterklaas is jarig
fn:distinct-values(//score-partwise//score-instrument/instrument-name)
let $notes := //score-partwise[.//score-instrument/instrument-name eq "Grand Piano"]//note
let $rest-notes := //score-partwise[.//score-instrument/instrument-name eq "Grand Piano"]//note[./rest]
return
$notes except $rest-notes
<note>
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>2</duration>
<type>eighth</type>
...
</note>
<note>
...
This shows the feasibility of automated musicological
analysis on digital score libraries using the latest software
tools. Bottom line: it’s easy.
Hi Matt, just want to report a small typo: it's MusicXML rather than MusicML. Anyhow, nice article!
Thomas
Posted by: free lead sheets | September 05, 2008 at 04:37 AM
Thanks for the great post and the complements on the quality of the MusicXML! But please note that what is described here is MusicXML, not MusicML.
Around 2000 there were many competing ideas for marking up music notation. MusicML was one of the alternatives to MusicXML that was later abandoned. I see that someone else is now using MusicML to refer to a music metadata markup language.
Posted by: Michael Good | September 05, 2008 at 02:55 PM