ampl = sin(1:100/2)
plot(ampl, type = 'b')
lines(1:100, rep(0,100), lty = 2)
zc = vector()
for (i in seq_along(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
Run the code above in your browser using DataLab