1c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*
2c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * Copyright (C) 2004-2010 NXP Software
3c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * Copyright (C) 2010 The Android Open Source Project
4c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent *
5c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * Licensed under the Apache License, Version 2.0 (the "License");
6c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * you may not use this file except in compliance with the License.
7c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * You may obtain a copy of the License at
8c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent *
9c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent *      http://www.apache.org/licenses/LICENSE-2.0
10c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent *
11c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * Unless required by applicable law or agreed to in writing, software
12c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * distributed under the License is distributed on an "AS IS" BASIS,
13c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * See the License for the specific language governing permissions and
15c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * limitations under the License.
16c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent */
17c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
18c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/****************************************************************************************/
19c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
20c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*  Includes                                                                            */
21c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
22c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/****************************************************************************************/
23c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#include "LVREV_Private.h"
24c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#include "Filter.h"
25c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
26c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/****************************************************************************************/
27c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
28c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/* FUNCTION:                LVREV_ApplyNewSettings                                      */
29c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
30c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/* DESCRIPTION:                                                                         */
31c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*  Applies the new control parameters                                                  */
32c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
33c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/* PARAMETERS:                                                                          */
34c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*  pPrivate                Pointer to the instance private parameters                  */
35c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
36c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/* RETURNS:                                                                             */
37c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*  LVREV_Success           Succeeded                                                   */
38c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*  LVREV_NULLADDRESS       When pPrivate is NULL                                       */
39c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
40c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/* NOTES:                                                                               */
41c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
42c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/****************************************************************************************/
43c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
44c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric LaurentLVREV_ReturnStatus_en LVREV_ApplyNewSettings (LVREV_Instance_st     *pPrivate)
45c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent{
46c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
47c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_Mode_en  OperatingMode;
48c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_INT32    NumberOfDelayLines;
49c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
50c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
51c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /* Check for NULL pointer */
52c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    if(pPrivate == LVM_NULL)
53c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
54c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        return LVREV_NULLADDRESS;
55c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
56c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
57c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    OperatingMode = pPrivate->NewParams.OperatingMode;
58c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
59c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    if(pPrivate->InstanceParams.NumDelays == LVREV_DELAYLINES_4)
60c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
61c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        NumberOfDelayLines = 4;
62c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
63c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    else if(pPrivate->InstanceParams.NumDelays == LVREV_DELAYLINES_2)
64c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
65c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        NumberOfDelayLines = 2;
66c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
67c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    else
68c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
69c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        NumberOfDelayLines = 1;
70c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
71c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
72c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /*
73c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     * Update the high pass filter coefficients
74c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     */
75c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    if((pPrivate->NewParams.HPF        != pPrivate->CurrentParams.HPF)        ||
76c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent       (pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
77c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent       (pPrivate->bFirstControl        == LVM_TRUE))
78c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
79c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32       Omega;
80c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        FO_C32_Coefs_t  Coeffs;
81c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
82c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        Omega = LVM_GetOmega(pPrivate->NewParams.HPF, pPrivate->NewParams.SampleRate);
83c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_FO_HPF(Omega, &Coeffs);
84c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        FO_1I_D32F32Cll_TRC_WRA_01_Init( &pPrivate->pFastCoef->HPCoefs, &pPrivate->pFastData->HPTaps, &Coeffs);
85c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LoadConst_32(0,
86c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            (void *)&pPrivate->pFastData->HPTaps, /* Destination Cast to void: no dereferencing in function*/
87c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            sizeof(Biquad_1I_Order1_Taps_t)/sizeof(LVM_INT32));
88c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
89c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
90c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
91c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /*
92c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     * Update the low pass filter coefficients
93c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     */
94c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    if((pPrivate->NewParams.LPF        != pPrivate->CurrentParams.LPF)        ||
95c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent       (pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
96c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent       (pPrivate->bFirstControl        == LVM_TRUE))
97c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
98c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32       Omega;
99c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        FO_C32_Coefs_t  Coeffs;
100c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
101c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
102c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        Coeffs.A0 = 0x7FFFFFFF;
103c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        Coeffs.A1 = 0;
104c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        Coeffs.B1 = 0;
105c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        if(pPrivate->NewParams.LPF <= (LVM_FsTable[pPrivate->NewParams.SampleRate] >> 1))
106c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
107c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            Omega = LVM_GetOmega(pPrivate->NewParams.LPF, pPrivate->NewParams.SampleRate);
108c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
109c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            /*
110c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent             * Do not apply filter if w =2*pi*fc/fs >= 2.9
111c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent             */
112c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            if(Omega<=LVREV_2_9_INQ29)
113c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
114c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                LVM_FO_LPF(Omega, &Coeffs);
115c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
116c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
117c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        FO_1I_D32F32Cll_TRC_WRA_01_Init( &pPrivate->pFastCoef->LPCoefs, &pPrivate->pFastData->LPTaps, &Coeffs);
118c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LoadConst_32(0,
119c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            (void *)&pPrivate->pFastData->LPTaps,        /* Destination Cast to void: no dereferencing in function*/
120c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            sizeof(Biquad_1I_Order1_Taps_t)/sizeof(LVM_INT32));
121c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
122c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
123c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
124c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /*
125c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     * Calculate the room size parameter
126c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     */
127c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    if( pPrivate->NewParams.RoomSize != pPrivate->CurrentParams.RoomSize)
128c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
129c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        /* Room size range is 10ms to 200ms
130c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent         * 0%   -- 10ms
131c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent         * 50%  -- 65ms
132c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent         * 100% -- 120ms
133c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent         */
134c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->RoomSizeInms = 10 + (((pPrivate->NewParams.RoomSize*11) + 5)/10);
135c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
136c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
137c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
138c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /*
139c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     * Update the T delay number of samples and the all pass delay number of samples
140c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     */
141c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    if( (pPrivate->NewParams.RoomSize   != pPrivate->CurrentParams.RoomSize)   ||
142c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        (pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
143c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        (pPrivate->bFirstControl        == LVM_TRUE))
144c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
145c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
146c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_UINT32  Temp;
147c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32   APDelaySize;
148c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32   Fs = LVM_GetFsFromTable(pPrivate->NewParams.SampleRate);
149c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_UINT32  DelayLengthSamples = (LVM_UINT32)(Fs * pPrivate->RoomSizeInms);
150c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT16   i;
151c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT16   ScaleTable[]  = {LVREV_T_3_Power_minus0_on_4, LVREV_T_3_Power_minus1_on_4, LVREV_T_3_Power_minus2_on_4, LVREV_T_3_Power_minus3_on_4};
152c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT16   MaxT_Delay[]  = {LVREV_MAX_T0_DELAY, LVREV_MAX_T1_DELAY, LVREV_MAX_T2_DELAY, LVREV_MAX_T3_DELAY};
153c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT16   MaxAP_Delay[] = {LVREV_MAX_AP0_DELAY, LVREV_MAX_AP1_DELAY, LVREV_MAX_AP2_DELAY, LVREV_MAX_AP3_DELAY};
154c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
155c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
156c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        /*
157c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent         * For each delay line
158c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent         */
159c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        for (i=0; i<NumberOfDelayLines; i++)
160c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
161c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            if (i != 0)
162c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
163c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                LVM_INT32 Temp1;  /* to avoid QAC warning on type conversion */
164c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                LVM_INT32 Temp2;  /* to avoid QAC warning on type conversion */
165c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
166c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                Temp2=(LVM_INT32)DelayLengthSamples;
167c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                MUL32x16INTO32(Temp2, ScaleTable[i], Temp1, 15)
168c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                Temp=(LVM_UINT32)Temp1;
169c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
170c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            else
171c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
172c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent               Temp = DelayLengthSamples;
173c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
174c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            APDelaySize = Temp  / 1500;
175c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
176c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
177c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            /*
178c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent             * Set the fixed delay
179c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent             */
180c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            Temp                  = (MaxT_Delay[i] - MaxAP_Delay[i]) * Fs / 48000;
181c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->Delay_AP[i] = pPrivate->T[i] - Temp;
182c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
183c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
184c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            /*
185c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent             * Set the tap selection
186c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent             */
187c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            if (pPrivate->AB_Selection)
188c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
189c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                /* Smooth from tap A to tap B */
190c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                pPrivate->pOffsetB[i]             = &pPrivate->pDelay_T[i][pPrivate->T[i] - Temp - APDelaySize];
191c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                pPrivate->B_DelaySize[i]          = APDelaySize;
192c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                pPrivate->Mixer_APTaps[i].Target1 = 0;
193c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                pPrivate->Mixer_APTaps[i].Target2 = 0x7fffffff;
194c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
195c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            else
196c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
197c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                /* Smooth from tap B to tap A */
198c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                pPrivate->pOffsetA[i]             = &pPrivate->pDelay_T[i][pPrivate->T[i] - Temp - APDelaySize];
199c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                pPrivate->A_DelaySize[i]          = APDelaySize;
200c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                pPrivate->Mixer_APTaps[i].Target2 = 0;
201c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                pPrivate->Mixer_APTaps[i].Target1 = 0x7fffffff;
202c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
203c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
204c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            /*
205c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent             * Set the maximum block size to the smallest delay size
206c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent             */
207c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->MaxBlkLen   = Temp;
208c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            if (pPrivate->MaxBlkLen > pPrivate->A_DelaySize[i])
209c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
210c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                pPrivate->MaxBlkLen = pPrivate->A_DelaySize[i];
211c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
212c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            if (pPrivate->MaxBlkLen > pPrivate->B_DelaySize[i])
213c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
214c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                pPrivate->MaxBlkLen = pPrivate->B_DelaySize[i];
215c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
216c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
217c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        if (pPrivate->AB_Selection)
218c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
219c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->AB_Selection = 0;
220c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
221c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        else
222c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
223c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->AB_Selection = 1;
224c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
225c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
226c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
227c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        /*
228c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent         * Limit the maximum block length
229c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent         */
230c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->MaxBlkLen=pPrivate->MaxBlkLen-2;                                  /* Just as a precausion, but no problem if we remove this line      */
231c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        if(pPrivate->MaxBlkLen > pPrivate->InstanceParams.MaxBlockSize)
232c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
233c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->MaxBlkLen = (LVM_INT32)pPrivate->InstanceParams.MaxBlockSize;
234c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
235c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
236c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
237c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
238c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /*
239c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     * Update the low pass filter coefficient
240c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     */
241c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    if( (pPrivate->NewParams.Damping    != pPrivate->CurrentParams.Damping)    ||
242c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        (pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
243c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        (pPrivate->bFirstControl        == LVM_TRUE))
244c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
245c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
246c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32       Temp;
247c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32       Omega;
248c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        FO_C32_Coefs_t  Coeffs;
249c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT16       i;
250c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT16       Damping      = (LVM_INT16)((pPrivate->NewParams.Damping * 100) + 1000);
251c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32       ScaleTable[] = {LVREV_T_3_Power_0_on_4, LVREV_T_3_Power_1_on_4, LVREV_T_3_Power_2_on_4, LVREV_T_3_Power_3_on_4};
252c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
253c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
254c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        /*
255c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent         * For each filter
256c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent         */
257c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        for (i=0; i<NumberOfDelayLines; i++)
258c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
259c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            if (i != 0)
260c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
261c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                MUL32x16INTO32(ScaleTable[i], Damping, Temp, 15)
262c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
263c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            else
264c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
265c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                Temp = Damping;
266c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
267c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            if(Temp <= (LVM_FsTable[pPrivate->NewParams.SampleRate] >> 1))
268c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
269c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                Omega = LVM_GetOmega((LVM_UINT16)Temp, pPrivate->NewParams.SampleRate);
270c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                LVM_FO_LPF(Omega, &Coeffs);
271c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
272c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            else
273c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
274c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                Coeffs.A0 = 0x7FF00000;
275c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                Coeffs.A1 = 0;
276c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                Coeffs.B1 = 0;
277c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
278c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            FO_1I_D32F32Cll_TRC_WRA_01_Init(&pPrivate->pFastCoef->RevLPCoefs[i], &pPrivate->pFastData->RevLPTaps[i], &Coeffs);
279c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
280c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
281c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
282c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
283c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /*
284c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     * Update All-pass filter mixer time constants
285c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     */
286c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    if( (pPrivate->NewParams.RoomSize   != pPrivate->CurrentParams.RoomSize)   ||
287c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        (pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
288c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        (pPrivate->NewParams.Density    != pPrivate->CurrentParams.Density))
289c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
290c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT16   i;
291c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32   Alpha    = (LVM_INT32)LVM_Mixer_TimeConstant(LVREV_ALLPASS_TC, LVM_GetFsFromTable(pPrivate->NewParams.SampleRate), 1);
292c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32   AlphaTap = (LVM_INT32)LVM_Mixer_TimeConstant(LVREV_ALLPASS_TAP_TC, LVM_GetFsFromTable(pPrivate->NewParams.SampleRate), 1);
293c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
294c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        for (i=0; i<4; i++)
295c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
296c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->Mixer_APTaps[i].Alpha1       = AlphaTap;
297c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->Mixer_APTaps[i].Alpha2       = AlphaTap;
298c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->Mixer_SGFeedback[i].Alpha    = Alpha;
299c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->Mixer_SGFeedforward[i].Alpha = Alpha;
300c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
301c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
302c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
303c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
304c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /*
305c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     * Update the feed back gain
306c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     */
307c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    if( (pPrivate->NewParams.RoomSize   != pPrivate->CurrentParams.RoomSize)   ||
308c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        (pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
309c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        (pPrivate->NewParams.T60        != pPrivate->CurrentParams.T60)        ||
310c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        (pPrivate->bFirstControl        == LVM_TRUE))
311c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
312c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
313c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32               G[4];                       /* Feedback gain (Q7.24) */
314c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
315c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        if(pPrivate->NewParams.T60 == 0)
316c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
317c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            G[3] = 0;
318c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            G[2] = 0;
319c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            G[1] = 0;
320c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            G[0] = 0;
321c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
322c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        else
323c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
324c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            LVM_INT32   Temp1;
325c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            LVM_INT32   Temp2;
326c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            LVM_INT16   i;
327c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            LVM_INT16   ScaleTable[] = {LVREV_T_3_Power_minus0_on_4, LVREV_T_3_Power_minus1_on_4, LVREV_T_3_Power_minus2_on_4, LVREV_T_3_Power_minus3_on_4};
328c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
329c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
330c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            /*
331c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent             * For each delay line
332c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent             */
333c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            for (i=0; i<NumberOfDelayLines; i++)
334c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
335c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                Temp1 = (3 * pPrivate->RoomSizeInms * ScaleTable[i]) / pPrivate->NewParams.T60;
336c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                if(Temp1 >= (4 << 15))
337c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                {
338c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                    G[i] = 0;
339c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                }
340c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                else if((Temp1 >= (2 << 15)))
341c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                {
342c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                    Temp2 = LVM_Power10(-(Temp1 << 14));
343c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                    Temp1 = LVM_Power10(-(Temp1 << 14));
344c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                    MUL32x32INTO32(Temp1,Temp2,Temp1,24)
345c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                }
346c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                else
347c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                {
348c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                    Temp1 = LVM_Power10(-(Temp1 << 15));
349c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                }
350c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                if (NumberOfDelayLines == 1)
351c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                {
352c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                    G[i] = Temp1;
353c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                }
354c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                else
355c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                {
356c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                    LVM_INT32   TempG;
357c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                    MUL32x16INTO32(Temp1,ONE_OVER_SQRT_TWO,TempG,15)
358c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                    G[i]=TempG;
359c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                }
360c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
361c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
362c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
363c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        /* Set up the feedback mixers for four delay lines */
364c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->FeedbackMixer[0].Target=G[0]<<7;
365c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->FeedbackMixer[1].Target=G[1]<<7;
366c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->FeedbackMixer[2].Target=G[2]<<7;
367c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->FeedbackMixer[3].Target=G[3]<<7;
368c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
369c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
370c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
371c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /*
372c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     * Calculate the gain correction
373c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     */
374c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    if((pPrivate->NewParams.RoomSize != pPrivate->CurrentParams.RoomSize) ||
375c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent       (pPrivate->NewParams.Level    != pPrivate->CurrentParams.Level)    ||
376c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent       (pPrivate->NewParams.T60      != pPrivate->CurrentParams.T60) )
377c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
378c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32 Index=0;
379c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32 i=0;
380c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32 Gain=0;
381c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32 RoomSize=0;
382c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32 T60;
383c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32 Coefs[5];
384c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
385c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        if(pPrivate->NewParams.RoomSize==0)
386c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
387c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            RoomSize=1;
388c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
389c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        else
390c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
391c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            RoomSize=(LVM_INT32)pPrivate->NewParams.RoomSize;
392c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
393c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
394c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        if(pPrivate->NewParams.T60<100)
395c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
396c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            T60 = 100 * LVREV_T60_SCALE;
397c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
398c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        else
399c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
400c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            T60 = pPrivate->NewParams.T60 * LVREV_T60_SCALE;
401c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
402c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
403c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        /* Find the nearest room size in table */
404c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        for(i=0;i<24;i++)
405c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
406c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            if(RoomSize<= LVREV_GainPolyTable[i][0])
407c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
408c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                Index=i;
409c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                break;
410c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
411c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
412c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
413c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
414c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        if(RoomSize==LVREV_GainPolyTable[Index][0])
415c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
416c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            /* Take table values if the room size is in table */
417c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            for(i=1;i<5;i++)
418c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
419c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                Coefs[i-1]=LVREV_GainPolyTable[Index][i];
420c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
421c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            Coefs[4]=0;
422c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            Gain=LVM_Polynomial(3,Coefs,T60);       /* Q.24 result */
423c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
424c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        else
425c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
426c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            /* Interpolate the gain between nearest room sizes */
427c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
428c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            LVM_INT32 Gain1,Gain2;
429c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            LVM_INT32 Tot_Dist,Dist;
430c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
431c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            Tot_Dist=LVREV_GainPolyTable[Index][0]-LVREV_GainPolyTable[Index-1][0];
432c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            Dist=RoomSize-LVREV_GainPolyTable[Index-1][0];
433c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
434c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
435c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            /* Get gain for first */
436c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            for(i=1;i<5;i++)
437c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
438c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                Coefs[i-1]=LVREV_GainPolyTable[Index-1][i];
439c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
440c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            Coefs[4]=0;
441c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
442c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            Gain1=LVM_Polynomial(3,Coefs,T60);      /* Q.24 result */
443c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
444c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            /* Get gain for second */
445c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            for(i=1;i<5;i++)
446c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
447c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                Coefs[i-1]=LVREV_GainPolyTable[Index][i];
448c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
449c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            Coefs[4]=0;
450c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
451c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            Gain2=LVM_Polynomial(3,Coefs,T60);      /* Q.24 result */
452c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
453c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            /* Linear Interpolate the gain */
454c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            Gain = Gain1+ (((Gain2-Gain1)*Dist)/(Tot_Dist));
455c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
456c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
457c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
458c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        /*
459c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent         * Get the inverse of gain: Q.15
460c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent         * Gain is mostly above one except few cases, take only gains above 1
461c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent         */
462c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        if(Gain < 16777216L)
463c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
464c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->Gain= 32767;
465c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
466c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        else
467c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
468c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->Gain=(LVM_INT16)(LVM_MAXINT_32/(Gain>>8));
469c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
470c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
471c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
472c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        Index=((32767*100)/(100+pPrivate->NewParams.Level));
473c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->Gain=(LVM_INT16)((pPrivate->Gain*Index)>>15);
474c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->GainMixer.Target = pPrivate->Gain*Index;
475c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
476c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
477c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
478c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /*
479c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     * Update the all pass comb filter coefficient
480c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     */
481c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    if( (pPrivate->NewParams.Density != pPrivate->CurrentParams.Density) ||
482c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        (pPrivate->bFirstControl     == LVM_TRUE))
483c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
484c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT16   i;
485c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32   b = pPrivate->NewParams.Density * LVREV_B_8_on_1000;
486c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
487c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        for (i=0;i<4; i++)
488c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
489c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->Mixer_SGFeedback[i].Target    = b;
490c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->Mixer_SGFeedforward[i].Target = b;
491c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
492c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
493c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
494c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
495c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /*
496c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     * Update the bypass mixer time constant
497c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     */
498c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    if((pPrivate->NewParams.SampleRate   != pPrivate->CurrentParams.SampleRate)   ||
499c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent       (pPrivate->bFirstControl          == LVM_TRUE))
500c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
501c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_UINT16   NumChannels = 1;                       /* Assume MONO format */
502c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        LVM_INT32    Alpha;
503c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
504c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        Alpha = (LVM_INT32)LVM_Mixer_TimeConstant(LVREV_FEEDBACKMIXER_TC, LVM_GetFsFromTable(pPrivate->NewParams.SampleRate), NumChannels);
505c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->FeedbackMixer[0].Alpha=Alpha;
506c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->FeedbackMixer[1].Alpha=Alpha;
507c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->FeedbackMixer[2].Alpha=Alpha;
508c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->FeedbackMixer[3].Alpha=Alpha;
509c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
5105185b0138aaeffeecc93b958cb9cd9821f260fafEric Laurent        NumChannels = 2;                                    /* Always stereo output */
511c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->BypassMixer.Alpha1 = (LVM_INT32)LVM_Mixer_TimeConstant(LVREV_BYPASSMIXER_TC, LVM_GetFsFromTable(pPrivate->NewParams.SampleRate), NumChannels);
512c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->BypassMixer.Alpha2 = pPrivate->BypassMixer.Alpha1;
513c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->GainMixer.Alpha    = pPrivate->BypassMixer.Alpha1;
514c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
515c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
516c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
517c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /*
518c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     * Update the bypass mixer targets
519c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     */
520c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    if( (pPrivate->NewParams.Level != pPrivate->CurrentParams.Level) &&
521c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        (pPrivate->NewParams.OperatingMode == LVM_MODE_ON))
522c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
523c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->BypassMixer.Target2 = ((LVM_INT32)(pPrivate->NewParams.Level * 32767)/100)<<16;
5242d3bf535004f7310fe04a4b5f46b6747cdb3c93fEric Laurent        pPrivate->BypassMixer.Target1 = 0x00000000;
525c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        if ((pPrivate->NewParams.Level == 0) && (pPrivate->bFirstControl == LVM_FALSE))
526c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
527c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->BypassMixer.CallbackSet2 = LVM_TRUE;
528c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
529c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        if (pPrivate->NewParams.Level != 0)
530c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
531c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->bDisableReverb = LVM_FALSE;
532c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
533c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
534c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
535c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    if(pPrivate->NewParams.OperatingMode != pPrivate->CurrentParams.OperatingMode)
536c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
537c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        if(pPrivate->NewParams.OperatingMode == LVM_MODE_ON)
538c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
539c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->BypassMixer.Target2 = ((LVM_INT32)(pPrivate->NewParams.Level * 32767)/100)<<16;
5402d3bf535004f7310fe04a4b5f46b6747cdb3c93fEric Laurent            pPrivate->BypassMixer.Target1 = 0x00000000;
541c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
542c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->BypassMixer.CallbackSet2 = LVM_FALSE;
543c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            OperatingMode                      = LVM_MODE_ON;
544c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            if (pPrivate->NewParams.Level == 0)
545c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
546c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                pPrivate->bDisableReverb = LVM_TRUE;
547c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
548c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            else
549c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            {
550c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                pPrivate->bDisableReverb = LVM_FALSE;
551c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            }
552c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
553c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        else if (pPrivate->bFirstControl == LVM_FALSE)
554c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
555c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->BypassMixer.Target2 = 0x00000000;
5562d3bf535004f7310fe04a4b5f46b6747cdb3c93fEric Laurent            pPrivate->BypassMixer.Target1 = 0x00000000;
557c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->BypassMixer.CallbackSet2 = LVM_TRUE;
558c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            pPrivate->GainMixer.Target    = 0x03FFFFFF;
559c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            OperatingMode = LVM_MODE_ON;
560c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
561c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        else
562c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        {
563c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent            OperatingMode = LVM_MODE_OFF;
564c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        }
565c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
566c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
567c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
568c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /*
569c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     * If it is the first call to ApplyNew settings force the current to the target to begin immediate playback of the effect
570c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     */
571c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    if(pPrivate->bFirstControl == LVM_TRUE)
572c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
573c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->BypassMixer.Current1 = pPrivate->BypassMixer.Target1;
574c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->BypassMixer.Current2 = pPrivate->BypassMixer.Target2;
575c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
576c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
577c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
578c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /*
579c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     * Copy the new parameters
580c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     */
581c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    pPrivate->CurrentParams = pPrivate->NewParams;
582c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    pPrivate->CurrentParams.OperatingMode = OperatingMode;
583c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
584c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
585c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /*
586c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     * Update flag
587c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent     */
588c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    if(pPrivate->bFirstControl == LVM_TRUE)
589c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    {
590c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent        pPrivate->bFirstControl = LVM_FALSE;
591c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    }
592c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
593c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
594c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    return LVREV_SUCCESS;
595c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent}
596c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
597c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
598c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/****************************************************************************************/
599c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
600c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/* FUNCTION:                BypassMixer_Callback                                        */
601c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
602c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/* DESCRIPTION:                                                                         */
603c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*  Controls the On to Off operating mode transition                                    */
604c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
605c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/* PARAMETERS:                                                                          */
606c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*  pPrivate                Pointer to the instance private parameters                  */
607c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
608c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/* RETURNS:                                                                             */
609c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*  LVREV_Success           Succeeded                                                   */
610c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*  LVREV_NULLADDRESS       When pPrivate is NULL                                       */
611c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
612c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/* NOTES:                                                                               */
613c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
614c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/****************************************************************************************/
615c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric LaurentLVM_INT32 BypassMixer_Callback (void *pCallbackData,
616c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                                void *pGeneralPurpose,
617c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                                LVM_INT16 GeneralPurpose )
618c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent{
619c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
620c59c6fd7f859b4010d788db89b8d4d76bbb70e57