Create a Key
object to represent a key signature.
Key(key, bar = NULL, to = NULL, scope = NULL)
A single integer between -7 and 7, which indicates the number of flat or sharp symbols in the key signature.
Optional. A positive integer, which indicates the number of the measure where to add the key signature. By default, the key signature will be added at the first measure.
Optional. A single character or a single positive integer, which indicates the musical line where to add the key signature. By default, the key signature will be added to the whole music rather than some specific musical line.
Optional. A single character of "part"
or "staff"
,
which indicates whether to add the key signature to a whole part or
only some staff of the part. Only when to
is specified, can this
argument be specified. The default value is "part"
.
A list of class Key
.
+.Music()
for adding a key signature to a Music
object.
# Create a G major
g <- Key(1, to = 1)
g
#> Key G Major (E Minor)
#>
#> * to be added to the part containing Line 1
# Add it only to some part of a `Music`
music <-
Music() +
Meter(4, 4) +
Line(c("C4", "D4")) +
Line("G3") +
g
music
#> Music
#>
#> $meters
#> # A tibble: 1 × 6
#> bar number unit actual_number actual_unit invisible
#> <int> <int> <int> <int> <int> <lgl>
#> 1 1 4 4 4 4 FALSE
#>
#> $notes
#> # A tibble: 3 × 7
#> line i j pitch midi duration length
#> <int> <int> <int> <chr> <int> <chr> <dbl>
#> 1 1 1 NA C4 60 NA 1
#> 2 1 2 NA D4 62 NA 1
#> 3 2 1 NA G3 55 NA 1
#>
#> $lines
#> # A tibble: 2 × 7
#> part staff voice segment bar offset name
#> <int> <int> <int> <int> <int> <dbl> <chr>
#> 1 1 1 1 1 1 0 NA
#> 2 2 1 1 1 1 0 NA
#>
#> $keys
#> # A tibble: 1 × 5
#> line scope bar key name
#> <int> <chr> <int> <int> <chr>
#> 1 1 part 1 1 G/Em
#>
# Generate the music score
if (interactive()) {
show(music)
}