addNote method
Add notes to the MIDIFile object
:param track: The track to which the note is added.
:param channel: the MIDI channel to assign to the note. Integer, 0-15
:param pitch: the MIDI pitch number Integer, 0-127
.
:param time: the time at which the note sounds. The value can be either
quarter notes Float, or ticks Integer
. Ticks may be specified by
passing eventtime_is_ticks=True to the MIDIFile constructor.
The default is quarter notes.
:param duration: the duration of the note. Like the time argument, the
value can be either quarter notes Float, or ticks Integer
.
:param volume: the volume (velocity) of the note. Integer, 0-127
.
:param annotation: Arbitrary data to attach to the note.
The annotation
parameter attaches arbitrary data to the note. This
is not used in the code, but can be useful anyway. As an example,
I have created a project that uses MIDIFile to write
csound <http:///csound.github.io/>
orchestra files directly from the
class EventList
.
Implementation
/// :param track: The track to which the note is added.
/// :param channel: the MIDI channel to assign to the note. [Integer, 0-15]
/// :param pitch: the MIDI pitch number [Integer, 0-127].
/// :param time: the time at which the note sounds. The value can be either
/// quarter notes [Float], or ticks [Integer]. Ticks may be specified by
/// passing _eventtime_is_ticks=True to the MIDIFile constructor.
/// The default is quarter notes.
/// :param duration: the duration of the note. Like the time argument, the
/// value can be either quarter notes [Float], or ticks [Integer].
/// :param volume: the volume (velocity) of the note. [Integer, 0-127].
/// :param annotation: Arbitrary data to attach to the note.
/// The ``annotation`` parameter attaches arbitrary data to the note. This
/// is not used in the code, but can be useful anyway. As an example,
/// I have created a project that uses MIDIFile to write
/// `csound <http:///csound.github.io/>`_ orchestra files directly from the
/// class ``EventList``.
addNote(
{required int track,
required int channel,
required int pitch,
required num time,
required num duration,
int volume = 100,
annotation = ''}) {
if (this._header.numeric_format == 1) {
track += 1;
}
this._tracks[track].addNoteByNumber(
channel,
pitch,
this._time_to_ticks(time),
this._time_to_ticks(duration),
volume,
annotation: annotation,
insertion_order: this._event_counter,
);
this._event_counter += 1;
}