/  Basic Classes

ezNote

ezMeasure

ezPart

ezScore

ezCC

Basic data structures for holding symbolic music information.

ezNote

inherits : Object

Basic SMucK note object carrying information about the note's onset, duration, pitch, and velocity. To be used in score importing, generating, editing, and playback.

constructors

ezNote()

Default constructor, creates a note with onset 0, duration 1, pitch 60, and velocity 1.0.

ezNote(float onset, float beats, float pitch, float velocity)

Constructor for ezNote specifying onset, beats, pitch, and velocity.

ezNote(string sm_input)

Constructor for ezNote using a SMucKish input string.

member functions

float beats()

Get the duration of the note in beats.

float beats(float value)

Set the duration of the note in beats.

ezNote copy()

Return a copy of the ezNote.

float[] data()

Get the user-defined data associated with the note.

float[] data(float[] value)

Set the user-defined data associated with the note, using a float array.

float data(int index)

Get the user-defined data associated with the note, using an index.

float data(int index, float value)

Set the user-defined data associated with the note, using an index.

int isRest()

Return whether the note is a rest.

int isRest(int value)

Set whether the note is a rest.

float onset()

Get the onset of the note in beats, relative to the start of the measure.

float onset(float value)

Set the onset of the note in beats, relative to the start of the measure.

float pitch()

Get the pitch of the note as a MIDI note number.

float pitch(float value)

Set the pitch of the note as a MIDI note number.

void print()

Print the note parameters.

string text()

Get the text annotation associated with the note.

string text(string value)

Set the text annotation associated with the note.

float velocity()

Get the velocity of the note.

float velocity(float value)

Set the velocity of the note.


ezMeasure

inherits : Object

SMucK measure object. An ezMeasure object contains one or more ezNotes, and may contain ezCCs (MIDI control messages). Note contents can be set using the SMucKish input syntax.

constructors

ezMeasure()

Default constructor, creates an empty measure.

ezMeasure(string input)

Create an ezMeasure from a SMucKish input string.

ezMeasure(ezNote[] notes)

Create an ezMeasure from an array of ezNote objects.

member functions

void add(ezNote note)

Add an ezNote to the measure.

void add(ezNote[] notes)

Add an array of ezNotes to the measure.

void add(ezCC cc)

Add an ezCC to the measure.

void add(ezCC[] ccs)

Add an array of ezCCs to the measure.

float beats()

Get the length of the measure in beats.

ezCC[] ccs()

Get the CCs in the measure as an ezCC array.

ezCC[] ccs(ezCC[] ccs)

Set the CCs of the measure using an ezCC array.

ezMeasure copy()

Return a copy of the ezMeasure.

ezNote[] notes()

Get the notes in the measure as an ezNote array.

ezNote[] notes(ezNote[] notes)

Set the notes of the measure using an ezNote array.

float onset()

Get the onset of the measure in beats (start time within the part)

float onset(float value)

Set the onset of the measure in beats (start time within the part)

float[][] pitches()

Get the pitches of the notes in the measure as a 2D array of MIDI note numbers.

float[][] pitches(string input)

Set the pitches of the notes in the measure, using a SMucKish input string.

float[][] pitches(string[] input)

Set the pitches of the notes in the measure, using an array of SMucKish string tokens.

float[][] pitches(float[][] input)

Set the pitches of the notes in the measure directly from a 2D array of MIDI note numbers.

int polyphony()

Get the max number of concurrent (sounding) voices in the measure. Rest notes are not counted.

void print()

Print the parameters for each note in the measure.

void rest()

Set all notes to rests.

float[] rhythms()

Get the rhythms of the notes in the measure as an array of floats.

float[] rhythms(string input)

Set the rhythms of the notes in the measure, using a SMucKish input string.

float[] rhythms(string[] input)

Set the rhythms of the notes in the measure, using an array of SMucKish string tokens.

float[] rhythms(float[] input)

Set the rhythms of the notes in the measure directly from an array of floats.

void sort()

Sort the notes and CCs arrays in place by onset time.

ezMeasure[] split(float constantLength)

Split the measure into multiple measures by constant bar length. Returns an array of ezMeasure. Each resulting measure contains notes whose onset falls in that window; note onsets are relative to the new measure. Remainder at end becomes a shorter final measure. Empty windows create an empty measure.

ezMeasure[] split(float[] lengths)

Split the measure into multiple measures by a list of bar lengths. Uses list in order; if list is exhausted, uses the last element for remainder. If list is longer than material, creates only as many measures as needed. Empty windows create an empty measure.

string text()

Get the text annotation of the measure.

string text(string value)

Set the text annotation of the measure.

float[] velocities()

Get the velocities of the notes in the measure as an array of floats.

float[] velocities(string input)

Set the velocities of the notes in the measure, using a SMucKish input string.

float[] velocities(string[] input)

Set the velocities of the notes in the measure, using an array of SMucKish string tokens.

float[] velocities(float[] input)

Set the velocities of the notes in the measure directly from an array of floats.


ezPart

inherits : Object

SMucK part object. An ezPart object contains one or more ezMeasures. Measure contents can be set using the SMucKish input syntax, or when importing a MIDI file into an ezScore object.

constructors

ezPart()

Default constructor, creates an empty part.

ezPart(string input)

Create an ezPart from a SMucKish input string.

ezPart(string[] input)

Create an ezPart from an array of SMucKish input strings.

ezPart(ezMeasure[] new_measures)

Create an ezPart from an array of ezMeasure objects.

member functions

void add(ezMeasure measure)

Add an ezMeasure to the part.

void add(ezMeasure[] new_measures)

Add an array of ezMeasures to the part.

float beats()

Get the length of the part in beats (sum of all measure lengths)

ezPart copy()

Return a copy of the ezPart.

ezPart copy(int index, int length)

Return a copy of the ezPart that has a subset of the measures.

void duplicate(int index, int length, int n)

Duplicate a range of measures n times.

void duplicate(int index, int n)

Duplicate a measure n times.

void erase(int index)

Erase an ezMeasure from the part at a given index.

void erase(int index, int length)

Erase a range of ezMeasures from the part.

void insert(int index, ezMeasure new_measure)

Insert an ezMeasure into the part at a given index.

void insert(int index, string input)

Insert an ezMeasure into the part at a given index, using a SMucKish input string.

void insert(int index, ezMeasure[] new_measures)

Insert an array of ezMeasures into the part at a given index.

void insert(int index, string[] inputs)

Insert an array of ezMeasures into the part at a given index, using an array of SMucKish input strings.

ezMeasure[] measures()

Get the measures in the part, as an ezMeasure array.

ezMeasure[] measures(ezMeasure[] measures)

Set the measures in the part, using an ezMeasure array. Onsets are recomputed so the timeline stays contiguous.

void meter(float barLength)

Impose constant bar length on all measures in the part. Skips empty measures. Bar length is in beats (quarter = 1). Constant barLength may not align to musical barlines in mixed-meter parts. For large MIDI imports, calling meter() after import improves playback performance by splitting long measures.

void meter(float[] lengths)

Impose a list of bar lengths on the part. Skips empty measures. Uses lengths in order; when exhausted, repeats last.

void meter(float num, float denom)

Impose time signature on all measures. num/denom; denominator is note value (4=quarter, 8=eighth).

void meter(float[][] timeSigs)

Impose variable time signatures on all measures. Each element is [num, denom].

void meter(string sig)

Impose time signature from string (e.g. 4/4, 12/8) on all measures.

void meter(string[] sigs)

Impose variable time signatures from strings (e.g. [4/4, 3/4]) on all measures.

void normalizeNegativeOnsets()

Correct misplaced notes: move each note with onset < 0 to the measure that contains its absolute start time, or clamp to 0 in the first measure. Preserves absolute time; measure lengths and onsets are recomputed. Use only when notes were incorrectly placed (e.g. after import or manual mistakes). Do NOT call on parts that use negative onset intentionally for notes tied over the barline (continuation in the next measure); calling this would move those notes and change measure boundaries.

int polyphony()

Get the max polyphony needed for the whole part (max over all measures' polyphony).

void print()

Print the part.

void replace(int index, ezMeasure new_measure)

Replace an ezMeasure in the part at a given index with a new ezMeasure.

void replace(int index, string input)

Replace an ezMeasure in the part at a given index with a new ezMeasure, using a SMucKish input string.

void replace(int index, ezMeasure[] new_measures)

Replace a range of ezMeasures in the part with an array of new ezMeasures.

void replace(int index, int length, ezMeasure[] new_measures)

Replace a range of ezMeasures in the part with an array of new ezMeasures.

void replace(int index, int length, string[] inputs)

Replace a range of ezMeasures in the part with new ezMeasures, using an array of SMucKish input strings.

void replace(int index, string[] inputs)

Replace a range of ezMeasures in the part with new ezMeasures, using an array of SMucKish input strings.

void rest(int index)

Turn all notes in a measure at a given index into rests.

void rest(int index, int length)

Turn all notes in a range of measures into rests.

void splitMeasure(int measureIndex, float constantLength)

Split the measure at the given index into multiple measures by constant bar length. Replaces that measure with the result of measure.split(constantLength). Onsets are set to split-window starts (0, L, 2*L, ...) so bars align every constantLength beats. Skips empty measures. Errors if barLength <= 0.

void splitMeasure(int measureIndex, float[] lengths)

Split the measure at the given index into multiple measures by a list of bar lengths. Replaces that measure with the result of measure.split(lengths). Onsets are set to split-window starts so bars align to the given lengths. Skips empty measures. Errors if lengths array is empty.

string text()

Get the text annotation of the part.

string text(string value)

Set the text annotation of the part.


ezScore

inherits : Object

SMucK score object. An ezScore object contains one or more ezParts. Score contents can be set using the SMucKish input syntax, or by importing a MIDI file (notes, CC data). ezScore objects can be passed to an ezScorePlayer object for playback.

constructors

ezScore()

Default constructor, creates an empty score.

ezScore(string input)

Create an ezScore from a SMucKish input string or MIDI file. If the input argument is a MIDI filename (ending in .mid), the MIDI file is imported. Otherwise, the input string is interpreted as a SMucKish input string.

ezScore(string input, float bpm)

Create an ezScore from a SMucKish input string or MIDI file, with a specified BPM.

ezScore(ezPart[] new_parts)

Create an ezScore from an array of ezPart objects.

member functions

void add(ezPart part)

Add an ezPart to the score.

void add(string input)

Add an ezPart to the score, using a SMucKish input string.

void add(ezPart[] new_parts)

Add multiple ezParts to the score, using an array of ezParts.

void add(string[] inputs)

Add multiple ezParts to the score, using an array of SMucKish strings.

float beats()

Get the end of the score in beats (the last note's release point)

float bpm(float value)

Set the tempo in BPM (beats per minute) for the score.

float bpm()

Get the tempo in BPM (beats per minute) for the score.

dur duration()

Get the duration of the score in milliseconds.

void meter(float barLength)

Impose constant bar length on all measures in all parts. Skips empty measures. Bar length is in beats (quarter = 1). Constant barLength may not align to musical barlines in mixed-meter parts. Errors if barLength <= 0. For large MIDI imports, calling meter() after import improves playback performance by splitting long measures.

void meter(float[] lengths)

Impose variable bar lengths on all measures in all parts. Skips empty measures. Errors if lengths array is empty.

void meter(float num, float denom)

Impose time signature on all measures in all parts. num/denom; denominator is note value (4=quarter, 8=eighth). Errors if denom <= 0.

void meter(float[][] timeSigs)

Impose variable time signatures on all measures in all parts. Each element is [num, denom]. Errors if array empty or any denom <= 0.

void meter(string sig)

Impose time signature from string (e.g. 4/4, 12/8) on all measures in all parts.

void meter(string[] sigs)

Impose variable time signatures from strings (e.g. [4/4, 3/4]) on all measures in all parts.

ezPart[] parts()

Get the parts for the score as an ezPart array.

ezPart[] parts(ezPart[] parts)

Set the parts for the score, using an ezPart array.

int polyphony(int part)

Get the maximum polyphony for a given part.

void read(string filename)

Read a MIDI file into the ezScore object. Imports notes and CC events. For large files, call meter() after import to improve playback performance.

string text()

Get the text annotation of the score.

string text(string value)

Set the text annotation of the score.


ezCC

inherits : Object

MIDI control message (CC, Aftertouch, Pitch Bend) with onset time. Used in scores and playback alongside ezNote.

constructors

ezCC()

Default constructor for ezCC.

ezCC(int command, int channel, int data1, int data2, float onset)

Create ezCC. command: 11 = CC, 10 = aftertouch, 13 = channel pressure, 14 = pitch bend. channel: 0-15. data1, data2: 0-127.

member functions

int channel()

Return the channel: 0-15.

void channel(int channel)

Set the channel: 0-15.

int command()

Return the command byte: 11=CC, 10=aftertouch, 13=channel pressure, 14=pitch bend.

void command(int command)

Set the command byte: 11=CC, 10=aftertouch, 13=channel pressure, 14=pitch bend.

ezCC copy()

Return a copy of the ezCC.

int data1()

Return the first data byte: 0-127.

void data1(int data1)

Set the first data byte: 0-127.

int data2()

Return the second data byte: 0-127.

void data2(int data2)

Set the second data byte: 0-127.

int isAftertouch()

True if command is Polyphonic Aftertouch (10).

int isCC()

True if command is Control Change (11).

int isChannelPressure()

True if command is Channel Pressure (13).

int isPitchBend()

True if command is Pitch Bend (14).

int normalize2Byte()

Return 14-bit value from data1 (LSB) and data2 (MSB): (data2 << 7) | data1. Useful for pitch bend (0-16383).

float onset()

Return the onset time in beats.

void onset(float onset)

Set the onset time in beats.

static member functions

ezCC aftertouch(int channel, int noteNumber, int pressure, float onset)

Static factory method for creating a polyphonic aftertouch ezCC object. Set channel: 0-15, noteNumber: 0-127, pressure: 0-127, onset: time in beats.

ezCC cc(int channel, int controllerNum, int value, float onset)

Static factory method for creating a control change ezCC object. Set channel: 0-15, controllerNum: 0-127, value: 0-127, onset: time in beats.

ezCC channelPressure(int channel, int pressure, float onset)

Static factory method for creating a channel pressure ezCC object. Set channel: 0-15, pressure: 0-127, onset: time in beats.

ezCC expression(int channel, int value, float onset)

Static factory method for creating a expression ezCC object. Set channel: 0-15, value: 0-127, onset: time in beats.

ezCC modulation(int channel, int value, float onset)

Static factory method for creating a modulation wheel ezCC object. Set channel: 0-15, value: 0-127, onset: time in beats.

ezCC pan(int channel, int value, float onset)

Static factory method for creating a pan ezCC object. Set channel: 0-15, value: 0-127 (64=center), onset: time in beats.

ezCC pitchBend(int channel, int value, float onset)

Static factory method for creating a pitch bend ezCC object. Set channel: 0-15, value: 0-16383 (14-bit, 8192=center), onset: time in beats. Converts to data1 LSB, data2 MSB.

ezCC volume(int channel, int value, float onset)

Static factory method for creating a channel volume ezCC object. Set channel: 0-15, value: 0-127, onset: time in beats.