Skip to content

Note

Notes contain the simplest possible musical events, consisting of pitch, duration, etc.

The pitch can be a MIDI pitch or a frequency in hertz (8.17 to 12600.0). Pass REST for the value to make a silent note (a rest). When you create a note, you can also set the dynamic (volume), pan (stereo position), or length (sound duration).

Creating a Note

You can create a Note using the following functions:

Note(value, duration)
Note(value, duration, dynamic, pan, length)
Parameter Type Default Description
value int or float required A MIDI pitch from 0 to 127, or a frequency in hertz (8.17 to 12600.0) to reach pitches between the standard notes. Use REST for a rest.
duration int or float required How long the note lasts in the written score, as a float where 1.0 is a quarter note.
dynamic int 85 How loud the note is, from 0 to 127.
pan int or float 0.5 The stereo position, from 0.0 (left) through 0.5 (center) to 1.0 (right).
length int or float None How long the note actually sounds, in the same units as duration. Defaults to 90% of the duration, so notes sound distinct.

For example,

note = Note(A4, HN)

Functions

Once a Note note has been created, the following functions are available.

Function Description
note.getPitch() Return the note's pitch.
note.getDuration() Return how long the note lasts in the written score.
note.getDynamic() Return how loud the note is.
note.getPan() Return the note's stereo position.
note.getLength() Return how long the note actually sounds.
note.setPitch(pitch) Set the note's pitch.
note.setDuration(duration) Set how long the note lasts in the written score.
note.setDynamic(dynamic) Set how loud the note is.
note.setPan(pan) Set the note's stereo position.
note.setLength(length) Set how long the note actually sounds.
note.isRest() Report whether the note is a rest.
note.copy() Return a copy of the note.

When working with frequencies, the following functions may also be used:

Function Description
note.getFrequency() Return the note's pitch as a frequency.
note.setFrequency(frequency) Set the note's pitch from a frequency.
note.getPitchBend() Return the note's pitch bend, the gap between its pitch and its exact frequency.