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

On Mon, Dec 17, 2012 at 6:17 PM, Marcos Caceres <marcosscaceres@gmail.com>wrote:

>
>
> On Monday, December 17, 2012 at 4:03 PM, Jussi Kalliokoski wrote:
>
> > On Mon, Dec 17, 2012 at 5:42 PM, Marcos Caceres <
> marcosscaceres@gmail.com (mailto:marcosscaceres@gmail.com)> wrote:
> > >
> > >
> > > On Monday, December 17, 2012 at 2:45 PM, Jussi Kalliokoski wrote:
> > >
> > > > On Sun, Dec 16, 2012 at 9:30 AM, Marcos Caceres <
> marcosscaceres@gmail.com (mailto:marcosscaceres@gmail.com) (mailto:
> marcosscaceres@gmail.com)> 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
> > > >
> > > >
> > > >
> > > > Heh, we actually had a veeeery looooong discussion about this
> earlier: https://www.w3.org/Bugs/Public/show_bug.cgi?id=18764
> > > Yeah, I read through the whole thread - it was really interesting.
> But, in the end, I didn't see how the spec ended up with just the array
> (instead of the array and the 3 bytes). I am in agreement that people will
> end up writing wrappers all over the place for this, but it would be great
> to at least not have to for some things.
> >
> >
> > Well, it actually came as a bit of surprise for me too (Chris changed
> it), but I like the form it took.
> >
> > > Like I mentioned previously, as a JS developer, I kept screwing up and
> not putting things into an array. It's another thing I have to think about,
> which, IMHO, I shouldn't have to.
> >
> >
> > To me, as a JS developer as well, I think it adds structure to the
> function call, separating the data from the timestamp. Longer signatures
> are more overhead, at least for my head.Can you give me an example of what
> you mean?
> >
>
> Just so we are on the same page, can you give me an example of what you
> mean? (I conceptualize things better in JS).
>
> In my own case, I kept finding I was doing things like this (specially as
> I'm testing sounds being emitted - not real data):
>
> output.send(90,60,122);
>
> I did this a lot particularly in the console.
>

Sure!

output.send(90, 60, 122, 100) // wat! looks like a part of the data?!

output.send([90, 60, 122], 100) // now the data is separate from the
timestamp

My point is that if you think about the action the send() has, it sends
some data at a specified time; that's two arguments, data and timestamp.
You can go arbitrarily splitting that into more arguments, but what's the
point?

Cheers,
Jussi

Received on Monday, 17 December 2012 16:35:43 UTC