Note class

class Note(*args, note_str=None, note=None, octave=None, midi=None)

Can be created using keywords or implicitly. 1 string argument is mapped to note_str, 1 str and 1 int arguments are mapped to note and octave, 1 int argument is mapped to midi.

Parameters:
  • *args – When no keywords are specified, attempts to implicitly map to another parameter or parameters.
  • note_str (str) – The ASCII representation of a note ordered as [note letter][optional accidental][octave number], for example A4, C#2. Also accepts lower case, and normally unusual accidentals, for example fb4 would create a note E4.
  • note (str) – The note letter, or more formally the alphabetical representation of the pitch class. Accidentals are allowed. Can’t be used with note_str, but requires that octave be specified.
  • octave (int) – The octave of the note. Can’t be used with note_str, but requires that note be specified.
Raises:
  • TypeError – When note_str is called with either note or octave.
  • TypeError – When implicit variable mapping fails, or when not enough or too many variables are given.
note

The note letter, e.g. ‘A’ or ‘F#’.

pc

Pitch class, see https://en.wikipedia.org/wiki/Pitch_class#Integer_notation.

octave

Octave number for the note.

midi

MIDI note number.

freq

Frequency of the note in Hz.

pitch_class_map

dict Class attribute that maps pitch classes (pc) to note.

pitch_class_map_complement

dict Class attribute, the inverse of pitch_class_map.

classmethod _note_octave_to_midi(note, octave)

Used to get the midi value for a given note and octave.

classmethod _midi_to_note_octave(m)

Takes a MIDI number m and returns a note and octave.