Learn R Programming

soundgen (version 1.8.2)

modulationSpectrumFolder: Modulation spectrum per folder

Description

Extracts modulation spectra of all wav/mp3 files in a folder - separately for each file, without averaging. Good for saving plots of the modulation spectra and/or measuring the roughness of multiple files. See modulationSpectrum for further details.

Usage

modulationSpectrumFolder(
  myfolder,
  summaryFun = c("mean", "sd"),
  htmlPlots = TRUE,
  verbose = TRUE,
  amRes = 5,
  maxDur = 5,
  logSpec = FALSE,
  windowLength = 25,
  step = NULL,
  overlap = 80,
  wn = "hamming",
  zp = 0,
  power = 1,
  roughRange = c(30, 150),
  plot = FALSE,
  savePlots = FALSE,
  logWarp = NA,
  quantiles = c(0.5, 0.8, 0.9),
  kernelSize = 5,
  kernelSD = 0.5,
  colorTheme = c("bw", "seewave", "...")[1],
  xlab = "Hz",
  ylab = "1/KHz",
  width = 900,
  height = 500,
  units = "px",
  res = NA,
  ...
)

Arguments

myfolder

full path to target folder

summaryFun

functions used to summarize each acoustic characteristic, eg "c('mean', 'sd')"; user-defined functions are fine (see examples); NAs are omitted automatically for mean/median/sd/min/max/range/sum, otherwise take care of NAs yourself; if summaryFun = NULL, analyze() returns a list containing frame-by-frame values

htmlPlots

if TRUE, saves an html file with clickable plots

verbose

if TRUE, reports progress and estimated time left

amRes

target resolution of amplitude modulation, Hz. If NULL, the entire sound is analyzed at once (or in chunks maxDur s long), resulting in a single roughness value. Otherwise, roughness is calculated per frame, each selected to contain enough STFT windows to calculate roughness with precision given by amRes

maxDur

maximum allowed duration of a single sound, s (longer sounds are split, and their modulation spectra averaged)

logSpec

if TRUE, the spectrogram is log-transformed prior to taking 2D FFT

windowLength

length of FFT window, ms

step

you can override overlap by specifying FFT step, ms

overlap

overlap between successive FFT frames, %

wn

window type: gaussian, hanning, hamming, bartlett, rectangular, blackman, flattop

zp

window length after zero padding, points

power

raise modulation spectrum to this power (eg power = 2 for ^2, or "power spectrum")

roughRange

the range of temporal modulation frequencies that constitute the "roughness" zone, Hz

plot

if TRUE, produces a spectrogram with pitch contour overlaid

savePlots

if TRUE, saves plots as .png files

logWarp

the base of log for warping the modulation spectrum (ie log2 if logWarp = 2); set to NULL or NA if you don't want to log-warp

quantiles

labeled contour values, % (e.g., "50" marks regions that contain 50% of the sum total of the entire modulation spectrum)

kernelSize

the size of Gaussian kernel used for smoothing (1 = no smoothing)

kernelSD

the SD of Gaussian kernel used for smoothing, relative to its size

colorTheme

black and white ('bw'), as in seewave package ('seewave'), or any palette from palette such as 'heat.colors', 'cm.colors', etc

xlab

plotting parameters

ylab

plotting parameters

width

parameters passed to png if the plot is saved

height

parameters passed to png if the plot is saved

units

parameters passed to png if the plot is saved

res

parameters passed to png if the plot is saved

...

other graphical parameters passed to spectrogram

Value

If summaryFun is defined, returns a dataframe with just roughness per audio file, otherwise returns a list with the actual modulation spectra.

See Also

modulationSpectrum

Examples

Run this code
# NOT RUN {
ms = modulationSpectrumFolder('~/Downloads/temp', savePlots = TRUE,
                              kernelSize = 15)
ms
# }

Run the code above in your browser using DataLab