voice: Voice

Description Usage Arguments Details Value Note Examples

View source: R/voice.R

Description

Generates an optimized voicing for a chord sequence.

Usage

1
2
3
voice(x, opt = voice_opt(), fix_melody = rep(NA_integer_, times =
  length(x)), fix_content = lapply(x, function(...) integer()),
  fix_chords = vector("list", length(x)))

Arguments

x

Chord sequence to voice. This should take the form of a vec object from the hrep package. A vec object is essentially a typed list; here the type should be one of three chord representations from the hrep package, namely pc_chord, pc_set, or pi_chord. See Note for more information.

opt

A list of options as created by voice_opt.

fix_melody

A numeric vector specifying the desired melody notes (i.e. top line) for the voicing, as MIDI pitches. The ith element should correspond to the melody note for the ith chord of x. NA values mean that the melody is unconstrained.

fix_content

A list of potentially empty numeric vectors specifying pitches that must be included in the corresponding chords of x. Can be used to produce melodies internal to the texture.

fix_chords

A list of voicings to fix in advance within the generated result, each given as numeric vectors of MIDI pitches. A NULL element means that the voicing for the corresponding chord is unconstrained. Note that specifying a voicing manually overrides all other voicing options (e.g. range limits), and the voicing will be accepted even if it is incompatible with the corresponding element of x.

Details

By default, the algorithm optimizes the sum of the linear predictors for each chord transition. By setting the exp_cost, norm_cost, and log_cost arguments of voice_opt to TRUE, it is possible alternatively to optimize the probability of the sequence.

Value

A voiced chord sequence, represented as a vec object with type pi_chord. This object can be inspected using as.list.

Note

Voicing sequences of type pi_chord preserves the original bass pitch classes. The original doublings for each pitch class can also be preserved by setting dbl_change = TRUE in voice_opt.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
library(magrittr)
library(hrep)
chords <- list(
  pc_chord(c(0, 4, 7)),
  pc_chord(c(0, 5, 9)),
  pc_chord(c(2, 7, 11))
) %>%
  vec("pc_chord")
  
voice(chords, 
      voice_opt(min_notes = 3, max_notes = 3))
      
voice(chords, 
      voice_opt(min_notes = 3, max_notes = 3), 
      fix_melody = c(76, 77, 79))
      
voice(chords, 
      voice_opt(min_notes = 3, max_notes = 4), 
      fix_content = list(c(60, 72), c(65, 77), c(67, 79)))
      
voice(chords, 
      voice_opt(min_notes = 3, max_notes = 3), 
      fix_chords = list(NULL, c(53, 57, 60), NULL))  

pmcharrison/voicer documentation built on Dec. 17, 2020, 1:09 p.m.