Create a Grace object. The Grace object can be added to an existing note or chord. It will turn the note or chord to a grace note or chord.

Grace(i, to = NULL, slash = NULL)

Arguments

i

A single positive integer, which represents the position of the Grace object in a musical line.

to

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

slash

Optional. A single logical, which indicates if there is a slash symbol on the grace note or chord. The default value is TRUE.

Value

A list of class Grace.

Details

A Grace object can not be added to a rest, tuplet, or note or chord that has a dotted duration. There must be a note or chord after the note or chord where the Grace object is added.

See also

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

Examples

# Create a `Grace`
grace <- Grace(1)
grace
#> Grace Note 
#> 
#> * to be added at position 1 

# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4"), c(0.5, 1)) + grace
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 C4       60 NA          0.5
#> 2     1     2    NA D4       62 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   
#> 
#> $graces
#> # A tibble: 1 × 3
#>    line     i slash
#>   <int> <int> <lgl>
#> 1     1     1 TRUE 
#> 

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