I will try to render notes played in realtime using a moving scroll on canvas.Well i have to console.log the expression and figure out what goes wrong.
The parameters of canvas is the "shown bars", and that is basicly the width of canvas divided by the bars you like it to show. There is of course measures of the metronome that decide how fast "many pixels" the bar move.
Keylength is just another graphical element before scrollbar start render.
So i have a metronome coupled with the clock, and now i have to reder using a setting in FPS, from that i calculate pause between drawings the pause correspond to the note moved some pixels. So the idea is that scrollbar and the metronome clock should sync ***over time***.
So the bars will be the relative measure for where the notes have moved since last draw update. Well that is my theory.
Below the rendertime is time for the scroll to move thru full canvas. BAR_REND_MULT how many times the scroll moved over canvas. Rstarttime is the realtime clock.
***For some reason it just draw the first cycle?//
I was thinking when the multiple goes up Rstarttime again will be less then 1?
This is the pseudo code.
if realtimeclock/time to render 1 canvas*canvas rendered>1 then reset the renderposition "totalmove" and add 1 to render multiple else keep movin scrollbar.
function drawscrollbar(){
ctm.strokeStyle = "red";
ctm.lineWidth=1;
ctm.beginPath();
ctm.moveTo(totalmove,0);
ctm.lineTo(totalmove,Mheight);
ctm.stroke();
drawnlines++;
if (totalmove!=keylength){
ctm.strokeStyle = "black";
ctm.lineWidth=2;
ctm.beginPath();
ctm.moveTo(totalmove-(pixelmove),0);
ctm.lineTo(totalmove-(pixelmove),Mheight);
ctm.stroke();
}
if (Rstarttime/RENDERtime*BAR_REND_MULT>1) { ctm.fillStyle = "black";totalmove=keylength;
BAR_REND_MULT++;} else {totalmove=pixelmove+totalmove;}
}
I will try to render notes played in realtime using a moving scroll on canvas.By the way do anyone know how the metronome usually rendered, right now i run it in a separate thread with setInterval
The parameters of canvas is the "shown bars", and that is basicly the width of canvas divided by the bars you like it to show. There is of course measures of the metronome that decide how fast "many pixels" the bar move.
Keylength is just another graphical element before scrollbar start render.
So i have a metronome coupled with the clock, and now i have to reder using a setting in FPS, from that i calculate pause between drawings the pause correspond to the note moved some pixels. So the idea is that scrollbar and the metronome clock should sync ***over time***.
So the bars will be the relative measure for where the notes have moved since last draw update. Well that is my theory.
Below the rendertime is time for the scroll to move thru full canvas. BAR_REND_MULT how many times the scroll moved over canvas. Rstarttime is the realtime clock.
***For some reason it just draw the first cycle?//
I was thinking when the multiple goes up Rstarttime again will be less then 1?
This is the pseudo code.
if realtimeclock/time to render 1 canvas*canvas rendered>1 then reset the renderposition "totalmove" and add 1 to render multiple else keep movin scrollbar.
function drawscrollbar(){
ctm.strokeStyle = "red";
ctm.lineWidth=1;
ctm.beginPath();
ctm.moveTo(totalmove,0);
ctm.lineTo(totalmove,Mheight);
ctm.stroke();
drawnlines++;
if (totalmove!=keylength){
ctm.strokeStyle = "black";
ctm.lineWidth=2;
ctm.beginPath();
ctm.moveTo(totalmove-(pixelmove),0);
ctm.lineTo(totalmove-(pixelmove),Mheight);
ctm.stroke();
}
if (Rstarttime/RENDERtime*BAR_REND_MULT>1) { ctm.fillStyle = "black";totalmove=keylength;
BAR_REND_MULT++;} else {totalmove=pixelmove+totalmove;}
}
I will try to render notes played in realtime using a moving scroll on canvas.Solved but it never drift apart, but it isn't perfect.
The parameters of canvas is the "shown bars", and that is basicly the width of canvas divided by the bars you like it to show. There is of course measures of the metronome that decide how fast "many pixels" the bar move.
Keylength is just another graphical element before scrollbar start render.
So i have a metronome coupled with the clock, and now i have to reder using a setting in FPS, from that i calculate pause between drawings the pause correspond to the note moved some pixels. So the idea is that scrollbar and the metronome clock should sync ***over time***.
So the bars will be the relative measure for where the notes have moved since last draw update. Well that is my theory.
Below the rendertime is time for the scroll to move thru full canvas. BAR_REND_MULT how many times the scroll moved over canvas. Rstarttime is the realtime clock.
***For some reason it just draw the first cycle?//
I was thinking when the multiple goes up Rstarttime again will be less then 1?
This is the pseudo code.
if realtimeclock/time to render 1 canvas*canvas rendered>1 then reset the renderposition "totalmove" and add 1 to render multiple else keep movin scrollbar.
function drawscrollbar(){
ctm.strokeStyle = "red";
ctm.lineWidth=1;
ctm.beginPath();
ctm.moveTo(totalmove,0);
ctm.lineTo(totalmove,Mheight);
ctm.stroke();
drawnlines++;
if (totalmove!=keylength){
ctm.strokeStyle = "black";
ctm.lineWidth=2;
ctm.beginPath();
ctm.moveTo(totalmove-(pixelmove),0);
ctm.lineTo(totalmove-(pixelmove),Mheight);
ctm.stroke();
}
if (Rstarttime/RENDERtime*BAR_REND_MULT>1) { ctm.fillStyle = "black";totalmove=keylength;
BAR_REND_MULT++;} else {totalmove=pixelmove+totalmove;}
}
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,007 |
Nodes: | 10 (0 / 10) |
Uptime: | 223:47:48 |
Calls: | 13,144 |
Calls today: | 1 |
Files: | 186,574 |
D/L today: |
139 files (45,743K bytes) |
Messages: | 3,310,881 |