Ccing the maintainer if the tuneR package. Looks to me like sawtooth (and square) don't behave as expected when using xunit="samples". Workaround is to use xunit="time" instead:
sawtooth(110,duration=1/100,samp.rate=sample_rate,xunit="time") I looked at the code but found it to be opaque. -- Sent from my phone. Please excuse my brevity. On November 12, 2017 6:15:45 AM PST, Michael Tiemann <mdtiem...@gmail.com> wrote: >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]] > >______________________________________________ >R-help@r-project.org 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. ______________________________________________ R-help@r-project.org 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.