soundgen (version 2.6.2)

medianSmoother: Median smoothing

Description

Internal soundgen function.

Usage

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

Value

Returns a dataframe of the same dimensions as df.

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.

Examples

Run this code
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)

Run the code above in your browser using DataLab