[R] create waveform sawtooth

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Mon Nov 13 00:57:27 CET 2017

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:


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 <mdtiemann at 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:
>sample_rate <- 12000
>reverse <- FALSE
>freqs <- c(111,112,113,114,115,116,117,118)
>for (i in 1:length(freqs)) {
>temp <-
>    lines(temp at left,type="l",lty=2,col=mycolors[i])
>	[[alternative HTML version deleted]]
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list