XQuery/MusicXML to Arduino

Motivation
You want to play music available in MusicXML format on an Arduino.

Approach
Fetch the Music XML file (either plain XML or compressed) and transform one monophic part to code to be included in an Arduino sketch.

Script
}; declare option exist:serialize "method=text media-type=text/text";

let $uri := request:get-parameter("uri",) let $part := request:get-parameter("part","P1") let $format := request:get-parameter("format","xml") let $doc := if ($format = "xml") then doc ($uri) else if ($format = "zip") then fw:unzip($uri) else (: get the requested part :) let $part := $doc//part[@id = $part] (: use the data in the first measure to set the temp :) let $measure := $part/measure[1] let $tempo := (xs:integer($measure/sound/@tempo), 100)[1] (: convert the notes into an internal XML format :) let $notes := fw:mxl-to-midi($part) return

(: generate the sketch fragmemt:) int tempo = {$tempo}; {fw:notes-to-arduino($notes) }

Examples

 * 1) Good King Wensceslas
 * 2) HTML Form interface