Collection of periodic functions with period normalized to turns.
const fn = require('periodic-function/<fn>')
//π radians
let halfTurn = fn(.5)
//2π radians
let fullTurn = fn(1)The fn takes the amount of turn t as the first argument and optional parameters. The list of available functions:
| Signature | Waveform | Meaning | 
|---|---|---|
| sine(t, phase=0) |  | Math.sinnormalized to0..1rather than radians0..2π. To turn into cos, setphase=.25. | 
| triangle(t, ratio=0.5) |  | Triangular waveform with regulated ratio. To turn into sawtooth set ratio=0orratio=1. | 
| sawtooth(t, inverse=false) |  | Edge case of triangular waveform, whether descending or ascending. | 
| square(t, ratio=0.5) |  | Rectangular waveform with regulated ratio. To turn into pulse set ratio=0. | 
| pulse(t, tlr=0) |  | Delta-pulse, which is 1at0and0anywhere else. Passtlras a precision tolerance, ie.1e-5. | 
| fourier(t, real, imag?, normalize=false) |  | Fourier Series coefficients, ie. harmonics. 0harmonic is static level,1st is base frequency,2nd is double base frequency,3rd is triple etc. Setnormalize=trueto bring max harmonic to1. | 
| clausen(t, limit=10) |  | Clausen function. Pass limitto indicate number of iterations, precision/performance tradeoff. | 
| step(t, samples) |  | Step function, picks closest sample value out of a set. | 
| interpolate(t, samples) |  | Interpolates between closest values in a sample set. | 
| noise(t) |  | Repeated sample of noise. | 
If you feel like it is not complete list of you know example of a good periodic function, suitable for dsp, welcome to contribute.
© 2017 Dima Yv. MIT License
