Track LP filter coefficients
trk_lpc.RdLinear Prediction analysis of audio signals using the autocorrelation method
and Durbin recursion, implemented in the libassp C library
(Scheffers 2012)
. Returns per-frame RMS amplitudes and direct-form
LP filter (predictor) coefficients. Use trk_lpc when direct-form LP
coefficients are needed for synthesis or spectral estimation.
Usage
trk_lpc(listOfFiles = NULL,
beginTime = 0.0,
centerTime = FALSE,
endTime = 0.0,
windowShift = 5.0,
windowSize = 20.0,
effectiveLength = TRUE,
window = 'BLACKMAN',
analysisOrder = NULL,
preemphasis = -0.95,
toFile = FALSE,
explicitExt = NULL,
outputDirectory = NULL,
assertLossless = NULL,
logToFile = FALSE,
keepConverted = FALSE,
convertOverwrites = FALSE,
verbose = TRUE)Arguments
- listOfFiles
Character vector of audio file paths. Any format supported by av is accepted; non-native inputs are transcoded automatically.
- beginTime
Start time for the extracted portion in seconds. Default: NULL (beginning of signal). Note: uses
beginTime/endTime(seconds) matching DSP function conventions, unlikeread_audio()which usesbegin/end.- centerTime
Numeric or logical. Single-frame analysis time point in seconds; overrides
beginTime,endTime, andwindowShift. DefaultFALSE.- endTime
The end time of the section of the sound files that should be analysed (in seconds). Use 0 for end of file.
- windowShift
Numeric. Frame shift in milliseconds; sets output frame rate (
1000 / windowShiftHz). Default 5.0 ms (200 Hz). Must be strictly less than 32 ms (the 512-sample analysis window at 16 kHz). Values other than the training default (5 ms) may slightly reduce accuracy.- windowSize
Numeric. Smoothing filter window size in milliseconds, applied to both median (periodicity) and mean (F0) post-processing filters. Default 15 ms.
- effectiveLength
Logical. Make window size effective rather than exact. Default
FALSE.- window
Character. Analysis window function type. Default
"BLACKMAN". See AsspWindowTypes for supported types.- analysisOrder
Integer. Number of lag coefficients per frame.
0sets order to sample rate in kHz + 3 (e.g. 19 for 16 kHz audio). Default 0.- preemphasis
Numeric. Pre-emphasis factor (-1 <= val <= 0); default is sample-rate- and nominalF1-dependent.
- toFile
Logical. If
TRUE, write SSFF output files and return the count written. IfFALSE, return anAsspDataObj(single file only). DefaultTRUE.- explicitExt
By default, a character "d" will be prepended to the file name suffix when writing the output to file. The user can also specify an explicit extension which will be used instead.
- outputDirectory
The directory where the slice file should be stored. If not defiled (NULL), the sparse slice file will placed in the same folder as the media file.
- assertLossless
Character vector of additional file extensions to treat as losslessly encoded.
- logToFile
Logical. Write processing log to a file in
outputDirectoryrather than the console. DefaultFALSE.- keepConverted
Logical. Retain intermediate transcoded files. Default
FALSE.- convertOverwrites
Logical. Allow transcoding to overwrite existing files. Default
FALSE.- verbose
Logical. Show a progress bar (sequential path) or a progress-aware parallel apply (
pbapply/pbmcapply, if installed).
Value
If toFile = FALSE: an AsspDataObj with tracks:
RMS[dB]REAL32, dB, n_frames x 1. RMS amplitude of the input frame.
gain[dB]REAL32, dB, n_frames x 1. RMS amplitude of the LP residual.
LPCiREAL32, dimensionless, n_frames x
analysisOrdercolumns. Direct-form LP predictor coefficients a_1 … a_p (expands to LPC1…LPCp).
Frame rate: 1000 / windowShift Hz (default 200 Hz).
If toFile = TRUE: integer count of files written, returned invisibly.
Details
Coefficients are the direct-form LP predictor coefficients (a_1 … a_p) from
the Durbin recursion. See trk_rfc for parameter details. The LPC
spectrum can be evaluated by trk_lps_spectrum.
References
Scheffers M (2012). “Advanced Speech Signal Processor.” https://sourceforge.net/projects/libassp/files/libassp/.
Examples
path2wav <- list.files(system.file("samples", "sustained", package = "superassp"),
pattern = glob2rx("a1.wav"), full.names = TRUE)
res <- trk_lpc(path2wav, toFile = FALSE)
#> Applying `lpcana()` to 1 recording
matplot(seq(0, n_records(res) - 1) / sample_rate(res) +
attr(res, "startTime"),
res[["LPCi"]], type = "l",
xlab = "time (s)", ylab = "LP filter coefficients")