getDuration | R Documentation |
Returns the duration of one or more audio files (mostly useful for running on
an entire folder). If threshold
is set, it also removes the leading
and trailing silences or near-silences, thus returning the duration of
relatively loud central fragments of each sound. Silences are located based
on the amplitude of root mean square (RMS) amplitude with
getRMS
. Note that the threshold is set relative to the observed
maximum RMS, just as in analyze
. This means that even very
quiet sounds are not treated as nothing but silence.
getDuration(
x,
samplingRate = NULL,
silence = 0.01,
rms = list(windowLength = 20, step = 5),
reportEvery = NULL,
cores = 1
)
x |
path to a folder, one or more wav or mp3 files c('file1.wav', 'file2.mp3'), Wave object, numeric vector, or a list of Wave objects or numeric vectors |
samplingRate |
sampling rate of |
silence |
leading and trailing sections quieter than this proportion of
maximum RMS amplitude are removed when calculating
|
rms |
a list of control parameters passed to |
reportEvery |
when processing multiple inputs, report estimated time left every ... iterations (NULL = default, NA = don't report) |
cores |
number of cores for parallel processing |
Returns duration
(s) and duration_noSilence
(duration
without leading and trailing silences).
analyze
getLoudness
s = c(rep(0, 550), runif(400, -1, 1), rep(0, 50))
osc(s, samplingRate = 1000)
# true duration_noSilence is 400 ms
getDuration(s, samplingRate = 1000, silence = .01)
getDuration(s, samplingRate = 1000, silence = .1,
rms = list(windowLength = 5, step = 1))
## Not run:
d = getDuration('~/Downloads/temp')
hist(d$duration - d$duration_noSilence)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.