<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>20510</bug_id>
          
          <creation_ts>2012-12-24 08:23:52 +0000</creation_ts>
          <short_desc>send(sequence&lt;short&gt; data) should just be send(any data)</short_desc>
          <delta_ts>2013-01-18 15:50:53 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>AudioWG</product>
          <component>MIDI API</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>TBD</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Marcos Caceres">w3c</reporter>
          <assigned_to name="Chris Wilson">cwilso</assigned_to>
          <cc>cwilso</cc>
    
    <cc>jussi.kalliokoski</cc>
    
    <cc>w3c</cc>
          
          <qa_contact>public-audio</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>80557</commentid>
    <comment_count>0</comment_count>
    <who name="Marcos Caceres">w3c</who>
    <bug_when>2012-12-24 08:23:52 +0000</bug_when>
    <thetext>If the first argument of send() is going to be coerced in to a Uint8Array, then send should just take any as a type. That avoids a whole bunch of unnecessary checks that will be performed when whatever value if thrown into new Uint8Array().

For example:

send({}) === []
send(function(){}) === []
send(Node) === []

send(&quot;&quot;) === [0]
send([&quot; &quot;]) === []

send([undefined,null,Node,Array, [1,23,432]]) === [0, 0, 0, 0, 0]

This one is important:
send([&quot;100&quot;, &quot;200&quot;, &quot;300&quot;]) === [100, 200, 44]


And so on…</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80574</commentid>
    <comment_count>1</comment_count>
    <who name="Jussi Kalliokoski">jussi.kalliokoski</who>
    <bug_when>2012-12-25 23:18:35 +0000</bug_when>
    <thetext>(In reply to comment #0)
&gt; If the first argument of send() is going to be coerced in to a Uint8Array,
&gt; then send should just take any as a type. That avoids a whole bunch of
&gt; unnecessary checks that will be performed when whatever value if thrown into
&gt; new Uint8Array().
&gt; 
&gt; For example:
&gt; 
&gt; send({}) === []
&gt; send(function(){}) === []
&gt; send(Node) === []
&gt; 
&gt; send(&quot;&quot;) === [0]
&gt; send([&quot; &quot;]) === []
&gt; 
&gt; send([undefined,null,Node,Array, [1,23,432]]) === [0, 0, 0, 0, 0]
&gt; 
&gt; This one is important:
&gt; send([&quot;100&quot;, &quot;200&quot;, &quot;300&quot;]) === [100, 200, 44]
&gt; 
&gt; 
&gt; And so on…

Sounds good to me, but I have to point out that this will make it impossible to overload send():

send(3) = [0,0,0]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80576</commentid>
    <comment_count>2</comment_count>
    <who name="Chris Wilson">cwilso</who>
    <bug_when>2012-12-25 23:23:40 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; Sounds good to me, but I have to point out that this will make it impossible
&gt; to overload send():
&gt; 
&gt; send(3) = [0,0,0]

And doesn&apos;t cause problems with the optional timestamp at the end, also?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80577</commentid>
    <comment_count>3</comment_count>
    <who name="Jussi Kalliokoski">jussi.kalliokoski</who>
    <bug_when>2012-12-25 23:29:47 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; And doesn&apos;t cause problems with the optional timestamp at the end, also?

Unless I misunderstood something, no, this would just affect the first argument.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80580</commentid>
    <comment_count>4</comment_count>
    <who name="Marcos Caceres">w3c</who>
    <bug_when>2012-12-25 23:49:57 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; Sounds good to me, but I have to point out that this will make it impossible
&gt; to overload send():
&gt; 
&gt; send(3) = [0,0,0]

True. And good point about it expanding out :/ I didn&apos;t think of that and I don&apos;t know if that is bad or not. 

I guess worst case you get people sending something like:

send(0x90); 

Will any hardware die if it gets a long string of 0s?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80581</commentid>
    <comment_count>5</comment_count>
    <who name="Jussi Kalliokoski">jussi.kalliokoski</who>
    <bug_when>2012-12-26 00:07:39 +0000</bug_when>
    <thetext>(In reply to comment #4) 
&gt; Will any hardware die if it gets a long string of 0s?

I doubt it. IIRC by spec that would be an invalid message, and therefore probably won&apos;t even be sent to USB-MIDI devices. As for normal MIDI devices, unless buggy, I think the message would just be skipped if they adhere to the spec. That might be a different case if we allowed partial messages (you&apos;d probably be going FUBAR anyway if you sent a new message in the middle of a partial message anyway), but we don&apos;t.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80595</commentid>
    <comment_count>6</comment_count>
    <who name="Chris Wilson">cwilso</who>
    <bug_when>2012-12-26 17:18:40 +0000</bug_when>
    <thetext>I still don&apos;t see why this is a benefit (allowing &quot;any&quot;).  This seems like being overly permissive (no checks), but there&apos;s one narrow &quot;magic correct&quot; version (an array of something that&apos;s actually numbers) that will actually work.  The others are just degenerate non-functional oddities.

Also - then I presume

.send( 0xf8 )

would actually work.  (Sends a Timing Clock message &quot;tick&quot;.)  that seems to me like it will continually re-open the question of &quot;why doesn&apos;t send( 0x90, 0x40, 0x7f ) work again?&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80598</commentid>
    <comment_count>7</comment_count>
    <who name="Marcos Caceres">w3c</who>
    <bug_when>2012-12-26 17:38:10 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; I still don&apos;t see why this is a benefit (allowing &quot;any&quot;).  This seems like
&gt; being overly permissive (no checks), but there&apos;s one narrow &quot;magic correct&quot;
&gt; version (an array of something that&apos;s actually numbers) that will actually
&gt; work.  The others are just degenerate non-functional oddities.
&gt; 
&gt; Also - then I presume
&gt; 
&gt; .send( 0xf8 )
&gt; 
&gt; would actually work. 

No, you just get an array with 240 zeros in it :) 

&gt; (Sends a Timing Clock message &quot;tick&quot;.)  that seems to
&gt; me like it will continually re-open the question of &quot;why doesn&apos;t send( 0x90,
&gt; 0x40, 0x7f ) work again?&quot;

Ok, then lets just go with the sequence:

sequence&lt;octet&gt; data

And let WebIDL do its magic on each item of the array:
http://www.w3.org/TR/WebIDL/#es-octet</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80599</commentid>
    <comment_count>8</comment_count>
    <who name="Marcos Caceres">w3c</who>
    <bug_when>2012-12-26 17:39:30 +0000</bug_when>
    <thetext>(In reply to comment #7)
&gt; (In reply to comment #6)
&gt; No, you just get an array with 240 zeros in it :) 

err, 248. Anyways :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80600</commentid>
    <comment_count>9</comment_count>
    <who name="Chris Wilson">cwilso</who>
    <bug_when>2012-12-26 17:46:42 +0000</bug_when>
    <thetext>That sounds more directive to me.  :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80601</commentid>
    <comment_count>10</comment_count>
    <who name="Marcos Caceres">w3c</who>
    <bug_when>2012-12-26 17:58:11 +0000</bug_when>
    <thetext>(In reply to comment #9)
&gt; That sounds more directive to me.  :)

Ok, but the WebIDL bit is important here... in section 7.3.1 Methods, the spec has wording about how to send() messages that might conflict with WebIDL. 

For example:
&quot;If data is not a valid sequence, does not contain a valid MIDI message, or if timestamp is passed but is not a valid DOMHighResTimeStamp, throw a TYPE_ERROR exception.&quot;

1. &quot;valid MIDI message&quot; is not defined, AFACT. 
2. and this is not needed, as it&apos;s handled by WebIDL: &quot;if timestamp is passed but is not a valid DOMHighResTimeStamp, throw a TYPE_ERROR exception.&quot; 

(I think I already filed 2. above)

Also:
&quot;The data MUST contain one or more valid, complete MIDI messages. Running status is not allowed in the data, as underlying systems may not support it.&quot;

1. Data is not a &quot;conformance class&quot;, hence an RFC2119 keyword cannot be used there. Please change it to:

&quot;The data contains one or more MIDI messages.&quot; 

The above is a statement of fact (which may or may not be true, but that is irrelevant until processed). 

2. It&apos;s unclear what &quot;Running status is not allowed in the data&quot; means. There is no algorithm defined in the specification to check for this (and do something if &quot;running status&quot; is found).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80608</commentid>
    <comment_count>11</comment_count>
    <who name="Chris Wilson">cwilso</who>
    <bug_when>2012-12-26 18:44:30 +0000</bug_when>
    <thetext>(In reply to comment #10)
&gt; &quot;If data is not a valid sequence, does not contain a valid MIDI message, or
&gt; if timestamp is passed but is not a valid DOMHighResTimeStamp, throw a
&gt; TYPE_ERROR exception.&quot;
&gt; 
&gt; 1. &quot;valid MIDI message&quot; is not defined, AFACT. 

Actually, it&apos;s defined by [[!MIDI]].  (Explicitly, as in there&apos;s a list of MIDI messages, + definition of sysex.)

&gt; 2. and this is not needed, as it&apos;s handled by WebIDL: &quot;if timestamp is
&gt; passed but is not a valid DOMHighResTimeStamp, throw a TYPE_ERROR
&gt; exception.&quot; 
&gt; 
&gt; (I think I already filed 2. above)

You did.  Already fixed.

&gt; Also:
&gt; &quot;The data MUST contain one or more valid, complete MIDI messages. Running
&gt; status is not allowed in the data, as underlying systems may not support it.&quot;
&gt; 
&gt; 1. Data is not a &quot;conformance class&quot;, hence an RFC2119 keyword cannot be
&gt; used there. Please change it to:
&gt; 
&gt; &quot;The data contains one or more MIDI messages.&quot; 
&gt; 
&gt; The above is a statement of fact (which may or may not be true, but that is
&gt; irrelevant until processed).

OK.
 
&gt; 2. It&apos;s unclear what &quot;Running status is not allowed in the data&quot; means.
&gt; There is no algorithm defined in the specification to check for this (and do
&gt; something if &quot;running status&quot; is found).

Defined by [[!MIDI]] as well.  Online definitions of running status tend to be shaky; it is, in my opinion, a bit of a hack.  Or, more precisely - the format of MIDI messages is pretty well documented online (by http://www.midi.org/techspecs/midimessages.php, for example), but running status is not.  In short - if you process according to that link and fail if something looks like it&apos;s not a MIDI message, you are detecting and failing on running status.  Running status is additional compression layered on top.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80609</commentid>
    <comment_count>12</comment_count>
    <who name="Chris Wilson">cwilso</who>
    <bug_when>2012-12-26 18:48:53 +0000</bug_when>
    <thetext>https://github.com/WebAudio/web-midi-api/commit/827afb647d68ea2007dcf78946ec9d8a90f84f9a</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81565</commentid>
    <comment_count>13</comment_count>
    <who name="Olivier Thereaux">olivier.thereaux</who>
    <bug_when>2013-01-18 15:50:53 +0000</bug_when>
    <thetext>Batch-closing RESOLVED MIDI issues. Reminder: midi issues now tracked at https://github.com/WebAudio/web-midi-api/issues</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>