XMLNote Note representations for MusicXML documents

Inherits from: Object : XMLMusicObj

Note representations for MusicXML files, to be used along with XMLScore, XMLPart and XMLVoice

See also: MusicXMLOverview for other elements in the system.

Some Important Issues Regarding XMLNote (optional)

MusicXML is a VERY complex system, and different notation programs handle the code in different ways. Overall, the MusicXML files created from SuperCollider should open fine in Finale, Sibelius and NoteAbility Pro. Also, while this first version (June 2008) works well, until a number of people have used it there may be some instability in the library. While future changes will attempt to be backwards compatible, this may not always be possible.

Creation / Class Methods

*new (aPitchClass, beat, duration, tuplet)

Creates a new instance of XMLNote

aPitchClass - An instance of PitchClass, or an integer representing a midi note keynum.

beat - The beat the XMLNote appears on. Must be >= 1.0.

duration - A duration value for the XMLNote, based on the note name. e.g, 0.25 (or 1/4) is a quarter-note. 1.0 is a whole note. 0.75 is a dotted half note. Symbols may also be used as defined in XMLMusicObj:

\l -> "long"

\b -> "breve"

\w -> "whole"

\h -> "half"

\q -> "quarter"

\e -> "eighth"

\s -> "16th"

\t -> "32nd"

\x -> "64th"

\o -> "128th"

All symbols may also may also have up to two dots appended to them as follows:

\qd; // dotted quarter

\edd; // double dotted eighth

tuplet - a ratio expressing a tuplet relation. e.g. 3/2 represents three in the space of two.

See the examples below for more

Examples

// simple example

(

// create an XMLScore

z = XMLScore.new;

// add a voice to the XMLScore

z.add(y = XMLPart(meter: XMLMeter(4, 4), key: XMLKey.major(\Bf)));

// create a B-flat major scale in quarter notes

// uses XMLVoice's internal 'clock' to keep track of beats

[58, 60, 62, 63, 65, 67, 69, 70].do({arg keynum;

y.add(XMLNote(keynum, y.now, \q))

});

// output the XMLScore

z.output("~/Desktop/test.xml".standardizePath);

)

// same as above, but with triplet eighth notes

(

z = XMLScore.new;

z.add(y = XMLPart(meter: XMLMeter(4, 4), key: XMLKey.major(\Bf)));

[58, 60, 62, 63, 65, 67, 69, 70].do({arg keynum;

y.add(XMLNote(keynum, y.now, \e, 3/2)); // 3 eighths in the space of 2

});

z.output("~/Desktop/test.xml".standardizePath);

)

// a short melodic example with changing meters, and tuplets in simple meters

(

var curkey, notedur, tuplet, curMeter;

// create an XMLScore

z = XMLScore.new;

// add a voice to the XMLScore

z.add(y = XMLPart(key: XMLKey.major(\Bf)));

y.addMeter(1, XMLMeter(4, 4));

y.addMeter(2, XMLMeter(6, 8, \compound)); // a compound meter

y.addMeter(4, XMLMeter(4, 4));

// uses XMLVoice's internal 'clock' to keep track of beats

while({

// see XMLVoice for more utilities for getting values from a voice's attributes

curkey = [58, 60, 62, 63, 65, 67, 69, 70].choose;

curMeter = y.getMeterFromBeat(y.now);

tuplet = (curMeter.type == \compound).if({1/1}, {3/2});

y.add(XMLNote(curkey, y.now, \e, tuplet));

(y.now < 13)

});

// output the XMLScore

z.output("~/Desktop/test.xml".standardizePath);

)