///////////////////////////////////////////////////////////
//             Trace PRO Control API                     //
//                                                       //
//          Delphi 5+ Import Unit for tproifc.dll        //
//                                                       //
//            (c) 12/2006 MARIAN A. Hellner              //
//                                                       //
//      Interface validated with driver versions:        //
//         v1.08                                         //
///////////////////////////////////////////////////////////

unit tproifc;

interface

uses windows;

const
  TPRO_DLL = 'tproifc.dll';
  TPRO_NUMCHANNELS = 36;

type
 // holds level information for one MONO channel
  TPRO_CHNLEVELINFO = record
    Pre        : Integer;   // Source Level Pre Gain
    Post       : Integer;   // Level measured after Gain/Pan/Volume/Mute
    AdOvl      : BOOL;      // AD Channels only: AD signaled an Input Overload

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

  // holds level information for all available
  // audio signals of one card
  TPRO_LEVELINFO = record
    CardId: Integer;     // IN: ID of target card
    reserved: Integer;
    Levels: array[0..TPRO_NUMCHANNELS-1] of TPRO_CHNLEVELINFO;
   // LevelInfo for each Mono signal available; indexes see: tpro_lvi_XXX constants
  end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Exported functions

// Initialization/Finalization --------------------------------

function  tpro_Init: BOOL; cdecl; external TPRO_DLL;
// initializes TPROIFC
// Input: none
// Output: Success

procedure tpro_Done; cdecl; external TPRO_DLL;
// finalizes usage of TPROIFC
// Input: None
// Output: None

function  tpro_GetNumCards: Integer; cdecl; external TPRO_DLL;
// returns the number of installed, active Trace PRO PCI cards

// Mixer Functions  -------------------------------------------

function  tpro_mx_GetValue   (crdid, typid, chnid, parid: Integer; var Value: Integer) : Integer; cdecl; external TPRO_DLL;
// 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)
//   Value  = variable for the result
// Output:
//   Value filled will the current parameter value
//   return < 0 ? Error : Success

function  tpro_mx_GetValueEx (crdid, typid, chnid, parid, sparid: Integer; var Value: Integer) : Integer; cdecl; external TPRO_DLL;
// 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)
//   Value  = variable for the result
// Output:
//   Value filled will the current parameter value
//   return < 0 ? Error : Success

function  tpro_mx_SetValue   (crdid, typid, chnid, parid, Value: Integer) : Integer; cdecl; external TPRO_DLL;
// 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

function  tpro_mx_SetValueEx (crdid, typid, chnid, parid, sparid, Value: Integer) : Integer; cdecl; external TPRO_DLL;
// 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

// Level Functions  -------------------------------------------

function  tpro_RequestLevel (var LevelInfo: TPRO_LEVELINFO): Integer; cdecl; external TPRO_DLL;
// Switchs Level Anaysis for specific stereo channels on/off
// Input:
//   LevelInfo = level information structure,
//   LevelInfo.CardId = ID of target card
//   LevelInfo.Levels[].Requests = initialized with >0 if Level required
// Output:
//   LevelInfo.Levels[].Code   = Error Code for Request
//   LevelInfo.Levels[].Handle = Driver specific handle for client channel
//   return < 0 ? Error : Success


function  tpro_GetLevel (var LevelInfo: TPRO_LEVELINFO): Integer; cdecl; external TPRO_DLL;
// Get the Levels for all requested MONO channels
// Input:
//   LevelInfo = level information structure,
//   LevelInfo.CardId = ID of target card
// Output:
//   LevelInfo.Levels[].Code       = Error Code for Get ( < 0 ? Error : Success)
//   LevelInfo.Levels[].Pre        = Level of the Source Signal (PRE Gain/Fader)
//   LevelInfo.Levels[].Post       = Level of the Signal after Gain, Pan, Fader, Mute
//   LevelInfo.Levels[].AdOvl      = if TRUE then the AD Converter signaled an Input Overload
//   LevelInfo.Levels[].ParChanged = if TRUE then any parameter of the channel has changed
//   return < 0 ? Error : Success

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

  tpro_typid_Chn    = 0;
  tpro_typid_Sum    = 1;
  tpro_typid_Out    = 2;

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

// typ_id == tpro_typid_Chn
  tpro_chnid_mixAnaIn1     =  0;
  tpro_chnid_mixAnaIn2     =  1;
  tpro_chnid_mixDigInL     =  2;
  tpro_chnid_mixDigInR     =  3;

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

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

// typ_id == tpro_typid_Sum
  tpro_chnid_sumMasterL    = 0;
  tpro_chnid_sumMasterR    = 1;
  tpro_chnid_sumAux1       = 2;
  tpro_chnid_sumAux2       = 3;
  tpro_chnid_sumAux3       = 4;
  tpro_chnid_sumAux4       = 5;
  tpro_chnid_sumAux5       = 6;
  tpro_chnid_sumAux6       = 7;

// typ_id == tpro_typid_Out
  tpro_chnid_outAna        = 0;
  tpro_chnid_outDig        = 1;
  tpro_chnid_outTdm12      = 2;
  tpro_chnid_outTdm34      = 3;
  tpro_chnid_outTdm56      = 4;
  tpro_chnid_outTdm78      = 5;

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

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

// typ_id == tpro_typid_Sum
  tpro_parid_SumVol        = 0;

// typ_id == tpro_typid_Out
  tpro_parid_OutRoute      = 0;
  tpro_parid_OutMute       = 1;
  tpro_parid_OutVolLeft    = 2;
  tpro_parid_OutVolRight   = 3;
  tpro_parid_OutTdmOnBus   = 4;
  tpro_parid_OutLevelRange = 5;  // for Analog Output Channel Only
  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
  tpro_sparid_Aux1 = 0;
  tpro_sparid_Aux2 = 1;
  tpro_sparid_Aux3 = 2;
  tpro_sparid_Aux4 = 3;
  tpro_sparid_Aux5 = 4;
  tpro_sparid_Aux6 = 5;

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

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

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

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

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

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

const
// Channel Indexes to Levels[]

  tpro_lvi_AnaIn1      = 0;
  tpro_lvi_AnaIn2      = 1;

  tpro_lvi_DigInL      = 2;
  tpro_lvi_DigInR      = 3;

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

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

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

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

implementation

end.
