soundgen (version 1.5.0)

morphDF: Morph dataframes

Description

Internal soundgen function.

Usage

morphDF(a, b, nMorphs = 5, method = c("smooth", "perAnchor")[2],
  lenSmooth = 50, matchIdx = NULL, plot = F, ...)

Arguments

a, b

dataframes to morph

nMorphs

length of morphing sequence

method

morphing method. 'smooth' equalizes contour lengths and takes a weighted mean. 'perAnchor' is a more sophisticated algorithm that attempts to match individual anchors

lenSmooth

the length of curves generated from anchors prior to averaging (only applicable if method is 'smooth')

matchIdx

manual override of anchor matching: if you have a better idea of which anchors should morph into each other, specify

plot

if TRUE, plots the morphing sequence of anchors

...

other graphical pars passed on to plot

Value

A list of length nMorphs containing anchor dataframes for morphing

Details

Morphs two dataframes of anchors, with two columns and at least two rows in each.

Examples

Run this code
# NOT RUN {
a = data.frame(time=c(0, .2, .9, 1), value=c(100, 110, 180, 110))
b = data.frame(time=c(0, .3, .5, .8, 1), value=c(300, 220, 190, 400, 350))
plot (a, type = 'b', ylim = c(0, 500))
points (b, type = 'b', col = 'blue')
m = soundgen:::morphDF(a, b, nMorphs = 15, method = 'smooth', plot = TRUE)
m = soundgen:::morphDF(a, b, nMorphs = 15, method = 'perAnchor', plot = TRUE)

m = soundgen:::morphDF(a = data.frame(time = c(0, 1), freq = c(700, 700)),
                       b = data.frame(time = c(0, 1), freq = c(400, 600)),
                       nMorphs = 5, method = 'perAnchor', plot = TRUE)
m = soundgen:::morphDF(a = data.frame(time = c(-30, 120, 350), value = c(-120, 10, -120)),
                       b = data.frame(time = c(50, 500), value = c(0, -30)),
                       nMorphs = 10, method = 'perAnchor', plot = TRUE)
m = soundgen:::morphDF(a = data.frame(time = c(-50, 1214), value = c(-50, -70)),
                       b = data.frame(time = c(0, 49, 256), value = c(-120, 10, -120)),
                       nMorphs = 8, method = 'perAnchor', plot = TRUE)
# }

Run the code above in your browser using DataLab