Part

A Part contains a set of Phrases to be played by a particular instrument.  These Phrases are played in parallel (i.e., simultaneously), and thus may overlap (according to their start times and durations).

There are 128 different instruments to select from.

Parts may have a title (a string).

Parts may also be assigned to one of sixteen MIDI channels (0 – 15) available on a standard computer.  Each MIDI channel is capable of playing any of the 128 different instruments possible, but only one at a time. So, it is important to keep parts using different instruments in different MIDI channels. If two parts are using the same instrument, they may be assigned to the same MIDI channel.

It should be noted that MIDI channel 9 is reserved for percussion sounds.  Regardless of a part’s selected instrument, if that part is assigned to MIDI channel 9, its notes will generate percussion sounds, based on the notes’ pitches.

The music library provides several functions to create musical parts.  It also provides several others to retrieve or modify existing parts.

Here are functions used to create parts.  Each of these functions creates a new Part object, so you need to save it in a variable (or other memory location).

 

Function Description
Part() Creates an empty part.
Part(instrument) Creates an empty part with the timbre of the specified instrument (0 – 127).
Part(instrument, channel) Creates an empty part with the timbre of the specified instrument (0 – 127), and using the specified MIDI channel (0 – 15).
Part(title, instrument, channel) Creates an empty part with the specified title (a string), with the timbre of the specified instrument (0 – 127), and using the specified MIDI channel (0 – 15).
Part(phrase) Creates a Part containing the specified phrase.

 

Below are functions used to retrieve and modify attributes of existing parts.  It is assumed that a part has already been created, for example, as follows:

 

 

This creates a part with a descriptive title, using instrument FLUTE (see Appendix A, for a complete list of instruments), and assigned to MIDI channel 0 of the computer’s audio system.  Again, you should assign parts with different instruments to different MIDI channels (0-8, and 10-15).  Remember that MIDI channel 9 is dedicated to percussive sounds, as explained above.

Function Description
part.addPhrase(phrase) Add a phrase to this part.  If the phrase does not have a specific start time, it is added to the end of the part.
part.addPhraseList(listOfPhrases) Adds the specified phrases (a list) to the part. If a phrase does not have a specific start time, it is added to the end of the part.
part.copy() Returns a new Part with the same phrases and attributes as part.  This is used to create a copy to be modified, while the original part is not affected.
part.empty() Removes all phrases from this part.
part.getChannel() Returns the channel for this part.
part.getEndTime() Returns the part’s end time (a float).
part.getInstrument() Returns the part’s instrument number (MIDI program change).
part.getPhraseList() Returns the part’s phrases (a list).
part.getSize() Returns the number of phrases in this part.
part.getTempo() Returns the part’s tempo (a float).
part.getTitle() Returns the part’s title (a string).
part.getVolume() Returns the part’s volume (0 – 127).
part.setChannel(channel) Sets the MIDI channel for this part (0 – 15).
part.setInstrument(instrument) Set instrument number (MIDI program change) for this part (0 – 127).
part.setPan(pan) Sets the pan position for all notes in this part (0.0 – 1.0).
part.setTempo(tempo) Sets the part’s tempo (a float).
part.setTitle(title) Give the part a new title (a string).
part.setDynamic(dynamic) Set the part’s dynamic (0 – 127).