piano = Piano()
piano()Visualization
Base
Here we will create an Instrument base class to for code reusability.
Instrument
Instrument ()
Initialize self. See help(type(self)) for accurate signature.
Piano
The Piano object is the basic piano visualization on which we can place Note, Interval, Chord and Scale objects.
Piano
Piano ()
Initialize self. See help(type(self)) for accurate signature.
Initialization
To get an empty piano, just call on an initialized Piano object without arguments.
Highlighting
We can highlight single Note objects with the visualize_note method.
For example, here we highlight the C# notes on the piano.
piano.visualize_note(Note("C#"))Chord objects can be visualized on the piano by passing a chord to visualize_chord.
# Notes for a Cmaj7 chord
chord = Chord.from_short("Cmaj7")
chord.notes[C4, E4, G4, B4]
piano.visualize_chord(chord)A scale can be highlighted by calling visualize_scale with a Scale object and a root note.
major = Scale("major")
piano.visualize_scale(major, root="D")You can decide to visualize more octaves with the octs parameter.
double_harmonic_major = Scale("double harmonic major")
piano.visualize_scale(double_harmonic_major, root="C", octs=3)Guitar
Just like with Piano we can visualize Note, Chord and Scale objects on a guitar fretboard.
Guitar
Guitar ()
Initialize self. See help(type(self)) for accurate signature.
guitar = Guitar()
guitar.visualize_note(Note("C", oct=5))guitar.visualize_chord(Chord.from_short("Cmaj7"))guitar.visualize_scale(Scale("major"), root="C")