View source: R/wrassp_zcrana.R
zcrana | R Documentation |
Analysis of the averages of the short-term positive and
negative zero-crossing rates of the signal in listOfFiles
using the libassp C library
\insertCites5hsuperassp function. If toFile
is TRUE
, the results will be written to an output fil in the SSFF binary format, with the
same name as the input file, but with an extension .zcr and with a track named 'ZCRHz'.
zcrana(
listOfFiles = NULL,
beginTime = 0,
centerTime = FALSE,
endTime = 0,
windowShift = 5,
windowSize = 25,
toFile = TRUE,
explicitExt = "zcr",
outputDirectory = NULL,
assertLossless = NULL,
logToFile = FALSE,
convertOverwrites = FALSE,
keepConverted = FALSE,
verbose = TRUE
)
listOfFiles |
vector of file paths to be processed by function |
beginTime |
the time point (in seconds) of the start of the analysed
interval. A NULL or 0 is interpreted as the start of the signal file.
If a vector of time points is supplied, the length of that vector needs
to correspond with the length of |
centerTime |
sets a single-frame analysis time point (in seconds).
Overrides |
endTime |
the time point (in seconds) of the end of the analysed
interval. A NULL or 0 is interpreted as the end of the signal file.
If a vector of time points is supplied, the length of that vector needs
to correspond with the length of |
windowShift |
the amount of time (in ms) that the analysis window will be shifted between analysis frames |
windowSize |
the analysis window size (in ms); overrides the effect of
the |
toFile |
Should the function write the results to a file, with the
(default) file extension ( |
explicitExt |
the file extension will be used when
result files are written ( |
outputDirectory |
directory in which output files are stored. Defaults to NULL which means that the result file will be stored in the same directory as the input file. |
assertLossless |
an optional list of file extensions that the user wants to assert contains losslessly encoded signals data. |
logToFile |
whether to log commands to a separate logfile in the
|
verbose |
display verbose information about processing steps taken, as well as progress bars. |
Input signals not in a natively supported file format will be converted before the autocorrelation functions are computed. The conversion process will display warnings about input files that are not in known losslessly encoded formats.
The function is a re-write of the wrassp::zcrana function, but with media pre-conversion, better checking of preconditions such as the input file existance, structured logging, and the use of a more modern framework for user feedback.
The native file type of this function is "wav" files (in "pcm_s16le" format), SUNs "au", NIST, or CSL formats (kay or NSP extension). Input signal conversion, when needed, is done by libavcodec and the excellent av wrapper package.
If toFile
is FALSE
, the function returns a list of AsspDataObj
objects. If toFile
is TRUE
, the number (integer) of successfully
processed and stored output files is returned.
This function is not considered computationally expensive enough to require caching of results if applied to many signals. However, if the number of signals it will be applied to is very long, then caching of results may be warranted.
Raphael Winkelmann
Lasse Bombien
Fredrik Nylén
# get path to audio file
path2wav <- list.files(system.file("samples","sustained", package = "superassp"), pattern = glob2rx("a1.wav"), full.names = TRUE)
# calculate zcr values
res <- zcrana(path2wav, toFile=FALSE)
# plot zcr values
plot(seq(0,numRecs.AsspDataObj(res) - 1) / rate.AsspDataObj(res) +
attr(res, 'startTime'),
res[["ZCR[Hz]"]],
type='l',
xlab='time (s)',
ylab='Zero Crossing Rates (Hz)')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.