comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Thinking of using Ada for a job at home. Couple of questions first.
Date: Wed, 3 Mar 2010 20:17:28 +0100
Date: 2010-03-03T20:17:28+01:00	[thread overview]
Message-ID: <fbxv573py6j7$.133yfvpzlstya$.dlg@40tude.net> (raw)
In-Reply-To: au1to5966sjtka244r3ce5dujj2j4ijfjt@4ax.com

On Wed, 03 Mar 2010 16:19:31 +0000, John McCabe wrote:

> 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.

I vaguely remember that there is no proper API for that (either in Ada or
in C). It is communicated over the Windows messages or worse at the process
level. I don't remember. Anyway if there exists proper C API, there is no
problem to convert it to Ada. It is a matter of a pair minutes of work.

> So, in principle, would that be the way to do this, or would you be
> able to suggest a better mechanism?

In practice that usually does not work well. The approach I am using is
reading the octet stream or else what is natural for the device or the
protocol at hand, and then constructing the necessary Ada objects on the
fly. I don't mess with representation clauses. If 100 nanoseconds overhead
impose a serious performance problem to your program it won't work anyway.
And under Windows we are talking about 1ms jitter at least. So no reason to
worry about that.

> Finally, is there a straightforward way to do that sort of thing using
> tagged records?

Yes, as above. This is the way I usually do it.

>  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?

No, why do you need message objects? What for? Once a message is received
and interpreted there is no need to keep it in any form, so to have a
Message type [or an hierarchy of]. Instead of that you create a tagged
Connection type, with primitive higher-level operations invoked by the
driver as it reads incoming messages.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  parent reply	other threads:[~2010-03-03 19:17 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-03 16:19 Thinking of using Ada for a job at home. Couple of questions first John McCabe
2010-03-03 18:22 ` Jeffrey R. Carter
2010-03-03 20:09   ` John McCabe
2010-03-03 21:00     ` Simon Wright
2010-03-03 18:58 ` Hibou57 (Yannick Duchêne)
2010-03-03 20:17   ` John McCabe
2010-03-04  6:22     ` Hibou57 (Yannick Duchêne)
2010-03-04 11:39       ` John McCabe
2010-03-09 14:49         ` Warren Gay
2010-03-09 15:33           ` Jacob Sparre Andersen
2010-03-09 20:22           ` jonathan
2010-03-09 21:57             ` Charmed Snark
2010-03-09 22:54               ` jonathan
2010-03-10 17:46                 ` Charmed Snark
2010-03-10 19:12                   ` jonathan
2010-03-10 20:41                     ` Simon Wright
2010-03-10 21:00                       ` Pascal Obry
2010-03-09 20:32           ` Simon Wright
2010-03-10  6:42           ` J-P. Rosen
2010-03-03 19:17 ` Dmitry A. Kazakov [this message]
2010-03-03 20:38   ` John McCabe
2010-03-03 20:56     ` Simon Wright
2010-03-03 21:00       ` John McCabe
2010-03-03 21:10         ` John McCabe
2010-03-04  6:39         ` Hibou57 (Yannick Duchêne)
2010-03-03 21:35       ` tmoran
2010-03-04  6:43         ` Hibou57 (Yannick Duchêne)
2010-03-03 22:20     ` Dmitry A. Kazakov
2010-03-03 19:52 ` Gautier write-only
2010-03-03 20:57   ` John McCabe
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox