Basic summary functions for noteworthy strings.

tally_notes(notes, rests = FALSE)

tally_pitches(notes, rests = FALSE)

octaves(notes)

tally_octaves(notes)

distinct_notes(notes, rests = FALSE)

distinct_pitches(notes, rests = FALSE)

distinct_octaves(notes)

pitch_range(notes)

semitone_range(notes)

semitone_span(notes)

octave_range(notes)

octave_span(notes)

Arguments

notes

character, a noteworthy string, space-delimited or vector of individual entries.

rests

logical, include rests r and silent rests s in tally.

Value

varies by function

Details

These functions provide basic summaries of noteworthy strings.

Returned object depends on the nature of the function. It can be integers, logical, character. Results can be a vector of equal length of a single value summary.

Use the tally_* and distinct_* functions specifically for summaries of unique elements.

distinct_notes() and distinct_pitches() filter a noteworthy string to its unique elements, respectively. These functions return another noteworthy string.

*_span functions are just the size of a range, e.g., semitone_range() and semitone_span().

Examples

x <- "r s e_2 a_, c#f#a#"
tally_notes(x)
#> # A tibble: 5 × 2
#>   note      n
#>   <chr> <int>
#> 1 c#        1
#> 2 e_        1
#> 3 f#        1
#> 4 a_        1
#> 5 a#        1
tally_pitches(x)
#> # A tibble: 5 × 2
#>   pitch     n
#>   <chr> <int>
#> 1 e_2       1
#> 2 a_,       1
#> 3 c#        1
#> 4 f#        1
#> 5 a#        1
octaves(x)
#> [[1]]
#> [1] NA
#> 
#> [[2]]
#> [1] NA
#> 
#> [[3]]
#> [1] 2
#> 
#> [[4]]
#> [1] 2
#> 
#> [[5]]
#> [1] 3 3 3
#> 
tally_octaves(x)
#> # A tibble: 2 × 2
#>   octave     n
#>    <int> <int>
#> 1      2     2
#> 2      3     3
distinct_notes(x)
#> <Noteworthy string>
#>   Format: space-delimited time
#>   Values: d_ e_ g_ a_ b_
distinct_pitches(x)
#> <Noteworthy string>
#>   Format: space-delimited time
#>   Values: e_, a_, d_ g_ b_
distinct_octaves(x)
#> [1] 2 3

pitch_range(x)
#> [1] "e_," "b_" 
semitone_range(x)
#> [1] 39 58
semitone_span(x)
#> [1] 19
octave_range(x)
#> [1] 2 3
octave_span(x)
#> [1] 1