1 // **************************************************************************** 2 // 3 // CDspCommObjectVmixer.cpp 4 // 5 // Implementation file for DSP interface class with vmixer support. 6 // 7 // ---------------------------------------------------------------------------- 8 // 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 12 // www.echoaudio.com 13 // 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. 18 // 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. 23 // 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 27 // 28 // **************************************************************************** 29 30 #include "CEchoGals.h" 31 #include "CDspCommObjectVmixer.h" 32 33 34 /**************************************************************************** 35 36 Construction and destruction 37 38 ****************************************************************************/ 39 40 //=========================================================================== 41 // 42 // Constructor 43 // 44 //=========================================================================== 45 46 CDspCommObjectVmixer::CDspCommObjectVmixer 47 ( 48 PDWORD pdwRegBase, // Virtual ptr to DSP registers 49 PCOsSupport pOsSupport 50 ) : CDspCommObject( pdwRegBase, pOsSupport ) 51 { 52 } // CDspCommObjectVmixer::CDspCommObjectVmixer( DWORD dwPhysRegBase ) 53 54 55 //=========================================================================== 56 // 57 // Destructor 58 // 59 //=========================================================================== 60 61 CDspCommObjectVmixer::~CDspCommObjectVmixer() 62 { 63 } // CDspCommObjectVmixer::~CDspCommObjectVmixer() 64 65 66 67 68 /**************************************************************************** 69 70 Hardware setup and config 71 72 ****************************************************************************/ 73 74 //=========================================================================== 75 // 76 // GetAudioMeters 77 // 78 // Meters are written to the comm page by the DSP as follows: 79 // 80 // Output busses 81 // Input busses 82 // Output pipes (vmixer cards only) 83 // 84 //=========================================================================== 85 86 ECHOSTATUS CDspCommObjectVmixer::GetAudioMeters 87 ( 88 PECHOGALS_METERS pMeters 89 ) 90 { 91 WORD i; 92 93 pMeters->iNumPipesIn = 0; 94 95 // 96 // Output 97 // 98 DWORD dwCh = 0; 99 100 pMeters->iNumBussesOut = (INT32) m_wNumBussesOut; 101 for (i = 0; i < m_wNumBussesOut; i++) 102 { 103 pMeters->iBusOutVU[i] = 104 DSP_TO_GENERIC( ((INT32) (char) m_pDspCommPage->VUMeter[ dwCh ]) ); 105 106 pMeters->iBusOutPeak[i] = 107 DSP_TO_GENERIC( ((INT32) (char) m_pDspCommPage->PeakMeter[ dwCh ]) ); 108 109 dwCh++; 110 } 111 112 pMeters->iNumBussesIn = (INT32) m_wNumBussesIn; 113 for (i = 0; i < m_wNumPipesIn; i++) 114 { 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 ]) ); 119 120 dwCh++; 121 } 122 123 pMeters->iNumPipesOut = (INT32) m_wNumPipesOut; 124 for (i = 0; i < m_wNumPipesOut; i++) 125 { 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 ]) ); 130 131 dwCh++; 132 } 133 134 return ECHOSTATUS_OK; 135 136 } // GetAudioMeters 137 138 139 //=========================================================================== 140 // 141 // GetPipeOutGain and SetPipeOutGain 142 // 143 // This doesn't set the line out volume; instead, it sets the 144 // vmixer volume. 145 // 146 //=========================================================================== 147 148 ECHOSTATUS CDspCommObjectVmixer::SetPipeOutGain 149 ( 150 WORD wPipeOut, 151 WORD wBusOut, 152 INT32 iGain, 153 BOOL fImmediate 154 ) 155 { 156 if (wPipeOut >= m_wNumPipesOut) 157 { 158 ECHO_DEBUGPRINTF( ("CDspCommObjectVmixer::SetPipeOutGain: Invalid out pipe " 159 "%d\n", 160 wPipeOut) ); 161 162 return ECHOSTATUS_INVALID_CHANNEL; 163 } 164 165 iGain = GENERIC_TO_DSP(iGain); 166 167 if ( wBusOut < m_wNumBussesOut ) 168 { 169 if ( !WaitForHandshake() ) 170 return ECHOSTATUS_DSP_DEAD; 171 172 DWORD dwIndex = wBusOut * m_wNumPipesOut + wPipeOut; 173 m_pDspCommPage->byVmixerLevel[ dwIndex ] = (BYTE) iGain; 174 175 ECHO_DEBUGPRINTF( ("CDspCommObjectVmixer::SetPipeOutGain: Out pipe %d, " 176 "out bus %d = 0x%lx\n", 177 wPipeOut, 178 wBusOut, 179 iGain) ); 180 181 if (fImmediate) 182 { 183 return UpdateVmixerLevel(); 184 } 185 186 return ECHOSTATUS_OK; 187 } 188 189 ECHO_DEBUGPRINTF( ("CDspCommObjectVmixer::SetPipeOutGain: Invalid out bus " 190 "%d\n", 191 wBusOut) ); 192 193 return ECHOSTATUS_INVALID_CHANNEL; 194 195 } // SetPipeOutGain 196 197 198 ECHOSTATUS CDspCommObjectVmixer::GetPipeOutGain 199 ( 200 WORD wPipeOut, 201 WORD wBusOut, 202 INT32 &iGain 203 ) 204 { 205 if (wPipeOut >= m_wNumPipesOut) 206 { 207 ECHO_DEBUGPRINTF( ("CDspCommObjectVmixer::GetPipeOutGain: Invalid out pipe " 208 "%d\n", 209 wPipeOut) ); 210 211 return ECHOSTATUS_INVALID_CHANNEL; 212 } 213 214 if (wBusOut < m_wNumBussesOut) 215 { 216 iGain = m_pDspCommPage->byVmixerLevel[ wBusOut * m_wNumPipesOut + wPipeOut ]; 217 iGain = DSP_TO_GENERIC(iGain); 218 return ECHOSTATUS_OK; 219 } 220 221 ECHO_DEBUGPRINTF( ("CDspCommObjectVmixer::GetPipeOutGain: Invalid out bus " 222 "%d\n", 223 wBusOut) ); 224 225 return ECHOSTATUS_INVALID_CHANNEL; 226 227 } // GetPipeOutGain 228 229 //=========================================================================== 230 // 231 // SetBusOutGain 232 // 233 //=========================================================================== 234 235 ECHOSTATUS CDspCommObjectVmixer::SetBusOutGain(WORD wBusOut,INT32 iGain) 236 { 237 if ( wBusOut < m_wNumBussesOut ) 238 { 239 if ( !WaitForHandshake() ) 240 return ECHOSTATUS_DSP_DEAD; 241 242 iGain = GENERIC_TO_DSP(iGain); 243 m_pDspCommPage->OutLineLevel[ wBusOut ] = (BYTE) iGain; 244 245 ECHO_DEBUGPRINTF( ("CDspCommObjectVmixer::SetBusOutGain: Out bus %d " 246 "= %lu\n", 247 wBusOut, 248 iGain) ); 249 250 return UpdateAudioOutLineLevel(); 251 252 } 253 254 ECHO_DEBUGPRINTF( ("CDspCommObjectVmixer::SetBusOutGain: Invalid out bus " 255 "%d\n", 256 wBusOut) ); 257 258 return ECHOSTATUS_INVALID_CHANNEL; 259 } 260 261 262 //=========================================================================== 263 // 264 // Tell the DSP to read and update vmixer levels 265 // from the comm page. 266 // 267 //=========================================================================== 268 269 ECHOSTATUS CDspCommObjectVmixer::UpdateVmixerLevel() 270 { 271 ECHO_DEBUGPRINTF( ( "CDspCommObjectVmixer::UpdateVmixerLevel:\n" ) ); 272 273 ClearHandshake(); 274 return( SendVector( DSP_VC_SET_VMIXER_GAIN ) ); 275 } 276 277 278 // **** CDspCommObjectVmixer.cpp **** 279