Description Usage Arguments Value Examples
View source: R/sourceSpectrum.R
Harmonics are generated as separate sine waves. But we don't want each
harmonic to be equally strong, so we normally specify some rolloff function
that describes the loss of energy in upper harmonics relative to the
fundamental frequency (f0). getRolloff
provides flexible
control over this rolloff function, going beyond simple exponential decay
(rolloff
). Use quadratic terms to modify the behavior of a few lower
harmonics, rolloffOct
to adjust the rate of decay per
octave, and rolloffKHz
for rolloff correction depending on
f0. Plot the output with different parameter values and see examples below
and the vignette to get a feel for how to use getRolloff
effectively.
1 2 3 4 | getRolloff(pitch_per_gc = c(440), nHarmonics = 100, rolloff = -12,
rolloffOct = -2, rolloffParab = 0, rolloffParabHarm = 2,
rolloffParabCeiling = NULL, rolloffKHz = -6, baseline = 200,
throwaway = -120, samplingRate = 16000, plot = FALSE)
|
pitch_per_gc |
a vector of f0 per glottal cycle, Hz |
nHarmonics |
maximum number of harmonics to generate (very weak
harmonics with amplitude < |
rolloff |
basic rolloff at a constant rate of |
rolloffOct |
basic rolloff changes from lower to upper
harmonics (regardless of f0) by |
rolloffParab |
an optional quadratic term affecting only the
first |
rolloffParabHarm |
the number of harmonics affected by
|
rolloffParabCeiling |
quadratic adjustment is applied only up to
|
rolloffKHz |
rolloff changes linearly with f0 by
|
baseline |
The "neutral" frequency, at which no adjustment of rolloff
takes place regardless of |
throwaway |
discard harmonics and noise that are quieter than this number (in dB, defaults to -120) to save computational resources |
samplingRate |
sampling rate (needed to stop at Nyquist frequency and for plotting purposes) |
plot |
if TRUE, produces a plot |
Returns a matrix of amplitude multiplication factors for adjusting the amplitude of harmonics relative fo f0. Each row of output contains one harmonic, and each column contains one glottal cycle.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | # steady exponential rolloff of -12 dB per octave
rolloff = getRolloff(pitch_per_gc = 150, rolloff = -12,
rolloffOct = 0, plot = TRUE)
# the rate of rolloff slows down with each octave
rolloff = getRolloff(pitch_per_gc = 150, rolloff = -12,
rolloffOct = 2, plot = TRUE)
# the rate of rolloff increases with each octave
rolloff = getRolloff(pitch_per_gc = 150, rolloff = -12,
rolloffOct = -2, plot = TRUE)
# variable f0: the lower f0, the more harmonics are non-zero
rolloff = getRolloff(pitch_per_gc = c(150, 800, 3000),
rolloffOct = 0, plot = TRUE)
# without the correction for f0 (rolloffKHz),
# high-pitched sounds have the same rolloff as low-pitched sounds,
# producing unnaturally strong high-frequency harmonics
rolloff = getRolloff(pitch_per_gc = c(150, 800, 3000),
rolloffOct = 0, rolloffKHz = 0, plot = TRUE)
# parabolic adjustment of lower harmonics
rolloff = getRolloff(pitch_per_gc = 350, rolloffParab = 0,
rolloffParabHarm = 2, plot = TRUE)
# rolloffParabHarm = 1 affects only f0
rolloff = getRolloff(pitch_per_gc = 150, rolloffParab = 30,
rolloffParabHarm = 1, plot = TRUE)
# rolloffParabHarm=2 or 3 affects only h1
rolloff = getRolloff(pitch_per_gc = 150, rolloffParab = 30,
rolloffParabHarm = 2, plot = TRUE)
# rolloffParabHarm = 4 affects h1 and h2, etc
rolloff = getRolloff(pitch_per_gc = 150, rolloffParab = 30,
rolloffParabHarm = 4, plot = TRUE)
# negative rolloffParab weakens lower harmonics
rolloff = getRolloff(pitch_per_gc = 150, rolloffParab = -20,
rolloffParabHarm = 7, plot = TRUE)
# only harmonics below 2000 Hz are affected
rolloff = getRolloff(pitch_per_gc = c(150, 600),
rolloffParab = -20, rolloffParabCeiling = 2000,
plot = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.