Create a Velocity object to set some notes' velocities.

Velocity(velocity, to = NULL, i = NULL, j = NULL)

Arguments

velocity

A single integer between 0 and 127, which indicates the velocity to apply.

to

Optional. A single character or a single positive integer, which indicates the musical line where to apply the velocity. If not provided, the velocity will be applied to all notes.

i

Optional. A single positive integer, which represents the position of the velocity in a musical line.

j

Optional. A single positive integer, which represents the position of the velocity in a chord.

Value

A list of class Velocity.

See also

Examples

# Create a `Velocity`
velocity <- Velocity(10)
velocity
#> Velocity 10 
#> 
#> * to be applied to all notes 

# Add it to a `Music`
music <- Music() + Meter(4, 4) + Line(c("C4", "D4")) + velocity
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            1
#> 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   
#> 
#> $velocities
#> # A tibble: 1 × 4
#>    line     i     j velocity
#>   <int> <int> <int>    <int>
#> 1    NA    NA    NA       10
#> 

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