View source: R/modulationSpectrum_utilities.R
getRough | R Documentation |
Internal soundgen function
getRough(m, roughRange = c(30, 150), roughMean = NULL, roughSD = NULL)
m |
numeric matrix of non-negative values with colnames giving temporal modulation frequency |
roughRange |
the range of temporal modulation frequencies that constitute the "roughness" zone, Hz |
roughMean , roughSD |
the mean (Hz) and standard deviation (semitones) of
a lognormal distribution used to weight roughness estimates. If either is
null, roughness is calculated simply as the proportion of spectrum within
|
Helper function for calculating roughness - the proportion of energy / amplitude in the roughness range
Returns roughness in percent.
m = modulationSpectrum(soundgen(jitterDep = 2, addSilence = 0),
samplingRate = 16000)$original
# proportion within roughRange
plot(soundgen:::getRough(m, roughRange = c(30, Inf))[, 1:2])
plot(soundgen:::getRough(m, roughRange = c(30, 150))[, 1:2])
# lognormal weighting function instead of roughRange
plot(soundgen:::getRough(m, roughRange = NULL,
roughMean = 75, roughSD = 1)[, 1:2]) # narrow
plot(soundgen:::getRough(m, roughRange = NULL,
roughMean = 75, roughSD = 5000)[, 1:2]) # very broad
# lognormal weighting function truncated at roughRange
plot(soundgen:::getRough(m, roughRange = c(30, 150),
roughMean = 75, roughSD = 3)[, 1:2])
plot(soundgen:::getRough(m, roughRange = c(30, 150),
roughMean = 75, roughSD = 5000)[, 1:2])
# approaches proportion in roughRange as SD --> Inf
# a nice plot weighting by amplitude
r2 = soundgen:::getRough(m)
plot(r2$freq, r2$rough, cex = r2$amp ^ 2 + .25)
sum(r2$rough) # simple sum across all bands
sum(r2$rough * r2$amp / sum(r2$amp)) # amplitude-weighted mean
# log-amplitude-weighted mean
sum(r2$rough * log(r2$amp+1e-6) / sum(log(r2$amp+1e-6)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.