///////////////////////////////////////////////////////////
//             Trace PRO Control API - TPROIFC           //
//                                                       //
//              Headefile for tproifc.dll                //
//                                                       //
//            (c) 12/2006 MARIAN A. Hellner              //
///////////////////////////////////////////////////////////

#ifndef __tproifc_h
#define __tproifc_h

#if defined(__cplusplus)
extern "C"
{
#endif

#define TPROCALL __declspec( dllimport ) __cdecl

///////////////////////////////////////////////////////////////////////////////////////////////////
// Initialization/Finalization

BOOL TPROCALL tpro_Init();
// initializes TPROIFC
// Input: none
// Output: Success

VOID TPROCALL tpro_Done();
// finalizes usage of TPROIFC
// Input: None
// Output: None

LONG TPROCALL tpro_GetNumCards();
// returns the number of installed, active Trace PRO PCI cards

///////////////////////////////////////////////////////////////////////////////////////////////////
// Handling Mixer Parameter Values

LONG TPROCALL tpro_mx_GetValue (
     LONG  crdid,
     LONG  typid,
     LONG  chnid,
     LONG  parid,
     PLONG pValue
);
// Gets the current Value of a specific mixer parameter
// Input:
//   crdid  = Card Id
//   typid  = Channel Type Id (see tpro_typid defines)
//   chnid  = Channel Id (see tpro_chnid defines)
//   parid  = Parameter Id (see tpro_parid defines)
//   pValue = Pointer to a LONG variable for the result
// Output:
//   *pValue filled will the current parameter value
//   return < 0 ? Error : Success


LONG TPROCALL tpro_mx_GetValueEx (
     LONG  crdid,
     LONG  typid,
     LONG  chnid,
     LONG  parid,
     LONG  sparid,
     PLONG pValue
);
// Gets the current Value of a specific mixer parameter
// Input:
//   crdid  = Card Id
//   typid  = Channel Type Id (see tpro_typid defines)
//   chnid  = Channel Id (see tpro_chnid defines)
//   parid  = Parameter Id (see tpro_parid defines)
//   sparid = Sub-Parameter Id (see tpro_sparid defines)
//   pValue = Pointer to a LONG variable for the result
// Output:
//   *pValue filled will the current parameter value
//   return < 0 ? Error : Success

LONG TPROCALL tpro_mx_SetValue (
     LONG  crdid,
     LONG  typid,
     LONG  chnid,
     LONG  parid,
     LONG  Value
);
// Sets the Value of a specific mixer parameter
// Input:
//   crdid  = Card Id
//   typid  = Channel Type Id (see tpro_typid defines)
//   chnid  = Channel Id (see tpro_chnid defines)
//   parid  = Parameter Id (see tpro_parid defines)
//   Value  = New Value for the Parameter
// Output:
//   return < 0 ? Error : Success

LONG TPROCALL tpro_mx_SetValueEx (
     LONG  crdid,
     LONG  typid,
     LONG  chnid,
     LONG  parid,
     LONG  sparid,
     LONG  Value
);
// Sets the Value of a specific mixer parameter
// Input:
//   crdid  = Card Id
//   typid  = Channel Type Id (see tpro_typid defines)
//   chnid  = Channel Id (see tpro_chnid defines)
//   parid  = Parameter Id (see tpro_parid defines)
//   sparid = Sub-Parameter Id (see tpro_sparid defines)
//   Value  = New Value for the Parameter
// Output:
//   return < 0 ? Error : Success

///////////////////////////////////////////////////////////////////////////////////////////////////
// Channel Type ID's (tpro_typid_xxx constants for typid parameter)

#define tpro_typid_Chn      0
#define tpro_typid_Sum      1
#define tpro_typid_Out      2

///////////////////////////////////////////////////////////////////////////////////////////////////
// Channel ID's (tpro_chnid_xxx constants for chnid parameter)

// typid == tpro_typid_Chn
#define tpro_chnid_mixAnaIn1        0
#define tpro_chnid_mixAnaIn2        1
#define tpro_chnid_mixDigInL        2
#define tpro_chnid_mixDigInR        3

#define tpro_chnid_mixPlay1         4
#define tpro_chnid_mixPlay2         5
#define tpro_chnid_mixPlay3         6
#define tpro_chnid_mixPlay4         7
#define tpro_chnid_mixPlay5         8
#define tpro_chnid_mixPlay6         9
#define tpro_chnid_mixPlay7        10
#define tpro_chnid_mixPlay8        11

#define tpro_chnid_mixTdm1         12
#define tpro_chnid_mixTdm2         13
#define tpro_chnid_mixTdm3         14
#define tpro_chnid_mixTdm4         15
#define tpro_chnid_mixTdm5         16
#define tpro_chnid_mixTdm6         17
#define tpro_chnid_mixTdm7         18
#define tpro_chnid_mixTdm8         19

// typid == tpro_typid_Sum
#define tpro_chnid_sumMasterL      0
#define tpro_chnid_sumMasterR      1
#define tpro_chnid_sumAux1         2
#define tpro_chnid_sumAux2         3
#define tpro_chnid_sumAux3         4
#define tpro_chnid_sumAux4         5
#define tpro_chnid_sumAux5         6
#define tpro_chnid_sumAux6         7

// typid == tpro_typid_Out
#define tpro_chnid_outAna          0
#define tpro_chnid_outDig          1
#define tpro_chnid_outTdm12        2
#define tpro_chnid_outTdm34        3
#define tpro_chnid_outTdm56        4
#define tpro_chnid_outTdm78        5

///////////////////////////////////////////////////////////////////////////////////////////////////
// Parameter ID's (tpro_parid_xxx for parid parameter)

// typid == tpro_typid_Chn
#define tpro_parid_SrcSel          0  // Digital Input Channels Only
#define tpro_parid_Gain            1
#define tpro_parid_BusVol          2  // needs SubParId specification for Bus Number
#define tpro_parid_BusPre          3  // needs SubParId specification for Bus Number
#define tpro_parid_Mute            4
#define tpro_parid_Solo            5
#define tpro_parid_Master_Pan      6
#define tpro_parid_Master_Vol      7
#define tpro_parid_GainRange       8  // for Analog Input Channels only
#define tpro_parid_AnaGain         9  // for Analog Input Channels only

// typid == tpro_typid_Sum
#define tpro_parid_SumVol          0

// typid == tpro_typid_Out
#define tpro_parid_OutRoute        0
#define tpro_parid_OutMute         1
#define tpro_parid_OutVolLeft      2
#define tpro_parid_OutVolRight     3
#define tpro_parid_OutTdmOnBus     4
#define tpro_parid_OutLevelRange   5  // for Analog Output Channel Only
#define tpro_parid_OutFormat       6  // for Digital Output Channel Only

////////////////////////////////////////////////////////////////////
// SUB - Parameter ID's (tpro_sparid_xxx for sparid parameter)

// parid == tpro_parid_BusVol OR tpro_parid_BusPre
#define tpro_sparid_Aux1   0
#define tpro_sparid_Aux2   1
#define tpro_sparid_Aux3   2
#define tpro_sparid_Aux4   3
#define tpro_sparid_Aux5   4
#define tpro_sparid_Aux6   5

///////////////////////////////////////////////////////////////////////////////////////////////////
// Parameter Values (valid range vor "value" parameter)

// parid == tpro_parid_SrcSel
#define tpro_val_InpRoute_AES   0   // Digital XLR Input
#define tpro_val_InpRoute_CD    1   // Internal Digital Audio CD Input (2-Pin-S/PDIF)

// parid == tpro_parid_OutRoute
#define tpro_val_Play12        0
#define tpro_val_Play34        1
#define tpro_val_Play56        2
#define tpro_val_Play78        3
#define tpro_val_Play910       4
#define tpro_val_Play1112      5
#define tpro_val_Play1314      6
#define tpro_val_Play1516      7
#define tpro_val_Rec12         8
#define tpro_val_Rec34         9
#define tpro_val_Rec56        10
#define tpro_val_Rec78        11
#define tpro_val_Tdm12        12
#define tpro_val_Tdm34        13
#define tpro_val_Tdm56        14
#define tpro_val_Tdm78        15
#define tpro_val_MxMaster     16
#define tpro_val_MxAux12      17
#define tpro_val_MxAux34      18
#define tpro_val_MxAux56      19
#define tpro_val_Play         20
#define tpro_val_Rec          21
#define tpro_val_NotSet       22

// parid == tpro_parid_GainRange
#define tpro_val_GainRange_6dbv    0      // Value for -6 dBV    0dbfs
#define tpro_val_GainRange_8dbu    1      // Value for +8 dBu    0dbfs
#define tpro_val_GainRange_15dbu   2      // Value for +15 dBu    0dbfs
#define tpro_val_GainRange_18dbu   3      // Value for +18 dBu    0dbfs

// parid == tpro_parid_OutLevelRange
#define tpro_val_OutLevelRange_6dbv    0  // Value for -6dBv    0dbfs
#define tpro_val_OutLevelRange_8dbu    1  // Value for  8dBu    0dbfs
#define tpro_val_OutLevelRange_18dbu   2  // Value for 18dB8    0dbfs

// parid == tpro_parid_OutFormat
#define tpro_val_OutFormat_Audio       0  // AES3 Output Channel State is set to "Audio"
#define tpro_val_OutFormat_NonAudio    1  // AES3 Output Channel State is set to "Non-Audio"


///////////////////////////////////////////////////////////////////////////////////////////////////
// Level Functions

#define TPRO_NUMCHANNELS  36

 // holds level information for one MONO channel
typedef struct {
  LONG   Pre;          // Source Level Pre Gain
  LONG   Post;         // Level measured after Gain/Pan/Volume/Mute
  BOOL   AdOvl;        // AD Channels only: AD signaled an Input Overload

  BOOL   ParChanged;   // Any of channel parameters has changed - read parameter values again
  LONG   Code;         // Channel specific Error Code of last Get/Request Operation
  LONG   Requests;     // Number of clients who need the level info of this channel
  ULONG  Handle;       // Driver spec. Handle, do not use
  ULONG  hDev;         // Driver spec. Handle, do not use
} TPRO_CHNLEVELINFO, *PTPRO_CHNLEVELINFO;

  // holds level information for all available
  // audio signals of one card
typedef struct {
  LONG CardId;     // IN: ID of target card
  LONG reserved;
  TPRO_CHNLEVELINFO Levels[TPRO_NUMCHANNELS];
   // LevelInfo for each Mono signal available; indexes see: tpro_lvi_XXX constants
} TPRO_LEVELINFO, *PTPRO_LEVELINFO;

// Channel Indexes to Levels[]
#define tpro_lvi_AnaIn1        0 
#define tpro_lvi_AnaIn2        1 

#define tpro_lvi_DigInL        2 
#define tpro_lvi_DigInR        3 

#define tpro_lvi_Play1         4 
#define tpro_lvi_Play2         5 
#define tpro_lvi_Play3         6 
#define tpro_lvi_Play4         7 
#define tpro_lvi_Play5         8 
#define tpro_lvi_Play6         9 
#define tpro_lvi_Play7         10 
#define tpro_lvi_Play8         11 

#define tpro_lvi_Tdm1          12 
#define tpro_lvi_Tdm2          13 
#define tpro_lvi_Tdm3          14 
#define tpro_lvi_Tdm4          15 
#define tpro_lvi_Tdm5          16 
#define tpro_lvi_Tdm6          17 
#define tpro_lvi_Tdm7          18 
#define tpro_lvi_Tdm8          19 

#define tpro_lvi_Play9         20 
#define tpro_lvi_Play10        21 
#define tpro_lvi_Play11        22 
#define tpro_lvi_Play12        23 
#define tpro_lvi_Play13        24 
#define tpro_lvi_Play14        25 
#define tpro_lvi_Play15        26 
#define tpro_lvi_Play16        27 

#define tpro_lvi_Sum1          28  // Master Sum L
#define tpro_lvi_Sum2          29  // Master Sum R
#define tpro_lvi_Sum3          30  // Aux 1
#define tpro_lvi_Sum4          31  // Aux 2
#define tpro_lvi_Sum5          32  // Aux 3
#define tpro_lvi_Sum6          33  // Aux 4
#define tpro_lvi_Sum7          34  // Aux 5
#define tpro_lvi_Sum8          35  // Aux 6

LONG TPROCALL tpro_RequestLevel (PTPRO_LEVELINFO pLevelInfo);
// Switchs Level Anaysis for specific MONO channels on/off
// Input:
//   pLevelInfo = pointer to level information structure,
//   pLevelInfo->CardId = ID of target card
//   pLevelInfo->Levels[].Requests = initialized with >0 if Level required
// Output:
//   pLevelInfo->Levels[].Code = Error Code for Request
//   pLevelInfo->Levels[].Handle = Driver specific handle for client channel
//   return < 0 ? Error : Success

LONG TPROCALL tpro_GetLevel (PTPRO_LEVELINFO pLevelInfo);
// Get the Levels for all requested MONO channels
// Input:
//   pLevelInfo = pointer to level information structure,
//   pLevelInfo->CardId = ID of target card
// Output:
//   pLevelInfo->Levels[].Code       = Error Code for Get ( < 0 ? Error : Success)
//   pLevelInfo->Levels[].Pre        = Level of the Source Signal (PRE Gain/Fader)
//   pLevelInfo->Levels[].Post       = Level of the Signal after Gain, Pan, Fader, Mute
//   pLevelInfo->Levels[].AdOvl      = if TRUE then the AD Converter signaled an Input Overload
//   pLevelInfo->Levels[].ParChanged = if TRUE then any parameter of the channel has changed
//   return < 0 ? Error : Success

#if defined(__cplusplus)
}
#endif

#endif // __tproifc_h

