Skip to content

Instantly share code, notes, and snippets.

@richardTowers
Created February 1, 2013 22:50
Show Gist options
  • Save richardTowers/4694726 to your computer and use it in GitHub Desktop.
Save richardTowers/4694726 to your computer and use it in GitHub Desktop.
Reads a music XML file and counts the notes that are C5.
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