Create a Line
object to represent a musical line. In gm,
the musical line is the basic unit of music. It appears in different
forms, such as voices, staffs, and parts in music scores.
Line(
pitches = NULL,
durations = NULL,
tie = NULL,
name = NULL,
as = NULL,
to = NULL,
after = NULL,
bar = NULL,
offset = NULL
)
A list or vector which represents the pitches
of a musical line. The items of pitches
can be
single characters like "C4"
, which represent pitch notations,
single integers between 12 and 127, which represent MIDI note numbers,
single NA
s, which represent rests, and
vectors of pitch notations and MIDI note numbers, which represent chords.
If not provided, the default value is NA
. If pitches
and durations
are not of the same length, the shorter one will be recycled.
pitches
and durations
can not both be empty.
A list or vector which represents the
durations of a musical line. The items of durations
can be
single numbers, which represent note lengths, and
single characters like "quarter"
, which represent duration notations.
If not provided, the default value is 1.
Deprecated. Was used to add ties to notes. Please use
Tie()
instead.
Optional. A single character which represents the name of the musical line. When adding components to a musical line, it can be referred to by its name.
Optional. A single character which can be "part"
, "staff"
,
"voice"
, and "segment"
. It specifies how the musical line appears in
the music score. The default value is "part"
.
Optional. A single character or integer, which represents the name or row number of a reference musical line to which to add the current musical line. By default, the musical line will be added at the end of the score.
Optional. A single logical which indicates whether to add the
musical line after or before the reference musical line. The default value
is TRUE
.
Optional. A positive integer, which indicates the number of the measure where to add the musical line. By default, the musical line will be added at the first measure.
Optional. A non-negative number,
which indicates the position in a measure where to add the musical line.
The default value is 0
.
A list of class Line
.
+.Music()
for adding a musical line to a Music
object.
# Create a musical line
line <- Line(c("C4", "D4", "E4"))
line
#> Line
#>
#> * of notes:
#>
#> # A tibble: 3 × 6
#> i j pitch midi duration length
#> <int> <int> <chr> <int> <chr> <dbl>
#> 1 1 NA C4 60 NA 1
#> 2 2 NA D4 62 NA 1
#> 3 3 NA E4 64 NA 1
# Add it to a music
music <- Music() + Meter(4, 4) + line
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
#>
# Generate the music score
if (interactive()) {
show(music)
}