affilter: affilter function adapted from libassp

affilterR Documentation

affilter function adapted from libassp

Description

Filters the audio signal in listOfFiles. By specifying the high-pass and/or low-pass cut-off frequency one of four filter characteristics may be selected as shown in the table below. Per default a high-pass filter from 0 to 4000 Hz is applied. The Kaiser-window design method is used to compute the coefficients of a linear-phase FIR filter with unity gain in the pass-band. The cut-off frequencies (-6 dB points)

Usage

affilter(
  listOfFiles = NULL,
  optLogFilePath = NULL,
  highPass = 4000,
  lowPass = 0,
  stopBand = 96,
  transition = 250,
  useIIR = FALSE,
  numIIRsections = 4,
  toFile = TRUE,
  explicitExt = NULL,
  outputDirectory = NULL,
  forceToLog = useWrasspLogger,
  verbose = TRUE
)

Arguments

listOfFiles

vector of file paths to be processed by function

optLogFilePath

path to option log file

highPass

= : set the high-pass cut-off frequency to Hz (default: 4000, high-pass filtering is applied)

lowPass

= : set the low-pass cut-off frequency to Hz (default: 0, no low-pass filtering)

stopBand

= : set the stop-band attenuation to dB (default: 93.0 dB, minimum: 21.0 dB)

transition

= : set the width of the transition band to Hz (default: 250.0 Hz)

useIIR

switch from the default FIR to IIR filter

numIIRsections

= : set the number of 2nd order sections to (default: 4) where each section adds 12dB/oct to the slope of the filter

toFile

write results to file (for default extension see details section))

explicitExt

set if you wish to override the default extension

outputDirectory

directory in which output files are stored. Defaults to NULL, i.e. the directory of the input files

forceToLog

is set by the global package variable useWrasspLogger. This is set to FALSE by default and should be set to TRUE is logging is desired.

verbose

display infos & show progress bar

Details

of the filters are in the middle of the transition band. The filtered signal will be written to a file with the base name of the input file and an extension corresponding to the filter characteristic (see table). The format of the output file will be the same as that of the input file.

hp lp filter characteristic extension
'>0' 0 high-pass from hp '.hpf'
0 > 0 low-pass up to lp '.lpf'
'>0' '>hp' band-pass from hp to lp '.bpf'
'>lp' '>0' band-stop between lp and hp '.bsf'

Value

nrOfProcessedFiles or if only one file to process return AsspDataObj of that file

Author(s)

Raphael Winkelmann

Lasse Bombien

Examples

# get path to audio file
path2wav <- list.files(system.file("extdata", package = "wrassp"), 
                       pattern = glob2rx("*.wav"), 
                       full.names = TRUE)[1]

# band-pass filter signal between 4000 and 5000 Hz
res <- affilter(path2wav, highPass=4000, lowPass=5000, toFile=FALSE)

# plot samples
# (only plot every 10th element to accelerate plotting)
plot(seq(0,numRecs.AsspDataObj(res) - 1, 10) / rate.AsspDataObj(res), 
     res$audio[c(TRUE, rep(FALSE,9))], 
     type='l', 
     xlab='time (s)', 
     ylab='Audio samples')
     

humlab-speech/superassp documentation built on May 8, 2024, 2:27 p.m.