getRolloff: Control rolloff of harmonics

Description Usage Arguments Value Examples

View source: R/sourceSpectrum.R

Description

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.

Usage

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)

Arguments

pitch_per_gc

a vector of f0 per glottal cycle, Hz

nHarmonics

maximum number of harmonics to generate (very weak harmonics with amplitude < throwaway will be discarded)

rolloff

basic rolloff at a constant rate of rolloff db/octave (exponential decay). See getRolloff for more details

rolloffOct

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

rolloffParab

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.

rolloffParabHarm

the number of harmonics affected by rolloffParab

rolloffParabCeiling

quadratic adjustment is applied only up to rolloffParabCeiling, Hz. If not NULL, it overrides rolloffParabHarm

rolloffKHz

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

baseline

The "neutral" frequency, at which no adjustment of rolloff takes place regardless of rolloffKHz

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

Value

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.

Examples

 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)

tatters/soundgen_beta documentation built on May 14, 2019, 9 a.m.