Created
February 1, 2013 22:50
-
-
Save richardTowers/4694726 to your computer and use it in GitHub Desktop.
Reads a music XML file and counts the notes that are C5.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rexml/document" | |
include REXML | |
file = File.new( "String Quartet No. 3 in G Major, K. 156.xml" ) | |
doc = Document.new file | |
notes = XPath.match( doc, "//note/pitch[step='C' and octave='5' and not(alter)]" ) | |
puts notes.length |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment