/* ---------------------------------------------------------------------------- CHANNEL.hpp Describes a CHANNEL object, which represents an ASIO compliant sound channel. The most important aspect of this CHANNEL idea is that these objects are simply a convienient way of loading the g_Layla table. The bufSW routine then uses this table to process sound buffers efficiently. bufSW does most of the work. The CHANNEL instantiations are simply a convienent way to map waveforms or memory locations to sound buffers. Nothing really happens until Go or Ramp are called, only house keeping is being set up. CHANNEL has to know how to use a wave object because he knows WHEN a sound buffer needs to be initiialized and he knows WHERE the buffer is. WAVE knows how to initialize the buffer, but not WHERE or WHEN. Some typical call sequences are given below: CHANNEL chTX( 2 ,CH_OUT ) ,chNULL( 4 ,CH_OUT ); CHANNEL chMeas( 1 ,CH_IN ); CHANNEL chMaster; chTX.link ( &waveTX ); chNULL.link ( &waveNULL ); chMeas.link ( &measurement ,LenMeasurement ); chTX.play(); // Plays just this channel chMeas.record(); // Records just this channel chMaster.Go(); // Starts playing all outputs and recording all inputs chMaster.Ramp( FADE_IN | FADE_OUT ); // Ramps all outputs up or down chMaster.Stop(); // Shuts down the ASIO driver, releasing resources ???? chTX.update(); // Lets channel know that underlying waveform has changed OR... WAVE tracks change with a flag... output CHANNELs check this flag to see if a sound buffer update is requried. */ #ifndef _CHANNEL_ #define _CHANNEL_ #include "misctyps.h" #include "globals.h" #include "WAVES2.hpp" typedef enum { CH_NULL ,CH_IN ,CH_OUT } CHDIR; class CHANNEL { //------------- Class construction/destruction public: CHANNEL ( void ); // Constructs a master channel CHANNEL ( long SoundBufSZ ); // Constructs a master channel, setting sound buffer size CHANNEL ( WAVE *pwave ,int Channel ); // Constructs an output (D/A) channel CHANNEL ( void *pv ,ulong WVsize ,int Channel );// Constructs an input (A/D) channel ~CHANNEL( void ); // Destructor private: int channel ( void * ,ulong ,int ,CHDIR ); // Common initializer protected: // Define but don't implement to prevent these operations CHANNEL ( CHANNEL &refCHANNEL ); // Copy constructors (disallow?) CHANNEL ( CHANNEL *pCHANNEL ); CHANNEL &operator = ( CHANNEL &refCHANNEL ); //------------- Class methods public: void chan ( int Channel ); // Remaps the channel (deactivated after call to .go) void link ( WAVE *pwave ); // Links channel to waveform void link ( void *pvMem ,ulong Len ); // Links to general memory void lock ( void ); // Lock waveform away from sound buffer manager void unlock ( void ); // Un lock waveform void change ( void ); // Flags channel as updated so appropriate sound buffer can be loaded void convert ( void ); // Converts channel from binary to floating point representation void convert ( WAVEPTR pWV ); void cvrtSeg ( WAVEPTR wpToSegment ); // Converts only a channel segment from binary to fp representation void go ( void ); // Starts playing/recording all linked channels void ramp ( void ); // Ramps all linked output channels void stop ( void ); // Stops playing/recording all linked channels int clear ( void ); // Returns true if channels can be accessed int done ( void ); // Returns true if entire waveform has been read/written int busy ( void ); // Returns non-zero parameter indicating how close to being done void GetNew ( void ); // Forces channel to load an entire new waveform int seg ( int WhichSegment ); // Returns true if passed segment has been read/written int NextSeg ( void ); // Returns next segment to be read/written int NextSeg ( int SegmentOffset ); // Returns the next segment plus the indicated offset int CurSeg ( void ); // Returns the most recently read in segment WAVEPTR SegAddr ( int WhichSegment ); // Returns address of the indicated segement uint Missed ( void ); // Returns missed channels uint BufStat ( void ); // Returns sound buffer service status uint Status ( void ); // Returns channel object status //------------- Member variables public: int m_Ch; // Active channel number CHDIR m_Dir; // Channel direction WAVE *m_pWAVE; // Linked waveform long *m_plWave; ulong m_WVsize; int m_TblIdx; // Index into LAYA wave/chan mapping table static int g_ON; // Flag to indicate if the ASIO driver has been turned on static int g_Init; static int g_NumCh; static WAVE *g_pWAVE; // General waveform processor static uint g_Status; }; #endif