/* ---------------------------------------------------------------------------- LAYLA.h PURPOSE: Handles the LAYLA sound box via the ASIO interface. WAVEtoCHN WAVECHN_TBL The structures above are key to operation of the LAYLA hardware via the ASIO sound driver. These structures contain where to get new waveforms for D/A channels and how many segments are contained in each measured waveform. These tables also contain access control bits allowing the sound driver thread to coordinate with the CIN. The access bits mean that a given sound buffer is not being logically accessed at the same time. There is one WAVECHN_TBL table for all A/D channels and one for all D/A channels. */ #ifndef _LAYLA_ #define _LAYLA_ #include // Need NULL definition #include "misctyps.h" #include "CHANNEL.hpp" // ----------------------------- Data types #define LAYLA_CHNS 8 // Number of input & output channels // #define SAMPLE_RATE 96000L // Sample rate in Hz #define SAMPLE_RATE 65536L // Sample rate in Hz #define WIDTH 32 // Sound buffer width in bits #define BYTES ( WIDTH / 8 ) // Sound buffer width in bytes #define NUM_SAMPLES ( FAST_FFT_SZ ) // Number of samples in a sound buffer #define BUF_SIZE ( g_lBufSZ * BYTES ) // Sound buffer length in bytes #define ASIO_RUNFAULT ( 0x0001 ) #define ASIO_LINKED ( 0x0004 ) #define ASIO_OPENED ( 0x0008 ) #define ASIO_ACCESSED ( 0x0010 ) #define ASIO_SIZEFAULT ( 0x0020 ) #define ASIO_SAMPFAULT ( 0x0040 ) #define ASIO_BUFFAULT ( 0x0080 ) typedef struct { CHANNEL *pCH; // Pointer to channel object int Chan; // Channel number we are mapped to long *pWV; // Pointer to input/output waveform ulong LenWV; // Length of the waveform int NumSeg; // Number of sound buffers necessary to hold waveform int CurSeg; // Waveform segment TO BE processed int Changed; // Flag to indicate if the underlying waveform has changed int Accessed; // Indicates if other side is accessing the waveform int NotPure; // When 0 indicates that the wave is "pure" containing no transitions } WAVEtoCHN; typedef struct { int ChCnt; // Count of active channels in the table int Changed; // Flag to indicate if table has changed WAVEtoCHN wvch[ LAYLA_CHNS+1 ]; // Wave to Channel mapping uint Missed; // Idicates if sound processing got behind (1 bit each active channel) } WAVECHN_TBL; // ------------------------------ Function prototypes void LAYLA_init ( void ); // Initializes LAYLA interface void LAYLA_init2 ( long SoundBufSize ); // Initializes LAYLA interface specifying sound buffer size int LAYLA_go ( void ); // Instatiates ASIO driver, creates sound buffers, starts playing/recording int LAYLA_ramp ( void ); // Same as go, but output sound buffers are ramped up int LAYLA_stop ( void ); // Stops ASIO driver, releases sound resources int LAYLA_map ( CHANNEL *pCH ); // Makes an entry in the WAVE to CHANNEL mapping table int LAYLA_update( int TblIdx ,CHANNEL *pCH ); // Updates a table entry // ------------------------------ Master Wave to Channel mapping, extern if you are not Layla implementation #ifdef _LAYLA_IMPLEMENTATION_ WAVECHN_TBL _wvchIN; // Wave to Channel mapping table; input channels WAVECHN_TBL _wvchOUT; // Wave to Channel mapping table; output channels long g_lBufSZ; uint g_ErrNum; #else extern WAVECHN_TBL _wvchIN; // Wave to Channel mapping table; input channels extern WAVECHN_TBL _wvchOUT; // Wave to Channel mapping table; output channels extern long g_lBufSZ; // Sound buffer size extern uint g_ErrNum; // Error bits #endif #endif