piano: PIANO

Description Usage Arguments Value Examples

Description

piano gives a data.frame of a piano which first (most left) key plays tone "A0". One can expand or shrink the keyboard by giving the piano's left.key, right.key. The returned dataframe then contains all keys between left.key and right.key, their colors, notes and played frequencies.

Usage

1
piano(left.key = 1, right.key = 97)

Arguments

left.key

left key of piano

right.key

right key of piano

Value

piano with keys, their colors, notes and frequencies

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
load.pkgs( c( "ggplot2", "ggthemes" ) )
piano( key.of.note( "C1" ), key.of.note( "C3" ) )
ggplot( piano( ) ) +
  geom_histogram( aes( note, -c( 1, .63 )[ match( color, c( "ivory", "ebony" ) ) ], fill = color ), stat = "identity" ) +
  geom_histogram( aes( note, .001 * frequency, alpha = note ), fill = "orange", stat = "identity" ) +
  scale_fill_manual( values = c( "#000000", "#f0f3f4" ), guide = F ) +
  geom_text( aes( note, label = note, col = color ), y = -.2, angle = 90 ) +
  annotate( geom = "text", x = 24.98, y = 3.02, xmin = 30, xmax = 60, ymin = 1, ymax = 5, label = "THE PIANO", col = "white", size = 20 )+
  annotate( geom = "text", x = 25,    y = 3,    xmin = 30, xmax = 60, ymin = 1, ymax = 5, label = "THE PIANO", col = "black", size = 20 )+
  scale_color_manual( values = c( "#f0f3f4", "#000000" ), guide = F ) +
  scale_alpha_discrete( range = c(.7,.1),guide = F ) +
  theme_solid( fill = "#405060" ) +
  theme(
    axis.text.x = element_blank( ),
    axis.title.x = element_blank( ),
    axis.text.y = element_blank( ),
    axis.title.y = element_blank( ),
    legend.key = element_blank( ) )

TPeschel/hlpr4life documentation built on May 9, 2019, 2:25 p.m.