# long format: anchors are a dataframe
a = getSmoothContour(anchors = data.frame(
time = c(50, 137, 300), value = c(0.03, 0.78, 0.5)),
normalizeTime = FALSE,
voiced = 200, valueFloor = 0, plot = TRUE, main = '',
samplingRate = 16000) # breathing
# short format: anchors are a vector (equal time steps assumed)
a = getSmoothContour(anchors = c(350, 800, 600),
len = 5500, thisIsPitch = TRUE, plot = TRUE,
samplingRate = 3500) # pitch
# a single anchor gives constant value
a = getSmoothContour(anchors = 800,
len = 500, thisIsPitch = TRUE, plot = TRUE, samplingRate = 500)
# two pitch anchors give loglinear F0 change
a = getSmoothContour(anchors = c(220, 440),
len = 500, thisIsPitch = TRUE, plot = TRUE, samplingRate = 500)
## Two closely spaced anchors produce a pitch jump
# one loess for the entire contour
a1 = getSmoothContour(anchors = list(time = c(0, .15, .2, .7, 1),
value = c(360, 116, 550, 700, 610)), len = 500, thisIsPitch = TRUE,
plot = TRUE, samplingRate = 500)
# two segments with a linear transition
a2 = getSmoothContour(anchors = list(time = c(0, .15, .17, .7, 1),
value = c(360, 116, 550, 700, 610)), len = 500, thisIsPitch = TRUE,
plot = TRUE, samplingRate = 500)
# two segments with an abrupt jump
a3 = getSmoothContour(anchors = list(time = c(0, .15, .155, .7, 1),
value = c(360, 116, 550, 700, 610)), len = 500, thisIsPitch = TRUE,
plot = TRUE, samplingRate = 500)
# compare:
plot(a2)
plot(a3) # NB: the segment before the jump is upsampled to compensate
## Control the amount of smoothing
getSmoothContour(c(1, 3, 9, 10, 9, 9, 2), len = 100, plot = TRUE,
loessSpan = NULL) # default amount of smoothing (depends on dur)
getSmoothContour(c(1, 3, 9, 10, 9, 9, 2), len = 100, plot = TRUE,
loessSpan = .85) # more smoothing than default
getSmoothContour(c(1, 3, 9, 10, 9, 9, 2), len = 100, plot = TRUE,
loessSpan = .5) # less smoothing
getSmoothContour(c(1, 3, 9, 10, 9, 9, 2), len = 100, plot = TRUE,
interpol = 'approx') # linear interpolation (no smoothing)
## Upsample preserving leading and trailing NAs
anchors = data.frame(time = c(1, 4, 5, 7, 10, 20, 23, 25, 30),
value = c(NA, NA, 10, 15, 12, NA, 17, 15, NA))
plot(anchors, type = 'b')
anchors_ups = getSmoothContour(
anchors, len = 200,
interpol = 'approx', # only approx can propagate NAs
NA_to_zero = FALSE, # preserve NAs
discontThres = 0) # don't break into sub-contours
plot(anchors_ups, type = 'b')
Run the code above in your browser using DataLab