13895766dSshatty // ****************************************************************************
23895766dSshatty //
33895766dSshatty // CLineLevel.cpp
43895766dSshatty //
53895766dSshatty // Source file for EchoGals generic driver line level control class.
63895766dSshatty //
73895766dSshatty // Controls line levels for input and output busses.
83895766dSshatty //
93895766dSshatty // Implemented as a base class with 2 derived classes, one for
103895766dSshatty // each type of bus.
113895766dSshatty //
12c2ddc71cSJérôme Duval // ----------------------------------------------------------------------------
13c2ddc71cSJérôme Duval //
14*626bc4beSJérôme Duval // This file is part of Echo Digital Audio's generic driver library.
15*626bc4beSJérôme Duval // Copyright Echo Digital Audio Corporation (c) 1998 - 2005
163895766dSshatty // All rights reserved
173895766dSshatty // www.echoaudio.com
183895766dSshatty //
19*626bc4beSJérôme Duval // This library is free software; you can redistribute it and/or
20*626bc4beSJérôme Duval // modify it under the terms of the GNU Lesser General Public
21*626bc4beSJérôme Duval // License as published by the Free Software Foundation; either
22*626bc4beSJérôme Duval // version 2.1 of the License, or (at your option) any later version.
233895766dSshatty //
24*626bc4beSJérôme Duval // This library is distributed in the hope that it will be useful,
25c2ddc71cSJérôme Duval // but WITHOUT ANY WARRANTY; without even the implied warranty of
26*626bc4beSJérôme Duval // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27*626bc4beSJérôme Duval // Lesser General Public License for more details.
283895766dSshatty //
29*626bc4beSJérôme Duval // You should have received a copy of the GNU Lesser General Public
30*626bc4beSJérôme Duval // License along with this library; if not, write to the Free Software
31*626bc4beSJérôme Duval // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
323895766dSshatty //
333895766dSshatty // ****************************************************************************
343895766dSshatty
353895766dSshatty #include "CEchoGals.h"
363895766dSshatty
373895766dSshatty
383895766dSshatty /****************************************************************************
393895766dSshatty
403895766dSshatty CLineLevel - Construction and destruction
413895766dSshatty
423895766dSshatty ****************************************************************************/
433895766dSshatty
443895766dSshatty //===========================================================================
453895766dSshatty //
463895766dSshatty // Constructor
473895766dSshatty //
483895766dSshatty //===========================================================================
493895766dSshatty
CLineLevel()503895766dSshatty CLineLevel::CLineLevel()
513895766dSshatty {
523895766dSshatty
533895766dSshatty Init( 0, NULL, NULL );
543895766dSshatty
553895766dSshatty } // CLineLevel::CLineLevel()
563895766dSshatty
573895766dSshatty
583895766dSshatty //===========================================================================
593895766dSshatty //
603895766dSshatty // Destructor
613895766dSshatty //
623895766dSshatty //===========================================================================
633895766dSshatty
~CLineLevel()643895766dSshatty CLineLevel::~CLineLevel()
653895766dSshatty {
663895766dSshatty } // CLineLevel::~CLineLevel()
673895766dSshatty
683895766dSshatty
693895766dSshatty //===========================================================================
703895766dSshatty //
713895766dSshatty // Initialization
723895766dSshatty //
733895766dSshatty //===========================================================================
743895766dSshatty
Init(WORD wChannelIndex,CEchoGals * pEchoGals,INT32 iGain)753895766dSshatty void CLineLevel::Init
763895766dSshatty (
773895766dSshatty WORD wChannelIndex, // Which channel we represent
783895766dSshatty CEchoGals * pEchoGals, // For setting line levels
793895766dSshatty INT32 iGain // Initial gain setting
803895766dSshatty )
813895766dSshatty {
823895766dSshatty m_iGain = 0; // Current gain in dB X 256
833895766dSshatty m_fMuted = FALSE;
843895766dSshatty m_pEchoGals = pEchoGals; // Ptr to our creator object
853895766dSshatty m_wChannelIndex = wChannelIndex;
863895766dSshatty // pipe index for this line
873895766dSshatty
883895766dSshatty } // void CLineLevel::Init
893895766dSshatty
903895766dSshatty
913895766dSshatty /****************************************************************************
923895766dSshatty
933895766dSshatty CLineLevel - Set and get stuff
943895766dSshatty
953895766dSshatty ****************************************************************************/
963895766dSshatty
973895766dSshatty //===========================================================================
983895766dSshatty //
993895766dSshatty // Set the mute
1003895766dSshatty //
1013895766dSshatty //===========================================================================
1023895766dSshatty
SetMute(BOOL fMute)1033895766dSshatty ECHOSTATUS CLineLevel::SetMute( BOOL fMute )
1043895766dSshatty {
1053895766dSshatty m_fMuted = fMute;
1063895766dSshatty return SetGain(ECHOGAIN_UPDATE);
1073895766dSshatty }
1083895766dSshatty
1093895766dSshatty
1103895766dSshatty
1113895766dSshatty /****************************************************************************
1123895766dSshatty
1133895766dSshatty CBusInLineLevel - Construction and destruction
1143895766dSshatty
1153895766dSshatty ****************************************************************************/
1163895766dSshatty
1173895766dSshatty //===========================================================================
1183895766dSshatty //
1193895766dSshatty // Construction/destruction
1203895766dSshatty //
1213895766dSshatty //===========================================================================
1223895766dSshatty
CBusInLineLevel()1233895766dSshatty CBusInLineLevel::CBusInLineLevel()
1243895766dSshatty {
1253895766dSshatty } // CBusInLineLevel::CBusInLineLevel()
1263895766dSshatty
1273895766dSshatty
~CBusInLineLevel()1283895766dSshatty CBusInLineLevel::~CBusInLineLevel()
1293895766dSshatty {
1303895766dSshatty } // COutLineLevel::~COutLineLevel()
1313895766dSshatty
1323895766dSshatty
1333895766dSshatty
1343895766dSshatty /****************************************************************************
1353895766dSshatty
1363895766dSshatty CBusInLineLevel - Get and set stuff
1373895766dSshatty
1383895766dSshatty ****************************************************************************/
1393895766dSshatty
1403895766dSshatty
1413895766dSshatty //===========================================================================
1423895766dSshatty //
1433895766dSshatty // Set the mute
1443895766dSshatty //
1453895766dSshatty //===========================================================================
1463895766dSshatty
SetMute(BOOL fMute)1473895766dSshatty ECHOSTATUS CBusInLineLevel::SetMute( BOOL fMute )
1483895766dSshatty {
1493895766dSshatty if (fMute != m_fMuted)
1503895766dSshatty {
1513895766dSshatty m_pEchoGals->MixerControlChanged(ECHO_BUS_IN,
1523895766dSshatty MXN_MUTE,
1533895766dSshatty m_wChannelIndex);
1543895766dSshatty }
1553895766dSshatty return CLineLevel::SetMute(fMute);
1563895766dSshatty }
1573895766dSshatty
1583895766dSshatty
1593895766dSshatty //===========================================================================
1603895766dSshatty //
1613895766dSshatty // Set the gain
1623895766dSshatty //
1633895766dSshatty //===========================================================================
1643895766dSshatty
SetGain(INT32 iGain,BOOL fImmediate)1653895766dSshatty ECHOSTATUS CBusInLineLevel::SetGain
1663895766dSshatty (
1673895766dSshatty INT32 iGain,
1683895766dSshatty BOOL fImmediate
1693895766dSshatty )
1703895766dSshatty {
1713895766dSshatty ECHOSTATUS Status;
1723895766dSshatty
1733895766dSshatty if ( NULL == m_pEchoGals ||
1743895766dSshatty NULL == m_pEchoGals->GetDspCommObject() ||
1753895766dSshatty m_pEchoGals->GetDspCommObject()->IsBoardBad() )
1763895766dSshatty return ECHOSTATUS_DSP_DEAD;
1773895766dSshatty
1783895766dSshatty //
1793895766dSshatty // If the magic ECHOGAIN_UPDATE value was passed in,
1803895766dSshatty // use the stored gain. Otherwise, clamp the gain.
1813895766dSshatty //
1823895766dSshatty if ( ECHOGAIN_UPDATE == iGain )
1833895766dSshatty iGain = m_iGain;
1843895766dSshatty else if ( iGain < ECHOGAIN_MININP )
1853895766dSshatty iGain = ECHOGAIN_MININP;
1863895766dSshatty else if ( iGain > ECHOGAIN_MAXINP )
1873895766dSshatty iGain = ECHOGAIN_MAXINP;
1883895766dSshatty
1893895766dSshatty //
1903895766dSshatty // Generate a control notify if necessary
1913895766dSshatty //
1923895766dSshatty if ( m_iGain != iGain )
1933895766dSshatty {
1943895766dSshatty m_iGain = iGain;
1953895766dSshatty m_pEchoGals->MixerControlChanged(ECHO_BUS_IN,
1963895766dSshatty MXN_LEVEL,
1973895766dSshatty m_wChannelIndex);
1983895766dSshatty }
1993895766dSshatty
2003895766dSshatty //
2013895766dSshatty // Mute?
2023895766dSshatty //
2033895766dSshatty if (m_fMuted)
2043895766dSshatty {
2053895766dSshatty iGain = ECHOGAIN_MININP;
2063895766dSshatty }
2073895766dSshatty
2083895766dSshatty //
2093895766dSshatty // Tell the DSP what to do
2103895766dSshatty //
2113895766dSshatty iGain <<= 1; // Preserver half-dB steps in input gain
2123895766dSshatty Status =
2133895766dSshatty m_pEchoGals->GetDspCommObject()->SetBusInGain
2143895766dSshatty ( m_wChannelIndex,
2153895766dSshatty (BYTE) ( GENERIC_TO_DSP( iGain ) ) );
2163895766dSshatty // Shift iGain up by 1 to preserve half-dB steps
2173895766dSshatty
2183895766dSshatty return Status;
2193895766dSshatty
2203895766dSshatty } // ECHOSTATUS CBusInLineLevel::SetGain
2213895766dSshatty
2223895766dSshatty
2233895766dSshatty
2243895766dSshatty /****************************************************************************
2253895766dSshatty
2263895766dSshatty CBusOutLineLevel - Construction and destruction
2273895766dSshatty
2283895766dSshatty ****************************************************************************/
2293895766dSshatty
2303895766dSshatty //===========================================================================
2313895766dSshatty //
2323895766dSshatty // Construction/destruction
2333895766dSshatty //
2343895766dSshatty //===========================================================================
2353895766dSshatty
2363895766dSshatty //
2373895766dSshatty // Construction/destruction
2383895766dSshatty //
CBusOutLineLevel()2393895766dSshatty CBusOutLineLevel::CBusOutLineLevel()
2403895766dSshatty {
2413895766dSshatty } // CBusOutLineLevel::CBusOutLineLevel()
2423895766dSshatty
2433895766dSshatty
~CBusOutLineLevel()2443895766dSshatty CBusOutLineLevel::~CBusOutLineLevel()
2453895766dSshatty {
2463895766dSshatty } // CBusOutLineLevel::~CBusOutLineLevel()
2473895766dSshatty
2483895766dSshatty
2493895766dSshatty
2503895766dSshatty
2513895766dSshatty /****************************************************************************
2523895766dSshatty
2533895766dSshatty CBusOutLineLevel - Get and set stuff
2543895766dSshatty
2553895766dSshatty ****************************************************************************/
2563895766dSshatty
2573895766dSshatty
2583895766dSshatty //===========================================================================
2593895766dSshatty //
2603895766dSshatty // Set the mute
2613895766dSshatty //
2623895766dSshatty //===========================================================================
2633895766dSshatty
SetMute(BOOL fMute)2643895766dSshatty ECHOSTATUS CBusOutLineLevel::SetMute( BOOL fMute )
2653895766dSshatty {
2663895766dSshatty if (fMute != m_fMuted)
2673895766dSshatty {
2683895766dSshatty m_pEchoGals->MixerControlChanged(ECHO_BUS_OUT,
2693895766dSshatty MXN_MUTE,
2703895766dSshatty m_wChannelIndex);
2713895766dSshatty }
2723895766dSshatty return CLineLevel::SetMute(fMute);
2733895766dSshatty }
2743895766dSshatty
2753895766dSshatty
2763895766dSshatty //===========================================================================
2773895766dSshatty //
2783895766dSshatty // Set the gain
2793895766dSshatty //
2803895766dSshatty //===========================================================================
2813895766dSshatty
SetGain(INT32 iGain,BOOL fImmediate)2823895766dSshatty ECHOSTATUS CBusOutLineLevel::SetGain
2833895766dSshatty (
2843895766dSshatty INT32 iGain,
2853895766dSshatty BOOL fImmediate
2863895766dSshatty )
2873895766dSshatty {
2883895766dSshatty ECHOSTATUS Status = ECHOSTATUS_OK;
2893895766dSshatty
2903895766dSshatty if ( NULL == m_pEchoGals ||
2913895766dSshatty NULL == m_pEchoGals->GetDspCommObject() ||
2923895766dSshatty m_pEchoGals->GetDspCommObject()->IsBoardBad() )
2933895766dSshatty return ECHOSTATUS_DSP_DEAD;
2943895766dSshatty
2953895766dSshatty //
2963895766dSshatty // If iGain is ECHOGAIN_UPDATE, then the caller
2973895766dSshatty // wants this function to re-do the gain setting
2983895766dSshatty // with the currently stored value
2993895766dSshatty //
3003895766dSshatty // Otherwise, clamp the gain setting
3013895766dSshatty //
3023895766dSshatty if ( ECHOGAIN_UPDATE == iGain )
3033895766dSshatty iGain = m_iGain;
3043895766dSshatty else if ( iGain < ECHOGAIN_MUTED )
3053895766dSshatty iGain = ECHOGAIN_MUTED;
3063895766dSshatty else if ( iGain > ECHOGAIN_MAXOUT )
3073895766dSshatty iGain = ECHOGAIN_MAXOUT;
3083895766dSshatty
3093895766dSshatty //
3103895766dSshatty // Mark this control as changed
3113895766dSshatty //
3123895766dSshatty if ( m_iGain != iGain )
3133895766dSshatty {
3143895766dSshatty m_iGain = iGain;
3153895766dSshatty
3163895766dSshatty if ( ECHOSTATUS_OK == Status )
3173895766dSshatty Status = m_pEchoGals->MixerControlChanged(ECHO_BUS_OUT,
3183895766dSshatty MXN_LEVEL,
3193895766dSshatty m_wChannelIndex);
3203895766dSshatty }
3213895766dSshatty
3223895766dSshatty //
3233895766dSshatty // Set the gain to mute if this bus is muted
3243895766dSshatty //
325c2ddc71cSJérôme Duval INT32 iGainTemp = iGain;
3263895766dSshatty if ( m_fMuted )
3273895766dSshatty iGainTemp = ECHOGAIN_MUTED;
3283895766dSshatty
3293895766dSshatty //
3303895766dSshatty // Tell all the monitors for this output bus to
3313895766dSshatty // update their gains
3323895766dSshatty //
3333895766dSshatty m_pEchoGals->AdjustMonitorsForBusOut(m_wChannelIndex);
3343895766dSshatty
3353895766dSshatty //
3363895766dSshatty // Tell all the output pipes for this output bus
3373895766dSshatty // to update their gains
3383895766dSshatty //
3393895766dSshatty m_pEchoGals->AdjustPipesOutForBusOut(m_wChannelIndex,iGainTemp);
3403895766dSshatty
3413895766dSshatty return Status;
3423895766dSshatty
3433895766dSshatty } // ECHOSTATUS CBusOutLineLevel::SetGain
3443895766dSshatty
3453895766dSshatty
3463895766dSshatty // **** CLineLevel.cpp ****
347