Learn R Programming

soundgen (version 1.7.0)

getLoudnessFolder: Loudness per folder

Description

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

Usage

getLoudnessFolder(
  myfolder,
  windowLength = 50,
  step = NULL,
  overlap = 50,
  SPL_measured = 70,
  Pref = 2e-05,
  spreadSpectrum = TRUE,
  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, %

SPL_measured

sound pressure level at which the sound is presented, dB

Pref

reference pressure, Pa

spreadSpectrum

if TRUE, applies a spreading function to account for frequency masking

summary

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

summaryFun

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

verbose

if TRUE, reports estimated time left

See Also

getLoudness getRMS analyze

Examples

Run this code
# NOT RUN {
getLoudnessFolder('~/Downloads/temp1')
# Compare:
analyzeFolder('~/Downloads/temp1', pitchMethods = NULL,
              plot = FALSE)$loudness_mean
# (per STFT frame; should be very similar, but not identical unless silence =
0, because # analyze() discards frames considered silent)

# custom summaryFun
difRan = function(x) diff(range(x))
getLoudnessFolder('~/Downloads/temp', summaryFun = c('mean', 'difRan'))

# save loudness values per frame without summarizing
l = getLoudnessFolder('~/Downloads/temp', summary = FALSE)
# }

Run the code above in your browser using DataLab