[comp.os.msdos.programmer] Turbo C++ derived classes problem?

todd@uhunix1.uhcc.Hawaii.Edu (Todd Ogasawara) (12/29/90)

I'm having execution speed problems when executing functions in a class
that is the second of two derived classes using Turbo C++.

I'm writing some code to drive my IBM Music Feature card (yeah, I know.. I
should have gotten a Roland LA-PC, but it wasn't available back when I
bought the Music Feature :-( ) and ran into what appears to be an odd
problem. Here it is....

1. I have a base class with member functions that handle low-level tasks
   like initializing the card, send a data byte, read a data byte, etc. We
   can call this 'A'.
2. I have a class derived from 'A' that deals with actually playing
   notes/sounds on the card. It deals at the level of note values, note
   velocity, note duration, etc. We can call this 'B1'
3. I have a second class also derived from 'A'. It is supposed to deal with
   aspects unique to the card such as selecting a voice, switching voice
   banks, etc. We can call this 'B2'.

Since I am a C++ neophyte, I tested all the individual functions in "toy C"
programs to make sure they had the desired action and that any problems
would be unrelated to the actual dealings with the Music Feature card. In
other words, every thing worked when isolated in a simple C function.

I found that functions in class 'B2' weren't working despite the fact that
they worked in standalone C programs (e.g., switching voice banks). I went
into the debugger and verified that bytes were being stuck in the right
places. However, I also noted that the desired actions (i.e., a sound
coming out of the Music Feature) weren't happening either! I soon figured
out that it must be that the Music Feature required a "tight data stream"
and that if bytes were "too far apart in time" the Music Feature card was
throwing away the bytes.

In any case, it turned out that I found that functions in derived class
'B2' executes much slower than functions in derived class 'B1'. I verified
this by putting some 'printf' between the 'putbyte' lines. If the function
is executed when defined in 'B1', then the Music Feature card gets the data
stream and responds appropriately and I see the printf strings whiz by. If
the function is in class 'B2', I can see the print strings crawl onto my
screen and the Music Feature card doesn't respond.

Anyway, I got things to work by only having one derived class. But this
puts a crimp in the way I designed the program since it depended on
buidling generations of derived classes each of which performs more
sophisticated functions in driving the Music Feature card.

Any hints/tips/fixes or even RTFMs would be appreciated...todd
--
Todd Ogasawara, U. of Hawaii
UUCP:		{uunet,ucbvax,dcdwest}!ucsd!nosc!uhunix!todd
BITNET:		todd@uhunix
INTERNET:	todd@uhunix.UHCC.HAWAII.EDU