= 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.
"C#")) piano.visualize_note(Note(
Chord
objects can be visualized on the piano by passing a chord to visualize_chord
.
# Notes for a Cmaj7 chord
= Chord.from_short("Cmaj7")
chord 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.
= Scale("major")
major ="D") piano.visualize_scale(major, root
You can decide to visualize more octaves with the octs
parameter.
= Scale("double harmonic major")
double_harmonic_major ="C", octs=3) piano.visualize_scale(double_harmonic_major, root
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 "C", oct=5)) guitar.visualize_note(Note(
"Cmaj7")) guitar.visualize_chord(Chord.from_short(
"major"), root="C") guitar.visualize_scale(Scale(