Relational operators for comparing two noteworthy class objects.

# S3 method for noteworthy
==(e1, e2)

# S3 method for noteworthy
!=(e1, e2)

# S3 method for noteworthy
<(e1, e2)

# S3 method for noteworthy
<=(e1, e2)

# S3 method for noteworthy
>(e1, e2)

# S3 method for noteworthy
>=(e1, e2)

Arguments

e1

noteworthy string.

e2

noteworthy string.

Value

logical vector

Details

Equality is assessed in the same manner as used for note_sort() when sorting pitches. What matters is the underlying semitone value associated with each pitch, not the string notation such as flat vs. sharp (see pitch_is_identical()). When comparing chords, or a chord vs. a single note, comparison favors the root. Comparison is made of the respective lowest pitches, then proceeds to the next pitch if equal.

For these operators, the objects on the left and right side of the operator must both be noteworthy or an error is returned.

The examples include a chord with its pitches entered out of pitch order. This does not affect the results because pitches within chords are sorted before note to note comparisons at each timestep are done between e1 and e2.

Examples

x <- as_noteworthy("f# a d'f#'a' d'f#'a'")
y <- as_noteworthy("g_ b f#'a'd' d'd''")
x == y
#> [1]  TRUE FALSE  TRUE FALSE
x != y
#> [1] FALSE  TRUE FALSE  TRUE
x < y
#> [1] FALSE  TRUE FALSE  TRUE
x > y
#> [1] FALSE FALSE FALSE FALSE
x <= y
#> [1] TRUE TRUE TRUE TRUE
x >= y
#> [1]  TRUE FALSE  TRUE FALSE