View source: R/pitch_postprocessing.R
medianSmoother | R Documentation |
Internal soundgen function.
medianSmoother(df, smoothing_ww, smoothingThres, inviolable = NULL)
df |
dataframe (each column is processed separately, so multiple contours can be fed into this function at once to speed things up) |
smoothing_ww |
width of smoothing window (points) |
smoothingThres |
tolerated deviance from moving median (semitones) |
inviolable |
a vector of indices of the rows rows of df that should not be modified (meant for manual pitch values) |
Internal helper function for smoothing pitch contours or other contours. Only outliers are modified, so it's not like smoothing with a kernel. NB: the expected input is pitch, so deviance is calculated on a log-scale.
Returns a dataframe of the same dimensions as df.
df = data.frame(a = rnorm(20, mean = 100, sd = 20),
b = rnorm(20, mean = 100, sd = 10))
df1 = soundgen:::medianSmoother(df, smoothing_ww = 5,
smoothingThres = 1,
inviolable = c(rep(TRUE, 10), rep(FALSE, 10)))
plot(df[, 2], type='b')
lines(df1[, 2], type='b', col='blue', pch=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.