Description Usage Arguments Value Examples
View source: R/smoothContours.R
Returns a smooth contour based on an arbitrary number of anchors. Used by
soundgen
for generating intonation contour, mouth opening, etc.
Note that pitch contours are treated as a special case: values are
log-transformed prior to smoothing, so that with 2 anchors we get a linear
transition on a log scale (as if we were operating with musical notes rather
than frequencies in Hz). Pitch plots have two Y axes: one showing Hz and the
other showing musical notation.
1 2 3 4 5 |
anchors |
a dataframe of anchors with specified time and amplitude.
|
len |
the required length of the output contour. If NULL, it will be
calculated based on the maximum time value (in ms) and |
thisIsPitch |
(boolean) is this a pitch contour? If true, log-transforms before smoothing and plots in both Hz and musical notation |
method |
smoothing method: 'spline' or 'loess' (default). Consider 'spline' if you have a lot of anchors and not much patience, since it is much faster than 'loess', but it may produce weird results when there are only a few anchors |
valueFloor, valueCeiling |
lower/upper bounds for the contour |
plot |
(boolean) produce a plot? |
main, xlim, ylim |
plotting options |
samplingRate |
sampling rate used to convert time values to points (Hz) |
voiced, contourLabel |
graphical pars for plotting breathing contours (see examples below) |
... |
other plotting options passed to |
Returns a numeric vector.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | a = getSmoothContour(anchors = data.frame(
time = c(50, 137, 300), value = c(0.03, 0.78, 0.5)),
voiced = 200, valueFloor = 0, plot = TRUE, main = '',
samplingRate = 16000) # breathing
a = getSmoothContour(anchors = data.frame(
time = c(0, .1), value = c(350, 800)),
len = 5500, thisIsPitch = TRUE, plot = TRUE,
samplingRate = 3500) # pitch
# a single anchor gives constant pitch
a = getSmoothContour(anchors = data.frame(time = 0, value = 800),
len = 500, thisIsPitch = TRUE, plot = TRUE, samplingRate = 500)
# two anchors give loglinear pitch change
a = getSmoothContour(anchors = data.frame(
time = c(0, 1), value = c(220, 440)),
len = 500, thisIsPitch = TRUE, plot = TRUE, samplingRate = 500)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.