Acoustic template detection in R