Learn R Programming

soundgen (version 1.7.0)

getRMSFolder: RMS amplitude per folder

Description

A wrapper around getRMS that goes through all wav/mp3 files in a folder and returns either a list with RMS values per frame from each file or, if summary = TRUE, a dataframe with a single summary value of RMS per file. This summary value can be mean, max and so on, as per summaryFun.

Usage

getRMSFolder(
  myfolder,
  windowLength = 50,
  step = NULL,
  overlap = 70,
  normalize = TRUE,
  killDC = FALSE,
  windowDC = 200,
  summary = TRUE,
  summaryFun = "mean",
  verbose = TRUE
)

Arguments

myfolder

path to folder containing wav/mp3 files

windowLength

length of FFT window, ms

step

you can override overlap by specifying FFT step, ms

overlap

overlap between successive FFT frames, %

normalize

if TRUE, RMS amplitude is normalized to [0, 1]

killDC

if TRUE, removed DC offset (see also flatEnv)

windowDC

the window for calculating DC offset, ms

summary

if TRUE, returns only a single value of RMS per file

summaryFun

the function used to summarize RMS values across all frames (if summary = TRUE)

verbose

if TRUE, reports estimated time left

See Also

getRMS analyzegetLoudness

Examples

Run this code
# NOT RUN {
getRMSFolder('~/Downloads/temp')
# Compare:
analyzeFolder('~/Downloads/temp', pitchMethods = NULL,
              plot = FALSE)$ampl_mean
# (per STFT frame, but should be very similar)

User-defined summary functions:
difRan = function(x) diff(range(x))
getRMSFolder('~/Downloads/temp', summaryFun = c('mean', 'difRan'))

meanSD = function(x) {
  paste0('mean = ', round(mean(x), 2), '; sd = ', round(sd(x), 2))
}
getRMSFolder('~/Downloads/temp', summaryFun = 'meanSD')
# }

Run the code above in your browser using DataLab