Mcclellan and others,
This answer helped and subsequently turned me into the world of Fourier. Using a related page and some Wikipedia, I think I got square and sawtooth patterns, but the triangle pattern still eludes me. Does anyone know?
It really gives you the ability to phase shift, as Nick Thompson explains this article (although he calls the AudioContext methods differently, the principle is the same).
Regarding square and sawtooth patterns:
var n = 4096; var real = new Float32Array(n); var imag = new Float32Array(n); var ac = new AudioContext(); var osc = ac.createOscillator(); for(x=1;x<n;x+=2) imag[x] = 4.0 / (Math.PI * x); var wave = ac.createPeriodicWave(real, imag); osc.setPeriodicWave(wave); osc.connect(ac.destination); osc.start(); osc.stop(2);
In this case, the activated pattern, square pattern will be played. What will be the formula of the triangle?
source share