R/2-add-pedal.R

Defines functions add.Pedal

Documented in add.Pedal

#' @keywords internal
#' @export
add.Pedal <- function(object, music) {
  to <- object[["to"]]
  i <- object[["i"]]
  j <- object[["j"]]
  lines <- music[["lines"]]
  notes <- music[["notes"]]

  # Validation
  check_add_to(to, lines, object)
  line <- normalize_to(to, lines)
  check_i(i, line, notes)
  check_i(j, line, notes)

  # Normalization
  names(object)[names(object) == "to"] <- "line"
  object[["line"]] <- line

  . <- sort(c(i, j))
  object[["i"]] <- .[1]
  object[["j"]] <- .[2]

  # Construction
  music[["pedals"]] <- update_2d(music[["pedals"]], object)
  music
}
flujoo/gm documentation built on July 12, 2024, 4:56 p.m.