Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Counting in binary is just like counting in decimal -- if you are all thumbs. -- Glaser and Way


devel / comp.lang.javascript / Re: Conditions help.

SubjectAuthor
* Conditions help.Jonas Thörnvall
`* Re: Conditions help.luserdroog
 `* Re: Conditions help.Jonas Thörnvall
  `* Re: Conditions help.Jonas Thörnvall
   +- Re: Conditions help.Jonas Thörnvall
   `* Re: Conditions help.Jonas Thörnvall
    `* Re: Conditions help.luserdroog
     `* Re: Conditions help.Jonas Thörnvall
      `- Re: Conditions help.Jonas Thörnvall

1
Conditions help.

<c3f08328-8cae-464e-8dd2-02e77ebe2a8cn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a05:620a:2a10:: with SMTP id o16mr12175388qkp.357.1636723131716;
Fri, 12 Nov 2021 05:18:51 -0800 (PST)
X-Received: by 2002:a05:6808:98e:: with SMTP id a14mr16815754oic.48.1636723131439;
Fri, 12 Nov 2021 05:18:51 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.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: Fri, 12 Nov 2021 05:18:51 -0800 (PST)
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: <c3f08328-8cae-464e-8dd2-02e77ebe2a8cn@googlegroups.com>
Subject: Conditions help.
From: jonas.thornvall@gmail.com (Jonas Thörnvall)
Injection-Date: Fri, 12 Nov 2021 13:18:51 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Jonas Thörnvall - Fri, 12 Nov 2021 13:18 UTC

I've been sitting to long trying to compare and adjust notes in time got dizzy.
How should this while be constructed to break when the two data1 is equal or it reach end of midimessages for track.

It does not seem to enter... although data1 is the same.
while(track[editTrack].midiMess[stopEvent].data1!=track[editTrack].midiMess[y].data1 && y<track[editTrack].midiMess.length){
alert(track[editTrack].midiMess[y].data1);
timeNextNote=track[editTrack].midiMess[y].time;
y++;
}

Re: Conditions help.

<d8082f6c-ebfc-4449-a1a3-2119c14fceafn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a05:620a:24c3:: with SMTP id m3mr7115146qkn.301.1637077037998;
Tue, 16 Nov 2021 07:37:17 -0800 (PST)
X-Received: by 2002:a05:6808:53:: with SMTP id v19mr21021291oic.8.1637077037756;
Tue, 16 Nov 2021 07:37:17 -0800 (PST)
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, 16 Nov 2021 07:37:17 -0800 (PST)
In-Reply-To: <c3f08328-8cae-464e-8dd2-02e77ebe2a8cn@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: <c3f08328-8cae-464e-8dd2-02e77ebe2a8cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d8082f6c-ebfc-4449-a1a3-2119c14fceafn@googlegroups.com>
Subject: Re: Conditions help.
From: luser.droog@gmail.com (luserdroog)
Injection-Date: Tue, 16 Nov 2021 15:37:17 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 28
 by: luserdroog - Tue, 16 Nov 2021 15:37 UTC

On Friday, November 12, 2021 at 7:18:55 AM UTC-6, jonas.t...@gmail.com wrote:
> I've been sitting to long trying to compare and adjust notes in time got dizzy.
> How should this while be constructed to break when the two data1 is equal or it reach end of midimessages for track.
>
> It does not seem to enter... although data1 is the same.
> while(track[editTrack].midiMess[stopEvent].data1!=track[editTrack].midiMess[y].data1 && y<track[editTrack].midiMess.length){
> alert(track[editTrack].midiMess[y].data1);
> timeNextNote=track[editTrack].midiMess[y].time;
> y++;
> }

Why do you need to "adjust notes in time"?
This sounds like part of a higher-level operation that might be handled differently
to avoid the whole issue.

It's seems that you're translating notes (pitch, start time, duration) into a list
of on/off events (ON pitch, time) (OFF pitch, time) and then sort them by time.

So I'd expect a high-level function for this to look roughly like this:

function midi_from_notes( notes ){
var events;
notes.forEach( note=>events.push( { type:"ON"; pitch:note.pitch; time:note.start_time } ) );
notes.forEach( note=>events.push( { type:"OFF"; pitch:note.pitch; time:note.start_time + note.duration } ) );
return events.sort( ev=>ev.time );
}

I may be forgetting some details about midi. If you need relative times, then you can do
another loop for that, or write a helper function to do the looping.

Re: Conditions help.

<3f6cc701-cca3-4b68-866a-f918dd80c00dn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a05:620a:892:: with SMTP id b18mr8518549qka.360.1637093880055;
Tue, 16 Nov 2021 12:18:00 -0800 (PST)
X-Received: by 2002:a05:6808:3097:: with SMTP id bl23mr9074789oib.0.1637093879812;
Tue, 16 Nov 2021 12:17:59 -0800 (PST)
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, 16 Nov 2021 12:17:59 -0800 (PST)
In-Reply-To: <d8082f6c-ebfc-4449-a1a3-2119c14fceafn@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: <c3f08328-8cae-464e-8dd2-02e77ebe2a8cn@googlegroups.com> <d8082f6c-ebfc-4449-a1a3-2119c14fceafn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3f6cc701-cca3-4b68-866a-f918dd80c00dn@googlegroups.com>
Subject: Re: Conditions help.
From: jonas.thornvall@gmail.com (Jonas Thörnvall)
Injection-Date: Tue, 16 Nov 2021 20:18:00 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 29
 by: Jonas Thörnvall - Tue, 16 Nov 2021 20:17 UTC

tisdag 16 november 2021 kl. 16:37:22 UTC+1 skrev luser...@gmail.com:
> On Friday, November 12, 2021 at 7:18:55 AM UTC-6, jonas.t...@gmail.com wrote:
> > I've been sitting to long trying to compare and adjust notes in time got dizzy.
> > How should this while be constructed to break when the two data1 is equal or it reach end of midimessages for track.
> >
> > It does not seem to enter... although data1 is the same.
> > while(track[editTrack].midiMess[stopEvent].data1!=track[editTrack].midiMess[y].data1 && y<track[editTrack].midiMess.length){
> > alert(track[editTrack].midiMess[y].data1);
> > timeNextNote=track[editTrack].midiMess[y].time;
> > y++;
> > }
> Why do you need to "adjust notes in time"?
> This sounds like part of a higher-level operation that might be handled differently
> to avoid the whole issue.
>
> It's seems that you're translating notes (pitch, start time, duration) into a list
> of on/off events (ON pitch, time) (OFF pitch, time) and then sort them by time.
>
> So I'd expect a high-level function for this to look roughly like this:
>
> function midi_from_notes( notes ){
> var events;
> notes.forEach( note=>events.push( { type:"ON"; pitch:note.pitch; time:note.start_time } ) );
> notes.forEach( note=>events.push( { type:"OFF"; pitch:note.pitch; time:note.start_time + note.duration } ) );
> return events.sort( ev=>ev.time );
> }
>
> I may be forgetting some details about midi. If you need relative times, then you can do
> another loop for that, or write a helper function to do the looping.
So you say i should just remove the note and push a new one, and sort again. That may actually be easier then update the array element, will think about it.

Re: Conditions help.

<9060b76b-9393-4766-82e4-01f274e6cb87n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:ac8:5b83:: with SMTP id a3mr10819390qta.62.1637094383617;
Tue, 16 Nov 2021 12:26:23 -0800 (PST)
X-Received: by 2002:aca:2205:: with SMTP id b5mr8895821oic.177.1637094383364;
Tue, 16 Nov 2021 12:26:23 -0800 (PST)
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, 16 Nov 2021 12:26:23 -0800 (PST)
In-Reply-To: <3f6cc701-cca3-4b68-866a-f918dd80c00dn@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: <c3f08328-8cae-464e-8dd2-02e77ebe2a8cn@googlegroups.com>
<d8082f6c-ebfc-4449-a1a3-2119c14fceafn@googlegroups.com> <3f6cc701-cca3-4b68-866a-f918dd80c00dn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9060b76b-9393-4766-82e4-01f274e6cb87n@googlegroups.com>
Subject: Re: Conditions help.
From: jonas.thornvall@gmail.com (Jonas Thörnvall)
Injection-Date: Tue, 16 Nov 2021 20:26:23 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 53
 by: Jonas Thörnvall - Tue, 16 Nov 2021 20:26 UTC

tisdag 16 november 2021 kl. 21:18:04 UTC+1 skrev Jonas Thörnvall:
> tisdag 16 november 2021 kl. 16:37:22 UTC+1 skrev luser...@gmail.com:
> > On Friday, November 12, 2021 at 7:18:55 AM UTC-6, jonas.t...@gmail.com wrote:
> > > I've been sitting to long trying to compare and adjust notes in time got dizzy.
> > > How should this while be constructed to break when the two data1 is equal or it reach end of midimessages for track.
> > >
> > > It does not seem to enter... although data1 is the same.
> > > while(track[editTrack].midiMess[stopEvent].data1!=track[editTrack].midiMess[y].data1 && y<track[editTrack].midiMess.length){
> > > alert(track[editTrack].midiMess[y].data1);
> > > timeNextNote=track[editTrack].midiMess[y].time;
> > > y++;
> > > }
> > Why do you need to "adjust notes in time"?
> > This sounds like part of a higher-level operation that might be handled differently
> > to avoid the whole issue.
> >
> > It's seems that you're translating notes (pitch, start time, duration) into a list
> > of on/off events (ON pitch, time) (OFF pitch, time) and then sort them by time.
> >
> > So I'd expect a high-level function for this to look roughly like this:
> >
> > function midi_from_notes( notes ){
> > var events;
> > notes.forEach( note=>events.push( { type:"ON"; pitch:note.pitch; time:note.start_time } ) );
> > notes.forEach( note=>events.push( { type:"OFF"; pitch:note.pitch; time:note.start_time + note.duration } ) );
> > return events.sort( ev=>ev.time );
> > }
> >
> > I may be forgetting some details about midi. If you need relative times, then you can do
> > another loop for that, or write a helper function to do the looping.
> So you say i should just remove the note and push a new one, and sort again. That may actually be easier then update the array element, will think about it.

But i remember now, the main obstacle is really the max + - "positional" that is set by the corresponding "same note value" before and after.
I have no problem of extending length, of note but howto keep track that it stay smaller then the next note of same value.

I solved it for the ON case looking at where "same note" **before*** end, but are somehow not bright enough to do it for the OFF case extending end.
I have a look at it a day i feel awake and lucky...

Re: Conditions help.

<e01bb828-422f-4fec-9d1e-cec3d5c58260n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a05:622a:1495:: with SMTP id t21mr11319341qtx.152.1637095930384;
Tue, 16 Nov 2021 12:52:10 -0800 (PST)
X-Received: by 2002:a9d:6ac7:: with SMTP id m7mr8777132otq.306.1637095930107;
Tue, 16 Nov 2021 12:52:10 -0800 (PST)
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, 16 Nov 2021 12:52:09 -0800 (PST)
In-Reply-To: <9060b76b-9393-4766-82e4-01f274e6cb87n@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: <c3f08328-8cae-464e-8dd2-02e77ebe2a8cn@googlegroups.com>
<d8082f6c-ebfc-4449-a1a3-2119c14fceafn@googlegroups.com> <3f6cc701-cca3-4b68-866a-f918dd80c00dn@googlegroups.com>
<9060b76b-9393-4766-82e4-01f274e6cb87n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e01bb828-422f-4fec-9d1e-cec3d5c58260n@googlegroups.com>
Subject: Re: Conditions help.
From: jonas.thornvall@gmail.com (Jonas Thörnvall)
Injection-Date: Tue, 16 Nov 2021 20:52:10 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 75
 by: Jonas Thörnvall - Tue, 16 Nov 2021 20:52 UTC

tisdag 16 november 2021 kl. 21:26:27 UTC+1 skrev Jonas Thörnvall:
> tisdag 16 november 2021 kl. 21:18:04 UTC+1 skrev Jonas Thörnvall:
> > tisdag 16 november 2021 kl. 16:37:22 UTC+1 skrev luser...@gmail.com:
> > > On Friday, November 12, 2021 at 7:18:55 AM UTC-6, jonas.t...@gmail.com wrote:
> > > > I've been sitting to long trying to compare and adjust notes in time got dizzy.
> > > > How should this while be constructed to break when the two data1 is equal or it reach end of midimessages for track.
> > > >
> > > > It does not seem to enter... although data1 is the same.
> > > > while(track[editTrack].midiMess[stopEvent].data1!=track[editTrack].midiMess[y].data1 && y<track[editTrack].midiMess.length){
> > > > alert(track[editTrack].midiMess[y].data1);
> > > > timeNextNote=track[editTrack].midiMess[y].time;
> > > > y++;
> > > > }
> > > Why do you need to "adjust notes in time"?
> > > This sounds like part of a higher-level operation that might be handled differently
> > > to avoid the whole issue.
> > >
> > > It's seems that you're translating notes (pitch, start time, duration) into a list
> > > of on/off events (ON pitch, time) (OFF pitch, time) and then sort them by time.
> > >
> > > So I'd expect a high-level function for this to look roughly like this:
> > >
> > > function midi_from_notes( notes ){
> > > var events;
> > > notes.forEach( note=>events.push( { type:"ON"; pitch:note.pitch; time:note.start_time } ) );
> > > notes.forEach( note=>events.push( { type:"OFF"; pitch:note.pitch; time:note.start_time + note.duration } ) );
> > > return events.sort( ev=>ev.time );
> > > }
> > >
> > > I may be forgetting some details about midi. If you need relative times, then you can do
> > > another loop for that, or write a helper function to do the looping.
> > So you say i should just remove the note and push a new one, and sort again. That may actually be easier then update the array element, will think about it.
> But i remember now, the main obstacle is really the max + - "positional" that is set by the corresponding "same note value" before and after.
> I have no problem of extending length, of note but howto keep track that it stay smaller then the next note of same value.
>
> I solved it for the ON case looking at where "same note" **before*** end, but are somehow not bright enough to do it for the OFF case extending end.
> I have a look at it a day i feel awake and lucky...

I agree it seem real simple, but when i start doing it get quite hard to actually implement.
Because when you move a note [x] with "some" milliseconds, you must first compare it "search for next note holding same value" [y] and should only be updated while less otherwise you create havoc.

[start x]->[start y] ->[end x]->[end y]

And i think that it was within using {x[ ***finding*** and comparing with element [y] my logic did crash. I got it working for ON [Moving both forward and backward] and for OFF [Moving backward].
OFF BACKWARD simply mean do not move beyond start of note.
ON FORWARD simple mean do not move beyond end of note.
ON BACKWARD do not move before previous "same note" start.
OFF FORWARD do not move beyond next "same note" value start.

I guess that i can't solve it for OFF FORWARD mean i simply do not find correct index [y] to compare with, it seem to walk right thru next note.
In theory it is simple find next "same note" values time to compare with.
If x less then y update else nothing.

Re: Conditions help.

<c91300aa-a6b8-4386-9629-3299252098a7n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a05:6214:4007:: with SMTP id kd7mr50088060qvb.52.1637096188534;
Tue, 16 Nov 2021 12:56:28 -0800 (PST)
X-Received: by 2002:a4a:b501:: with SMTP id r1mr5382146ooo.20.1637096188281;
Tue, 16 Nov 2021 12:56:28 -0800 (PST)
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, 16 Nov 2021 12:56:28 -0800 (PST)
In-Reply-To: <9060b76b-9393-4766-82e4-01f274e6cb87n@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: <c3f08328-8cae-464e-8dd2-02e77ebe2a8cn@googlegroups.com>
<d8082f6c-ebfc-4449-a1a3-2119c14fceafn@googlegroups.com> <3f6cc701-cca3-4b68-866a-f918dd80c00dn@googlegroups.com>
<9060b76b-9393-4766-82e4-01f274e6cb87n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c91300aa-a6b8-4386-9629-3299252098a7n@googlegroups.com>
Subject: Re: Conditions help.
From: jonas.thornvall@gmail.com (Jonas Thörnvall)
Injection-Date: Tue, 16 Nov 2021 20:56:28 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 58
 by: Jonas Thörnvall - Tue, 16 Nov 2021 20:56 UTC

tisdag 16 november 2021 kl. 21:26:27 UTC+1 skrev Jonas Thörnvall:
> tisdag 16 november 2021 kl. 21:18:04 UTC+1 skrev Jonas Thörnvall:
> > tisdag 16 november 2021 kl. 16:37:22 UTC+1 skrev luser...@gmail.com:
> > > On Friday, November 12, 2021 at 7:18:55 AM UTC-6, jonas.t...@gmail.com wrote:
> > > > I've been sitting to long trying to compare and adjust notes in time got dizzy.
> > > > How should this while be constructed to break when the two data1 is equal or it reach end of midimessages for track.
> > > >
> > > > It does not seem to enter... although data1 is the same.
> > > > while(track[editTrack].midiMess[stopEvent].data1!=track[editTrack].midiMess[y].data1 && y<track[editTrack].midiMess.length){
> > > > alert(track[editTrack].midiMess[y].data1);
> > > > timeNextNote=track[editTrack].midiMess[y].time;
> > > > y++;
> > > > }
> > > Why do you need to "adjust notes in time"?
> > > This sounds like part of a higher-level operation that might be handled differently
> > > to avoid the whole issue.
> > >
> > > It's seems that you're translating notes (pitch, start time, duration) into a list
> > > of on/off events (ON pitch, time) (OFF pitch, time) and then sort them by time.
> > >
> > > So I'd expect a high-level function for this to look roughly like this:
> > >
> > > function midi_from_notes( notes ){
> > > var events;
> > > notes.forEach( note=>events.push( { type:"ON"; pitch:note.pitch; time:note.start_time } ) );
> > > notes.forEach( note=>events.push( { type:"OFF"; pitch:note.pitch; time:note.start_time + note.duration } ) );
> > > return events.sort( ev=>ev.time );
> > > }
> > >
> > > I may be forgetting some details about midi. If you need relative times, then you can do
> > > another loop for that, or write a helper function to do the looping.
> > So you say i should just remove the note and push a new one, and sort again. That may actually be easier then update the array element, will think about it.
> But i remember now, the main obstacle is really the max + - "positional" that is set by the corresponding "same note value" before and after.
> I have no problem of extending length, of note but howto keep track that it stay smaller then the next note of same value.
>
> I solved it for the ON case looking at where "same note" **before*** end, but are somehow not bright enough to do it for the OFF case extending end.
> I have a look at it a day i feel awake and lucky...
Why i do this if because at some point i maybe want to move, change duration, change startpos of note using drag and drop without break start ends.
Right now i use poor mans solution slidebars where steps can be set to some milliseconds, or simply step forward backward with + and -.

Re: Conditions help.

<d5976ec8-1763-409a-a482-a19f80d5be64n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a05:620a:f8b:: with SMTP id b11mr17914609qkn.81.1637200468790;
Wed, 17 Nov 2021 17:54:28 -0800 (PST)
X-Received: by 2002:a05:6808:14c2:: with SMTP id f2mr4250983oiw.154.1637200468493;
Wed, 17 Nov 2021 17:54:28 -0800 (PST)
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, 17 Nov 2021 17:54:28 -0800 (PST)
In-Reply-To: <c91300aa-a6b8-4386-9629-3299252098a7n@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: <c3f08328-8cae-464e-8dd2-02e77ebe2a8cn@googlegroups.com>
<d8082f6c-ebfc-4449-a1a3-2119c14fceafn@googlegroups.com> <3f6cc701-cca3-4b68-866a-f918dd80c00dn@googlegroups.com>
<9060b76b-9393-4766-82e4-01f274e6cb87n@googlegroups.com> <c91300aa-a6b8-4386-9629-3299252098a7n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d5976ec8-1763-409a-a482-a19f80d5be64n@googlegroups.com>
Subject: Re: Conditions help.
From: luser.droog@gmail.com (luserdroog)
Injection-Date: Thu, 18 Nov 2021 01:54:28 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 104
 by: luserdroog - Thu, 18 Nov 2021 01:54 UTC

On Tuesday, November 16, 2021 at 2:56:33 PM UTC-6, jonas.t...@gmail.com wrote:
> tisdag 16 november 2021 kl. 21:26:27 UTC+1 skrev Jonas Thörnvall:
> > tisdag 16 november 2021 kl. 21:18:04 UTC+1 skrev Jonas Thörnvall:
> > > tisdag 16 november 2021 kl. 16:37:22 UTC+1 skrev luser...@gmail.com:
> > > > On Friday, November 12, 2021 at 7:18:55 AM UTC-6, jonas.t...@gmail.com wrote:
> > > > > I've been sitting to long trying to compare and adjust notes in time got dizzy.
> > > > > How should this while be constructed to break when the two data1 is equal or it reach end of midimessages for track.
> > > > >
> > > > > It does not seem to enter... although data1 is the same.
> > > > > while(track[editTrack].midiMess[stopEvent].data1!=track[editTrack].midiMess[y].data1 && y<track[editTrack].midiMess.length){
> > > > > alert(track[editTrack].midiMess[y].data1);
> > > > > timeNextNote=track[editTrack].midiMess[y].time;
> > > > > y++;
> > > > > }
> > > > Why do you need to "adjust notes in time"?
> > > > This sounds like part of a higher-level operation that might be handled differently
> > > > to avoid the whole issue.
> > > >
> > > > It's seems that you're translating notes (pitch, start time, duration) into a list
> > > > of on/off events (ON pitch, time) (OFF pitch, time) and then sort them by time.
> > > >
> > > > So I'd expect a high-level function for this to look roughly like this:
> > > >
> > > > function midi_from_notes( notes ){
> > > > var events;
> > > > notes.forEach( note=>events.push( { type:"ON"; pitch:note.pitch; time:note.start_time } ) );
> > > > notes.forEach( note=>events.push( { type:"OFF"; pitch:note.pitch; time:note.start_time + note.duration } ) );
> > > > return events.sort( ev=>ev.time );
> > > > }
> > > >
> > > > I may be forgetting some details about midi. If you need relative times, then you can do
> > > > another loop for that, or write a helper function to do the looping..
> > > So you say i should just remove the note and push a new one, and sort again. That may actually be easier then update the array element, will think about it.
> > But i remember now, the main obstacle is really the max + - "positional" that is set by the corresponding "same note value" before and after.
> > I have no problem of extending length, of note but howto keep track that it stay smaller then the next note of same value.
> >
> > I solved it for the ON case looking at where "same note" **before*** end, but are somehow not bright enough to do it for the OFF case extending end.
> > I have a look at it a day i feel awake and lucky...
> Why i do this if because at some point i maybe want to move, change duration, change startpos of note using drag and drop without break start ends.
> Right now i use poor mans solution slidebars where steps can be set to some milliseconds, or simply step forward backward with + and -.

Ok, I'm starting to understand some of what you're trying to do. From the
point of view of "abstraction" that I'm trying to present, it seems like you're
doing too much with this little bit of code. If I were doing this sort of program
I would completely separate the Output side from the Input and Data Manipulation
parts. That is, notes get converted into midi events and then you're done messing
with that list of midi events. Either send it out to the midi renderer, or if an edit was
made to the notes then you just throw away the list of events and generate a new
one.

Maybe not for this project, but I think it would be very helpful for you to learn
about the MVC or Model/View/Controller architecture. From the pov of MVC,
the notes is the Model, the list of midi events is the View (or *a* View, another
would be the boxes drawn on the screen. Then the Controller part handles all
the input actions, maybe consulting with the View to find out what thing was
clicked on then changing the Model and ordering the Views to re-draw themselves.

The advantage of separating things like this is when you have a bug to find..
You will be able to quickly determine which of the 3 parts is affected.
If it's the Model that's going wrong, then you don't have to look at any of
the code for the Views or Controller. If the Model is ok, then either the click isn't
being handled right (Controller) or the screen or audio looks or sound wrong
(Views).

https://stackoverflow.com/questions/2613310/ive-heard-global-variables-are-bad-what-alternative-solution-should-i-use

Re: Conditions help.

<b1a938ca-5e5d-44d8-8b74-67e93d435e3dn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:ad4:5fcd:: with SMTP id jq13mr64673170qvb.29.1637253757068;
Thu, 18 Nov 2021 08:42:37 -0800 (PST)
X-Received: by 2002:a05:6808:53:: with SMTP id v19mr9098060oic.8.1637253756829;
Thu, 18 Nov 2021 08:42:36 -0800 (PST)
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: Thu, 18 Nov 2021 08:42:36 -0800 (PST)
In-Reply-To: <d5976ec8-1763-409a-a482-a19f80d5be64n@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: <c3f08328-8cae-464e-8dd2-02e77ebe2a8cn@googlegroups.com>
<d8082f6c-ebfc-4449-a1a3-2119c14fceafn@googlegroups.com> <3f6cc701-cca3-4b68-866a-f918dd80c00dn@googlegroups.com>
<9060b76b-9393-4766-82e4-01f274e6cb87n@googlegroups.com> <c91300aa-a6b8-4386-9629-3299252098a7n@googlegroups.com>
<d5976ec8-1763-409a-a482-a19f80d5be64n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b1a938ca-5e5d-44d8-8b74-67e93d435e3dn@googlegroups.com>
Subject: Re: Conditions help.
From: jonas.thornvall@gmail.com (Jonas Thörnvall)
Injection-Date: Thu, 18 Nov 2021 16:42:37 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 152
 by: Jonas Thörnvall - Thu, 18 Nov 2021 16:42 UTC

torsdag 18 november 2021 kl. 02:54:43 UTC+1 skrev luser...@gmail.com:
> On Tuesday, November 16, 2021 at 2:56:33 PM UTC-6, jonas.t...@gmail.com wrote:
> > tisdag 16 november 2021 kl. 21:26:27 UTC+1 skrev Jonas Thörnvall:
> > > tisdag 16 november 2021 kl. 21:18:04 UTC+1 skrev Jonas Thörnvall:
> > > > tisdag 16 november 2021 kl. 16:37:22 UTC+1 skrev luser...@gmail.com:
> > > > > On Friday, November 12, 2021 at 7:18:55 AM UTC-6, jonas.t...@gmail.com wrote:
> > > > > > I've been sitting to long trying to compare and adjust notes in time got dizzy.
> > > > > > How should this while be constructed to break when the two data1 is equal or it reach end of midimessages for track.
> > > > > >
> > > > > > It does not seem to enter... although data1 is the same.
> > > > > > while(track[editTrack].midiMess[stopEvent].data1!=track[editTrack].midiMess[y].data1 && y<track[editTrack].midiMess.length){
> > > > > > alert(track[editTrack].midiMess[y].data1);
> > > > > > timeNextNote=track[editTrack].midiMess[y].time;
> > > > > > y++;
> > > > > > }
> > > > > Why do you need to "adjust notes in time"?
> > > > > This sounds like part of a higher-level operation that might be handled differently
> > > > > to avoid the whole issue.
> > > > >
> > > > > It's seems that you're translating notes (pitch, start time, duration) into a list
> > > > > of on/off events (ON pitch, time) (OFF pitch, time) and then sort them by time.
> > > > >
> > > > > So I'd expect a high-level function for this to look roughly like this:
> > > > >
> > > > > function midi_from_notes( notes ){
> > > > > var events;
> > > > > notes.forEach( note=>events.push( { type:"ON"; pitch:note.pitch; time:note.start_time } ) );
> > > > > notes.forEach( note=>events.push( { type:"OFF"; pitch:note.pitch; time:note.start_time + note.duration } ) );
> > > > > return events.sort( ev=>ev.time );
> > > > > }
> > > > >
> > > > > I may be forgetting some details about midi. If you need relative times, then you can do
> > > > > another loop for that, or write a helper function to do the looping.
> > > > So you say i should just remove the note and push a new one, and sort again. That may actually be easier then update the array element, will think about it.
> > > But i remember now, the main obstacle is really the max + - "positional" that is set by the corresponding "same note value" before and after.
> > > I have no problem of extending length, of note but howto keep track that it stay smaller then the next note of same value.
> > >
> > > I solved it for the ON case looking at where "same note" **before*** end, but are somehow not bright enough to do it for the OFF case extending end.
> > > I have a look at it a day i feel awake and lucky...
> > Why i do this if because at some point i maybe want to move, change duration, change startpos of note using drag and drop without break start ends..
> > Right now i use poor mans solution slidebars where steps can be set to some milliseconds, or simply step forward backward with + and -.
> Ok, I'm starting to understand some of what you're trying to do. From the
> point of view of "abstraction" that I'm trying to present, it seems like you're
> doing too much with this little bit of code. If I were doing this sort of program
> I would completely separate the Output side from the Input and Data Manipulation
> parts. That is, notes get converted into midi events and then you're done messing
> with that list of midi events. Either send it out to the midi renderer, or if an edit was
> made to the notes then you just throw away the list of events and generate a new
> one.
>
> Maybe not for this project, but I think it would be very helpful for you to learn
> about the MVC or Model/View/Controller architecture. From the pov of MVC,
> the notes is the Model, the list of midi events is the View (or *a* View, another
> would be the boxes drawn on the screen. Then the Controller part handles all
> the input actions, maybe consulting with the View to find out what thing was
> clicked on then changing the Model and ordering the Views to re-draw themselves.
>
> The advantage of separating things like this is when you have a bug to find.
> You will be able to quickly determine which of the 3 parts is affected.
> If it's the Model that's going wrong, then you don't have to look at any of
> the code for the Views or Controller. If the Model is ok, then either the click isn't
> being handled right (Controller) or the screen or audio looks or sound wrong
> (Views).
>
> https://stackoverflow.com/questions/2613310/ive-heard-global-variables-are-bad-what-alternative-solution-should-i-use

This project is built around least resistance principle basicly embed short code snippets into functions that acts like a pipeline from the UI.
***I really have global things all over the place unless it is local counters.****
It is fast to implement and fast to change without anything break. ***You can always pass parameters between functions later***

Regarding this specific problem you can't separate the changes you make from the structure of midi, a piano key can not be pressed twice without a release.
And that fact effect the editing of note logic if you want to keep the structure sane.

So basicly i tried to squeeze in alot of functionality as fast as possible and if i get stuck i go on with next thing.
Until i feel ready todo another iteration and straight the code up, and that usually work.
Of course such a refinement can go on forever, have not done any object oriented programming since smalltalk.

I have a feeling though that the abstraction of a project like this would be very hard to understand without some schematic.
Now this project just a pipeline stream of functions, without passing shit back and forth.

Sure there is some object structure holding the notes and some arrays, but many variables is stored in place using forms.
So the need for passing them is minimal, they are just fetched using getElementById.

I think there is some 300 KB of actual code i am not sure if that is much or little for a sequenser project "in javascript".
But considering it really do not seem to cludge up on my computer, the approach can't be totally of the wall.

And what i find great is that anyone that wrote some lines in Basic can probably follow the program flow.
I tried to avoid the things of javascript that is nonesensical, but it is hard it get more convoluted by the day.

http://jtmidi.000webhostapp.com/

Re: Conditions help.

<8df49bf9-e00e-42f8-b9e3-38c53480d800n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a05:6214:411d:: with SMTP id kc29mr64960458qvb.22.1637254199418;
Thu, 18 Nov 2021 08:49:59 -0800 (PST)
X-Received: by 2002:a05:6830:1008:: with SMTP id a8mr21944405otp.373.1637254199124;
Thu, 18 Nov 2021 08:49:59 -0800 (PST)
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: Thu, 18 Nov 2021 08:49:58 -0800 (PST)
In-Reply-To: <b1a938ca-5e5d-44d8-8b74-67e93d435e3dn@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: <c3f08328-8cae-464e-8dd2-02e77ebe2a8cn@googlegroups.com>
<d8082f6c-ebfc-4449-a1a3-2119c14fceafn@googlegroups.com> <3f6cc701-cca3-4b68-866a-f918dd80c00dn@googlegroups.com>
<9060b76b-9393-4766-82e4-01f274e6cb87n@googlegroups.com> <c91300aa-a6b8-4386-9629-3299252098a7n@googlegroups.com>
<d5976ec8-1763-409a-a482-a19f80d5be64n@googlegroups.com> <b1a938ca-5e5d-44d8-8b74-67e93d435e3dn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8df49bf9-e00e-42f8-b9e3-38c53480d800n@googlegroups.com>
Subject: Re: Conditions help.
From: jonas.thornvall@gmail.com (Jonas Thörnvall)
Injection-Date: Thu, 18 Nov 2021 16:49:59 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 152
 by: Jonas Thörnvall - Thu, 18 Nov 2021 16:49 UTC

torsdag 18 november 2021 kl. 17:42:41 UTC+1 skrev Jonas Thörnvall:
> torsdag 18 november 2021 kl. 02:54:43 UTC+1 skrev luser...@gmail.com:
> > On Tuesday, November 16, 2021 at 2:56:33 PM UTC-6, jonas.t...@gmail.com wrote:
> > > tisdag 16 november 2021 kl. 21:26:27 UTC+1 skrev Jonas Thörnvall:
> > > > tisdag 16 november 2021 kl. 21:18:04 UTC+1 skrev Jonas Thörnvall:
> > > > > tisdag 16 november 2021 kl. 16:37:22 UTC+1 skrev luser...@gmail.com:
> > > > > > On Friday, November 12, 2021 at 7:18:55 AM UTC-6, jonas.t...@gmail.com wrote:
> > > > > > > I've been sitting to long trying to compare and adjust notes in time got dizzy.
> > > > > > > How should this while be constructed to break when the two data1 is equal or it reach end of midimessages for track.
> > > > > > >
> > > > > > > It does not seem to enter... although data1 is the same.
> > > > > > > while(track[editTrack].midiMess[stopEvent].data1!=track[editTrack].midiMess[y].data1 && y<track[editTrack].midiMess.length){
> > > > > > > alert(track[editTrack].midiMess[y].data1);
> > > > > > > timeNextNote=track[editTrack].midiMess[y].time;
> > > > > > > y++;
> > > > > > > }
> > > > > > Why do you need to "adjust notes in time"?
> > > > > > This sounds like part of a higher-level operation that might be handled differently
> > > > > > to avoid the whole issue.
> > > > > >
> > > > > > It's seems that you're translating notes (pitch, start time, duration) into a list
> > > > > > of on/off events (ON pitch, time) (OFF pitch, time) and then sort them by time.
> > > > > >
> > > > > > So I'd expect a high-level function for this to look roughly like this:
> > > > > >
> > > > > > function midi_from_notes( notes ){
> > > > > > var events;
> > > > > > notes.forEach( note=>events.push( { type:"ON"; pitch:note.pitch; time:note.start_time } ) );
> > > > > > notes.forEach( note=>events.push( { type:"OFF"; pitch:note.pitch; time:note.start_time + note.duration } ) );
> > > > > > return events.sort( ev=>ev.time );
> > > > > > }
> > > > > >
> > > > > > I may be forgetting some details about midi. If you need relative times, then you can do
> > > > > > another loop for that, or write a helper function to do the looping.
> > > > > So you say i should just remove the note and push a new one, and sort again. That may actually be easier then update the array element, will think about it.
> > > > But i remember now, the main obstacle is really the max + - "positional" that is set by the corresponding "same note value" before and after.
> > > > I have no problem of extending length, of note but howto keep track that it stay smaller then the next note of same value.
> > > >
> > > > I solved it for the ON case looking at where "same note" **before*** end, but are somehow not bright enough to do it for the OFF case extending end.
> > > > I have a look at it a day i feel awake and lucky...
> > > Why i do this if because at some point i maybe want to move, change duration, change startpos of note using drag and drop without break start ends.
> > > Right now i use poor mans solution slidebars where steps can be set to some milliseconds, or simply step forward backward with + and -.
> > Ok, I'm starting to understand some of what you're trying to do. From the
> > point of view of "abstraction" that I'm trying to present, it seems like you're
> > doing too much with this little bit of code. If I were doing this sort of program
> > I would completely separate the Output side from the Input and Data Manipulation
> > parts. That is, notes get converted into midi events and then you're done messing
> > with that list of midi events. Either send it out to the midi renderer, or if an edit was
> > made to the notes then you just throw away the list of events and generate a new
> > one.
> >
> > Maybe not for this project, but I think it would be very helpful for you to learn
> > about the MVC or Model/View/Controller architecture. From the pov of MVC,
> > the notes is the Model, the list of midi events is the View (or *a* View, another
> > would be the boxes drawn on the screen. Then the Controller part handles all
> > the input actions, maybe consulting with the View to find out what thing was
> > clicked on then changing the Model and ordering the Views to re-draw themselves.
> >
> > The advantage of separating things like this is when you have a bug to find.
> > You will be able to quickly determine which of the 3 parts is affected.
> > If it's the Model that's going wrong, then you don't have to look at any of
> > the code for the Views or Controller. If the Model is ok, then either the click isn't
> > being handled right (Controller) or the screen or audio looks or sound wrong
> > (Views).
> >
> > https://stackoverflow.com/questions/2613310/ive-heard-global-variables-are-bad-what-alternative-solution-should-i-use
> This project is built around least resistance principle basicly embed short code snippets into functions that acts like a pipeline from the UI.
> ***I really have global things all over the place unless it is local counters.****
> It is fast to implement and fast to change without anything break. ***You can always pass parameters between functions later***
>
> Regarding this specific problem you can't separate the changes you make from the structure of midi, a piano key can not be pressed twice without a release.
> And that fact effect the editing of note logic if you want to keep the structure sane.
>
> So basicly i tried to squeeze in alot of functionality as fast as possible and if i get stuck i go on with next thing.
> Until i feel ready todo another iteration and straight the code up, and that usually work.
> Of course such a refinement can go on forever, have not done any object oriented programming since smalltalk.
>
> I have a feeling though that the abstraction of a project like this would be very hard to understand without some schematic.
> Now this project just a pipeline stream of functions, without passing shit back and forth.
>
> Sure there is some object structure holding the notes and some arrays, but many variables is stored in place using forms.
> So the need for passing them is minimal, they are just fetched using getElementById.
>
> I think there is some 300 KB of actual code i am not sure if that is much or little for a sequenser project "in javascript".
> But considering it really do not seem to cludge up on my computer, the approach can't be totally of the wall.
>
> And what i find great is that anyone that wrote some lines in Basic can probably follow the program flow.
> I tried to avoid the things of javascript that is nonesensical, but it is hard it get more convoluted by the day.
>
> http://jtmidi.000webhostapp.com/
https://www.youtube.com/watch?v=DcHKOC64KnE


devel / comp.lang.javascript / Re: Conditions help.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor