pitch: Pitch analysis using a Modified Harmonic Sieve

pitchR Documentation

Pitch analysis using a Modified Harmonic Sieve

Description

This function finds the pitch (in Hz) along files in using Michel Scheffers' Modified Harmonic Sieve algorithm implmented in libassp \insertCites5hsuperassp. Input signals not in a file format natively supported 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.

Usage

pitch(
  listOfFiles = NULL,
  beginTime = 0,
  centerTime = FALSE,
  endTime = 0,
  windowShift = 5,
  gender = "u",
  maxF = 600,
  minF = 50,
  minAmp = 50,
  minAC1 = 0.25,
  minRMS = 18,
  maxZCR = 3000,
  minProb = 0.52,
  plainSpectrum = FALSE,
  toFile = TRUE,
  explicitExt = "pit",
  outputDirectory = NULL,
  assertLossless = NULL,
  logToFile = FALSE,
  convertOverwrites = FALSE,
  keepConverted = FALSE,
  verbose = TRUE
)

Arguments

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 listOfFiles.

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 listOfFiles.

windowShift

the amount of time (in ms) that the analysis window will be shifted between analysis frames

gender

= set gender-specific fo ranges; may be: "female" (80.0 - 640.0 Hz) "male" (50.0 - 400.0 Hz) "unknown" (default; 50.0 - 600.0 Hz)

maxF

= : set maximum fo value to Hz (default: 500.0)

minF

= : set minimum fo value to Hz (default: 50.0)

minAmp

= : minimum signal amplitude (default: 50)

minAC1

= : minimum 1st correlation coefficient (default: 0.250)

minRMS

= : minimum RMS amplitude in dB (default: 18.0)

maxZCR

= : maximum zero crossing rate in Hz (default: 3000)

minProb

= : minimum quality value of fo fit (default: 0.520)

toFile

Should the function write the results to a file, with the (default) file extension (TRUE) or returned as a list of AsspDataObj objects (FALSE)?

explicitExt

the file extension will be used when result files are written (toFile=TRUE), but the file extension can be set to something else using this function argument.

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 outputDirectory. Logging will otherwise be in the function-specific logging namespace of logger and will be put wherever this namespace is defined to place its output. See logger::log_appender for details.

verbose

display verbose information about processing steps taken, as well as progress bars.

Details

The results will be will be written to an SSFF formated file with the base name of the input file and extension .pit in a track pitchHz.

The function is a re-write of the wrassp::mhsF0 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::av_audio_convert wrapper function

Value

The number of successfully written files (if toFile=TRUE), or a vector of AsspDataObj objects (if toFile=FALSE).

Note

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 large, then caching of results may be warranted.

Author(s)

Raphael Winkelmann

Lasse Bombien

Fredrik Nylén

References

\insertAllCited

See Also

ksv_fo for an algorithm for tracking the fundamental frequency fo.

Examples

# get path to audio file
path2wav <- list.files(system.file("samples","sustained", package = "superassp"), pattern = glob2rx("a1.wav"), full.names = TRUE)

# calculate short-term autocorrelation
res <- pitch(path2wav, toFile=FALSE)

# plot fundamental frequency contour
plot(seq(0,numRecs.AsspDataObj(res) - 1) / rate.AsspDataObj(res) +
       attr(res, 'startTime'),
     res[["pitch[Hz]"]],
     type='l',
     xlab='time (s)',
     ylab="Pitch (Hz)")


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