sparse_pc_spectrum: Sparse pitch-class spectrum

View source: R/sparse-pc-spectrum.R

sparse_pc_spectrumR Documentation

Sparse pitch-class spectrum

Description

This function represents an input object as a sparse pitch-class spectrum.

Usage

sparse_pc_spectrum(x, ...)

## S3 method for class 'sparse_fr_spectrum'
sparse_pc_spectrum(x, coherent = FALSE, ...)

## S3 method for class 'list'
sparse_pc_spectrum(x, ...)

## Default S3 method:
sparse_pc_spectrum(x, ...)

## S3 method for class 'pi_chord'
sparse_pc_spectrum(x, amplitude = 1, coherent = FALSE, ...)

Arguments

x

Input sonority.

...

Arguments passed on to expand_harmonics

num_harmonics

(Integerish scalar) Number of harmonics (including the fundamental) to which each tone should be expanded.

roll_off

(Numeric scalar) Parametrises the amount of amplitude roll-off in the harmonics, with greater values corresponding to higher roll-off.

digits

Number of digits to which each partial's MIDI pitch should be rounded.

label_harmonics

If TRUE, then the harmonics in the resulting spectrum are labelled with their harmonic numbers.

coherent

Whether the amplitudes from different spectral components should be combined assuming coherent summation, where the amplitudes simply add together (default is FALSE). Otherwise incoherent summation is used, where the amplitudes are squared, added, then square rooted.

amplitude

(Numeric vector) Vector of amplitudes to assign to each pitch. If a scalar value is provided, this value is assigned to all pitches

Details

A sparse pitch-class spectrum describes an input sonority as a finite set of spectral components, each defined by a pitch class (expressed as numbers in the range [0, 12)) and an amplitude (expressed in arbitrary units, but with the fundamental frequencies of chord pitches typically taking the value 1).

A sparse pitch-class spectrum is most easily created by coercion from a different chord representation. If a numeric vector is provided as the input, it is treated as a pi_chord representation, for example sparse_pc_spectrum(c(60, 64, 67)) will create a sparse pitch-class spectrum by expanding the harmonics implied by a C major triad.

A sparse pitch-class spectrum can also be created directly by providing a list with two elements, the first being labelled "pc", and the second labelled "amplitude", each of which being numeric vectors of the same length. In this case no harmonic expansion is performed. The first element will be taken as a vector of pitches, and the second element will be taken as a vector of corresponding amplitudes. For example, one might write sparse_pc_spectrum(list(pitch = c(0, 4, 7), amplitude = c(3, 1, 2))).

Value

An object of class sparse_pc_spectrum.


pmcharrison/hrep documentation built on Feb. 18, 2024, 2:33 a.m.