# NOT RUN {
s = soundgen() + .25 # with added DC offset
osc(s)
r = getRMS(s, samplingRate = 16000,
windowLength = 40, overlap = 50, killDC = TRUE,
plot = TRUE, type = 'l', lty = 2, main = 'RMS envelope')
# short window = jagged envelope
r = getRMS(s, samplingRate = 16000,
windowLength = 5, overlap = 0, killDC = TRUE,
plot = TRUE, col = 'blue', pch = 13, main = 'RMS envelope')
# }
# NOT RUN {
r = getRMS('~/Downloads/temp', savePlots = '~/Downloads/temp/plots')
r$summary
# Compare:
analyze('~/Downloads/temp', pitchMethods = NULL,
plot = FALSE)$ampl_mean
# (per STFT frame, but should be very similar)
User-defined summary functions:
ran = function(x) diff(range(x))
meanSD = function(x) {
paste0('mean = ', round(mean(x), 2), '; sd = ', round(sd(x), 2))
}
getRMS('~/Downloads/temp', summaryFun = c('mean', 'ran', 'meanSD'))$summary
# }
Run the code above in your browser using DataLab