A Part object contains a set of Phrase objects to be played by a particular instrument. These phrase objects are played in parallel (i.e., simultaneously), and thus may overlap (according to their start times and durations). Even if the particular instrument does not allow for polyphony (e.g., a flute), a part using this instrument can have different simultaneous melodies. In other words, a part can be thought of as a group of several instruments of the same type (e.g., flutes), each playing a different melody (a phrase).
There are 128 different instruments to pick 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’s audio system. 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.
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).
|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.|
You can create a Part as follows:
p = Part("An example flute part", FLUTE, 0)
This creates a Part p 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.
Once a part has been created, the following functions are available:
|p.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.|
|p.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.|
|p.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.|
|p.empty()||Removes all phrases from this part.|
|p.getChannel()||Returns the channel for this part.|
|p.getEndTime()||Returns the part’s end time (a float).|
|p.getInstrument()||Returns the part’s instrument number (MIDI program change).|
|p.getPhraseList()||Returns the part’s phrases (a list).|
|p.getSize()||Returns the number of phrases in this part.|
|p.getTempo()||Returns the part’s tempo (a float).|
|p.getTitle()||Returns the part’s title (a string).|
|p.getVolume()||Returns the part’s volume (0 – 127).|
|p.setChannel(channel)||Sets the MIDI channel for this part (0 – 15).|
|p.setInstrument(instrument)||Set instrument number (MIDI program change) for this part (0 – 127).|
|p.setPan(pan)||Sets the pan position for all notes in this part (0.0 – 1.0).|
|p.setTempo(tempo)||Sets the part’s tempo (a float).|
|p.setTitle(title)||Give the part a new title (a string).|
|p.setDynamic(dynamic)||Set the part’s dynamic (0 – 127).|