Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #37161 > unrolled thread

Object iterators

Started byJonas Thörnvall <jonas.thornvall@gmail.com>
First post2019-08-31 17:12 -0700
Last post2020-05-24 04:21 -0700
Articles 17 — 3 participants

Back to article view | Back to comp.lang.javascript


Contents

  Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-08-31 17:12 -0700
    Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-08-31 17:17 -0700
      Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-08-31 17:24 -0700
    Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-01 02:53 -0700
      Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-01 02:59 -0700
        Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-01 03:07 -0700
      Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-01 03:20 -0700
        Re: Object iterators John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-01 11:59 +0100
          Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-01 05:54 -0700
            Re: Object iterators John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-02 11:08 +0100
          Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-01 12:54 -0700
            Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-02 02:36 -0700
            Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-02 10:16 -0700
              Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-02 10:19 -0700
              Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-02 10:30 -0700
                Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-03 23:26 -0700
                Re: Object iterators 1975.nenad@googlemail.com - 2020-05-24 04:21 -0700

#37161 — Object iterators

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-08-31 17:12 -0700
SubjectObject iterators
Message-ID<8910e5f0-4fc9-417e-a5c8-1bec8693194a@googlegroups.com>
Well they probably have their use, but i've been googling on web midi api for some months looking for howto ***set*** inputs iterator to a single port.

inputs = mid.inputs.values();

for (var input = inputs.next();
     input && !input.done;
     input = inputs.next()) {
    // each time there is a midi message call the onMIDIMessage function
    input.value.onmidimessage = onMIDIMessage;
}

I can't find a single example where one set a single input port without looping thru.

I do not want to read all inputs port using the iterator, i just want to set one input say port 3.


I would prefered the inputs in an indexed array, because i just do not get howto pick a single port from the input object iterator.

[toc] | [next] | [standalone]


#37162

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-08-31 17:17 -0700
Message-ID<1a1cdb95-7403-42ad-a6e5-0104f2665ccb@googlegroups.com>
In reply to#37161
Den söndag 1 september 2019 kl. 02:12:59 UTC+2 skrev Jonas Thörnvall:
> Well they probably have their use, but i've been googling on web midi api for some months looking for howto ***set*** inputs iterator to a single port.
> 
> inputs = mid.inputs.values();
> 
> for (var input = inputs.next();
>      input && !input.done;
>      input = inputs.next()) {
>     // each time there is a midi message call the onMIDIMessage function
>     input.value.onmidimessage = onMIDIMessage;
> }
> 
> I can't find a single example where one set a single input port without looping thru.
> 
> I do not want to read all inputs port using the iterator, i just want to set one input say port 3.
> 
> 
> I would prefered the inputs in an indexed array, because i just do not get howto pick a single port from the input object iterator.

https://www.smashingmagazine.com/2018/03/web-midi-api/

[toc] | [prev] | [next] | [standalone]


#37163

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-08-31 17:24 -0700
Message-ID<ce4a665d-210f-49e6-a6ed-5191cbdbb91a@googlegroups.com>
In reply to#37162
Den söndag 1 september 2019 kl. 02:17:27 UTC+2 skrev Jonas Thörnvall:
> Den söndag 1 september 2019 kl. 02:12:59 UTC+2 skrev Jonas Thörnvall:
> > Well they probably have their use, but i've been googling on web midi api for some months looking for howto ***set*** inputs iterator to a single port.
> > 
> > inputs = mid.inputs.values();
> > 
> > for (var input = inputs.next();
> >      input && !input.done;
> >      input = inputs.next()) {
> >     // each time there is a midi message call the onMIDIMessage function
> >     input.value.onmidimessage = onMIDIMessage;
> > }
> > 
> > I can't find a single example where one set a single input port without looping thru.
> > 
> > I do not want to read all inputs port using the iterator, i just want to set one input say port 3.
> > 
> > 
> > I would prefered the inputs in an indexed array, because i just do not get howto pick a single port from the input object iterator.
> 
> https://www.smashingmagazine.com/2018/03/web-midi-api/

I think i get that this create a listener on port of input.
input.value.onmidimessage = onMIDIMessage; 

But i do not fucking get howto set input without iterating thru inputs....
And that seem weird to me.

[toc] | [prev] | [next] | [standalone]


#37164

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-01 02:53 -0700
Message-ID<4c1ea5a9-c407-4752-920e-ec33b756af59@googlegroups.com>
In reply to#37161
Den söndag 1 september 2019 kl. 02:12:59 UTC+2 skrev Jonas Thörnvall:
> Well they probably have their use, but i've been googling on web midi api for some months looking for howto ***set*** inputs iterator to a single port.
> 
> inputs = mid.inputs.values();
> 
> for (var input = inputs.next();
>      input && !input.done;
>      input = inputs.next()) {
>     // each time there is a midi message call the onMIDIMessage function
>     input.value.onmidimessage = onMIDIMessage;
> }
> 
> I can't find a single example where one set a single input port without looping thru.
> 
> I do not want to read all inputs port using the iterator, i just want to set one input say port 3.
> 
> 
> I would prefered the inputs in an indexed array, because i just do not get howto pick a single port from the input object iterator.

Found this....
========================
For the record, the Iterator API does not allow you to do this. There is no notion of a "current" object. The Iterator.next() method gives you the next object ... and moves on.

(The ListIterator.previous() and ListIterator.next() methods are analogous. Note that in the ListIterator case, method behaviour is documented in terms of a cursor that denotes a position before / between / after elements in the sequence being iterated.)

The solution is to assign the result of calling it.next() to a temporary variable, as described by the accepted answer
========================

So who implemented this as an object iterator, did i????
It is not clear to me what does  
//This is the midi object i guess holding input and output ports
mid = midi;
//Here it becomes unclear to me WTF is going on?????
inputs = mid.inputs.values();
//It seem like we read out inputs values "that apparently is part of the midi //object, it is monkey syntax basicly inputs.values()

But why the fuck they end up in an iterator "inputs?" had it not been more natural to have them end up in an array so you can pick one????

So is it, I that have implemented this as an iterator, or have some deranged little fuck decided that input ports of midi objects are iterators?????

Because that is where my logic breaks down, i guess the inputs are implemented as iterators but why?????

I mean i have no fucking problem to iterate thru an input ports array in a for loop and no problem to set a single one of those to a listener. Using input.

input.value.onmidimessage = onMIDIMessage;

So who the fuck decided that the input ports should be iterators where i can not pick a port because they are not indexed?

If it was me then tell me where the fuck in the code i did it.
Better yet tell how the fuck to get the ports in an array so i can access them one by one two by two or whatever. 


[toc] | [prev] | [next] | [standalone]


#37165

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-01 02:59 -0700
Message-ID<6f9c9f11-45fc-4dc0-86e8-1cf37328b3df@googlegroups.com>
In reply to#37164
Den söndag 1 september 2019 kl. 11:53:34 UTC+2 skrev Jonas Thörnvall:
> Den söndag 1 september 2019 kl. 02:12:59 UTC+2 skrev Jonas Thörnvall:
> > Well they probably have their use, but i've been googling on web midi api for some months looking for howto ***set*** inputs iterator to a single port.
> > 
> > inputs = mid.inputs.values();
> > 
> > for (var input = inputs.next();
> >      input && !input.done;
> >      input = inputs.next()) {
> >     // each time there is a midi message call the onMIDIMessage function
> >     input.value.onmidimessage = onMIDIMessage;
> > }
> > 
> > I can't find a single example where one set a single input port without looping thru.
> > 
> > I do not want to read all inputs port using the iterator, i just want to set one input say port 3.
> > 
> > 
> > I would prefered the inputs in an indexed array, because i just do not get howto pick a single port from the input object iterator.
> 
> Found this....
> ========================
> For the record, the Iterator API does not allow you to do this. There is no notion of a "current" object. The Iterator.next() method gives you the next object ... and moves on.
> 
> (The ListIterator.previous() and ListIterator.next() methods are analogous. Note that in the ListIterator case, method behaviour is documented in terms of a cursor that denotes a position before / between / after elements in the sequence being iterated.)
> 
> The solution is to assign the result of calling it.next() to a temporary variable, as described by the accepted answer
> ========================
> 
> So who implemented this as an object iterator, did i????
> It is not clear to me what does  
> //This is the midi object i guess holding input and output ports
> mid = midi;
> //Here it becomes unclear to me WTF is going on?????
> inputs = mid.inputs.values();
> //It seem like we read out inputs values "that apparently is part of the midi //object, it is monkey syntax basicly inputs.values()
> 
> But why the fuck they end up in an iterator "inputs?" had it not been more natural to have them end up in an array so you can pick one????
> 
> So is it, I that have implemented this as an iterator, or have some deranged little fuck decided that input ports of midi objects are iterators?????
> 
> Because that is where my logic breaks down, i guess the inputs are implemented as iterators but why?????
> 
> I mean i have no fucking problem to iterate thru an input ports array in a for loop and no problem to set a single one of those to a listener. Using input.
> 
> input.value.onmidimessage = onMIDIMessage;
> 
> So who the fuck decided that the input ports should be iterators where i can not pick a port because they are not indexed?
> 
> If it was me then tell me where the fuck in the code i did it.
> Better yet tell how the fuck to get the ports in an array so i can access them one by one two by two or whatever.

By the way i did try to do it like i did with the output ports but had no luck with it.

 var iter = mid.outputs.values();
  for (var i = iter.next(); i && !i.done; i = iter.next()) {
    outportarr.push(i.value);
  }

[toc] | [prev] | [next] | [standalone]


#37166

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-01 03:07 -0700
Message-ID<b139c657-383e-4db6-9799-0286f8aa1724@googlegroups.com>
In reply to#37165
Den söndag 1 september 2019 kl. 11:59:15 UTC+2 skrev Jonas Thörnvall:
> Den söndag 1 september 2019 kl. 11:53:34 UTC+2 skrev Jonas Thörnvall:
> > Den söndag 1 september 2019 kl. 02:12:59 UTC+2 skrev Jonas Thörnvall:
> > > Well they probably have their use, but i've been googling on web midi api for some months looking for howto ***set*** inputs iterator to a single port.
> > > 
> > > inputs = mid.inputs.values();
> > > 
> > > for (var input = inputs.next();
> > >      input && !input.done;
> > >      input = inputs.next()) {
> > >     // each time there is a midi message call the onMIDIMessage function
> > >     input.value.onmidimessage = onMIDIMessage;
> > > }
> > > 
> > > I can't find a single example where one set a single input port without looping thru.
> > > 
> > > I do not want to read all inputs port using the iterator, i just want to set one input say port 3.
> > > 
> > > 
> > > I would prefered the inputs in an indexed array, because i just do not get howto pick a single port from the input object iterator.
> > 
> > Found this....
> > ========================
> > For the record, the Iterator API does not allow you to do this. There is no notion of a "current" object. The Iterator.next() method gives you the next object ... and moves on.
> > 
> > (The ListIterator.previous() and ListIterator.next() methods are analogous. Note that in the ListIterator case, method behaviour is documented in terms of a cursor that denotes a position before / between / after elements in the sequence being iterated.)
> > 
> > The solution is to assign the result of calling it.next() to a temporary variable, as described by the accepted answer
> > ========================
> > 
> > So who implemented this as an object iterator, did i????
> > It is not clear to me what does  
> > //This is the midi object i guess holding input and output ports
> > mid = midi;
> > //Here it becomes unclear to me WTF is going on?????
> > inputs = mid.inputs.values();
> > //It seem like we read out inputs values "that apparently is part of the midi //object, it is monkey syntax basicly inputs.values()
> > 
> > But why the fuck they end up in an iterator "inputs?" had it not been more natural to have them end up in an array so you can pick one????
> > 
> > So is it, I that have implemented this as an iterator, or have some deranged little fuck decided that input ports of midi objects are iterators?????
> > 
> > Because that is where my logic breaks down, i guess the inputs are implemented as iterators but why?????
> > 
> > I mean i have no fucking problem to iterate thru an input ports array in a for loop and no problem to set a single one of those to a listener. Using input.
> > 
> > input.value.onmidimessage = onMIDIMessage;
> > 
> > So who the fuck decided that the input ports should be iterators where i can not pick a port because they are not indexed?
> > 
> > If it was me then tell me where the fuck in the code i did it.
> > Better yet tell how the fuck to get the ports in an array so i can access them one by one two by two or whatever.
> 
> By the way i did try to do it like i did with the output ports but had no luck with it.
> 
>  var iter = mid.outputs.values();
>   for (var i = iter.next(); i && !i.done; i = iter.next()) {
>     outportarr.push(i.value);
>   }

This was my attempt what is wrong with it???
function success(midi) {
   mid=midi;
   var iter = mid.inputs.values();
   for (var i = iter.next(); i && !i.done; i = iter.next()) {
    inportarr.push(i.value);
   }
  inportarr[1].onmidimessage = onMIDIMessage;
}

[toc] | [prev] | [next] | [standalone]


#37167

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-01 03:20 -0700
Message-ID<ec9caa3f-68c8-4ac6-b805-e168f86cb0f0@googlegroups.com>
In reply to#37164
Den söndag 1 september 2019 kl. 11:53:34 UTC+2 skrev Jonas Thörnvall:
> Den söndag 1 september 2019 kl. 02:12:59 UTC+2 skrev Jonas Thörnvall:
> > Well they probably have their use, but i've been googling on web midi api for some months looking for howto ***set*** inputs iterator to a single port.
> > 
> > inputs = mid.inputs.values();
> > 
> > for (var input = inputs.next();
> >      input && !input.done;
> >      input = inputs.next()) {
> >     // each time there is a midi message call the onMIDIMessage function
> >     input.value.onmidimessage = onMIDIMessage;
> > }
> > 
> > I can't find a single example where one set a single input port without looping thru.
> > 
> > I do not want to read all inputs port using the iterator, i just want to set one input say port 3.
> > 
> > 
> > I would prefered the inputs in an indexed array, because i just do not get howto pick a single port from the input object iterator.
> 
> Found this....
> ========================
> For the record, the Iterator API does not allow you to do this. There is no notion of a "current" object. The Iterator.next() method gives you the next object ... and moves on.
> 
> (The ListIterator.previous() and ListIterator.next() methods are analogous. Note that in the ListIterator case, method behaviour is documented in terms of a cursor that denotes a position before / between / after elements in the sequence being iterated.)
> 
> The solution is to assign the result of calling it.next() to a temporary variable, as described by the accepted answer
> ========================
> 
> So who implemented this as an object iterator, did i????
> It is not clear to me what does  
> //This is the midi object i guess holding input and output ports
> mid = midi;
> //Here it becomes unclear to me WTF is going on?????
> inputs = mid.inputs.values();
> //It seem like we read out inputs values "that apparently is part of the midi //object, it is monkey syntax basicly inputs.values()
> 
> But why the fuck they end up in an iterator "inputs?" had it not been more natural to have them end up in an array so you can pick one????
> 
> So is it, I that have implemented this as an iterator, or have some deranged little fuck decided that input ports of midi objects are iterators?????
> 
> Because that is where my logic breaks down, i guess the inputs are implemented as iterators but why?????
> 
> I mean i have no fucking problem to iterate thru an input ports array in a for loop and no problem to set a single one of those to a listener. Using input.
> 
> input.value.onmidimessage = onMIDIMessage;
> 
> So who the fuck decided that the input ports should be iterators where i can not pick a port because they are not indexed?
> 
> If it was me then tell me where the fuck in the code i did it.
> Better yet tell how the fuck to get the ports in an array so i can access them one by one two by two or whatever.

By the way what kind of syntax, is this?
input.value.onmidimessage = onMIDIMessage;

omMIDIMessage is a function, to me it looks like an assigment i assign a function to input.value.onmidimessage?

So is input.value.onmidimessage a listener or is it just onmidimessage that is the listener and input.value the object port?

I mean the syntax is really not clear is it?

[toc] | [prev] | [next] | [standalone]


#37168

FromJohn G Harris <niam@jghnorth.org.uk.invalid>
Date2019-09-01 11:59 +0100
Message-ID<639nme9cjsjjkd8va38frenr8u6bbktr7u@4ax.com>
In reply to#37167
On Sun, 1 Sep 2019 03:20:11 -0700 (PDT), Jonas Thörnvall
<jonas.thornvall@gmail.com> wrote:

  <snip>
>By the way what kind of syntax, is this?
>input.value.onmidimessage = onMIDIMessage;
>
>omMIDIMessage is a function, to me it looks like an assigment i assign a function to input.value.onmidimessage?
>
>So is input.value.onmidimessage a listener or is it just onmidimessage that is the listener and input.value the object port?
>
>I mean the syntax is really not clear is it?

The syntax is perfectly clear. After this statement the value of 
  input.value.onmidimessage
is now the same function object as the value of 
  onMIDIMessage

As a result, doing 
  input.value.onmidimessage(x)
is the same as doing
  onMIDIMessage(x)

  John

[toc] | [prev] | [next] | [standalone]


#37169

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-01 05:54 -0700
Message-ID<c134885b-e998-4834-a8ea-0cdc9f4dc6ac@googlegroups.com>
In reply to#37168
Den söndag 1 september 2019 kl. 12:59:31 UTC+2 skrev John G Harris:
> On Sun, 1 Sep 2019 03:20:11 -0700 (PDT), Jonas Thörnvall
> <jonas.thornvall@gmail.com> wrote:
> 
>   <snip>
> >By the way what kind of syntax, is this?
> >input.value.onmidimessage = onMIDIMessage;
> >
> >omMIDIMessage is a function, to me it looks like an assigment i assign a function to input.value.onmidimessage?
> >
> >So is input.value.onmidimessage a listener or is it just onmidimessage that is the listener and input.value the object port?
> >
> >I mean the syntax is really not clear is it?
> 
> The syntax is perfectly clear. After this statement the value of 
>   input.value.onmidimessage
> is now the same function object as the value of 
>   onMIDIMessage
> 
> As a result, doing 
>   input.value.onmidimessage(x)
> is the same as doing
>   onMIDIMessage(x)
> 
>   John

function object???

[toc] | [prev] | [next] | [standalone]


#37173

FromJohn G Harris <niam@jghnorth.org.uk.invalid>
Date2019-09-02 11:08 +0100
Message-ID<dfqpmepune8r8bp4225fa35iir4m56ngs8@4ax.com>
In reply to#37169
On Sun, 1 Sep 2019 05:54:18 -0700 (PDT), Jonas Thörnvall
<jonas.thornvall@gmail.com> wrote:

  <snip>
>function object???

What is a "function object" :

When the compiler sees something like
  function f(x) {return 1 + x;}
it creats the code that implements the function, and code that creates
an object and that puts the function's code inside it. When the
program is run the result of executing all this code is an object
containing a function's code : a function object.

In some ways it's a very special object : it has code inside it. In
other ways it's a normal object : it can be assigned and has ordinary
properties.

Now, if the compiler sees something like 
  f(3);
it creates code that finds the object named f, and that executes the
code held inside the object, making sure that the code can find the
value 3 (in this example).

On the other hand, if the compiler sees something like
  a.b = f;
then it creates code that finds the object named f and treats it like
any other object. Now the value of the property named b in the object
named a is also our function object. 

From now on, if the compiler sees a.b(3) it creates code that finds
the object named a.b, our function object, then executes it as before.

Something to remember : f without round brackets is the function
object, f with round brackets, f(...), executes the function.

  John

[toc] | [prev] | [next] | [standalone]


#37170

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-01 12:54 -0700
Message-ID<a9d2bf4a-5e03-425f-94d2-6be646c855e5@googlegroups.com>
In reply to#37168
Den söndag 1 september 2019 kl. 12:59:31 UTC+2 skrev John G Harris:
> On Sun, 1 Sep 2019 03:20:11 -0700 (PDT), Jonas Thörnvall
> <jonas.thornvall@gmail.com> wrote:
> 
>   <snip>
> >By the way what kind of syntax, is this?
> >input.value.onmidimessage = onMIDIMessage;
> >
> >omMIDIMessage is a function, to me it looks like an assigment i assign a function to input.value.onmidimessage?
> >
> >So is input.value.onmidimessage a listener or is it just onmidimessage that is the listener and input.value the object port?
> >
> >I mean the syntax is really not clear is it?
> 
> The syntax is perfectly clear. After this statement the value of 
>   input.value.onmidimessage
> is now the same function object as the value of 
>   onMIDIMessage
> 
> As a result, doing 
>   input.value.onmidimessage(x)
> is the same as doing
>   onMIDIMessage(x)
> 
>   John

Well John could you explain it in plain words not as syntax references?
function success(midi) {
  mid = midi;
  inputs = mid.inputs.values();
  for (input = inputs.next(); input && !input.done; input = inputs.next()) {
  
    input.value.onmidimessage = onMIDIMessage;
  }
}

For me this interpretate to. A succesful midi object was created "They never explain what it actually is but i guess it is hold inputs and outputs "because these must exist "as reserved words or constants?" how else could i extract them from the midiobject with inputs = mid.inputs.values();. Apparently this assignment to inputs "create an iterator object?" whatever that is... Well i get the gist a stepthru object, can't imagine why anyone would prefer it over an array but beyond point....

So i get the loop and its function, apparently it just steps thru the ports and assign them to input.

However
input.value.onmidimessage = onMIDIMessage;
Is hieroglyphs to me?
What is "omnimidimessage" who created it "it is a reserved word, reserved object a constant" what is it?

Input value i just interpretate like a port???
onMIDIMessage is a function that we somehow do what with?
I can see i assign it to input.value.onmidimessage?

What is the thingy "code" that actually make the listener to the port?
And why is a function call an assignment.

I can't follow the logic of the statements, i fucking know what is happening but the how and why is beyond me. That makes it very hard for me to make a listener for a single port. And how do you kill the listener on an input port? 

[toc] | [prev] | [next] | [standalone]


#37172

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-02 02:36 -0700
Message-ID<a6614e63-be1d-4832-ab3f-bbd79e6a415b@googlegroups.com>
In reply to#37170
Den söndag 1 september 2019 kl. 21:54:41 UTC+2 skrev Jonas Thörnvall:
> Den söndag 1 september 2019 kl. 12:59:31 UTC+2 skrev John G Harris:
> > On Sun, 1 Sep 2019 03:20:11 -0700 (PDT), Jonas Thörnvall
> > <jonas.thornvall@gmail.com> wrote:
> > 
> >   <snip>
> > >By the way what kind of syntax, is this?
> > >input.value.onmidimessage = onMIDIMessage;
> > >
> > >omMIDIMessage is a function, to me it looks like an assigment i assign a function to input.value.onmidimessage?
> > >
> > >So is input.value.onmidimessage a listener or is it just onmidimessage that is the listener and input.value the object port?
> > >
> > >I mean the syntax is really not clear is it?
> > 
> > The syntax is perfectly clear. After this statement the value of 
> >   input.value.onmidimessage
> > is now the same function object as the value of 
> >   onMIDIMessage
> > 
> > As a result, doing 
> >   input.value.onmidimessage(x)
> > is the same as doing
> >   onMIDIMessage(x)
> > 
> >   John
> 
> Well John could you explain it in plain words not as syntax references?
> function success(midi) {
>   mid = midi;
>   inputs = mid.inputs.values();
>   for (input = inputs.next(); input && !input.done; input = inputs.next()) {
>   
>     input.value.onmidimessage = onMIDIMessage;
>   }
> }
> 
> For me this interpretate to. A succesful midi object was created "They never explain what it actually is but i guess it is hold inputs and outputs "because these must exist "as reserved words or constants?" how else could i extract them from the midiobject with inputs = mid.inputs.values();. Apparently this assignment to inputs "create an iterator object?" whatever that is... Well i get the gist a stepthru object, can't imagine why anyone would prefer it over an array but beyond point....
> 
> So i get the loop and its function, apparently it just steps thru the ports and assign them to input.
> 
> However
> input.value.onmidimessage = onMIDIMessage;
> Is hieroglyphs to me?
> What is "omnimidimessage" who created it "it is a reserved word, reserved object a constant" what is it?
> 
> Input value i just interpretate like a port???
> onMIDIMessage is a function that we somehow do what with?
> I can see i assign it to input.value.onmidimessage?
> 
> What is the thingy "code" that actually make the listener to the port?
> And why is a function call an assignment.
> 
> I can't follow the logic of the statements, i fucking know what is happening but the how and why is beyond me. That makes it very hard for me to make a listener for a single port. And how do you kill the listener on an input port?

Finally find something so lets find out if it works...

function startLoggingMIDIInput( midiAccess, indexOfPort ) {
  midiAccess.inputs.forEach( function(entry) {entry.onmidimessage = onMIDIMessage;});
}

[toc] | [prev] | [next] | [standalone]


#37174

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-02 10:16 -0700
Message-ID<5a71a523-ac87-4a4d-ae67-acd3396dd8e8@googlegroups.com>
In reply to#37170
Den söndag 1 september 2019 kl. 21:54:41 UTC+2 skrev Jonas Thörnvall:
> Den söndag 1 september 2019 kl. 12:59:31 UTC+2 skrev John G Harris:
> > On Sun, 1 Sep 2019 03:20:11 -0700 (PDT), Jonas Thörnvall
> > <jonas.thornvall@gmail.com> wrote:
> > 
> >   <snip>
> > >By the way what kind of syntax, is this?
> > >input.value.onmidimessage = onMIDIMessage;
> > >
> > >omMIDIMessage is a function, to me it looks like an assigment i assign a function to input.value.onmidimessage?
> > >
> > >So is input.value.onmidimessage a listener or is it just onmidimessage that is the listener and input.value the object port?
> > >
> > >I mean the syntax is really not clear is it?
> > 
> > The syntax is perfectly clear. After this statement the value of 
> >   input.value.onmidimessage
> > is now the same function object as the value of 
> >   onMIDIMessage
> > 
> > As a result, doing 
> >   input.value.onmidimessage(x)
> > is the same as doing
> >   onMIDIMessage(x)
> > 
> >   John
> 
> Well John could you explain it in plain words not as syntax references?
> function success(midi) {
>   mid = midi;
>   inputs = mid.inputs.values();
>   for (input = inputs.next(); input && !input.done; input = inputs.next()) {
>   
>     input.value.onmidimessage = onMIDIMessage;
>   }
> }
> 
> For me this interpretate to. A succesful midi object was created "They never explain what it actually is but i guess it is hold inputs and outputs "because these must exist "as reserved words or constants?" how else could i extract them from the midiobject with inputs = mid.inputs.values();. Apparently this assignment to inputs "create an iterator object?" whatever that is... Well i get the gist a stepthru object, can't imagine why anyone would prefer it over an array but beyond point....
> 
> So i get the loop and its function, apparently it just steps thru the ports and assign them to input.
> 
> However
> input.value.onmidimessage = onMIDIMessage;
> Is hieroglyphs to me?
> What is "omnimidimessage" who created it "it is a reserved word, reserved object a constant" what is it?
> 
> Input value i just interpretate like a port???
> onMIDIMessage is a function that we somehow do what with?
> I can see i assign it to input.value.onmidimessage?
> 
> What is the thingy "code" that actually make the listener to the port?
> And why is a function call an assignment.
> 
> I can't follow the logic of the statements, i fucking know what is happening but the how and why is beyond me. That makes it very hard for me to make a listener for a single port. And how do you kill the listener on an input port?

Well i guess when things implemented idiotic, they will by nature inherit idiotic solutions. I come up with one i just list the ports with checkboxes, the checked ones i will do "onmidimessage" on.

But how to change the port listener state "on/off" after page loaded anyone?

Basicly i ask if this is the code to turn of listener "at a port".
 input.value.onmidimessage = onMIDIMessage; 
What is the code to turn it off...

[toc] | [prev] | [next] | [standalone]


#37175

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-02 10:19 -0700
Message-ID<ab79a561-c420-4343-8a7a-6bb6c07a0f06@googlegroups.com>
In reply to#37174
Den måndag 2 september 2019 kl. 19:16:38 UTC+2 skrev Jonas Thörnvall:
> Den söndag 1 september 2019 kl. 21:54:41 UTC+2 skrev Jonas Thörnvall:
> > Den söndag 1 september 2019 kl. 12:59:31 UTC+2 skrev John G Harris:
> > > On Sun, 1 Sep 2019 03:20:11 -0700 (PDT), Jonas Thörnvall
> > > <jonas.thornvall@gmail.com> wrote:
> > > 
> > >   <snip>
> > > >By the way what kind of syntax, is this?
> > > >input.value.onmidimessage = onMIDIMessage;
> > > >
> > > >omMIDIMessage is a function, to me it looks like an assigment i assign a function to input.value.onmidimessage?
> > > >
> > > >So is input.value.onmidimessage a listener or is it just onmidimessage that is the listener and input.value the object port?
> > > >
> > > >I mean the syntax is really not clear is it?
> > > 
> > > The syntax is perfectly clear. After this statement the value of 
> > >   input.value.onmidimessage
> > > is now the same function object as the value of 
> > >   onMIDIMessage
> > > 
> > > As a result, doing 
> > >   input.value.onmidimessage(x)
> > > is the same as doing
> > >   onMIDIMessage(x)
> > > 
> > >   John
> > 
> > Well John could you explain it in plain words not as syntax references?
> > function success(midi) {
> >   mid = midi;
> >   inputs = mid.inputs.values();
> >   for (input = inputs.next(); input && !input.done; input = inputs.next()) {
> >   
> >     input.value.onmidimessage = onMIDIMessage;
> >   }
> > }
> > 
> > For me this interpretate to. A succesful midi object was created "They never explain what it actually is but i guess it is hold inputs and outputs "because these must exist "as reserved words or constants?" how else could i extract them from the midiobject with inputs = mid.inputs.values();. Apparently this assignment to inputs "create an iterator object?" whatever that is... Well i get the gist a stepthru object, can't imagine why anyone would prefer it over an array but beyond point....
> > 
> > So i get the loop and its function, apparently it just steps thru the ports and assign them to input.
> > 
> > However
> > input.value.onmidimessage = onMIDIMessage;
> > Is hieroglyphs to me?
> > What is "omnimidimessage" who created it "it is a reserved word, reserved object a constant" what is it?
> > 
> > Input value i just interpretate like a port???
> > onMIDIMessage is a function that we somehow do what with?
> > I can see i assign it to input.value.onmidimessage?
> > 
> > What is the thingy "code" that actually make the listener to the port?
> > And why is a function call an assignment.
> > 
> > I can't follow the logic of the statements, i fucking know what is happening but the how and why is beyond me. That makes it very hard for me to make a listener for a single port. And how do you kill the listener on an input port?
> 
> Well i guess when things implemented idiotic, they will by nature inherit idiotic solutions. I come up with one i just list the ports with checkboxes, the checked ones i will do "onmidimessage" on.
> 
> But how to change the port listener state "on/off" after page loaded anyone?
> 
> Basicly i ask if this is the code to turn of listener "at a port".
>  input.value.onmidimessage = onMIDIMessage; 
> What is the code to turn it off...

Somehow i feel that implement the ports as iterators was an idiotic choice, but that is maybe because i do not understand objects and their eventhandlers.

[toc] | [prev] | [next] | [standalone]


#37176

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-02 10:30 -0700
Message-ID<7ff31766-056d-4e02-97b1-e4614c3b16d9@googlegroups.com>
In reply to#37174
Den måndag 2 september 2019 kl. 19:16:38 UTC+2 skrev Jonas Thörnvall:
> Den söndag 1 september 2019 kl. 21:54:41 UTC+2 skrev Jonas Thörnvall:
> > Den söndag 1 september 2019 kl. 12:59:31 UTC+2 skrev John G Harris:
> > > On Sun, 1 Sep 2019 03:20:11 -0700 (PDT), Jonas Thörnvall
> > > <jonas.thornvall@gmail.com> wrote:
> > > 
> > >   <snip>
> > > >By the way what kind of syntax, is this?
> > > >input.value.onmidimessage = onMIDIMessage;
> > > >
> > > >omMIDIMessage is a function, to me it looks like an assigment i assign a function to input.value.onmidimessage?
> > > >
> > > >So is input.value.onmidimessage a listener or is it just onmidimessage that is the listener and input.value the object port?
> > > >
> > > >I mean the syntax is really not clear is it?
> > > 
> > > The syntax is perfectly clear. After this statement the value of 
> > >   input.value.onmidimessage
> > > is now the same function object as the value of 
> > >   onMIDIMessage
> > > 
> > > As a result, doing 
> > >   input.value.onmidimessage(x)
> > > is the same as doing
> > >   onMIDIMessage(x)
> > > 
> > >   John
> > 
> > Well John could you explain it in plain words not as syntax references?
> > function success(midi) {
> >   mid = midi;
> >   inputs = mid.inputs.values();
> >   for (input = inputs.next(); input && !input.done; input = inputs.next()) {
> >   
> >     input.value.onmidimessage = onMIDIMessage;
> >   }
> > }
> > 
> > For me this interpretate to. A succesful midi object was created "They never explain what it actually is but i guess it is hold inputs and outputs "because these must exist "as reserved words or constants?" how else could i extract them from the midiobject with inputs = mid.inputs.values();. Apparently this assignment to inputs "create an iterator object?" whatever that is... Well i get the gist a stepthru object, can't imagine why anyone would prefer it over an array but beyond point....
> > 
> > So i get the loop and its function, apparently it just steps thru the ports and assign them to input.
> > 
> > However
> > input.value.onmidimessage = onMIDIMessage;
> > Is hieroglyphs to me?
> > What is "omnimidimessage" who created it "it is a reserved word, reserved object a constant" what is it?
> > 
> > Input value i just interpretate like a port???
> > onMIDIMessage is a function that we somehow do what with?
> > I can see i assign it to input.value.onmidimessage?
> > 
> > What is the thingy "code" that actually make the listener to the port?
> > And why is a function call an assignment.
> > 
> > I can't follow the logic of the statements, i fucking know what is happening but the how and why is beyond me. That makes it very hard for me to make a listener for a single port. And how do you kill the listener on an input port?
> 
> Well i guess when things implemented idiotic, they will by nature inherit idiotic solutions. I come up with one i just list the ports with checkboxes, the checked ones i will do "onmidimessage" on.
> 
> But how to change the port listener state "on/off" after page loaded anyone?
> 
> Basicly i ask if this is the code to turn of listener "at a port".
>  input.value.onmidimessage = onMIDIMessage; 
> What is the code to turn it off...

Solved it i just put the request of midi midiAccess into a function, and basicly   relist the ports using the checkboxes...

But there probably is a way to kill each input onmidimessage listener instead of reinit the full midi. 

[toc] | [prev] | [next] | [standalone]


#37177

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-03 23:26 -0700
Message-ID<b13a7ad4-69a3-4df2-b7ab-84932b8e57c8@googlegroups.com>
In reply to#37176
On Monday, September 2, 2019 at 7:30:49 PM UTC+2, Jonas Thörnvall wrote:
> Den måndag 2 september 2019 kl. 19:16:38 UTC+2 skrev Jonas Thörnvall:
> > Den söndag 1 september 2019 kl. 21:54:41 UTC+2 skrev Jonas Thörnvall:
> > > Den söndag 1 september 2019 kl. 12:59:31 UTC+2 skrev John G Harris:
> > > > On Sun, 1 Sep 2019 03:20:11 -0700 (PDT), Jonas Thörnvall
> > > > <jonas.thornvall@gmail.com> wrote:
> > > > 
> > > >   <snip>
> > > > >By the way what kind of syntax, is this?
> > > > >input.value.onmidimessage = onMIDIMessage;
> > > > >
> > > > >omMIDIMessage is a function, to me it looks like an assigment i assign a function to input.value.onmidimessage?
> > > > >
> > > > >So is input.value.onmidimessage a listener or is it just onmidimessage that is the listener and input.value the object port?
> > > > >
> > > > >I mean the syntax is really not clear is it?
> > > > 
> > > > The syntax is perfectly clear. After this statement the value of 
> > > >   input.value.onmidimessage
> > > > is now the same function object as the value of 
> > > >   onMIDIMessage
> > > > 
> > > > As a result, doing 
> > > >   input.value.onmidimessage(x)
> > > > is the same as doing
> > > >   onMIDIMessage(x)
> > > > 
> > > >   John
> > > 
> > > Well John could you explain it in plain words not as syntax references?
> > > function success(midi) {
> > >   mid = midi;
> > >   inputs = mid.inputs.values();
> > >   for (input = inputs.next(); input && !input.done; input = inputs.next()) {
> > >   
> > >     input.value.onmidimessage = onMIDIMessage;
> > >   }
> > > }
> > > 
> > > For me this interpretate to. A succesful midi object was created "They never explain what it actually is but i guess it is hold inputs and outputs "because these must exist "as reserved words or constants?" how else could i extract them from the midiobject with inputs = mid.inputs.values();. Apparently this assignment to inputs "create an iterator object?" whatever that is... Well i get the gist a stepthru object, can't imagine why anyone would prefer it over an array but beyond point....
> > > 
> > > So i get the loop and its function, apparently it just steps thru the ports and assign them to input.
> > > 
> > > However
> > > input.value.onmidimessage = onMIDIMessage;
> > > Is hieroglyphs to me?
> > > What is "omnimidimessage" who created it "it is a reserved word, reserved object a constant" what is it?
> > > 
> > > Input value i just interpretate like a port???
> > > onMIDIMessage is a function that we somehow do what with?
> > > I can see i assign it to input.value.onmidimessage?
> > > 
> > > What is the thingy "code" that actually make the listener to the port?
> > > And why is a function call an assignment.
> > > 
> > > I can't follow the logic of the statements, i fucking know what is happening but the how and why is beyond me. That makes it very hard for me to make a listener for a single port. And how do you kill the listener on an input port?
> > 
> > Well i guess when things implemented idiotic, they will by nature inherit idiotic solutions. I come up with one i just list the ports with checkboxes, the checked ones i will do "onmidimessage" on.
> > 
> > But how to change the port listener state "on/off" after page loaded anyone?
> > 
> > Basicly i ask if this is the code to turn of listener "at a port".
> >  input.value.onmidimessage = onMIDIMessage; 
> > What is the code to turn it off...
> 
> Solved it i just put the request of midi midiAccess into a function, and basicly   relist the ports using the checkboxes...
> 
> But there probably is a way to kill each input onmidimessage listener instead of reinit the full midi.

The reason for wanting to be able to select which inports to listen to is, you may have software synths, attaced via loopbacks. If you have a loopback port connected in <-> out well that is indeed a loop you just want loopback outport open to connect to your external "software" synthesizer.

[toc] | [prev] | [next] | [standalone]


#38440

From1975.nenad@googlemail.com
Date2020-05-24 04:21 -0700
Message-ID<31e85138-2d2e-4cc5-9f4c-650c701e0d8a@googlegroups.com>
In reply to#37176
Am Montag, 2. September 2019 19:30:49 UTC+2 schrieb Jonas Thörnvall:
> Den måndag 2 september 2019 kl. 19:16:38 UTC+2 skrev Jonas Thörnvall:
> > Den söndag 1 september 2019 kl. 21:54:41 UTC+2 skrev Jonas Thörnvall:
> > > Den söndag 1 september 2019 kl. 12:59:31 UTC+2 skrev John G Harris:
> > > > On Sun, 1 Sep 2019 03:20:11 -0700 (PDT), Jonas Thörnvall
> > > > <jonas.thornvall@gmail.com> wrote:
> > > > 
> > > >   <snip>
> > > > >By the way what kind of syntax, is this?
> > > > >input.value.onmidimessage = onMIDIMessage;
> > > > >
> > > > >omMIDIMessage is a function, to me it looks like an assigment i assign a function to input.value.onmidimessage?
> > > > >
> > > > >So is input.value.onmidimessage a listener or is it just onmidimessage that is the listener and input.value the object port?
> > > > >
> > > > >I mean the syntax is really not clear is it?
> > > > 
> > > > The syntax is perfectly clear. After this statement the value of 
> > > >   input.value.onmidimessage
> > > > is now the same function object as the value of 
> > > >   onMIDIMessage
> > > > 
> > > > As a result, doing 
> > > >   input.value.onmidimessage(x)
> > > > is the same as doing
> > > >   onMIDIMessage(x)
> > > > 
> > > >   John
> > > 
> > > Well John could you explain it in plain words not as syntax references?
> > > function success(midi) {
> > >   mid = midi;
> > >   inputs = mid.inputs.values();
> > >   for (input = inputs.next(); input && !input.done; input = inputs.next()) {
> > >   
> > >     input.value.onmidimessage = onMIDIMessage;
> > >   }
> > > }
> > > 
> > > For me this interpretate to. A succesful midi object was created "They never explain what it actually is but i guess it is hold inputs and outputs "because these must exist "as reserved words or constants?" how else could i extract them from the midiobject with inputs = mid.inputs.values();. Apparently this assignment to inputs "create an iterator object?" whatever that is... Well i get the gist a stepthru object, can't imagine why anyone would prefer it over an array but beyond point....
> > > 
> > > So i get the loop and its function, apparently it just steps thru the ports and assign them to input.
> > > 
> > > However
> > > input.value.onmidimessage = onMIDIMessage;
> > > Is hieroglyphs to me?
> > > What is "omnimidimessage" who created it "it is a reserved word, reserved object a constant" what is it?
> > > 
> > > Input value i just interpretate like a port???
> > > onMIDIMessage is a function that we somehow do what with?
> > > I can see i assign it to input.value.onmidimessage?
> > > 
> > > What is the thingy "code" that actually make the listener to the port?
> > > And why is a function call an assignment.
> > > 
> > > I can't follow the logic of the statements, i fucking know what is happening but the how and why is beyond me. That makes it very hard for me to make a listener for a single port. And how do you kill the listener on an input port?
> > 
> > Well i guess when things implemented idiotic, they will by nature inherit idiotic solutions. I come up with one i just list the ports with checkboxes, the checked ones i will do "onmidimessage" on.
> > 
> > But how to change the port listener state "on/off" after page loaded anyone?
> > 
> > Basicly i ask if this is the code to turn of listener "at a port".
> >  input.value.onmidimessage = onMIDIMessage; 
> > What is the code to turn it off...
> 
> Solved it i just put the request of midi midiAccess into a function, and basicly   relist the ports using the checkboxes...
> 
> But there probably is a way to kill each input onmidimessage listener instead of reinit the full midi.

Hey thx for your post. I have the same problem and didn't found a solution yet. May you post your "working" code?

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web