Board index » delphi » multiple device development

multiple device development

   i'm trying to develop a sound system for my turbo pascal
programs.  i am having trouble figuring out how to implement
the use of different sound cards.  different sound cards
require different procedures and variables unique to the
soundcard.  i have tried experimenting with objects, but
the oop in tp 7.0 does not seem versitle enough to allow me
to do what i want.  i would like to be able to detect the
sound device at run time and assign it so that i can execute
my sound card dependant procedures through a transparent
interface.  for example, if i had an object sounddevice,
after initialization i would be able to activate the detected
sound card by the line: sounddevice.activate;

   if anyone understands what i'm trying to do here, or has
delt with simlilar issues, please respond.  thanks in advance.

Roger Feese
rfe...@cse.unl.edu

 

Re:multiple device development


Quote
Roger Feese (rfe...@cse.unl.edu) wrote:

:    i'm trying to develop a sound system for my turbo pascal
: programs.  i am having trouble figuring out how to implement
: the use of different sound cards.  different sound cards
: require different procedures and variables unique to the
: soundcard.  i have tried experimenting with objects, but
: the oop in tp 7.0 does not seem versitle enough to allow me

  I don't see what your problem is. Where are you being hung up?

  What you need to do is think about what you want the object to look like
from the callers perspective, then you implement a "skeleton" object that
implements all the code that is common to _all_ sound cards. You *CANNOT*
start by implementing one soundcard, then expecting to be able to _easily_
"port" (extend) the object to other cards. Once you have the object mapped
out, declare all the procedures/routines that will be changed/superceded
by decendants of this object as "virtual", so that polymorphism may be
used at runtime.

  It may very well be that this object could be an "abstract" object, ie
one that can't be executed in it's native form, but it is also possible
that it could run (in a limited form) on all soundcards in it's native
state.

  Next you need to determine the needs of each different sundcard you want
to implement and write appropriate code for each card in decendant objects
of this "base" abstract object.

: to do what i want.  i would like to be able to detect the
: sound device at run time and assign it so that i can execute
: my sound card dependant procedures through a transparent
: interface.  for example, if i had an object sounddevice,
: after initialization i would be able to activate the detected
: sound card by the line: sounddevice.activate;

  This is the easy part. Put the soundcard object in it's own unit, and
call the autodetect routine (this needn't be - in fact, shouldn't be -
part of the soundcard object). Once you know what type of soundcard you
have, initialize the soundcard object.

Pseudo code example:

TYPE
   pSoundCard = ^oSoundCard;
   oSoundCard = OBJECT()
      ...
   end;  

   pAdlib = ^oAdlib;  
   oAdlib = OBJECT(oSoundCard)
      ...
   end;

   pSoundBlaster = ^oSoundBlaster;
   oSoundBlaster = OBJECT(oSoundcard)
      ...
   end;

var
   Sound :pSoundCard;

... { body of unit - implementation of SoundCard object and decendants }

BEGIN {  unit initialization section }  
   CardType := DetectSound;
   case CardType of
      Adlib: Sound := New(pAdlib, Init);
      SoundBlaster: Sound := New(pSoundBlaster, Init);
      Unknown: SoundError;
   end; { case }
END.

--
-- DLH "Warhammer"                           lhad...@knet.flemingc.on.ca
   Visit my home-page, get HTMLstrip and PMove:
                     http://www.knet.flemingc.on.ca/~lhadley/Profile.html

Microsoft Network is prohibited from redistributing this work in any form,
in whole or in part. Copyright, Larry Hadley, 1996. Please send notices of
violation to lhad...@knet.flemingc.on.ca and Postmas...@microsoft.com

Other Threads