knitr::opts_chunk$set( collapse = TRUE, message = FALSE, fig.width = 8, fig.height = 4, comment = "#>" )
library(ggplot2) library(dplyr) library(pichor)
Built-in data with information about some of the keys on a piano:
keys_chords
Details for drawing a diagram of a piano:
ggpiano(keys_chords)
Add key labels:
ggpiano(keys_chords, labels = TRUE)
Highlight certain keys:
keys_chords %>% highlight_keys(keys = c(7, 10, 14)) %>% ggpiano(labels = TRUE)
Work with chords:
chrd <- construct_chord_raw(root_tone = "F#", distances_rel = c(4, 3)) chrd as.character(chrd, brief = TRUE) chrd_Fsm <- construct_chord_minor(root_tone = "F#") chrd_Fsm as.character(chrd_Fsm, brief = TRUE) get_keys(chord = chrd_Fsm) get_keys_highest_tone(chord = chrd_Fsm, highest_tone = "A")
Highlight chords:
keys_chords %>% highlight_chord(chord = chrd_Fsm) %>% # root form by default ggpiano() keys_chords %>% highlight_chord(chord = chrd_Fsm, highest_tone = "A") %>% ggpiano()
Work with chord inversions:
chrd_Bm <- construct_chord_minor(root_tone = "B") get_keys(chord = chrd_Bm) get_keys_inversion(chord = chrd_Bm, inversion = 0) get_keys_inversion(chord = chrd_Bm, inversion = 1) get_keys_inversion(chord = chrd_Bm, inversion = 2)
Highlight chord inversions:
keys_chords %>% highlight_chord(chord = chrd_Bm, inversion = 0L) %>% ggpiano() keys_chords %>% highlight_chord(chord = chrd_Bm, inversion = 1L) %>% ggpiano() keys_chords %>% highlight_chord(chord = chrd_Bm, inversion = 2L) %>% ggpiano()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.