Learn R Programming

soundgen (version 1.7.0)

getPrior: Get prior for pitch candidates

Description

Prior for adjusting the estimated pitch certainties in analyze. For ex., if primarily working with speech, we could prioritize pitch candidates in the expected pitch range (100-1000 Hz) and dampen candidates with very high or very low frequency as unlikely but still remotely possible in everyday vocalizing contexts (think a soft pitch ceiling). Algorithm: the multiplier for each pitch candidate is the density of gamma distribution with mean = priorMean (Hz) and sd = priorSD (semitones) normalized so max = 1 over [pitchFloor, pitchCeiling]. Useful for previewing the prior given to analyze.

Usage

getPrior(
  priorMean,
  priorSD,
  pitchFloor = 75,
  pitchCeiling = 3000,
  len = 100,
  plot = TRUE,
  pitchCands = NULL,
  ...
)

Arguments

priorMean

specifies the mean (Hz) and standard deviation (semitones) of gamma distribution describing our prior knowledge about the most likely pitch values for this file. For ex., priorMean = 300, priorSD = 6 gives a prior with mean = 300 Hz and SD = 6 semitones (half an octave)

priorSD

specifies the mean (Hz) and standard deviation (semitones) of gamma distribution describing our prior knowledge about the most likely pitch values for this file. For ex., priorMean = 300, priorSD = 6 gives a prior with mean = 300 Hz and SD = 6 semitones (half an octave)

pitchFloor

absolute bounds for pitch candidates (Hz)

pitchCeiling

absolute bounds for pitch candidates (Hz)

len

the required length of output vector (resolution)

plot

if TRUE, plots the prior

pitchCands

a matrix of pitch candidate frequencies (for internal soundgen use)

...

additional graphical parameters passed on to plot()

Value

Returns a numeric vector of certainties of length len if pitchCands is NULL and a numeric matrix of the same dimensions as pitchCands otherwise.

See Also

analyze pitch_app

Examples

Run this code
# NOT RUN {
soundgen:::getPrior(priorMean = 150,  # Hz
                    priorSD = 2)      # semitones
soundgen:::getPrior(150, 6)
s = soundgen:::getPrior(450, 24, pitchCeiling = 6000)
plot(s, type = 'l')
# }

Run the code above in your browser using DataLab