Create a Line object.

Line objects represent musical lines.

Line(
  pitches,
  durations,
  tie = NULL,
  name = NULL,
  as = NULL,
  to = NULL,
  after = NULL,
  bar = NULL,
  offset = NULL
)

Arguments

pitches

A list whose members are

  1. single pitch notations, like "C4", to represent the pitch contents of notes,

  2. single MIDI note numbers, like 60 or "60", also to represent the pitch contents of notes,

  3. single NAs to represent the pitch contents of rests, or

  4. vectors of pitch notations and MIDI note numbers, like c("C4", "61"), to represent the pitch contents of chords.

durations

A list whose members are

  1. single duration notations or their abbreviations, like "quarter" or just "q",

  2. single duration values, like 1, which is equivalent to "quarter", or

  3. Duration objects returned by tuplet(), which is used to create complex tuplets.

tie

Optional. A list of indices of argument pitches, which indicates at which positions to add ties.

name

Optional. A single character to name the Line object.

as

Optional. "part", "staff" or "voice", to specify the state of the Line object. The default value is "part".

to

Optional. An index or a Line name, which indicates with which Line object as the reference to add the Line object.

after

Optional. A single logical which indicates whether to add the Line object after or before a reference Line object. The default value is TRUE.

bar

Optional. A positive integer which indicates the number of the measure to which to insert the Line object. By default, a Line object will be inserted to the first measure.

offset

Optional. A duration value, sum of duration values or 0, which indicates the position in a measure, at which to insert the Line object. The default value is 0.

Value

A list with class Line.

See also

+.Music() for adding Line objects to a Music object.

vignette("gm", package = "gm") for more details about Line objects.

Examples

# create a Music object
m <- Music() + Meter(4, 4) + Line(list("C4"), list(8), name = "a")

# create a Line object
l <- Line(
  pitches = list("C5", "C5", "C5"),
  durations = list(1, 1, 1),

  # tie the first two notes
  tie = list(1),

  # add the Line as a voice
  as = "voice",

  # with Line "a" as reference
  to = "a",

  # before Line "a"
  after = FALSE,

  # insert the Line to bar 2 with offset 1
  bar = 2,
  offset = 1
)
l
#> Line
#> 
#> * of length 3
#> * of pitches C5, C5, C5
#> * of durations 1, 1, 1
#> * tied at position 1
#> * to be inserted in bar 2 with offset 1
#> * as a voice
#> * to be inserted before Line "a" 

# add the Line object to the Music object
m <- m + l
m
#> Music
#> 
#> Line 1
#> 
#> * as part 1 staff 1 voice 1
#> * of length 3
#> * of pitches C5, C5, C5
#> * of durations 1, 1, 1
#> * tied at position 1
#> * to be inserted in bar 2 with offset 1
#> 
#> Line 2
#> 
#> * as part 1 staff 1 voice 2
#> * of length 1
#> * of pitch C4
#> * of duration 8
#> * of name "a"
#> 
#> Meter 4/4 

if (interactive()) {
  show(m)
}