-
Notifications
You must be signed in to change notification settings - Fork 0
Voices
So we've learned how to group Note
s into Measure
s, and now we're going to group Measure
s in a similar fashion - into Section
s.
The process is identical to adding a Note
to a Measure
:
#create Notes...
measure_one = Measure()
measure_two = Measure()
measure_three = Measure()
#add Notes to the Measures...
voice = Voice()
voice.add_measure(measure_one)
voice.add_measure(measure_two)
voice.add_measure(measure_three)
And in the same way as Note
s in Measure
s, the Measure
s will be written in the order they were added to the Voice
.
Again we see parallels to the additional functions in a Measure
. Using the Voice
we made above:
print(voice.get_number_of_measures()) # 3
retrieved_measure = voice.get_measure_at_index(2)
print(retrieved_measure.get_number_of_beats()) # prints the number of notes and rests in the third measure added
A new set of functions relate to a new field on Voice
: name
. This is not required, but we are able to set a unique name to each Voice
. When the MIDI file is placed into to a DAW, the name we set will show up as the name for the MIDI track, so it can be useful to quickly identify what each Voice
is.
voice_one.set_name('Trombone')
voice_two.set_name('that really quirky sound')
print(voice_one.get_name()) # Trombone
print(voice_two.get_name()) # that really quirky sound
Now we know how to make Note
s, how to group Note
s into Measures
, and how to group Measures
into a Voice
. In the next section, we will be - you guessed it - grouping Voice
s together into one unit: a Section
.