1 // ****************************************************************************
5 // Source file for EchoGals generic driver line level control class.
7 // Controls line levels for input and output busses.
9 // Implemented as a base class with 2 derived classes, one for
12 // ----------------------------------------------------------------------------
14 // This file is part of Echo Digital Audio's generic driver library.
15 // Copyright Echo Digital Audio Corporation (c) 1998 - 2005
16 // All rights reserved
19 // This library is free software; you can redistribute it and/or
20 // modify it under the terms of the GNU Lesser General Public
21 // License as published by the Free Software Foundation; either
22 // version 2.1 of the License, or (at your option) any later version.
24 // This library is distributed in the hope that it will be useful,
25 // but WITHOUT ANY WARRANTY; without even the implied warranty of
26 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 // Lesser General Public License for more details.
29 // You should have received a copy of the GNU Lesser General Public
30 // License along with this library; if not, write to the Free Software
31 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 // ****************************************************************************
35 #include "CEchoGals.h"
38 /****************************************************************************
40 CLineLevel - Construction and destruction
42 ****************************************************************************/
44 //===========================================================================
48 //===========================================================================
50 CLineLevel::CLineLevel()
53 Init( 0, NULL
, NULL
);
55 } // CLineLevel::CLineLevel()
58 //===========================================================================
62 //===========================================================================
64 CLineLevel::~CLineLevel()
66 } // CLineLevel::~CLineLevel()
69 //===========================================================================
73 //===========================================================================
77 WORD wChannelIndex
, // Which channel we represent
78 CEchoGals
* pEchoGals
, // For setting line levels
79 INT32 iGain
// Initial gain setting
82 m_iGain
= 0; // Current gain in dB X 256
84 m_pEchoGals
= pEchoGals
; // Ptr to our creator object
85 m_wChannelIndex
= wChannelIndex
;
86 // pipe index for this line
88 } // void CLineLevel::Init
91 /****************************************************************************
93 CLineLevel - Set and get stuff
95 ****************************************************************************/
97 //===========================================================================
101 //===========================================================================
103 ECHOSTATUS
CLineLevel::SetMute( BOOL fMute
)
106 return SetGain(ECHOGAIN_UPDATE
);
111 /****************************************************************************
113 CBusInLineLevel - Construction and destruction
115 ****************************************************************************/
117 //===========================================================================
119 // Construction/destruction
121 //===========================================================================
123 CBusInLineLevel::CBusInLineLevel()
125 } // CBusInLineLevel::CBusInLineLevel()
128 CBusInLineLevel::~CBusInLineLevel()
130 } // COutLineLevel::~COutLineLevel()
134 /****************************************************************************
136 CBusInLineLevel - Get and set stuff
138 ****************************************************************************/
141 //===========================================================================
145 //===========================================================================
147 ECHOSTATUS
CBusInLineLevel::SetMute( BOOL fMute
)
149 if (fMute
!= m_fMuted
)
151 m_pEchoGals
->MixerControlChanged(ECHO_BUS_IN
,
155 return CLineLevel::SetMute(fMute
);
159 //===========================================================================
163 //===========================================================================
165 ECHOSTATUS
CBusInLineLevel::SetGain
173 if ( NULL
== m_pEchoGals
||
174 NULL
== m_pEchoGals
->GetDspCommObject() ||
175 m_pEchoGals
->GetDspCommObject()->IsBoardBad() )
176 return ECHOSTATUS_DSP_DEAD
;
179 // If the magic ECHOGAIN_UPDATE value was passed in,
180 // use the stored gain. Otherwise, clamp the gain.
182 if ( ECHOGAIN_UPDATE
== iGain
)
184 else if ( iGain
< ECHOGAIN_MININP
)
185 iGain
= ECHOGAIN_MININP
;
186 else if ( iGain
> ECHOGAIN_MAXINP
)
187 iGain
= ECHOGAIN_MAXINP
;
190 // Generate a control notify if necessary
192 if ( m_iGain
!= iGain
)
195 m_pEchoGals
->MixerControlChanged(ECHO_BUS_IN
,
205 iGain
= ECHOGAIN_MININP
;
209 // Tell the DSP what to do
211 iGain
<<= 1; // Preserver half-dB steps in input gain
213 m_pEchoGals
->GetDspCommObject()->SetBusInGain
215 (BYTE
) ( GENERIC_TO_DSP( iGain
) ) );
216 // Shift iGain up by 1 to preserve half-dB steps
220 } // ECHOSTATUS CBusInLineLevel::SetGain
224 /****************************************************************************
226 CBusOutLineLevel - Construction and destruction
228 ****************************************************************************/
230 //===========================================================================
232 // Construction/destruction
234 //===========================================================================
237 // Construction/destruction
239 CBusOutLineLevel::CBusOutLineLevel()
241 } // CBusOutLineLevel::CBusOutLineLevel()
244 CBusOutLineLevel::~CBusOutLineLevel()
246 } // CBusOutLineLevel::~CBusOutLineLevel()
251 /****************************************************************************
253 CBusOutLineLevel - Get and set stuff
255 ****************************************************************************/
258 //===========================================================================
262 //===========================================================================
264 ECHOSTATUS
CBusOutLineLevel::SetMute( BOOL fMute
)
266 if (fMute
!= m_fMuted
)
268 m_pEchoGals
->MixerControlChanged(ECHO_BUS_OUT
,
272 return CLineLevel::SetMute(fMute
);
276 //===========================================================================
280 //===========================================================================
282 ECHOSTATUS
CBusOutLineLevel::SetGain
288 ECHOSTATUS Status
= ECHOSTATUS_OK
;
290 if ( NULL
== m_pEchoGals
||
291 NULL
== m_pEchoGals
->GetDspCommObject() ||
292 m_pEchoGals
->GetDspCommObject()->IsBoardBad() )
293 return ECHOSTATUS_DSP_DEAD
;
296 // If iGain is ECHOGAIN_UPDATE, then the caller
297 // wants this function to re-do the gain setting
298 // with the currently stored value
300 // Otherwise, clamp the gain setting
302 if ( ECHOGAIN_UPDATE
== iGain
)
304 else if ( iGain
< ECHOGAIN_MUTED
)
305 iGain
= ECHOGAIN_MUTED
;
306 else if ( iGain
> ECHOGAIN_MAXOUT
)
307 iGain
= ECHOGAIN_MAXOUT
;
310 // Mark this control as changed
312 if ( m_iGain
!= iGain
)
316 if ( ECHOSTATUS_OK
== Status
)
317 Status
= m_pEchoGals
->MixerControlChanged(ECHO_BUS_OUT
,
323 // Set the gain to mute if this bus is muted
325 INT32 iGainTemp
= iGain
;
327 iGainTemp
= ECHOGAIN_MUTED
;
330 // Tell all the monitors for this output bus to
331 // update their gains
333 m_pEchoGals
->AdjustMonitorsForBusOut(m_wChannelIndex
);
336 // Tell all the output pipes for this output bus
337 // to update their gains
339 m_pEchoGals
->AdjustPipesOutForBusOut(m_wChannelIndex
,iGainTemp
);
343 } // ECHOSTATUS CBusOutLineLevel::SetGain
346 // **** CLineLevel.cpp ****