Last chance! 50% off unlimited learning
Sale ends in
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.
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)
a vector of f0 per glottal cycle, Hz
maximum number of harmonics to generate (very weak
harmonics with amplitude < throwaway
will be discarded)
basic rolloff at a constant rate of rolloff
db/octave
(exponential decay). See getRolloff
for more details
basic rolloff changes from lower to upper
harmonics (regardless of f0) by rolloffOct
dB/oct. For
example, we can get steeper rolloff in the upper part of the spectrum
an optional quadratic term affecting only the
first rolloffParabHarm
harmonics. The middle harmonic
of the first rolloffParabHarm
harmonics is amplified or
dampened by rolloffParab
dB relative to the basic
exponential decay.
the number of harmonics affected by
rolloffParab
quadratic adjustment is applied only up to
rolloffParabCeiling
, Hz. If not NULL, it overrides
rolloffParabHarm
rolloff changes linearly with f0 by
rolloffKHz
dB/kHz. For ex., -6 dB/kHz gives a 6 dB
steeper basic rolloff as f0 goes up by 1000 Hz
The "neutral" frequency, at which no adjustment of rolloff
takes place regardless of rolloffKHz
discard harmonics and noise that are quieter than this number (in dB, defaults to -120) to save computational resources
sampling rate (needed to stop at Nyquist frequency and for plotting purposes)
if TRUE, produces a plot
Returns a matrix of amplitude multiplication factors for adjusting the amplitude of harmonics relative to f0. Each row of output contains one harmonic, and each column contains one glottal cycle.
# NOT RUN {
# 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)
# }
Run the code above in your browser using DataLab