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)))
Run the code above in your browser using DataLab