View source: R/soundgen_utilities.R
findZeroCrossing | R Documentation |
Internal soundgen function.
findZeroCrossing(ampl, location)
ampl |
a vector of amplitudes oscillating around zero, such as a sound waveform |
location |
the index indicating the desired location of a zero crossing |
findZeroCrossing
looks for the last negative point before a zero
crossing as close as possible to the specified location. Since this is
primarily intended for joining waveforms without a click, this function only
looks at upward segments of a waveform (see example).
Returns the index of the last negative value before zero crossing closest to specified location.
ampl = sin(1:100/2)
plot(ampl, type = 'b')
lines(1:100, rep(0,100), lty = 2)
zc = vector()
for (i in 1:length(ampl)){
zc[i] = soundgen:::findZeroCrossing (ampl, i)
# find zc closest to each of 100 points
}
for (z in unique(zc)){
points(z, ampl[z], col = 'red', pch = 17)
# only on upward segments
}
zc # see which zc is closest to each point
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.