public static void main(String[] args) throws Exception {
File file = new File("C:\\workspace\\music\\analysis\\db\\" + "21.xml");
XMLReader xr = XMLReaderFactory.createXMLReader();
NoteContentHandler handler = new NoteContentHandler();
xr.setContentHandler(handler);
try (Reader reader = new FileReader(file)) {
try {
xr.parse(new InputSource(reader));
} catch (Exception ex) {
System.out.println(file.getName());
throw ex;
}
}
List<NoteElement> noteList = handler.getNotes();
List<Integer> pitches = new ArrayList<Integer>();
for (NoteElement element : noteList) {
if (element != null && !element.isRest()) {
pitches.add(60 + element.getScaleDegree() + element.getOctave() * 7);
}