Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

The study of non-linear physics is like the study of non-elephant biology.


devel / comp.lang.javascript / Function calls that behave different depending on else leg.

SubjectAuthor
* Function calls that behave different depending on else leg.Jonas Thörnvall
+* Re: Function calls that behave different depending on else leg.Jonas Thörnvall
|`* Re: Function calls that behave different depending on else leg.Jonas Thörnvall
| `- Re: Function calls that behave different depending on else leg.Jonas Thörnvall
`* Re: Function calls that behave different depending on else leg.luserdroog
 `- Re: Function calls that behave different depending on else leg.Jonas Thörnvall

1
Function calls that behave different depending on else leg.

<c2c3ce9b-52b7-427c-a479-40d60e9835cen@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17380&group=comp.lang.javascript#17380

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a05:6214:1d2b:: with SMTP id f11mr11283379qvd.20.1635226697472;
Mon, 25 Oct 2021 22:38:17 -0700 (PDT)
X-Received: by 2002:a4a:c3c5:: with SMTP id e5mr6870249ooq.71.1635226697165;
Mon, 25 Oct 2021 22:38:17 -0700 (PDT)
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Date: Mon, 25 Oct 2021 22:38:16 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=84.217.164.86; posting-account=kxPkPAoAAACjJi8w0gL9bnyznPzdw9HW
NNTP-Posting-Host: 84.217.164.86
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c2c3ce9b-52b7-427c-a479-40d60e9835cen@googlegroups.com>
Subject: Function calls that behave different depending on else leg.
From: jonas.thornvall@gmail.com (Jonas Thörnvall)
Injection-Date: Tue, 26 Oct 2021 05:38:17 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Jonas Thörnvall - Tue, 26 Oct 2021 05:38 UTC

I have this function drawNotesCanvas that behave different depending on else leg although the same call to function as other leg?

What i want todo is draw out all tracks if track is zero, track zero is the "downmix of all tracks", used during playup.

But even if i hardcode channel and remove loop, it does not to what the other "single channel" else leg do. It has gotten me bewilderd for months "years".

snippet
============
if (activetrack==0){
//for (var i=1;i<=maxtrack;i++){
drawtrack=1; //1,2,3 or whatever channel do not do same as other leg
notePlot();
// }
} else {
drawtrack=activetrack;
notePlot();
}
}

fullcode
==================
var graphNotePosX= [];
var graphNotePosY= [];
var graphNoteLength= [];
var graphNoteHeight= [];
var graphNoteEvent= [];
var trColor=[];

trColor[0]="yellow";
trColor[1]="magenta";
trColor[2]="lightgrey";
trColor[3]="skyblue";
trColor[4]="yellow";
trColor[5]="fuchsia";
trColor[6]="pink";
trColor[7]="magenta";
trColor[8]="orange";
trColor[9]="cyan";
trColor[10]="white";
trColor[11]="lightgreen";
trColor[12]="silver";
trColor[13]="lightblue";
trColor[14]="olive";
trColor[15]="red";
trColor[16]="aqua";

// CLEAR NOTES ON CANVAS
function delRenderedNotes() {
ctm.fillStyle = "black";
ctm.fillRect(46, 24, Mwidth, Mheight);
}

// FETCH VALUES WHERE TO DRAW IN VIEW MODE
function drawNotesCanvas(){
startPoint=0;
endPoint=Mwidth;
editSPos=document.getElementById("SB").value;
editEPos=document.getElementById("EB").value;
TimeSPos=document.getElementById("EditStart").value;
TimeSPos=parseInt(TimeSPos);
TimeEPos=document.getElementById("EditEnd").value;
TimeEPos=parseInt(TimeEPos);
if (activetrack==0){
for (var i=1;i<=maxtrack;i++){
drawtrack=i;
notePlot();
}
} else {
drawtrack=activetrack;
notePlot();
}
}

// DRAWOUT NOTES ON MAIN CANVAS WHEN PAGE VIEW CHANGE
function notePlot(){
//console.log("NOTEPLOT TRACK="+drawtrack+" midiMess length="+track[drawtrack].midiMess.length);
var plotRightSide=0;var plotLeftSide=0;
var x=0;var z=0;var i=0;
nbrOfEV = track[drawtrack].midiMess.length;
distanceTotal=Mwidth-keylength;
TimeTotal=TimeEPos-TimeSPos;
while (x<nbrOfEV-1){
if (track[drawtrack].midiMess[x].time>TimeSPos && track[drawtrack].midiMess[x].time<TimeEPos && track[drawtrack].midiMess[x].data0==NOTE_ON){

TimeOnLeft=track[drawtrack].midiMess[x].time-TimeSPos;
TimePerc=TimeOnLeft/TimeTotal;
plotLeftSide=TimePerc*distanceTotal;
z=x+1;
TimeOnRight=TimeTotal-(TimeEPos-track[drawtrack].midiMess[z].time);
TimePerc=TimeOnRight/TimeTotal;
plotRightSide=TimePerc*distanceTotal;
recLength=plotRightSide-plotLeftSide;
ctm.fillStyle = trColor[drawtrack];
ctm.fillRect(50+plotLeftSide,(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8)),recLength,keyHeight-1);

//Saving the values of note graphic to array to compare with mouse
graphNotePosX[i]=50+plotLeftSide;
graphNotePosY[i]=(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8));
graphNoteLength[i]=recLength;
graphNoteHeight[i]=keyHeight-1;
graphNoteEvent[i]=x;
i++;
}
x++;
}
}

Re: Function calls that behave different depending on else leg.

<514e5b19-da98-4059-840c-be17998615fdn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17381&group=comp.lang.javascript#17381

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:ae9:e887:: with SMTP id a129mr17615797qkg.81.1635229449197;
Mon, 25 Oct 2021 23:24:09 -0700 (PDT)
X-Received: by 2002:a4a:e218:: with SMTP id b24mr5497443oot.36.1635229448918;
Mon, 25 Oct 2021 23:24:08 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Date: Mon, 25 Oct 2021 23:24:08 -0700 (PDT)
In-Reply-To: <c2c3ce9b-52b7-427c-a479-40d60e9835cen@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=84.217.164.86; posting-account=kxPkPAoAAACjJi8w0gL9bnyznPzdw9HW
NNTP-Posting-Host: 84.217.164.86
References: <c2c3ce9b-52b7-427c-a479-40d60e9835cen@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <514e5b19-da98-4059-840c-be17998615fdn@googlegroups.com>
Subject: Re: Function calls that behave different depending on else leg.
From: jonas.thornvall@gmail.com (Jonas Thörnvall)
Injection-Date: Tue, 26 Oct 2021 06:24:09 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 164
 by: Jonas Thörnvall - Tue, 26 Oct 2021 06:24 UTC

tisdag 26 oktober 2021 kl. 07:38:21 UTC+2 skrev Jonas Thörnvall:
> I have this function drawNotesCanvas that behave different depending on else leg although the same call to function as other leg?
>
> What i want todo is draw out all tracks if track is zero, track zero is the "downmix of all tracks", used during playup.
>
> But even if i hardcode channel and remove loop, it does not to what the other "single channel" else leg do. It has gotten me bewilderd for months "years".
>
> snippet
> ============
> if (activetrack==0){
> //for (var i=1;i<=maxtrack;i++){
> drawtrack=1; //1,2,3 or whatever channel do not do same as other leg
> notePlot();
> // }
> } else {
> drawtrack=activetrack;
> notePlot();
> }
> }
>
> fullcode
> ==================
> var graphNotePosX= [];
> var graphNotePosY= [];
> var graphNoteLength= [];
> var graphNoteHeight= [];
> var graphNoteEvent= [];
> var trColor=[];
>
> trColor[0]="yellow";
> trColor[1]="magenta";
> trColor[2]="lightgrey";
> trColor[3]="skyblue";
> trColor[4]="yellow";
> trColor[5]="fuchsia";
> trColor[6]="pink";
> trColor[7]="magenta";
> trColor[8]="orange";
> trColor[9]="cyan";
> trColor[10]="white";
> trColor[11]="lightgreen";
> trColor[12]="silver";
> trColor[13]="lightblue";
> trColor[14]="olive";
> trColor[15]="red";
> trColor[16]="aqua";
>
> // CLEAR NOTES ON CANVAS
> function delRenderedNotes() {
> ctm.fillStyle = "black";
> ctm.fillRect(46, 24, Mwidth, Mheight);
> }
>
> // FETCH VALUES WHERE TO DRAW IN VIEW MODE
> function drawNotesCanvas(){
> startPoint=0;
> endPoint=Mwidth;
> editSPos=document.getElementById("SB").value;
> editEPos=document.getElementById("EB").value;
> TimeSPos=document.getElementById("EditStart").value;
> TimeSPos=parseInt(TimeSPos);
> TimeEPos=document.getElementById("EditEnd").value;
> TimeEPos=parseInt(TimeEPos);
> if (activetrack==0){
> for (var i=1;i<=maxtrack;i++){
> drawtrack=i;
> notePlot();
> }
> } else {
> drawtrack=activetrack;
> notePlot();
> }
> }
>
> // DRAWOUT NOTES ON MAIN CANVAS WHEN PAGE VIEW CHANGE
> function notePlot(){
> //console.log("NOTEPLOT TRACK="+drawtrack+" midiMess length="+track[drawtrack].midiMess.length);
> var plotRightSide=0;var plotLeftSide=0;
> var x=0;var z=0;var i=0;
> nbrOfEV = track[drawtrack].midiMess.length;
> distanceTotal=Mwidth-keylength;
> TimeTotal=TimeEPos-TimeSPos;
> while (x<nbrOfEV-1){
> if (track[drawtrack].midiMess[x].time>TimeSPos && track[drawtrack].midiMess[x].time<TimeEPos && track[drawtrack].midiMess[x].data0==NOTE_ON){
>
> TimeOnLeft=track[drawtrack].midiMess[x].time-TimeSPos;
> TimePerc=TimeOnLeft/TimeTotal;
> plotLeftSide=TimePerc*distanceTotal;
> z=x+1;
> TimeOnRight=TimeTotal-(TimeEPos-track[drawtrack].midiMess[z].time);
> TimePerc=TimeOnRight/TimeTotal;
> plotRightSide=TimePerc*distanceTotal;
> recLength=plotRightSide-plotLeftSide;
> ctm.fillStyle = trColor[drawtrack];
> ctm.fillRect(50+plotLeftSide,(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8)),recLength,keyHeight-1);
>
> //Saving the values of note graphic to array to compare with mouse
> graphNotePosX[i]=50+plotLeftSide;
> graphNotePosY[i]=(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8));
> graphNoteLength[i]=recLength;
> graphNoteHeight[i]=keyHeight-1;
> graphNoteEvent[i]=x;
> i++;
> }
> x++;
> }
> }
By the way when i look at the code i wrote some/ a year ago i think there must be dark sorcery going on. It manages to draw out notelength just using the noteOn event, or maybe it doesn't....
Well i adjusted it apparently i thought i could just look at next event "or was lazy"....
function notePlot(){
//console.log("NOTEPLOT TRACK="+drawtrack+" midiMess length="+track[drawtrack].midiMess.length);
var plotRightSide=0;var plotLeftSide=0;
var x=0;var z=0;var i=0;
nbrOfEV = track[drawtrack].midiMess.length;
distanceTotal=Mwidth-keylength;
TimeTotal=TimeEPos-TimeSPos;
while (x<nbrOfEV-1){
if (track[drawtrack].midiMess[x].time>TimeSPos && track[drawtrack].midiMess[x].time<TimeEPos && track[drawtrack].midiMess[x].data0==NOTE_ON){

TimeOnLeft=track[drawtrack].midiMess[x].time-TimeSPos;
TimePerc=TimeOnLeft/TimeTotal;
plotLeftSide=TimePerc*distanceTotal;
////////////////////////////////////
//THIS CODE FIND THE NOTE OFF EVENT
var q=x+1;
findNote=track[drawtrack].midiMess[x].data1;
while (track[drawtrack].midiMess[q].data1!=findNote) {
q++;
}
///////////////////////////////////
TimeOnRight=TimeTotal-(TimeEPos-track[drawtrack].midiMess[q].time);
TimePerc=TimeOnRight/TimeTotal;
plotRightSide=TimePerc*distanceTotal;
recLength=plotRightSide-plotLeftSide;
ctm.fillStyle = trColor[drawtrack];
ctm.fillRect(50+plotLeftSide,(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8)),recLength,keyHeight-1);

//Saving the values of note graphic to array to compare with mouse
graphNotePosX[i]=50+plotLeftSide;
graphNotePosY[i]=(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8));
graphNoteLength[i]=recLength;
graphNoteHeight[i]=keyHeight-1;
graphNoteEvent[i]=x;
i++;
}
x++;
}

So i fixed "drawout" for note lengths "note off" but the multitrack draw at track zero, remain unsolved anyone got any idea?

Re: Function calls that behave different depending on else leg.

<2c65a9f5-370e-4d32-a3ee-874bded60832n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17382&group=comp.lang.javascript#17382

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:ac8:7763:: with SMTP id h3mr22038511qtu.159.1635229873972;
Mon, 25 Oct 2021 23:31:13 -0700 (PDT)
X-Received: by 2002:a05:6830:1c6b:: with SMTP id s11mr16978465otg.209.1635229873687;
Mon, 25 Oct 2021 23:31:13 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Date: Mon, 25 Oct 2021 23:31:13 -0700 (PDT)
In-Reply-To: <514e5b19-da98-4059-840c-be17998615fdn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=84.217.164.86; posting-account=kxPkPAoAAACjJi8w0gL9bnyznPzdw9HW
NNTP-Posting-Host: 84.217.164.86
References: <c2c3ce9b-52b7-427c-a479-40d60e9835cen@googlegroups.com> <514e5b19-da98-4059-840c-be17998615fdn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2c65a9f5-370e-4d32-a3ee-874bded60832n@googlegroups.com>
Subject: Re: Function calls that behave different depending on else leg.
From: jonas.thornvall@gmail.com (Jonas Thörnvall)
Injection-Date: Tue, 26 Oct 2021 06:31:13 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 168
 by: Jonas Thörnvall - Tue, 26 Oct 2021 06:31 UTC

tisdag 26 oktober 2021 kl. 08:24:13 UTC+2 skrev Jonas Thörnvall:
> tisdag 26 oktober 2021 kl. 07:38:21 UTC+2 skrev Jonas Thörnvall:
> > I have this function drawNotesCanvas that behave different depending on else leg although the same call to function as other leg?
> >
> > What i want todo is draw out all tracks if track is zero, track zero is the "downmix of all tracks", used during playup.
> >
> > But even if i hardcode channel and remove loop, it does not to what the other "single channel" else leg do. It has gotten me bewilderd for months "years".
> >
> > snippet
> > ============
> > if (activetrack==0){
> > //for (var i=1;i<=maxtrack;i++){
> > drawtrack=1; //1,2,3 or whatever channel do not do same as other leg
> > notePlot();
> > // }
> > } else {
> > drawtrack=activetrack;
> > notePlot();
> > }
> > }
> >
> > fullcode
> > ==================
> > var graphNotePosX= [];
> > var graphNotePosY= [];
> > var graphNoteLength= [];
> > var graphNoteHeight= [];
> > var graphNoteEvent= [];
> > var trColor=[];
> >
> > trColor[0]="yellow";
> > trColor[1]="magenta";
> > trColor[2]="lightgrey";
> > trColor[3]="skyblue";
> > trColor[4]="yellow";
> > trColor[5]="fuchsia";
> > trColor[6]="pink";
> > trColor[7]="magenta";
> > trColor[8]="orange";
> > trColor[9]="cyan";
> > trColor[10]="white";
> > trColor[11]="lightgreen";
> > trColor[12]="silver";
> > trColor[13]="lightblue";
> > trColor[14]="olive";
> > trColor[15]="red";
> > trColor[16]="aqua";
> >
> > // CLEAR NOTES ON CANVAS
> > function delRenderedNotes() {
> > ctm.fillStyle = "black";
> > ctm.fillRect(46, 24, Mwidth, Mheight);
> > }
> >
> > // FETCH VALUES WHERE TO DRAW IN VIEW MODE
> > function drawNotesCanvas(){
> > startPoint=0;
> > endPoint=Mwidth;
> > editSPos=document.getElementById("SB").value;
> > editEPos=document.getElementById("EB").value;
> > TimeSPos=document.getElementById("EditStart").value;
> > TimeSPos=parseInt(TimeSPos);
> > TimeEPos=document.getElementById("EditEnd").value;
> > TimeEPos=parseInt(TimeEPos);
> > if (activetrack==0){
> > for (var i=1;i<=maxtrack;i++){
> > drawtrack=i;
> > notePlot();
> > }
> > } else {
> > drawtrack=activetrack;
> > notePlot();
> > }
> > }
> >
> > // DRAWOUT NOTES ON MAIN CANVAS WHEN PAGE VIEW CHANGE
> > function notePlot(){
> > //console.log("NOTEPLOT TRACK="+drawtrack+" midiMess length="+track[drawtrack].midiMess.length);
> > var plotRightSide=0;var plotLeftSide=0;
> > var x=0;var z=0;var i=0;
> > nbrOfEV = track[drawtrack].midiMess.length;
> > distanceTotal=Mwidth-keylength;
> > TimeTotal=TimeEPos-TimeSPos;
> > while (x<nbrOfEV-1){
> > if (track[drawtrack].midiMess[x].time>TimeSPos && track[drawtrack].midiMess[x].time<TimeEPos && track[drawtrack].midiMess[x].data0==NOTE_ON){
> >
> > TimeOnLeft=track[drawtrack].midiMess[x].time-TimeSPos;
> > TimePerc=TimeOnLeft/TimeTotal;
> > plotLeftSide=TimePerc*distanceTotal;
> > z=x+1;
> > TimeOnRight=TimeTotal-(TimeEPos-track[drawtrack].midiMess[z].time);
> > TimePerc=TimeOnRight/TimeTotal;
> > plotRightSide=TimePerc*distanceTotal;
> > recLength=plotRightSide-plotLeftSide;
> > ctm.fillStyle = trColor[drawtrack];
> > ctm.fillRect(50+plotLeftSide,(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8)),recLength,keyHeight-1);
> >
> > //Saving the values of note graphic to array to compare with mouse
> > graphNotePosX[i]=50+plotLeftSide;
> > graphNotePosY[i]=(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack]..midiMess[x].data1-8));
> > graphNoteLength[i]=recLength;
> > graphNoteHeight[i]=keyHeight-1;
> > graphNoteEvent[i]=x;
> > i++;
> > }
> > x++;
> > }
> > }
> By the way when i look at the code i wrote some/ a year ago i think there must be dark sorcery going on. It manages to draw out notelength just using the noteOn event, or maybe it doesn't....
> Well i adjusted it apparently i thought i could just look at next event "or was lazy"....
> function notePlot(){
> //console.log("NOTEPLOT TRACK="+drawtrack+" midiMess length="+track[drawtrack].midiMess.length);
> var plotRightSide=0;var plotLeftSide=0;
> var x=0;var z=0;var i=0;
> nbrOfEV = track[drawtrack].midiMess.length;
> distanceTotal=Mwidth-keylength;
> TimeTotal=TimeEPos-TimeSPos;
> while (x<nbrOfEV-1){
> if (track[drawtrack].midiMess[x].time>TimeSPos && track[drawtrack].midiMess[x].time<TimeEPos && track[drawtrack].midiMess[x].data0==NOTE_ON){
>
> TimeOnLeft=track[drawtrack].midiMess[x].time-TimeSPos;
> TimePerc=TimeOnLeft/TimeTotal;
> plotLeftSide=TimePerc*distanceTotal;
> ////////////////////////////////////
> //THIS CODE FIND THE NOTE OFF EVENT
> var q=x+1;
> findNote=track[drawtrack].midiMess[x].data1;
> while (track[drawtrack].midiMess[q].data1!=findNote) {
> q++;
> }
> ///////////////////////////////////
> TimeOnRight=TimeTotal-(TimeEPos-track[drawtrack].midiMess[q].time);
> TimePerc=TimeOnRight/TimeTotal;
> plotRightSide=TimePerc*distanceTotal;
> recLength=plotRightSide-plotLeftSide;
> ctm.fillStyle = trColor[drawtrack];
> ctm.fillRect(50+plotLeftSide,(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8)),recLength,keyHeight-1);
>
> //Saving the values of note graphic to array to compare with mouse
> graphNotePosX[i]=50+plotLeftSide;
> graphNotePosY[i]=(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8));
> graphNoteLength[i]=recLength;
> graphNoteHeight[i]=keyHeight-1;
> graphNoteEvent[i]=x;
> i++;
> }
> x++;
> }
> So i fixed "drawout" for note lengths "note off" but the multitrack draw at track zero, remain unsolved anyone got any idea?
http://jtmidi.000webhostapp.com/

Re: Function calls that behave different depending on else leg.

<2c2e6343-3368-4b82-bbec-236cfaea59d0n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17386&group=comp.lang.javascript#17386

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a05:620a:1a28:: with SMTP id bk40mr21820427qkb.224.1635288651337;
Tue, 26 Oct 2021 15:50:51 -0700 (PDT)
X-Received: by 2002:a4a:4548:: with SMTP id y69mr19338997ooa.52.1635288651061;
Tue, 26 Oct 2021 15:50:51 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Date: Tue, 26 Oct 2021 15:50:50 -0700 (PDT)
In-Reply-To: <2c65a9f5-370e-4d32-a3ee-874bded60832n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=84.217.164.86; posting-account=kxPkPAoAAACjJi8w0gL9bnyznPzdw9HW
NNTP-Posting-Host: 84.217.164.86
References: <c2c3ce9b-52b7-427c-a479-40d60e9835cen@googlegroups.com>
<514e5b19-da98-4059-840c-be17998615fdn@googlegroups.com> <2c65a9f5-370e-4d32-a3ee-874bded60832n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2c2e6343-3368-4b82-bbec-236cfaea59d0n@googlegroups.com>
Subject: Re: Function calls that behave different depending on else leg.
From: jonas.thornvall@gmail.com (Jonas Thörnvall)
Injection-Date: Tue, 26 Oct 2021 22:50:51 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 176
 by: Jonas Thörnvall - Tue, 26 Oct 2021 22:50 UTC

tisdag 26 oktober 2021 kl. 08:31:18 UTC+2 skrev Jonas Thörnvall:
> tisdag 26 oktober 2021 kl. 08:24:13 UTC+2 skrev Jonas Thörnvall:
> > tisdag 26 oktober 2021 kl. 07:38:21 UTC+2 skrev Jonas Thörnvall:
> > > I have this function drawNotesCanvas that behave different depending on else leg although the same call to function as other leg?
> > >
> > > What i want todo is draw out all tracks if track is zero, track zero is the "downmix of all tracks", used during playup.
> > >
> > > But even if i hardcode channel and remove loop, it does not to what the other "single channel" else leg do. It has gotten me bewilderd for months "years".
> > >
> > > snippet
> > > ============
> > > if (activetrack==0){
> > > //for (var i=1;i<=maxtrack;i++){
> > > drawtrack=1; //1,2,3 or whatever channel do not do same as other leg
> > > notePlot();
> > > // }
> > > } else {
> > > drawtrack=activetrack;
> > > notePlot();
> > > }
> > > }
> > >
> > > fullcode
> > > ==================
> > > var graphNotePosX= [];
> > > var graphNotePosY= [];
> > > var graphNoteLength= [];
> > > var graphNoteHeight= [];
> > > var graphNoteEvent= [];
> > > var trColor=[];
> > >
> > > trColor[0]="yellow";
> > > trColor[1]="magenta";
> > > trColor[2]="lightgrey";
> > > trColor[3]="skyblue";
> > > trColor[4]="yellow";
> > > trColor[5]="fuchsia";
> > > trColor[6]="pink";
> > > trColor[7]="magenta";
> > > trColor[8]="orange";
> > > trColor[9]="cyan";
> > > trColor[10]="white";
> > > trColor[11]="lightgreen";
> > > trColor[12]="silver";
> > > trColor[13]="lightblue";
> > > trColor[14]="olive";
> > > trColor[15]="red";
> > > trColor[16]="aqua";
> > >
> > > // CLEAR NOTES ON CANVAS
> > > function delRenderedNotes() {
> > > ctm.fillStyle = "black";
> > > ctm.fillRect(46, 24, Mwidth, Mheight);
> > > }
> > >
> > > // FETCH VALUES WHERE TO DRAW IN VIEW MODE
> > > function drawNotesCanvas(){
> > > startPoint=0;
> > > endPoint=Mwidth;
> > > editSPos=document.getElementById("SB").value;
> > > editEPos=document.getElementById("EB").value;
> > > TimeSPos=document.getElementById("EditStart").value;
> > > TimeSPos=parseInt(TimeSPos);
> > > TimeEPos=document.getElementById("EditEnd").value;
> > > TimeEPos=parseInt(TimeEPos);
> > > if (activetrack==0){
> > > for (var i=1;i<=maxtrack;i++){
> > > drawtrack=i;
> > > notePlot();
> > > }
> > > } else {
> > > drawtrack=activetrack;
> > > notePlot();
> > > }
> > > }
> > >
> > > // DRAWOUT NOTES ON MAIN CANVAS WHEN PAGE VIEW CHANGE
> > > function notePlot(){
> > > //console.log("NOTEPLOT TRACK="+drawtrack+" midiMess length="+track[drawtrack].midiMess.length);
> > > var plotRightSide=0;var plotLeftSide=0;
> > > var x=0;var z=0;var i=0;
> > > nbrOfEV = track[drawtrack].midiMess.length;
> > > distanceTotal=Mwidth-keylength;
> > > TimeTotal=TimeEPos-TimeSPos;
> > > while (x<nbrOfEV-1){
> > > if (track[drawtrack].midiMess[x].time>TimeSPos && track[drawtrack].midiMess[x].time<TimeEPos && track[drawtrack].midiMess[x].data0==NOTE_ON){
> > >
> > > TimeOnLeft=track[drawtrack].midiMess[x].time-TimeSPos;
> > > TimePerc=TimeOnLeft/TimeTotal;
> > > plotLeftSide=TimePerc*distanceTotal;
> > > z=x+1;
> > > TimeOnRight=TimeTotal-(TimeEPos-track[drawtrack].midiMess[z].time);
> > > TimePerc=TimeOnRight/TimeTotal;
> > > plotRightSide=TimePerc*distanceTotal;
> > > recLength=plotRightSide-plotLeftSide;
> > > ctm.fillStyle = trColor[drawtrack];
> > > ctm.fillRect(50+plotLeftSide,(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8)),recLength,keyHeight-1);
> > >
> > > //Saving the values of note graphic to array to compare with mouse
> > > graphNotePosX[i]=50+plotLeftSide;
> > > graphNotePosY[i]=(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8));
> > > graphNoteLength[i]=recLength;
> > > graphNoteHeight[i]=keyHeight-1;
> > > graphNoteEvent[i]=x;
> > > i++;
> > > }
> > > x++;
> > > }
> > > }
> > By the way when i look at the code i wrote some/ a year ago i think there must be dark sorcery going on. It manages to draw out notelength just using the noteOn event, or maybe it doesn't....
> > Well i adjusted it apparently i thought i could just look at next event "or was lazy"....
> > function notePlot(){
> > //console.log("NOTEPLOT TRACK="+drawtrack+" midiMess length="+track[drawtrack].midiMess.length);
> > var plotRightSide=0;var plotLeftSide=0;
> > var x=0;var z=0;var i=0;
> > nbrOfEV = track[drawtrack].midiMess.length;
> > distanceTotal=Mwidth-keylength;
> > TimeTotal=TimeEPos-TimeSPos;
> > while (x<nbrOfEV-1){
> > if (track[drawtrack].midiMess[x].time>TimeSPos && track[drawtrack].midiMess[x].time<TimeEPos && track[drawtrack].midiMess[x].data0==NOTE_ON){
> >
> > TimeOnLeft=track[drawtrack].midiMess[x].time-TimeSPos;
> > TimePerc=TimeOnLeft/TimeTotal;
> > plotLeftSide=TimePerc*distanceTotal;
> > ////////////////////////////////////
> > //THIS CODE FIND THE NOTE OFF EVENT
> > var q=x+1;
> > findNote=track[drawtrack].midiMess[x].data1;
> > while (track[drawtrack].midiMess[q].data1!=findNote) {
> > q++;
> > }
> > ///////////////////////////////////
> > TimeOnRight=TimeTotal-(TimeEPos-track[drawtrack].midiMess[q].time);
> > TimePerc=TimeOnRight/TimeTotal;
> > plotRightSide=TimePerc*distanceTotal;
> > recLength=plotRightSide-plotLeftSide;
> > ctm.fillStyle = trColor[drawtrack];
> > ctm.fillRect(50+plotLeftSide,(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8)),recLength,keyHeight-1);
> >
> > //Saving the values of note graphic to array to compare with mouse
> > graphNotePosX[i]=50+plotLeftSide;
> > graphNotePosY[i]=(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack]..midiMess[x].data1-8));
> > graphNoteLength[i]=recLength;
> > graphNoteHeight[i]=keyHeight-1;
> > graphNoteEvent[i]=x;
> > i++;
> > }
> > x++;
> > }
> > So i fixed "drawout" for note lengths "note off" but the multitrack draw at track zero, remain unsolved anyone got any idea?
> http://jtmidi.000webhostapp.com/
To be honest i am probably just silly about estethics, having all tracks up is probably just confusing but i wanted sort of a graphical overview of full song all tracks in different color just when loaded.
And i tried to figure out what goes wrong quiet a few times....

Re: Function calls that behave different depending on else leg.

<a7440c69-4466-41d4-a868-595340e05b90n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17387&group=comp.lang.javascript#17387

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a37:a105:: with SMTP id k5mr189405qke.427.1635369125357;
Wed, 27 Oct 2021 14:12:05 -0700 (PDT)
X-Received: by 2002:a05:6830:19dc:: with SMTP id p28mr117236otp.185.1635369125036;
Wed, 27 Oct 2021 14:12:05 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Date: Wed, 27 Oct 2021 14:12:04 -0700 (PDT)
In-Reply-To: <c2c3ce9b-52b7-427c-a479-40d60e9835cen@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=97.87.183.68; posting-account=G1KGwgkAAAAyw4z0LxHH0fja6wAbo7Cz
NNTP-Posting-Host: 97.87.183.68
References: <c2c3ce9b-52b7-427c-a479-40d60e9835cen@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a7440c69-4466-41d4-a868-595340e05b90n@googlegroups.com>
Subject: Re: Function calls that behave different depending on else leg.
From: luser.droog@gmail.com (luserdroog)
Injection-Date: Wed, 27 Oct 2021 21:12:05 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 40
 by: luserdroog - Wed, 27 Oct 2021 21:12 UTC

On Tuesday, October 26, 2021 at 12:38:21 AM UTC-5, jonas.t...@gmail.com wrote:
> //Saving the values of note graphic to array to compare with mouse
> graphNotePosX[i]=50+plotLeftSide;
> graphNotePosY[i]=(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8));
> graphNoteLength[i]=recLength;
> graphNoteHeight[i]=keyHeight-1;
> graphNoteEvent[i]=x;

I (and others) have tried suggesting better abstraction to make your code more readable.
I think this block might be a good isolated example to try again.

This code just looks wrong. It's not the best use of data structure organization.
The graph note should be an object. All the named parts should be properties of
the object. And then since you need and array of them, make an array of them.

Consider if the code were rewritten like this (with corresponding changes to the data structure):

graphNote[i].PosX=50+plotLeftSide;
graphNote[i].PosY=(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8));
graphNote[i].Length=recLength;
graphNote[i].Height=keyHeight-1;
graphNote[i].Event=x;

If this is the initialization of a new object, that could be made clearer by combining all the lines
into a single assignment of a new object.

graphNote[i] = {
PosX=50+plotLeftSide,
PosY=(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8)),
Length=recLength,
Height=keyHeight-1,
Event=x,
};

Or, you could go still further and wrap it in a function with a descriptive name:

save_new_graph_note( i, drawtrack, x );

Abstraction lets you write less code overall, have less code to read and debug, isolate changes
to small parts of the program, and improve organization and efficiency. As a bonus,
it makes the code easier for others to understand if they want to offer help.

Re: Function calls that behave different depending on else leg.

<64b177ad-6ca7-442b-8b14-8ac50260cdc4n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17388&group=comp.lang.javascript#17388

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a05:6214:f62:: with SMTP id iy2mr19827448qvb.25.1635758369517;
Mon, 01 Nov 2021 02:19:29 -0700 (PDT)
X-Received: by 2002:a4a:c3c2:: with SMTP id e2mr7112233ooq.52.1635758369257;
Mon, 01 Nov 2021 02:19:29 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Date: Mon, 1 Nov 2021 02:19:29 -0700 (PDT)
In-Reply-To: <a7440c69-4466-41d4-a868-595340e05b90n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=84.217.164.86; posting-account=kxPkPAoAAACjJi8w0gL9bnyznPzdw9HW
NNTP-Posting-Host: 84.217.164.86
References: <c2c3ce9b-52b7-427c-a479-40d60e9835cen@googlegroups.com> <a7440c69-4466-41d4-a868-595340e05b90n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <64b177ad-6ca7-442b-8b14-8ac50260cdc4n@googlegroups.com>
Subject: Re: Function calls that behave different depending on else leg.
From: jonas.thornvall@gmail.com (Jonas Thörnvall)
Injection-Date: Mon, 01 Nov 2021 09:19:29 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 48
 by: Jonas Thörnvall - Mon, 1 Nov 2021 09:19 UTC

onsdag 27 oktober 2021 kl. 23:12:09 UTC+2 skrev luser...@gmail.com:
> On Tuesday, October 26, 2021 at 12:38:21 AM UTC-5, jonas.t...@gmail.com wrote:
> > //Saving the values of note graphic to array to compare with mouse
> > graphNotePosX[i]=50+plotLeftSide;
> > graphNotePosY[i]=(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8));
> > graphNoteLength[i]=recLength;
> > graphNoteHeight[i]=keyHeight-1;
> > graphNoteEvent[i]=x;
> I (and others) have tried suggesting better abstraction to make your code more readable.
> I think this block might be a good isolated example to try again.
>
> This code just looks wrong. It's not the best use of data structure organization.
> The graph note should be an object. All the named parts should be properties of
> the object. And then since you need and array of them, make an array of them.
>
> Consider if the code were rewritten like this (with corresponding changes to the data structure):
>
> graphNote[i].PosX=50+plotLeftSide;
> graphNote[i].PosY=(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8));
> graphNote[i].Length=recLength;
> graphNote[i].Height=keyHeight-1;
> graphNote[i].Event=x;
>
> If this is the initialization of a new object, that could be made clearer by combining all the lines
> into a single assignment of a new object.
>
> graphNote[i] = {
> PosX=50+plotLeftSide,
> PosY=(PistartX+keyHeight*88)-(keyHeight*(track[drawtrack].midiMess[x].data1-8)),
> Length=recLength,
> Height=keyHeight-1,
> Event=x,
> };
>
> Or, you could go still further and wrap it in a function with a descriptive name:
>
> save_new_graph_note( i, drawtrack, x );
>
> Abstraction lets you write less code overall, have less code to read and debug, isolate changes
> to small parts of the program, and improve organization and efficiency. As a bonus,
> it makes the code easier for others to understand if they want to offer help.
Yeah you are probably correct, but of course that is really just a region of "graphics" that is compared with mouse to be able to know if you clicked inside or outside object.
But i agree it probably would look more tidy comparing mouse position with properties of "graphical note" properties "it is just for open editor and read in note"

But that is not what goes wrong here for some reason the multi track leg do not behave like the single track leg, even if content the same "that is weird".
So i can make a copy and hardcode a track of single leg solution but it will not load "draw" that track.

Similar now when i run "all" tracks to draw in a loop only track one is drawn.
I **probably** could draw just track ZERO and get all the mixed down tracks, but then they would all have same colour and that is no fun.


devel / comp.lang.javascript / Function calls that behave different depending on else leg.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor