XMLMeter representation of a musical meter for MusicXML files
Inherits from: Object
See also: XMLScore and XMLNote as well as MusicXMLOverview
Creation / Class Methods
*new (upper, lower, type)
upper - an interger or Array of integers. Arrays create a complex meter (e.g., [3, 2, 3] = 3 + 2 + 3)
lower - the lower value for the meter. If a \simple meter, this value gets the beat. If \compound, three of this value gets the beat.
type - \simple of \compound. Default is \simple.
g = XMLMeter.new(4, 4);
g = XMLMeter.new(6, 8, \compound);
g = XMLMeter.new([3, 2, 3], 8);
Accessing Instance and Class Variables
type
Returns the type of meter.
numBeats
Explanation including the type of numBeats and a link to its help file.
Default value is nil.
Doing Some Task (optional)
A short bit of prose explaining something about the task.
beatDur (beat)
Returns the duration of a given beat in an XMLMeter.
// inline example
g = XMLMeter(4, 4);
g.beatDur(1);
g = XMLMeter([3, 2, 3, 2], 8);
g.beatDur(1);
g.beatDur(2);
g.measureDur;
measureDur
Returns the duration of a full measure for a given XMLMeter.
g = XMLMeter([3, 2, 3, 2], 8);
g.measureDur;
Examples
// 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 = XMLVoice(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));
while({
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);
)