Skip to content
hrep - Harmony Representations (an R package)
R Other
  1. R 98.8%
  2. Other 1.2%
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R
data-raw
data
inst
man
tests
.Rbuildignore
.gitignore
.travis.yml
DESCRIPTION
LICENSE
LICENSE.md
NAMESPACE
NEWS.md
README.Rmd
README.md
appveyor.yml
hrep.Rproj

README.md

Representing harmony with the hrep package

lifecycle Travis build status AppVeyor build status Coverage status DOI

The hrep R package provides utilities for representing and manipulating chord sequences for perceptually informed harmony modelling. The available representations include symbolic representations, acoustic representations, and sensory representations. Integer encodings are defined for several symbolic representations, allowing the user to efficiently express chord sequences as sequences of integers.

Resources

Installation

The hrep package may be installed from GitHub as follows:

if (!requireNamespace("devtools")) install.packages("devtools")
devtools::install_github("pmcharrison/hrep")

Example usage

Chords may be defined as sequences of integers, with each integer corresponding to a pitch or a pitch class. The following chord defines a C major triad in first inversion:

library(hrep)
x <- pi_chord(c(52, 60, 67))
print(x)
#> Pitch chord: 52 60 67

From this symbolic representation, it is possible to derive various acoustic and sensory representations, such as:

  1. A wave:
plot(wave(x))

  1. A sparse pitch spectrum:
plot(sparse_pi_spectrum(x))

  1. A sparse pitch-class spectrum:
plot(sparse_pc_spectrum(x))

  1. A smooth pitch-class spectrum:
plot(smooth_pc_spectrum(x))

Chords can be translated to various symbolic representations, which can be encoded to integer formats. For example, here we convert the chord to the pitch-class chord representation, and then encode it to an integer.

pc_chord((x))
#> Pitch-class chord: [4] 0 7
as.integer(encode(pc_chord(x)))
#> [1] 8210

Similarly, the following code expresses the chord as a pitch-class set, and then encodes the pitch-class set as an integer.

pc_set(x)
#> Pitch-class set: 0 4 7
as.integer(encode(pc_set(x)))
#> [1] 145
You can’t perform that action at this time.