Right now i stripped down my laggy play to a minimum, but i do not quite see how to adapt it to audioContext calls in intervals.
I simply use two arrays and shift them after each note played. I really need a playup that keep time and probably could do it if i just understand how the audioContext timer work.
function STARTPLAY(){
if (keepGoing) {
if (copyEv.length) {
outportarr[outportindex].send(noteMessage.shift(),copyEv.shift());
}
stopRec=setTimeout(STARTPLAY,copyEv[0]);
}
}
Well i do realise it somehow involve setting playup time to zero and wrap it so outportarr[outportindex].send(noteMessage.shift(),0);
But what i do not get is howto make the exact calls using audiocontext to the function, i do find the audiocontext approach convoluted?
Could someone show me?
function STARTPLAY(){
evTiming=copyEv[0];
if (keepGoing) {
if (copyEv.length) {
if(performance.now()-oldPerformance>evTiming){
oldPerformance=window.performance.now();
outportarr[outportindex].send(noteMessage.shift());
copyEv.shift();
}
}
}
}
Well ideally i would want to make the calls to STARTPLAY using the audiocontext timer be dependent on evTiming is that possible?
So dynamic calls using audiocontext timer anyone?
Sure there is someone out there who knows the 5 lines of code to make my sequenser "timing correc" using the audiocontext timer.
Found this example of a static beep player using audiocontext timer, i really do not understand it convoluted approach to start with.
function playSound(stepAdd) {
var osc = audioContext.createOscillator();
osc.connect(audioContext.destination);
osc.frequency.value = 500;
osc.start(stepAdd);
osc.stop(stepAdd + 0.1);
};
window.AudioContext = window.AudioContext || window.webkitAudioContext;
var audioContext = new AudioContext();
var stepAdd = audioContext.currentTime;
var nextNote = document.getElementById("nextNote"

;
var startBtn = document.getElementById("startBtn"

;
var stopBtn = document.getElementById("stopBtn"

;
var timerID;
function scheduler() {
while(stepAdd < audioContext.currentTime + 0.1) {
stepAdd += 0.5;
playSound(stepAdd);
}
timerID = window.setTimeout(scheduler, 100.0);
}
scheduler();