1 // ****************************************************************************
3 // CDspCommObjectVmixer.cpp
5 // Implementation file for DSP interface class with vmixer support.
7 // ----------------------------------------------------------------------------
9 // This file is part of Echo Digital Audio's generic driver library.
10 // Copyright Echo Digital Audio Corporation (c) 1998 - 2005
11 // All rights reserved
14 // This library is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU Lesser General Public
16 // License as published by the Free Software Foundation; either
17 // version 2.1 of the License, or (at your option) any later version.
19 // This library is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 // Lesser General Public License for more details.
24 // You should have received a copy of the GNU Lesser General Public
25 // License along with this library; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 // ****************************************************************************
30 #include "CEchoGals.h"
31 #include "CDspCommObjectVmixer.h"
34 /****************************************************************************
36 Construction and destruction
38 ****************************************************************************/
40 //===========================================================================
44 //===========================================================================
46 CDspCommObjectVmixer::CDspCommObjectVmixer
48 PDWORD pdwRegBase
, // Virtual ptr to DSP registers
49 PCOsSupport pOsSupport
50 ) : CDspCommObject( pdwRegBase
, pOsSupport
)
52 } // CDspCommObjectVmixer::CDspCommObjectVmixer( DWORD dwPhysRegBase )
55 //===========================================================================
59 //===========================================================================
61 CDspCommObjectVmixer::~CDspCommObjectVmixer()
63 } // CDspCommObjectVmixer::~CDspCommObjectVmixer()
68 /****************************************************************************
70 Hardware setup and config
72 ****************************************************************************/
74 //===========================================================================
78 // Meters are written to the comm page by the DSP as follows:
82 // Output pipes (vmixer cards only)
84 //===========================================================================
86 ECHOSTATUS
CDspCommObjectVmixer::GetAudioMeters
88 PECHOGALS_METERS pMeters
93 pMeters
->iNumPipesIn
= 0;
100 pMeters
->iNumBussesOut
= (INT32
) m_wNumBussesOut
;
101 for (i
= 0; i
< m_wNumBussesOut
; i
++)
103 pMeters
->iBusOutVU
[i
] =
104 DSP_TO_GENERIC( ((INT32
) (char) m_pDspCommPage
->VUMeter
[ dwCh
]) );
106 pMeters
->iBusOutPeak
[i
] =
107 DSP_TO_GENERIC( ((INT32
) (char) m_pDspCommPage
->PeakMeter
[ dwCh
]) );
112 pMeters
->iNumBussesIn
= (INT32
) m_wNumBussesIn
;
113 for (i
= 0; i
< m_wNumPipesIn
; i
++)
115 pMeters
->iBusInVU
[i
] =
116 DSP_TO_GENERIC( ((INT32
) (char) m_pDspCommPage
->VUMeter
[ dwCh
]) );
117 pMeters
->iBusInPeak
[i
] =
118 DSP_TO_GENERIC( ((INT32
) (char) m_pDspCommPage
->PeakMeter
[ dwCh
]) );
123 pMeters
->iNumPipesOut
= (INT32
) m_wNumPipesOut
;
124 for (i
= 0; i
< m_wNumPipesOut
; i
++)
126 pMeters
->iPipeOutVU
[i
] =
127 DSP_TO_GENERIC( ((INT32
) (char) m_pDspCommPage
->VUMeter
[ dwCh
]) );
128 pMeters
->iPipeOutPeak
[i
] =
129 DSP_TO_GENERIC( ((INT32
) (char) m_pDspCommPage
->PeakMeter
[ dwCh
]) );
134 return ECHOSTATUS_OK
;
139 //===========================================================================
141 // GetPipeOutGain and SetPipeOutGain
143 // This doesn't set the line out volume; instead, it sets the
146 //===========================================================================
148 ECHOSTATUS
CDspCommObjectVmixer::SetPipeOutGain
156 if (wPipeOut
>= m_wNumPipesOut
)
158 ECHO_DEBUGPRINTF( ("CDspCommObjectVmixer::SetPipeOutGain: Invalid out pipe "
162 return ECHOSTATUS_INVALID_CHANNEL
;
165 iGain
= GENERIC_TO_DSP(iGain
);
167 if ( wBusOut
< m_wNumBussesOut
)
169 if ( !WaitForHandshake() )
170 return ECHOSTATUS_DSP_DEAD
;
172 DWORD dwIndex
= wBusOut
* m_wNumPipesOut
+ wPipeOut
;
173 m_pDspCommPage
->byVmixerLevel
[ dwIndex
] = (BYTE
) iGain
;
176 ECHO_DEBUGPRINTF( ("CDspCommObjectVmixer::SetPipeOutGain: Out pipe %d, "
177 "out bus %d = 0x%lx\n",
185 return UpdateVmixerLevel();
188 return ECHOSTATUS_OK
;
191 ECHO_DEBUGPRINTF( ("CDspCommObjectVmixer::SetPipeOutGain: Invalid out bus "
195 return ECHOSTATUS_INVALID_CHANNEL
;
200 ECHOSTATUS
CDspCommObjectVmixer::GetPipeOutGain
207 if (wPipeOut
>= m_wNumPipesOut
)
209 ECHO_DEBUGPRINTF( ("CDspCommObjectVmixer::GetPipeOutGain: Invalid out pipe "
213 return ECHOSTATUS_INVALID_CHANNEL
;
216 if (wBusOut
< m_wNumBussesOut
)
218 iGain
= m_pDspCommPage
->byVmixerLevel
[ wBusOut
* m_wNumPipesOut
+ wPipeOut
];
219 iGain
= DSP_TO_GENERIC(iGain
);
220 return ECHOSTATUS_OK
;
223 ECHO_DEBUGPRINTF( ("CDspCommObjectVmixer::GetPipeOutGain: Invalid out bus "
227 return ECHOSTATUS_INVALID_CHANNEL
;
231 //===========================================================================
235 //===========================================================================
237 ECHOSTATUS
CDspCommObjectVmixer::SetBusOutGain(WORD wBusOut
,INT32 iGain
)
239 if ( wBusOut
< m_wNumBussesOut
)
241 if ( !WaitForHandshake() )
242 return ECHOSTATUS_DSP_DEAD
;
244 iGain
= GENERIC_TO_DSP(iGain
);
245 m_pDspCommPage
->OutLineLevel
[ wBusOut
] = (BYTE
) iGain
;
247 ECHO_DEBUGPRINTF( ("CDspCommObjectVmixer::SetBusOutGain: Out bus %d "
252 return UpdateAudioOutLineLevel();
256 ECHO_DEBUGPRINTF( ("CDspCommObjectVmixer::SetBusOutGain: Invalid out bus "
260 return ECHOSTATUS_INVALID_CHANNEL
;
264 //===========================================================================
266 // Tell the DSP to read and update vmixer levels
267 // from the comm page.
269 //===========================================================================
271 ECHOSTATUS
CDspCommObjectVmixer::UpdateVmixerLevel()
273 //ECHO_DEBUGPRINTF( ( "CDspCommObjectVmixer::UpdateVmixerLevel:\n" ) );
276 return( SendVector( DSP_VC_SET_VMIXER_GAIN
) );
280 // **** CDspCommObjectVmixer.cpp ****