soundgen (version 1.5.0)

getFormantDispersion: Get formant dispersion

Description

Internal soundgen function.

Usage

getFormantDispersion(formants, method = c("meanDispersion",
  "regression")[2], speedSound = 35400)

Arguments

formants

a character string like "aaui" referring to default presets for speaker "M1"; a vector of formant frequencies; or a list of formant times, frequencies, amplitudes, and bandwidths, with a single value of each for static or multiple values of each for moving formants

method

the method of estimating vocal tract length (see details)

speedSound

speed of sound in warm air, cm/s. Stevens (2000) "Acoustic phonetics", p. 138

Details

Estimates formant dispersion based on one or more formant frequencies.

Examples

Run this code
# NOT RUN {
soundgen:::getFormantDispersion(c(500, 1400, 2900, 3500),
  method = 'meanDispersion')
soundgen:::getFormantDispersion(c(500, 1400, 2900, 3500),
  method = 'regression')
soundgen:::getFormantDispersion(c(500, 1400, NA, 3500))
# }
# NOT RUN {
nIter = 100  # nIter = 10000 for better results
speedSound = 35400
out = data.frame(vtl = runif(nIter, 5, 70),
                 nFormants = round(runif(nIter, 1, 10)),
                 noise = runif(nIter, 0, .2),
                 vtl_est = rep(NA, nIter),
                 error = rep(NA, nIter))
for (i in 1:nIter) {
  a = 1:out$nFormants[i]
  formants = sort(speedSound * (2 * a - 1) / (4 * out$vtl[i]) * rnorm(n = length(a),
                                                                 mean = 1,
                                                                 sd = out$noise[i]))
  disp = soundgen:::getFormantDispersion(formants, method = 'fast')
  out$vtl_est[i] = speedSound / 2 / disp
  out$error[i] = (out$vtl[i] -  out$vtl_est[i]) / out$vtl[i]
}

library(ggplot2)
ggplot(out, aes(x = nFormants, y = error)) +
  geom_point(alpha = .1) +
  geom_smooth() +
  theme_bw()
ggplot(out, aes(x = noise, y = error)) +
  geom_point(alpha = .1) +
  geom_smooth() +
  theme_bw()
# }

Run the code above in your browser using DataCamp Workspace