Create a Hairpin object to represent a crescendo or diminuendo symbol.

Hairpin(symbol, i, j, to = NULL, above = NULL)

Arguments

symbol

A single character, which can be "<" or ">". They represent crescendo and diminuendo respectively.

i, j

A single positive integer. They indicate the start and end position of the Hairpin object in a musical line.

to

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

above

Optional. A single logical, which indicates whether the Hairpin object should appear above or below the staff.

Value

A list of class Hairpin.

See also

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

Examples

# Create a crescendo
crescendo <- Hairpin("<", 1, 3)
crescendo
#> Crescendo 
#> 
#> * from position 1 to 3 

# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4", "E4")) + crescendo
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     1     3    NA E4       64 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   
#> 
#> $hairpins
#> # A tibble: 1 × 5
#>    line     i     j symbol above
#>   <int> <int> <int> <chr>  <lgl>
#> 1     1     1     3 <      FALSE
#> 

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