Description Usage Arguments Details Value Examples
View source: R/utilities_soundgen.R
Internal soundgen function.
1 | 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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.