[openbeos-midi] Re: MIDI parser source (bytestream->MIDI messages)

  • From: "Matthijs Hollemans" <matthijs@xxxxxxxxxxxxxxxxxxx>
  • To: <openbeos-midi@xxxxxxxxxxxxx>
  • Date: Sat, 31 Jan 2004 17:30:36 +0100

Christian wrote:
> Please take a look at it and let me know if coding style and variable
> names are okay.

Coding style is an issue of much debate :-) Personally, I can't stand the
"official" OpenBeOS guidelines so I have ignored them in all the code I
wrote. I would prefer it if any changes to the Midi Kit code used the same
style as the rest of the Midi Kit code (in other words, my style :-).

Your code looks fine, except for the { braces, which I always put on the
next line. I haven't many complains otherwise. Although I wonder why you
declared all local variables "static," since that doesn't seem to be
necessary, judging from your code.

It would be nice to add a BMidiParser class to libmidi2.so, which would do
what your MidiIn::PushInput does, but with a configurable data source. So
the user of this class would have to provide a GetNextByte() method that
returns the next byte of input. If would return a special code to signify
the end of the data stream. Then the midi_server and your own code could
simply use the same class, preventing code duplication.

Unfortunately, we aren't really supposed to extend the public API. Now, we
could add BMidiParser to the BPrivate namespace, but then your app would be
using a private API which is also frowned upon. Oh well. There are other
additions like this that I would like to make to the Midi Kit, but I guess
these will simply have to wait until OpenBeOS R2.

> Once I'm sure that the code is correct, I'll integrate it into
> MidiPortProducer::GetData() and post the new PortDrivers.cpp.

Cool. Remember, though, that MidiPortProducer not only needs to parse the
byte stream, it also needs to talk to the drivers through the proper
protocol. Right now it simply uses a blocking read() call to get the
bytes -- which seems to work -- but there are also a number of ioctl() calls
to worry about. Unfortunately, I have no idea how these are supposed to
work. This doesn't change anything with respect to your changes, but it is
something to keep in mind :-)

-Matthijs


Other related posts: