My tuneR sawtooth wave function generator is broken.
When I use the sine function, I get exactly what I expect: a sine wave whose
frequency is defined by the freq parameter. In particular, higher frequencies
have shorter wavelengths (more cycles per second means shorter waves). When I
create a sawtooth wave, the opposite seems to occur: higher frequencies result
in longer waves. But that’s not all: as frequencies increase, it appears that
wavelengths increase to infinite length, then get shorter again as the wave
reverses, then it gets longer and flips again.
Here’s a small file that demonstrates the bad sawtooth waves:
library(tuneR)
sample_rate <- 12000
reverse <- FALSE
mycolors=c("red","orange","yellow","green","cyan","blue","violet","magenta")
plot(sawtooth(110,duration=round(sample_rate/100),samp.rate=sample_rate,xunit="samples")@left,type="l")
freqs <- c(111,112,113,114,115,116,117,118)
for (i in 1:length(freqs)) {
temp <-
sine(freqs[i],duration=round(sample_rate/100),samp.rate=sample_rate,xunit="samples")
lines(temp@left,type="l",lty=2,col=mycolors[i])
}
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.