I am creating three different linear tweets using the code found here on SO. With some other code snippets, I save these three sounds as separate .wav files. It still works.
Now I want to play these three sounds at the same time. Therefore, I thought that I could use the WebAudio API to feed three oscillator nodes with floating point arrays, which I got from the above code. But I will not get at least one node oscillator to reproduce its sound.
My code is still (compressed for one oscillator)
var osc = audioCtx.createOscillator();
var sineData = linearChirp(freq, (freq + signalLength), signalLength, audioCtx.sampleRate);
var imag = Float32Array.from(sineData.unshift(0));
var real = new Float32Array(imag.length);
var customWave = audioCtx.createPeriodicWave(real, imag);
osc.setPeriodicWave(customWave);
osc.start();
At the moment, I believe that I do not quite understand all the math behind the peridoc wave.
A code that plays three sounds at the same time works (with simple sin values ββin the nodes of the oscillator), so I assume that the problem is in my peridoc wave.
Another question: is there any other way? Maybe using three MediaElementAudioSourceNode associated with my three WAV files. I do not see a way to play them at the same time.
source
share