medianSmoother: Median smoothing

View source: R/utilities_pitch_postprocessing.R

medianSmootherR Documentation

Median smoothing

Description

Internal soundgen function.

Usage

medianSmoother(df, smoothing_ww, smoothingThres, inviolable = NULL)

Arguments

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)

Details

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.

Value

Returns a dataframe of the same dimensions as df.

Examples

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)

soundgen documentation built on Aug. 14, 2022, 5:05 p.m.