s = soundgen() + .25 # with added DC offset
# osc(s)
r = getRMS(s, samplingRate = 16000, from = .05,
windowLength = 40, overlap = 50, killDC = TRUE,
plot = TRUE, type = 'l', lty = 2, main = 'RMS envelope')
r
# short window = jagged envelope
r = getRMS(s, samplingRate = 16000,
windowLength = 5, overlap = 0, killDC = TRUE,
plot = TRUE, col = 'blue', pch = 13, main = 'RMS envelope')
# stereo
wave_stereo = tuneR::Wave(
left = runif(1000, -1, 1) * 16000,
right = runif(1000, -1, 1) / 3 * 16000,
bit = 16, samp.rate = 4000)
getRMS(wave_stereo)$summary
getRMS(wave_stereo, stereo = 'right')$summary
getRMS(wave_stereo, stereo = 'average')$summary
getRMS(wave_stereo, from = .05,
stereo = 'both', plot = TRUE)$summary
if (FALSE) {
r = getRMS('~/Downloads/temp', savePlots = TRUE)
r$summary
# Compare:
analyze('~/Downloads/temp', pitchMethods = NULL,
plot = FALSE)$summary$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