Create a Clef object to represent a clef.

Clef(sign, line = NULL, octave = NULL, to = NULL, bar = NULL, offset = NULL)

Arguments

sign

A single character, which can be "G", "F" or "C". Case insensitive.

line

Optional. A single integer, which depends on sign:

  • 1 or 2, if sign is "G";

  • an integer between 3 and 5, if sign is "F";

  • an integer between 1 and 5, if sign is "C".

octave

Optional. A single integer, which can be -1 or 1. octave can be specified only when

  • sign is "G" and line is 2, or

  • sign is "F" and line is 4.

to

Optional. A single character or a single positive integer, which indicates the musical line where to add the clef.

bar

Optional. A positive integer, which indicates the number of the measure where to add the clef. By default, the clef will be added at the first measure.

offset

Optional. A non-negative number, which indicates the clef's position in a measure. The default value is 0.

Value

A list of class Clef.

Details

See Wikipedia for more details.

See also

+.Music() for adding a Clef to a Music object.

Examples

# Create a bass clef
clef <- Clef("F")
clef
#> Bass Clef 

# Add the clef to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C3", "D3")) + clef
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: 2 × 7
#>    line     i     j pitch  midi duration length
#>   <int> <int> <int> <chr> <int> <chr>     <dbl>
#> 1     1     1    NA C3       48 NA            1
#> 2     1     2    NA D3       50 NA            1
#> 
#> $lines
#> # A tibble: 1 × 7
#>    part staff voice segment   bar offset name 
#>   <int> <int> <int>   <int> <int>  <dbl> <chr>
#> 1     1     1     1       1     1      0 NA   
#> 
#> $clefs
#> # A tibble: 1 × 7
#>    line   bar offset sign  clef_line octave name     
#>   <int> <int>  <dbl> <chr>     <int>  <int> <chr>    
#> 1     1     1      0 F             4     NA Bass Clef
#> 

# Generate the music score
if (interactive()) {
  show(music)
}