sparse_fr_spectrum: Sparse frequency spectrum

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

sparse_fr_spectrumR Documentation

Sparse frequency spectrum

Description

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

Usage

sparse_fr_spectrum(x, ...)

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

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

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

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

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

Arguments

x

Input sonority.

  • Numeric vectors will be treated as vectors of MIDI note numbers, and expanded into their implied harmonics.

  • Two-element lists will be treated as finalised spectra. The first element should be labelled "frequency", and correspond to a numeric vector of frequencies; the second element should be labelled "amplitude", and correspond to a numeric vector of amplitudes.

...

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.

Details

A sparse frequency spectrum comprises a finite set of spectral components, each defined by a frequency (in Hz) and an amplitude (expressed in arbitrary units, but with the fundamental frequencies of chord pitches typically taking the value 1).

Value

An object of class sparse_fr_spectrum.


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