Skip to content
'voicer', R package: Finding optimal voicings for chord sequences
R C++ TeX
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
src
tests
.Rbuildignore
.gitignore
.travis.yml
DESCRIPTION
LICENSE
LICENSE.md
NAMESPACE
NEWS.md
README.Rmd
README.md
appveyor.yml
voiceR.Rproj

README.md

voicer

lifecycle Travis build status AppVeyor build status Coverage status DOI

Chord voicing is the art of assigning pitch heights to pitch classes. This package, voicer, optimises the voicings of chord sequences according to an objective cost function. The Viterbi algorithm is used to guarantee solution optimality.

Paper

Harrison, P. M. C., & Pearce, M. T. (2019). A computational model for the analysis and generation of chord voicings. PsyArXiv. doi:10.31234/osf.io/wrgj7

Installation

To install from GitHub:

if (!require(devtools)) install.packages("devtools")
devtools::install_github("pmcharrison/voicer")

Example usage

voice is the main function to use. We pass voice vectors of chords as created by the hrep package. Important chord representations from the hrep package are:

  • pc_set() - create a pitch-class set (unordered pitch classes from 0 to 11)
  • pc_chord() - create a pitch-class chord (a pitch-class set where the bass note is identified)
  • pi_chord() - create a pitch chord (pitches as MIDI note numbers)
library(hrep)
library(magrittr)
library(voicer)

pc_set(c(0, 4, 7))
#> Pitch-class set: 0 4 7
pc_chord(c(4, 0, 7))
#> Pitch-class chord: [4] 0 7
pi_chord(c(60, 64, 67))
#> Pitch chord: 60 64 67

Using the function vec from the hrep package, we combine lists of chords into typed vectors.

x <- list(pc_set(c(0, 4, 7)), 
          pc_set(c(0, 5, 9)),
          pc_set(c(2, 7, 11)), 
          pc_set(c(0, 4, 7))) %>% vec("pc_set")
x
#> Vector of type 'pc_set', length = 4

We can then pass the resulting object to voice.

y <- voice(x)
y 
#> Vector of type 'pi_chord', length = 4
as.list(y)
#> [[1]]
#> Pitch chord: 48 52 67 72
#> 
#> [[2]]
#> Pitch chord: 48 53 69 72
#> 
#> [[3]]
#> Pitch chord: 50 55 67 71
#> 
#> [[4]]
#> Pitch chord: 52 55 67 72

We can do the same for vectors of type pc_chord.

list(pc_chord(c(0, 4, 7)), 
     pc_chord(c(9, 0, 5)),
     pc_chord(c(7, 2, 11)), 
     pc_chord(c(0, 4, 7))) %>% 
  vec("pc_chord") %>% 
  voice() %>% 
  as.list()
#> [[1]]
#> Pitch chord: 60 64 67 72
#> 
#> [[2]]
#> Pitch chord: 57 60 65 72
#> 
#> [[3]]
#> Pitch chord: 55 62 67 71
#> 
#> [[4]]
#> Pitch chord: 60 64 67 72

See ?voice for more details.

You can’t perform that action at this time.