12c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*
22c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Copyright (C) 2004-2010 NXP Software
32c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Copyright (C) 2010 The Android Open Source Project
42c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *
52c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Licensed under the Apache License, Version 2.0 (the "License");
62c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * you may not use this file except in compliance with the License.
72c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * You may obtain a copy of the License at
82c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *
92c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *      http://www.apache.org/licenses/LICENSE-2.0
102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *
112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Unless required by applicable law or agreed to in writing, software
122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * distributed under the License is distributed on an "AS IS" BASIS,
132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * See the License for the specific language governing permissions and
152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * limitations under the License.
162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent */
172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/****************************************************************************************/
202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Includes                                                                             */
222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/****************************************************************************************/
242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include "VectorArithmetic.h"
262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include "ScalarArithmetic.h"
272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include "LVM_Coeffs.h"
282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include "LVM_Tables.h"
292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include "LVM_Private.h"
302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/****************************************************************************************/
322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* FUNCTION:           LVM_SetControlParameters                                         */
342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* DESCRIPTION:                                                                         */
362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  Sets or changes the LifeVibes module parameters.                                    */
372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* PARAMETERS:                                                                          */
392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  hInstance          Instance handle                                                  */
402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  pParams            Pointer to a parameter structure                                 */
412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* RETURNS:                                                                             */
432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  LVM_SUCCESS        Succeeded                                                        */
442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  LVM_NULLADDRESS    When hInstance, pParams or any control pointers are NULL         */
452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  LVM_OUTOFRANGE     When any of the control parameters are out of range              */
462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* NOTES:                                                                               */
482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  1. This function may be interrupted by the LVM_Process function                     */
492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/****************************************************************************************/
512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
522c8e5cab3faa6d360e222b7a6c40a80083d021acEric LaurentLVM_ReturnStatus_en LVM_SetControlParameters(LVM_Handle_t           hInstance,
532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent                                             LVM_ControlParams_t    *pParams)
542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent{
552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    LVM_Instance_t    *pInstance =(LVM_Instance_t  *)hInstance;
562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if ((pParams == LVM_NULL) || (hInstance == LVM_NULL))
592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        return (LVM_NULLADDRESS);
612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    pInstance->NewParams = *pParams;
642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if(
662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        /* General parameters */
672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        ((pParams->OperatingMode != LVM_MODE_OFF) && (pParams->OperatingMode != LVM_MODE_ON))                                         ||
682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        ((pParams->SampleRate != LVM_FS_8000) && (pParams->SampleRate != LVM_FS_11025) && (pParams->SampleRate != LVM_FS_12000)       &&
692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        (pParams->SampleRate != LVM_FS_16000) && (pParams->SampleRate != LVM_FS_22050) && (pParams->SampleRate != LVM_FS_24000)       &&
702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        (pParams->SampleRate != LVM_FS_32000) && (pParams->SampleRate != LVM_FS_44100) && (pParams->SampleRate != LVM_FS_48000))      ||
712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        ((pParams->SourceFormat != LVM_STEREO) && (pParams->SourceFormat != LVM_MONOINSTEREO) && (pParams->SourceFormat != LVM_MONO)) ||
722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        (pParams->SpeakerType > LVM_EX_HEADPHONES))
732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        return (LVM_OUTOFRANGE);
752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    /*
782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     * Cinema Sound parameters
792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     */
802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if((pParams->VirtualizerOperatingMode != LVM_MODE_OFF) && (pParams->VirtualizerOperatingMode != LVM_MODE_ON))
812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        return (LVM_OUTOFRANGE);
832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if(pParams->VirtualizerType != LVM_CONCERTSOUND)
862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        return (LVM_OUTOFRANGE);
882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if(pParams->VirtualizerReverbLevel > LVM_VIRTUALIZER_MAX_REVERB_LEVEL)
912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        return (LVM_OUTOFRANGE);
932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if(pParams->CS_EffectLevel < LVM_CS_MIN_EFFECT_LEVEL)
962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        return (LVM_OUTOFRANGE);
982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
1002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    /*
1012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     * N-Band Equalizer
1022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     */
1032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if(pParams->EQNB_NBands > pInstance->InstParams.EQNB_NumBands)
1042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
1052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        return (LVM_OUTOFRANGE);
1062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
1072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
1082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    /* Definition pointer */
1092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if ((pParams->pEQNB_BandDefinition == LVM_NULL) &&
1102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        (pParams->EQNB_NBands != 0))
1112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
1122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        return (LVM_NULLADDRESS);
1132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
1142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
1152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    /*
1162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     * Copy the filter definitions for the Equaliser
1172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     */
1182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
1192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        LVM_INT16           i;
1202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
1212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        if (pParams->EQNB_NBands != 0)
1222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        {
1232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            for (i=0; i<pParams->EQNB_NBands; i++)
1242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            {
1252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent                pInstance->pEQNB_BandDefs[i] = pParams->pEQNB_BandDefinition[i];
1262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            }
1272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            pInstance->NewParams.pEQNB_BandDefinition = pInstance->pEQNB_BandDefs;
1282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        }
1292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
1302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if( /* N-Band Equaliser parameters */
1312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        ((pParams->EQNB_OperatingMode != LVM_EQNB_OFF) && (pParams->EQNB_OperatingMode != LVM_EQNB_ON)) ||
1322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        (pParams->EQNB_NBands > pInstance->InstParams.EQNB_NumBands))
1332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
1342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        return (LVM_OUTOFRANGE);
1352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
1362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    /* Band parameters*/
1372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
1382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        LVM_INT16 i;
1392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        for(i = 0; i < pParams->EQNB_NBands; i++)
1402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        {
1412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            if(((pParams->pEQNB_BandDefinition[i].Frequency < LVM_EQNB_MIN_BAND_FREQ)  ||
1422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent                (pParams->pEQNB_BandDefinition[i].Frequency > LVM_EQNB_MAX_BAND_FREQ)) ||
1432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent                ((pParams->pEQNB_BandDefinition[i].Gain     < LVM_EQNB_MIN_BAND_GAIN)  ||
1442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent                (pParams->pEQNB_BandDefinition[i].Gain      > LVM_EQNB_MAX_BAND_GAIN)) ||
1452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent                ((pParams->pEQNB_BandDefinition[i].QFactor  < LVM_EQNB_MIN_QFACTOR)     ||
1462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent                (pParams->pEQNB_BandDefinition[i].QFactor   > LVM_EQNB_MAX_QFACTOR)))
1472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            {
1482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent                return (LVM_OUTOFRANGE);
1492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            }
1502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        }
1512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
1522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
1532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    /*
1542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     * Bass Enhancement parameters
1552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     */
1562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if(((pParams->BE_OperatingMode != LVM_BE_OFF) && (pParams->BE_OperatingMode != LVM_BE_ON))                      ||
1572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        ((pParams->BE_EffectLevel < LVM_BE_MIN_EFFECTLEVEL ) || (pParams->BE_EffectLevel > LVM_BE_MAX_EFFECTLEVEL ))||
1582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        ((pParams->BE_CentreFreq != LVM_BE_CENTRE_55Hz) && (pParams->BE_CentreFreq != LVM_BE_CENTRE_66Hz)           &&
1592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        (pParams->BE_CentreFreq != LVM_BE_CENTRE_78Hz) && (pParams->BE_CentreFreq != LVM_BE_CENTRE_90Hz))           ||
1602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        ((pParams->BE_HPF != LVM_BE_HPF_OFF) && (pParams->BE_HPF != LVM_BE_HPF_ON)))
1612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
1622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        return (LVM_OUTOFRANGE);
1632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
1642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
1652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    /*
1662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     * Volume Control parameters
1672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     */
1682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if((pParams->VC_EffectLevel < LVM_VC_MIN_EFFECTLEVEL ) || (pParams->VC_EffectLevel > LVM_VC_MAX_EFFECTLEVEL ))
1692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
1702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        return (LVM_OUTOFRANGE);
1712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
1722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if((pParams->VC_Balance < LVM_VC_BALANCE_MIN ) || (pParams->VC_Balance > LVM_VC_BALANCE_MAX ))
1732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
1742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        return (LVM_OUTOFRANGE);
1752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
1762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
1772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    /*
1782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     * PSA parameters
1792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     */
1802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if( (pParams->PSA_PeakDecayRate > LVPSA_SPEED_HIGH) ||
1812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        (pParams->PSA_Enable > LVM_PSA_ON))
1822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
1832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        return (LVM_OUTOFRANGE);
1842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
1852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
1862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
1872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    /*
1882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    * Set the flag to indicate there are new parameters to use
1892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    *
1902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    * Protect the copy of the new parameters from interrupts to avoid possible problems
1912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    * with loss control parameters. This problem can occur if this control function is called more
1922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    * than once before a call to the process function. If the process function interrupts
1932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    * the copy to NewParams then one frame may have mixed parameters, some old and some new.
1942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    */
1952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    pInstance->ControlPending = LVM_TRUE;
1962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
1972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    return(LVM_SUCCESS);
1982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}
1992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
2002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
2012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/****************************************************************************************/
2022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
2032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* FUNCTION:             LVM_GetControlParameters                                       */
2042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
2052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* DESCRIPTION:                                                                         */
2062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  Request the LifeVibes module parameters. The current parameter set is returned      */
2072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  via the parameter pointer.                                                          */
2082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
2092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* PARAMETERS:                                                                          */
2102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  hInstance            Instance handle                                                */
2112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  pParams              Pointer to an empty parameter structure                        */
2122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
2132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* RETURNS:                                                                             */
2142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  LVM_SUCCESS          Succeeded                                                      */
2152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  LVM_NULLADDRESS      when any of hInstance or pParams is NULL                       */
2162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
2172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* NOTES:                                                                               */
2182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  1. This function may be interrupted by the LVM_Process function                     */
2192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
2202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/****************************************************************************************/
2212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
2222c8e5cab3faa6d360e222b7a6c40a80083d021acEric LaurentLVM_ReturnStatus_en LVM_GetControlParameters(LVM_Handle_t           hInstance,
2232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent                                             LVM_ControlParams_t    *pParams)
2242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent{
2252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    LVM_Instance_t    *pInstance =(LVM_Instance_t  *)hInstance;
2262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
2272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
2282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    /*
2292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     * Check pointer
2302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     */
2312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if ((pParams == LVM_NULL) || (hInstance == LVM_NULL))
2322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
2332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        return (LVM_NULLADDRESS);
2342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
2352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    *pParams = pInstance->NewParams;
2362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
2372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    /*
2382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     * Copy the filter definitions for the Equaliser
2392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     */
2402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
2412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        LVM_INT16           i;
2422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
2432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        if (pInstance->NewParams.EQNB_NBands != 0)
2442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        for (i=0; i<pInstance->NewParams.EQNB_NBands; i++)
2452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        {
2462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            pInstance->pEQNB_UserDefs[i] = pInstance->pEQNB_BandDefs[i];
2472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        }
2482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        pParams->pEQNB_BandDefinition = pInstance->pEQNB_UserDefs;
2492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
2502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
2512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    return(LVM_SUCCESS);
2522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}
2532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
2542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
2552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/****************************************************************************************/
2562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
2572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* FUNCTION:                LVM_SetTrebleBoost                                          */
2582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
2592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* DESCRIPTION:                                                                         */
2602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  Enable the treble boost when the settings are appropriate, i.e. non-zero gain       */
2612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  and the sample rate is high enough for the effect to be heard.                      */
2622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
2632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* PARAMETERS:                                                                          */
2642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  pInstance               Pointer to the instance structure                           */
2652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  pParams                 Pointer to the parameters to use                            */
2662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                      */
2672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/****************************************************************************************/
2682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LVM_SetTrebleBoost(LVM_Instance_t         *pInstance,
2692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent                        LVM_ControlParams_t    *pParams)
2702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent{
2712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    extern FO_C16_LShx_Coefs_t  LVM_TrebleBoostCoefs[];
2722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    LVM_INT16               Offset;
2732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    LVM_INT16               EffectLevel = 0;
2742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
2752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    /*
2762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     * Load the coefficients
2772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     */
2782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if ((pParams->TE_OperatingMode == LVM_TE_ON) &&
2792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        (pParams->SampleRate >= TrebleBoostMinRate) &&
2802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        (pParams->OperatingMode == LVM_MODE_ON) &&
2812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        (pParams->TE_EffectLevel > 0))
2822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
2832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        if((pParams->TE_EffectLevel == LVM_TE_LOW_MIPS) &&
2842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            ((pParams->SpeakerType == LVM_HEADPHONES)||
2852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            (pParams->SpeakerType == LVM_EX_HEADPHONES)))
2862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        {
2872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            pInstance->TE_Active = LVM_FALSE;
2882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        }
2892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        else
2902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        {
2912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            EffectLevel = pParams->TE_EffectLevel;
2922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            pInstance->TE_Active = LVM_TRUE;
2932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        }
2942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
2952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        if(pInstance->TE_Active == LVM_TRUE)
2962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        {
2972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            /*
2982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent             * Load the coefficients and enabled the treble boost
2992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent             */
3002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            Offset = (LVM_INT16)(EffectLevel - 1 + TrebleBoostSteps * (pParams->SampleRate - TrebleBoostMinRate));
3012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            FO_2I_D16F32Css_LShx_TRC_WRA_01_Init(&pInstance->pTE_State->TrebleBoost_State,
3022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent                                            &pInstance->pTE_Taps->TrebleBoost_Taps,
3032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent                                            &LVM_TrebleBoostCoefs[Offset]);
3042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
3052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            /*
3062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent             * Clear the taps
3072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent             */
30809d5ca3766d4bab91cdaad7206716a5747ebad77Eric Laurent            LoadConst_16((LVM_INT16)0,                                     /* Value */
30909d5ca3766d4bab91cdaad7206716a5747ebad77Eric Laurent                         (void *)&pInstance->pTE_Taps->TrebleBoost_Taps,  /* Destination.\
31009d5ca3766d4bab91cdaad7206716a5747ebad77Eric Laurent                                                     Cast to void: no dereferencing in function */
3112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent                         (LVM_UINT16)(sizeof(pInstance->pTE_Taps->TrebleBoost_Taps)/sizeof(LVM_INT16))); /* Number of words */
3122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        }
3132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
3142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    else
3152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
3162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        /*
3172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent         * Disable the treble boost
3182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent         */
3192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        pInstance->TE_Active = LVM_FALSE;
3202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
3212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
3222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    return;
3232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}
3242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
3252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
3262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/************************************************************************************/
3272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                  */
3282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* FUNCTION:            LVM_SetVolume                                               */
3292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                  */
3302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* DESCRIPTION:                                                                     */
3312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  Converts the input volume demand from dBs to linear.                            */
3322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                  */
3332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* PARAMETERS:                                                                      */
3342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  pInstance           Pointer to the instance                                     */
3352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  pParams             Initialisation parameters                                   */
3362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                  */
3372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/************************************************************************************/
3382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid    LVM_SetVolume(LVM_Instance_t         *pInstance,
3392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent                      LVM_ControlParams_t    *pParams)
3402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent{
3412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
3422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    LVM_UINT16      dBShifts;                                   /* 6dB shifts */
3432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    LVM_UINT16      dBOffset;                                   /* Table offset */
3442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    LVM_INT16       Volume = 0;                                 /* Required volume in dBs */
3452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
3462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    /*
3472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     * Limit the gain to the maximum allowed
3482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     */
3492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     if  (pParams->VC_EffectLevel > 0)
3502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     {
3512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent         Volume = 0;
3522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     }
3532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     else
3542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     {
3552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent         Volume = pParams->VC_EffectLevel;
3562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     }
3572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
3582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     /* Compensate this volume in PSA plot */
3592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     if(Volume > -60)  /* Limit volume loss to PSA Limits*/
3602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent         pInstance->PSA_GainOffset=(LVM_INT16)(-Volume);/* Loss is compensated by Gain*/
3612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     else
3622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent         pInstance->PSA_GainOffset=(LVM_INT16)60;/* Loss is compensated by Gain*/
3632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
3642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    pInstance->VC_AVLFixedVolume = 0;
3652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
3662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    /*
3672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     * Set volume control and AVL volumes according to headroom and volume user setting
3682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     */
3692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if(pParams->OperatingMode == LVM_MODE_ON)
3702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
3712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        /* Default Situation with no AVL and no RS */
3722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        if(pParams->EQNB_OperatingMode == LVM_EQNB_ON)
3732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        {
3742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent            if(Volume > -pInstance->Headroom)
3752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent                Volume = (LVM_INT16)-pInstance->Headroom;
3762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        }
3772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
3782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
3792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    /*
3802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     * Activate volume control if necessary
3812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     */
3822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    pInstance->VC_Active   = LVM_TRUE;
3832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if (Volume != 0)
3842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
3852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        pInstance->VC_VolumedB = Volume;
3862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
3872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    else
3882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
3892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        pInstance->VC_VolumedB = 0;
3902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
3912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
3922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    /*
3932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     * Calculate the required gain and shifts
3942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     */
3952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    dBOffset = (LVM_UINT16)((-Volume) % 6);             /* Get the dBs 0-5 */
3962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    dBShifts = (LVM_UINT16)(Volume / -6);               /* Get the 6dB shifts */
3972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
3982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
3992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    /*
4002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     * Set the parameters
4012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent     */
4022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if(dBShifts == 0)
4032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
4042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        LVC_Mixer_SetTarget(&pInstance->VC_Volume.MixerStream[0],
4052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent                                (LVM_INT32)LVM_VolumeTable[dBOffset]);
4062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
4072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    else
4082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
4092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        LVC_Mixer_SetTarget(&pInstance->VC_Volume.MixerStream[0],
4102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent                                (((LVM_INT32)LVM_VolumeTable[dBOffset])>>dBShifts));
4112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
4122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    pInstance->VC_Volume.MixerStream[0].CallbackSet = 1;
4132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    if(pInstance->NoSmoothVolume == LVM_TRUE)
4142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
4152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        LVC_Mixer_SetTimeConstant(&pInstance->VC_Volume.MixerStream[0],0,pInstance->Params.SampleRate,2);
4162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
4172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    else
4182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    {
4192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent        LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_Volume.MixerStream[0],LVM_VC_MIXER_TIME,pInstance->Params.SampleRate,2);
4202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    }
4212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}
4222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
4232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
4242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/************************************************************************************/
4252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                  */
4262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* FUNCTION:            LVM_SetHeadroom                                             */
4272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                  */
4282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* DESCRIPTION:                                                                     */
4292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  Find suitable headroom based on EQ settings.                                    */
4302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*                                                                                  */
4312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* PARAMETERS:                                                                      */
4322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  pInstance           Pointer to the instance                                     */
4332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*  pParams             Initialisation parameters                                   */
434