The ‘Note’ class

class music_essentials.chord.Chord(root_note)

Representation of group of notes that are played together.

__init__(root_note)

Create a new Chord.

Once the Chord has been created, additional notes can be added using add_note

Args:
root_note: Note
The first note to add to the chord.
Returns:
Chord
A new chord object, with a single note added.
Raises:
TypeError:
If anything but an instance of Note is provided for root_note.
Examples:
>>> c = Chord(Note.from_note_string('C4'))
>>> print(c)
C4
>>> c = Chord(Note.from_note_string('C4'))
>>> c.add_note(Note.from_note_string('E4'))
>>> print(c)
C4+E4
>>> c = Chord(5.5)
Expected Note for root note, got '5.5'
classmethod build_chord(tonic_key, chord_number, chord_type)

Build a chord.

Specify the tonic key, the chord number, and the type of chord to build. Receive an ordered list of the notes in the chord.

tonic_key : Note
They key in which the chord should be built
chord_number : str
The scale degree to start building the chord on
chord_type : str

The tonality of the key to build the cord in. Can be one of:

  • ‘major’/’maj’: Major tonality.
  • ‘minor’/’min’: Minor tonality.
list
The list of notes in the chord, in ascending order.
>>> c = Chord.build_chord(Note.from_note_string('C4'), 'I', 'major')
>>> print(c)
>>> C4+E4+G4
>>> c = Chord.build_chord(Note.from_note_string('C4'), 'V', 'major')
>>> print(c)
>>> G4+B4+D5
>>> c = Chord.build_chord(Note.from_note_string('C4'), 'IV', 'minor')
>>> print(c)
>>> F4+A4b+C5
root()

Get the root (i.e., lowest) note of the chord.

Returns:
Note
The lowest note of the chord.
Examples:
>>> c = Chord(Note.from_note_string('E4'))
>>> print(c.root())
E4
>>> c = Chord(Note.from_note_string('E4'))
>>> c.add_note(Note.from_note_string('D4'))
>>> print(c.root())
D4
add_note(new_note)

Add another note to the chord.

Args:
new_note : Note
The note to add.
Raises:
TypeError:
If new_note is not an instance of Note.
Examples:
>>> c = Chord(Note.from_note_string('C4'))
>>> c.add_note(Note.from_note_string('E4'))
>>> print(c)
C4+E4
>>> c = Chord(Note.from_note_string('G4'))
>>> c.add_note(Note.from_note_string('E4'))
>>> c.add_note(Note.from_note_string('D4'))
>>> print(c)
D4+E4+G4
__str__()

Get a string representation of the chord.

Returns:
str
A string representation of the chord, in the form <note_1>+<note_2>+...+<note_n>.