Working with Notes
The Note
class is the fundamental building block of the MusicTheory library. It represents a musical pitch with a specific name, alteration, and octave.
Understanding Notes
A note in music theory consists of three components:
- Note Name
One of the seven natural notes: C, D, E, F, G, A, B
- Alteration
Modifies the pitch: Double Flat (♭♭), Flat (♭), Natural (♮), Sharp (♯), Double Sharp (♯♯)
- Octave
The register of the note, following scientific pitch notation (Middle C = C4)
Creating Notes
Using the Constructor
The most explicit way to create a note:
Parsing from String
Parse notes from standard notation:
From MIDI Numbers
Convert MIDI note numbers to Note objects:
Note Properties
Basic Properties
Calculated Properties
Note Operations
Transposition
Transpose notes by intervals or semitones:
Enharmonic Equivalents
Get enharmonically equivalent notes (same pitch, different spelling):
Frequency and Tuning
The library uses A4 = 440 Hz as the standard tuning reference:
Common Patterns
Note Comparison
Notes can be compared for ordering:
Note Validation
Check if note properties are valid:
Working with Note Collections
Common operations with multiple notes:
Advanced Topics
Enharmonic Spelling
Understanding when to use sharps vs flats:
Octave Designation
The library follows scientific pitch notation:
C-1 to B-1: Sub-contra octave (MIDI 0-11)
C0 to B0: Contra octave (MIDI 12-23)
C1 to B1: Great octave (MIDI 24-35)
C2 to B2: Small octave (MIDI 36-47)
C3 to B3: One-line octave (MIDI 48-59)
C4 to B4: Two-line octave (Middle C) (MIDI 60-71)
C5 to B5: Three-line octave (MIDI 72-83)
C6 to B6: Four-line octave (MIDI 84-95)
C7 to B7: Five-line octave (MIDI 96-107)
C8 to B8: Six-line octave (MIDI 108-119)
C9 to G9: Seven-line octave (MIDI 120-127)