<?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>20254</bug_id>
          
          <creation_ts>2012-12-05 20:35:05 +0000</creation_ts>
          <short_desc>Add code examples</short_desc>
          <delta_ts>2013-01-02 11:29:24 +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>All</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="Chris Wilson">cwilso</reporter>
          <assigned_to name="Chris Wilson">cwilso</assigned_to>
          <cc>jussi.kalliokoski</cc>
    
    <cc>olivier.thereaux</cc>
    
    <cc>w3c_bugz</cc>
          
          <qa_contact>public-audio</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>79498</commentid>
    <comment_count>0</comment_count>
    <who name="Chris Wilson">cwilso</who>
    <bug_when>2012-12-05 20:35:05 +0000</bug_when>
    <thetext>We need more code examples in the spec.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79565</commentid>
    <comment_count>1</comment_count>
    <who name="Olivier Thereaux">olivier.thereaux</who>
    <bug_when>2012-12-06 17:08:24 +0000</bug_when>
    <thetext>You might want to break this down a bit after a first pass.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79659</commentid>
    <comment_count>2</comment_count>
    <who name="Chris Wilson">cwilso</who>
    <bug_when>2012-12-07 18:48:05 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; You might want to break this down a bit after a first pass.

Actually, since the API is so simple, I&apos;ll probably push in a bunch of examples in one go.

One question (email response to group is fine) - preferences for inline examples in each section, or separate example section?  I&apos;m leaning slightly to the latter.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79666</commentid>
    <comment_count>3</comment_count>
    <who name="Jussi Kalliokoski">jussi.kalliokoski</who>
    <bug_when>2012-12-07 19:50:06 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; (In reply to comment #1)
&gt; &gt; You might want to break this down a bit after a first pass.
&gt; 
&gt; Actually, since the API is so simple, I&apos;ll probably push in a bunch of
&gt; examples in one go.
&gt; 
&gt; One question (email response to group is fine) - preferences for inline
&gt; examples in each section, or separate example section?  I&apos;m leaning slightly
&gt; to the latter.

Due to the simplicity of the API, I agree that the latter is probably better.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79669</commentid>
    <comment_count>4</comment_count>
    <who name="Chris Wilson">cwilso</who>
    <bug_when>2012-12-07 20:42:23 +0000</bug_when>
    <thetext>Added a set of five basic examples that cover the entire API.  Other examples should be separately bugged.  https://dvcs.w3.org/hg/audio/rev/00b58322aa11.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79750</commentid>
    <comment_count>5</comment_count>
    <who name="Florian Bomers">w3c_bugz</who>
    <bug_when>2012-12-08 10:53:01 +0000</bug_when>
    <thetext>some remarks on the code examples:

9.1
&gt; function success( midiAccess )

should be named

&gt; function onMIDISuccess( midiAccess )


9.4
&gt; output.send( [0x90, 60, 0x00], window.performance.now() + 1000.0 ); 
&gt; // note off, middle C, zero velocity, timestamp = now + 1000ms.

This is actually a Note On message with 0 velocity, which is equivalent to a Note Off message with 64 velocity (if I recall correctly). It&apos;s probably easier to understand for MIDI newbies to use the actual Note Off message:

&gt; output.send( [0x80, 60, 0x00], window.performance.now() + 1000.0 ); 
&gt; // note off, middle C, zero velocity, timestamp = now + 1000ms.


9.5
same as 9.1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79849</commentid>
    <comment_count>6</comment_count>
    <who name="Chris Wilson">cwilso</who>
    <bug_when>2012-12-10 18:02:40 +0000</bug_when>
    <thetext>https://dvcs.w3.org/hg/audio/rev/d61cc0adee7e and https://dvcs.w3.org/hg/audio/rev/39efc30b003f contain these changes:

(In reply to comment #5)
&gt; should be named
&gt; &gt; function onMIDISuccess( midiAccess )

Done.

&gt; This is actually a Note On message with 0 velocity, which is equivalent to a
&gt; Note Off message with 64 velocity (if I recall correctly). It&apos;s probably
&gt; easier to understand for MIDI newbies to use the actual Note Off message:

Done.

&gt; 9.5
&gt; same as 9.1

Done.

From James&apos; email:
&gt;9.2
&gt;idx and i are the same variable. Change idx to i.

Done.

&gt;9.3
&gt;indexOfPort and index are the same variable. Change index to indexOfPort.

Done.

&gt;I  think I&apos;d also rename &quot;event&quot; to &quot;msg&quot; in onMIDIMessage(). Might give newbies a marginally easier time.

NOT done.  The parameter to the onmessage handler is an Event - I want that to be clear.

&gt;9.4
&gt;I think that a) the text should include the information that both messages are being sent on channel 0, and b) it might be helpful if you said a bit more about the omitted timestamp.

Done and done.

&gt;As in 9.3, change index to indexOfPort.

Done.

&gt;Can we have a sysex example in the official docs please?

Made it clearer that the echo example handles sysex.  Sysex is not a separate thing in the Web MIDI API - it&apos;s just another MIDIEvent, with more bytes.  (And, obviously, a different status code.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79854</commentid>
    <comment_count>7</comment_count>
    <who name="Florian Bomers">w3c_bugz</who>
    <bug_when>2012-12-10 19:55:54 +0000</bug_when>
    <thetext>(In reply to comment #6)

thanks for the super fast changes!

&gt; https://dvcs.w3.org/hg/audio/rev/d61cc0adee7e

includes the following addition:

&quot;This example sends a middle C note on message immediately on MIDI channel 0 [...]&quot;

I&apos;m sure you are aware of this -- MIDI channels are encoded as the lower 4 bits of the status byte from 0 to 15. But when referring to them, by convention, they are numbered 1 to 16. Therefore, I think it&apos;s better to change the text to say &quot;MIDI channel 1&quot;.

Now personally, I don&apos;t like this &quot;convention&quot;, but with MIDI being around for 30 years, it would bring more confusion than help trying to &quot;fix&quot; it now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79855</commentid>
    <comment_count>8</comment_count>
    <who name="Chris Wilson">cwilso</who>
    <bug_when>2012-12-10 20:06:49 +0000</bug_when>
    <thetext>(In reply to comment #7)
&gt; I&apos;m sure you are aware of this -- MIDI channels are encoded as the lower 4
&gt; bits of the status byte from 0 to 15. But when referring to them, by
&gt; convention, they are numbered 1 to 16. Therefore, I think it&apos;s better to
&gt; change the text to say &quot;MIDI channel 1&quot;.
&gt; 
&gt; Now personally, I don&apos;t like this &quot;convention&quot;, but with MIDI being around
&gt; for 30 years, it would bring more confusion than help trying to &quot;fix&quot; it now.

Fair enough.  Fixed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80822</commentid>
    <comment_count>9</comment_count>
    <who name="Olivier Thereaux">olivier.thereaux</who>
    <bug_when>2013-01-02 11:29:24 +0000</bug_when>
    <thetext>(In reply to comment #8)
&gt; &gt; Now personally, I don&apos;t like this &quot;convention&quot;, but with MIDI being around
&gt; &gt; for 30 years, it would bring more confusion than help trying to &quot;fix&quot; it now.
&gt; 
&gt; Fair enough.  Fixed.

I assume that with this fix, we can close this issue. Other requests for examples can be made into their own issues.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>