From: Jeffrey R. Carter on
John McCabe wrote:
>
> The second question is related to the implementation of the System
> Exclusive messages. Basically this is part of the reason I thought Ada
> would be good for this task. The SysEx messages basically consist of a
> smallish header and a variety of different structures that are
> differentiated by the "Function" type in the header. Now I seem to
> remember from when I did use Ada that it's possible to define the
> record representation of a variant record such that the discriminant
> is held within the body of the record. This would mean (I think) that
> I could read a block of data from the synthesizer straight in to a
> buffer that overlaid the variant record and essentially automatically
> created a record that could be read as the particular variant related
> to the incoming data. However I also seem to remember that's not quite
> a 'recommended' way of doing that sort of thing. The other thing that
> guided me in Ada's direction is that the structure of the SysEx
> messages requires a lot of bit-fields and I'm well aware that Ada's
> representation clauses are fantastic for that sort of thing.
>
> So, in principle, would that be the way to do this, or would you be
> able to suggest a better mechanism?

That is the way I would approach this, though I might keep the buffer and record
separate and use Unchecked_Conversion.

I can't tell you whether the tagged approach would work, because programming by
extension is a bad idea, and I avoid it whenever possible.

--
Jeff Carter
"Clear? Why, a 4-yr-old child could understand this
report. Run out and find me a 4-yr-old child. I can't
make head or tail out of it."
Duck Soup
94
From: Hibou57 (Yannick Duchêne) on
Le Wed, 03 Mar 2010 17:19:31 +0100, John McCabe
<john(a)nospam.assen.demon.co.uk> a écrit:
Hello,
> So the first question is do any of you know of any bindings to MS
> Windows MIDI (presumably the multimedia system) functions that already
> exist and are open source or something like that? I searched on Google
> for "ada midi" but it looks like there's a product called that so it
> came up with loads of stuff. I'm aware there are some binding to Win32
> from Ada but, as I've not been doing Ada in anger for a long time, I'm
> not sure if there's something for Ada 2005.
If there are possible funding, I would enjoy to re-organize my time to
honor this target under whatever license you may request.

If you ever you are interested in another stuff in the same area, I've
also started some times ago, but not terminated, an Ada binding to the VST
architecture. I've temporarily dropped the project for an undetermined
amount of time, because I need a project which could give me some earn. I
can't give a date, however, I'm pretty sure I will come back to it in the
future (at least, I hope I could)

> The second question is related to the implementation of the System
> Exclusive messages. Basically this is part of the reason I thought Ada
> would be good for this task. The SysEx messages basically consist of a
> smallish header and a variety of different structures that are
> differentiated by the "Function" type in the header. Now I seem to
> remember from when I did use Ada that it's possible to define the
> record representation of a variant record such that the discriminant
> is held within the body of the record. This would mean (I think) that
> I could read a block of data from the synthesizer straight in to a
> buffer that overlaid the variant record and essentially automatically
> created a record that could be read as the particular variant related
> to the incoming data. However I also seem to remember that's not quite
> a 'recommended' way of doing that sort of thing.
Excuse me, I'm not sure I've understood your words. Could you give a
concrete example of a process ?

Just to tell about what immediately comes into my mind : I'm not sure
variant record would be Ok for whole MIDI data sequences, as it comes into
sequence and not as a single block. The content of some MIDI messages are
splitted into multiple units which comes as a sequence. A variant record,
to be coherent, must be a whole, you cannot have something related to a
discriminant which remains dangling until some more data later arrives.

All this comment provided I've understood a bit of what you were to mean
(I apologize if I'm wrong).

> The other thing that
> guided me in Ada's direction is that the structure of the SysEx
> messages requires a lot of bit-fields and I'm well aware that Ada's
> representation clauses are fantastic for that sort of thing.
Another reason to use Ada : Ada is also a good choice in this area, due to
its tasking capabilities. This kind of application typically heavily
relies on multiple tasks (and even more heavily if you have to deal with
multiple synthesizers, what is a common case)

> So, in principle, would that be the way to do this, or would you be
> able to suggest a better mechanism?
>
> Finally, is there a straightforward way to do that sort of thing using
> tagged records? E.g. could I define a record which is the header
> format, then extend that in a number of different tagged extensions to
> create each individual message as a separate tagged record and use the
> OO and dispatching facilities to work with them?
I gonna go back to my docs to remind me about what's the layout of these
messages exactly.

> Any advice you've got the time to give on this would be very much
> appreciated.
You're welcome


--
No-no, this isn't an oops ...or I hope (TM) - Don't blame me... I'm just
not lucky
From: Hibou57 (Yannick Duchêne) on
Le Wed, 03 Mar 2010 21:17:12 +0100, John McCabe
<john(a)nospam.assen.demon.co.uk.nospam> a écrit:
> I've found a library
> called libjdkmidi that, if it would look easier to bind to than direct
> to Win32's mmsystem functions, might be worth doing.
Keep in mind it's a C++ library, not Ada

--
No-no, this isn't an oops ...or I hope (TM) - Don't blame me... I'm just
not lucky
From: Hibou57 (Yannick Duchêne) on
Le Wed, 03 Mar 2010 22:00:21 +0100, John McCabe
<john(a)nospam.assen.demon.co.uk.nospam> a écrit:
> That is unless (as I hope is NOT the case) any other MIDI data is
> interspersed with the SysEx messages. I would hope not but you never
> know. Guess it depends on a number of things.
I would say it's unlikely to be the case, as the status byte, which
identify the kind of message, only appears as the first byte of a sequence
which composes a MIDI message.

--
No-no, this isn't an oops ...or I hope (TM) - Don't blame me... I'm just
not lucky
From: Hibou57 (Yannick Duchêne) on
Le Wed, 03 Mar 2010 22:35:03 +0100, <tmoran(a)acm.org> a écrit:
> I don't know about MIDI, but for wav and video Windows generally assumes
> you can't do accurate timing, but it can.
For accurate timing, there is an audio driver interface, called ASIO4All,
which provides the ASIO interface for none-ASIO sound cards. It bypass the
normal Windows API audio stack, thus get better timing and less delay. But
be aware that ASIO4All is not a panacea for everyones, as it is sometime a
pain to use.


--
No-no, this isn't an oops ...or I hope (TM) - Don't blame me... I'm just
not lucky