Re: [Web MIDI API] send() method should also allow 3 shorts + timestamp

Hi Marcos,

IMO, a separate method for sending 3-byte MIDI messages does not
really hurt (although it might even /cause/ confusion -- sometimes you
need brackets, sometimes not...). But it's just a wrapper method and
can be implemented easily in an own method, or in a library. And
chances are that you'll use more specific wrappers in your code
anyway. Example:

 void sendController(short ctrl, double normalizedValue /* 0...1 */)
 {
    ctrlMIDIDevice.send([0xB0 | ctrlChannel, ctrl,
                        normalizedValue * 127]);
 }
 (where ctrlMIDIDevice and ctrlChannel are declared elsewhere).

I guess you know that there are valid MIDI messages of any length.
Personally, I'm very happy that the current webmidi API does not favor
any particular length of MIDI messages (as many other MIDI API's do).
Here, there is a good opportunity to encourage also advanced use of
MIDI with Sys Ex, Show Control, etc.

For a long discussion of different flavors of the send method(s) --
only for the very curious, I guess:
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=18764>

Regards,
Florian


On 12/16/2012 08:30, Marcos Caceres wrote:
> Currently, the send() method is defined as: void send
> (sequence<short> data, optional DOMHighResTimeStamp? timestamp);
> 
> However, it appears to me that it is extremely common to only want
> to send 3 bytes of data at a time (+ optional timestamp)… Having
> now been playing around with the API for about 10 hours, I actually
> keep forgetting to put things into an array (which leads to
> annoying errors). Can I recommend that the send interface be
> overloaded:
> 
> void send (sequence<short> data, optional DOMHighResTimeStamp?
> timestamp);
> void send (short byte1, short byte2, short byte3,
> optional DOMHighResTimeStamp? timestamp);
> 
> That would make the interface much more natural to work with and
> avoid having to remember to put things into an array all the time.
> 
> 
> -- Marcos Caceres http://datadriven.com.au
> 
> 
> 
> 

-- 
Florian Bomers
Bome Software

everything sounds.
http://www.bome.com

After the Beep!  -- iPhone voice networking
www.afterthebeep.com
__________________________________________________________________
Bome Software GmbH & Co KG        Gesellschafterin:
Dachauer Str.187                  Bome Komplementär GmbH
80637 München, Germany            Geschäftsführung: Florian Bömers
Amtsgericht München HRA95502      Amtsgericht München HRB185574

Received on Sunday, 16 December 2012 23:14:35 UTC