sparse_pi_spectrum: Sparse pitch spectrum

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

sparse_pi_spectrumR Documentation

Sparse pitch spectrum

Description

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

Usage

sparse_pi_spectrum(x, ...)

## S3 method for class 'sparse_pi_spectrum'
sparse_pi_spectrum(x, ...)

## S3 method for class 'sparse_fr_spectrum'
sparse_pi_spectrum(x, ...)

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

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

## S3 method for class 'pi_chord'
sparse_pi_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.

amplitude

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

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.

Details

A sparse pitch spectrum describes an input sonority as a finite set of spectral components, each defined by a pitch (expressed on the MIDI pitch scale) and an amplitude (expressed in arbitrary units, but with the fundamental frequencies of chord pitches typically taking the value 1).

A sparse pitch 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_pi_spectrum(c(60, 64, 67)) will create a sparse pitch spectrum by expanding the harmonics implied by a C major triad.

A sparse pitch spectrum can also be created directly by providing a list with two elements, the first being labelled "pitch", 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_pi_spectrum(list(pitch = c(60, 72, 79), amplitude = c(3, 2, 1))).

Value

An object of class sparse_pi_spectrum.


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