Merge commit '33e0d8343174339cc9622d63c23d47c0ba0d3baa' * commit '33e0d8343174339cc9622d63c23d47c0ba0d3baa': LVM release 1.05 delivery
This commit is contained in:
@@ -122,3 +122,58 @@ LOCAL_C_INCLUDES += \
|
||||
$(LOCAL_PATH)/StereoWidening/lib
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
# Reverb library
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_ARM_MODE := arm
|
||||
|
||||
LOCAL_SRC_FILES:= \
|
||||
Reverb/src/LVREV_ApplyNewSettings.c \
|
||||
Reverb/src/LVREV_ClearAudioBuffers.c \
|
||||
Reverb/src/LVREV_GetControlParameters.c \
|
||||
Reverb/src/LVREV_GetInstanceHandle.c \
|
||||
Reverb/src/LVREV_GetMemoryTable.c \
|
||||
Reverb/src/LVREV_Process.c \
|
||||
Reverb/src/LVREV_SetControlParameters.c \
|
||||
Reverb/src/LVREV_Tables.c \
|
||||
Common/src/Abs_32.c \
|
||||
Common/src/InstAlloc.c \
|
||||
Common/src/LoadConst_16.c \
|
||||
Common/src/LoadConst_32.c \
|
||||
Common/src/From2iToMono_32.c \
|
||||
Common/src/Mult3s_32x16.c \
|
||||
Common/src/FO_1I_D32F32C31_TRC_WRA_01.c \
|
||||
Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Init.c \
|
||||
Common/src/DelayAllPass_Sat_32x16To32.c \
|
||||
Common/src/Copy_16.c \
|
||||
Common/src/Mac3s_Sat_32x16.c \
|
||||
Common/src/DelayWrite_32.c \
|
||||
Common/src/Shift_Sat_v32xv32.c \
|
||||
Common/src/Add2_Sat_32x32.c \
|
||||
Common/src/JoinTo2i_32x32.c \
|
||||
Common/src/MonoTo2I_32.c \
|
||||
Common/src/LVM_FO_HPF.c \
|
||||
Common/src/LVM_FO_LPF.c \
|
||||
Common/src/LVM_Polynomial.c \
|
||||
Common/src/LVM_Power10.c \
|
||||
Common/src/LVM_GetOmega.c \
|
||||
Common/src/MixSoft_2St_D32C31_SAT.c \
|
||||
Common/src/MixSoft_1St_D32C31_WRA.c \
|
||||
Common/src/MixInSoft_D32C31_SAT.c \
|
||||
Common/src/LVM_Mixer_TimeConstant.c \
|
||||
Common/src/Core_MixHard_2St_D32C31_SAT.c \
|
||||
Common/src/Core_MixSoft_1St_D32C31_WRA.c \
|
||||
Common/src/Core_MixInSoft_D32C31_SAT.c
|
||||
|
||||
LOCAL_MODULE:= libreverb
|
||||
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(LOCAL_PATH)/Reverb/lib \
|
||||
$(LOCAL_PATH)/Reverb/src \
|
||||
$(LOCAL_PATH)/Common/lib \
|
||||
$(LOCAL_PATH)/Common/src
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
/****************************************************************************************
|
||||
|
||||
$Author: nxp007753 $
|
||||
$Revision: 1315 $
|
||||
$Date: 2010-07-23 11:52:08 +0200 (Fri, 23 Jul 2010) $
|
||||
$Author: beq06068 $
|
||||
$Revision: 1401 $
|
||||
$Date: 2010-08-03 09:52:22 +0200 (Tue, 03 Aug 2010) $
|
||||
|
||||
*****************************************************************************************/
|
||||
|
||||
@@ -128,7 +128,7 @@ void LVDBE_SetFilters(LVDBE_Instance_t *pInstance,
|
||||
(void *)&pInstance->pData->HPFTaps, /* Destination Cast to void: \
|
||||
no dereferencing in function*/
|
||||
sizeof(pInstance->pData->HPFTaps)/sizeof(LVM_INT16)); /* Number of words */
|
||||
BQ_2I_D32F32Cll_TRC_WRA_01_Init(&pInstance->pCoef->HPFInstance, /* Initialise the filter */
|
||||
BQ_2I_D32F32Cll_TRC_WRA_01_Init(&pInstance->pCoef->HPFInstance, /* Initialise the filter */
|
||||
&pInstance->pData->HPFTaps,
|
||||
(BQ_C32_Coefs_t *)&LVDBE_HPF_Table[Offset]);
|
||||
|
||||
@@ -140,7 +140,7 @@ void LVDBE_SetFilters(LVDBE_Instance_t *pInstance,
|
||||
(void *)&pInstance->pData->BPFTaps, /* Destination Cast to void:\
|
||||
no dereferencing in function*/
|
||||
sizeof(pInstance->pData->BPFTaps)/sizeof(LVM_INT16)); /* Number of words */
|
||||
BP_1I_D32F32Cll_TRC_WRA_02_Init(&pInstance->pCoef->BPFInstance, /* Initialise the filter */
|
||||
BP_1I_D32F32Cll_TRC_WRA_02_Init(&pInstance->pCoef->BPFInstance, /* Initialise the filter */
|
||||
&pInstance->pData->BPFTaps,
|
||||
(BP_C32_Coefs_t *)&LVDBE_BPF_Table[Offset]);
|
||||
|
||||
@@ -317,6 +317,7 @@ LVDBE_ReturnStatus_en LVDBE_Control(LVDBE_Handle_t hInstance,
|
||||
{
|
||||
|
||||
LVDBE_Instance_t *pInstance =(LVDBE_Instance_t *)hInstance;
|
||||
LVMixer3_2St_st *pBypassMixer_Instance = &pInstance->pData->BypassMixer;
|
||||
|
||||
|
||||
/*
|
||||
@@ -339,6 +340,14 @@ LVDBE_ReturnStatus_en LVDBE_Control(LVDBE_Handle_t hInstance,
|
||||
{
|
||||
LVDBE_SetAGC(pInstance, /* Instance pointer */
|
||||
pParams); /* New parameters */
|
||||
|
||||
LVC_Mixer_SetTimeConstant(&pBypassMixer_Instance->MixerStream[0],
|
||||
LVDBE_BYPASS_MIXER_TC,pParams->SampleRate,2);
|
||||
|
||||
LVC_Mixer_SetTimeConstant(&pBypassMixer_Instance->MixerStream[1],
|
||||
LVDBE_BYPASS_MIXER_TC,pParams->SampleRate,2);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -356,17 +365,13 @@ LVDBE_ReturnStatus_en LVDBE_Control(LVDBE_Handle_t hInstance,
|
||||
|
||||
if (pInstance->Params.OperatingMode==LVDBE_ON && pParams->OperatingMode==LVDBE_OFF)
|
||||
{
|
||||
LVDBE_Params_t Params = *pParams; /* make local copy of params */
|
||||
Params.EffectLevel = 0; /* zero effect level before switching off module*/
|
||||
pInstance->bTransitionOnToOff = LVM_TRUE; /* Set the CallBack */
|
||||
LVDBE_SetAGC(pInstance, /* Instance pointer */
|
||||
&Params); /* New parameters */
|
||||
LVC_Mixer_SetTarget(&pInstance->pData->BypassMixer.MixerStream[0],0);
|
||||
LVC_Mixer_SetTarget(&pInstance->pData->BypassMixer.MixerStream[1],0x00007FFF);
|
||||
}
|
||||
if (pInstance->Params.OperatingMode==LVDBE_OFF && pParams->OperatingMode==LVDBE_ON)
|
||||
{
|
||||
pInstance->bTransitionOnToOff = LVM_FALSE; /* Set the CallBack */
|
||||
LVDBE_SetAGC(pInstance, /* Instance pointer */
|
||||
pParams); /* New parameters */
|
||||
LVC_Mixer_SetTarget(&pInstance->pData->BypassMixer.MixerStream[0],0x00007FFF);
|
||||
LVC_Mixer_SetTarget(&pInstance->pData->BypassMixer.MixerStream[1],0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
/****************************************************************************************
|
||||
|
||||
$Author: nxp007753 $
|
||||
$Revision: 1081 $
|
||||
$Date: 2010-07-05 11:48:44 +0200 (Mon, 05 Jul 2010) $
|
||||
$Author: beq06068 $
|
||||
$Revision: 1399 $
|
||||
$Date: 2010-08-03 08:16:00 +0200 (Tue, 03 Aug 2010) $
|
||||
|
||||
*****************************************************************************************/
|
||||
|
||||
@@ -160,6 +160,7 @@ LVDBE_ReturnStatus_en LVDBE_Init(LVDBE_Handle_t *phInstance,
|
||||
|
||||
LVDBE_Instance_t *pInstance;
|
||||
LVMixer3_1St_st *pMixer_Instance;
|
||||
LVMixer3_2St_st *pBypassMixer_Instance;
|
||||
LVM_INT16 i;
|
||||
LVM_INT32 MixGain;
|
||||
|
||||
@@ -227,7 +228,7 @@ LVDBE_ReturnStatus_en LVDBE_Init(LVDBE_Handle_t *phInstance,
|
||||
/*
|
||||
* Initialise the filters
|
||||
*/
|
||||
LVDBE_SetFilters(pInstance, /* Set the filter taps and coefficients */
|
||||
LVDBE_SetFilters(pInstance, /* Set the filter taps and coefficients */
|
||||
&pInstance->Params);
|
||||
|
||||
|
||||
@@ -236,7 +237,8 @@ LVDBE_ReturnStatus_en LVDBE_Init(LVDBE_Handle_t *phInstance,
|
||||
*/
|
||||
LVDBE_SetAGC(pInstance, /* Set the AGC gain */
|
||||
&pInstance->Params);
|
||||
pInstance->pData->AGCInstance.AGC_Gain = pInstance->pData->AGCInstance.AGC_MaxGain; /* Default to the bass boost setting */
|
||||
pInstance->pData->AGCInstance.AGC_Gain = pInstance->pData->AGCInstance.AGC_MaxGain;
|
||||
/* Default to the bass boost setting */
|
||||
|
||||
|
||||
/*
|
||||
@@ -245,7 +247,8 @@ LVDBE_ReturnStatus_en LVDBE_Init(LVDBE_Handle_t *phInstance,
|
||||
LVDBE_SetVolume(pInstance, /* Set the Volume */
|
||||
&pInstance->Params);
|
||||
|
||||
pInstance->pData->AGCInstance.Volume = pInstance->pData->AGCInstance.Target; /* Initialise as the target */
|
||||
pInstance->pData->AGCInstance.Volume = pInstance->pData->AGCInstance.Target;
|
||||
/* Initialise as the target */
|
||||
|
||||
pMixer_Instance = &pInstance->pData->BypassVolume;
|
||||
MixGain = LVC_Mixer_GetTarget(&pMixer_Instance->MixerStream[0]);
|
||||
@@ -258,9 +261,31 @@ LVDBE_ReturnStatus_en LVDBE_Init(LVDBE_Handle_t *phInstance,
|
||||
pMixer_Instance->MixerStream[0].CallbackSet = 0;
|
||||
|
||||
/*
|
||||
* Initialise the clicks minimisation variable
|
||||
* Initialise the clicks minimisation BypassMixer
|
||||
*/
|
||||
pInstance->bTransitionOnToOff = LVM_FALSE;
|
||||
|
||||
pBypassMixer_Instance = &pInstance->pData->BypassMixer;
|
||||
|
||||
/*
|
||||
* Setup the mixer gain for the processed path
|
||||
*/
|
||||
pBypassMixer_Instance->MixerStream[0].CallbackParam = 0;
|
||||
pBypassMixer_Instance->MixerStream[0].pCallbackHandle = LVM_NULL;
|
||||
pBypassMixer_Instance->MixerStream[0].pCallBack = LVM_NULL;
|
||||
pBypassMixer_Instance->MixerStream[0].CallbackSet=0;
|
||||
LVC_Mixer_Init(&pBypassMixer_Instance->MixerStream[0],0,0);
|
||||
LVC_Mixer_SetTimeConstant(&pBypassMixer_Instance->MixerStream[0],
|
||||
LVDBE_BYPASS_MIXER_TC,pInstance->Params.SampleRate,2);
|
||||
/*
|
||||
* Setup the mixer gain for the unprocessed path
|
||||
*/
|
||||
pBypassMixer_Instance->MixerStream[1].CallbackParam = 0;
|
||||
pBypassMixer_Instance->MixerStream[1].pCallbackHandle = LVM_NULL;
|
||||
pBypassMixer_Instance->MixerStream[1].pCallBack = LVM_NULL;
|
||||
pBypassMixer_Instance->MixerStream[1].CallbackSet=0;
|
||||
LVC_Mixer_Init(&pBypassMixer_Instance->MixerStream[1],0x00007FFF,0x00007FFF);
|
||||
LVC_Mixer_SetTimeConstant(&pBypassMixer_Instance->MixerStream[1],
|
||||
LVDBE_BYPASS_MIXER_TC,pInstance->Params.SampleRate,2);
|
||||
|
||||
return(LVDBE_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
/****************************************************************************************
|
||||
|
||||
$Author: nxp007753 $
|
||||
$Revision: 1081 $
|
||||
$Date: 2010-07-05 11:48:44 +0200 (Mon, 05 Jul 2010) $
|
||||
$Author: beq06068 $
|
||||
$Revision: 1399 $
|
||||
$Date: 2010-08-03 08:16:00 +0200 (Tue, 03 Aug 2010) $
|
||||
|
||||
*****************************************************************************************/
|
||||
|
||||
@@ -75,6 +75,8 @@ extern "C" {
|
||||
#define LVDBE_SCRATCHBUFFERS_INPLACE 4 /* Number of buffers required for inplace processing */
|
||||
|
||||
#define LVDBE_MIXER_TC 5 /* Mixer time */
|
||||
#define LVDBE_BYPASS_MIXER_TC 100 /* Bypass mixer time */
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
@@ -92,6 +94,7 @@ typedef struct
|
||||
Biquad_2I_Order2_Taps_t HPFTaps; /* High pass filter taps */
|
||||
Biquad_1I_Order2_Taps_t BPFTaps; /* Band pass filter taps */
|
||||
LVMixer3_1St_st BypassVolume; /* Bypass volume scaler */
|
||||
LVMixer3_2St_st BypassMixer; /* Bypass Mixer for Click Removal */
|
||||
|
||||
} LVDBE_Data_t;
|
||||
|
||||
@@ -115,9 +118,6 @@ typedef struct
|
||||
/* Data and coefficient pointers */
|
||||
LVDBE_Data_t *pData; /* Instance data */
|
||||
LVDBE_Coef_t *pCoef; /* Instance coefficients */
|
||||
|
||||
LVM_INT32 bTransitionOnToOff;
|
||||
|
||||
} LVDBE_Instance_t;
|
||||
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
/****************************************************************************************
|
||||
|
||||
$Author: nxp007753 $
|
||||
$Revision: 1081 $
|
||||
$Date: 2010-07-05 11:48:44 +0200 (Mon, 05 Jul 2010) $
|
||||
$Author: beq06068 $
|
||||
$Revision: 1400 $
|
||||
$Date: 2010-08-03 09:22:37 +0200 (Tue, 03 Aug 2010) $
|
||||
|
||||
*****************************************************************************************/
|
||||
|
||||
@@ -89,10 +89,16 @@ LVDBE_ReturnStatus_en LVDBE_Process(LVDBE_Handle_t hInstance,
|
||||
|
||||
LVDBE_Instance_t *pInstance =(LVDBE_Instance_t *)hInstance;
|
||||
LVM_INT32 *pScratch = (LVM_INT32 *)pInstance->MemoryTable.Region[LVDBE_MEMREGION_SCRATCH].pBaseAddress;
|
||||
LVM_INT32 *pMono = (LVM_INT32 *)pOutData;
|
||||
LVM_INT32 *pMono;
|
||||
LVM_INT16 *pInput = (LVM_INT16 *)pInData;
|
||||
|
||||
|
||||
/* Scratch for Volume Control starts at offset of 2*NumSamples short values from pScratch */
|
||||
LVM_INT16 *pScratchVol = (LVM_INT16 *)(&pScratch[NumSamples]);
|
||||
|
||||
/* Scratch for Mono path starts at offset of 2*NumSamples 32-bit values from pScratch */
|
||||
pMono = &pScratch[2*NumSamples];
|
||||
|
||||
/*
|
||||
* Check the number of samples is not too large
|
||||
*/
|
||||
@@ -104,18 +110,20 @@ LVDBE_ReturnStatus_en LVDBE_Process(LVDBE_Handle_t hInstance,
|
||||
/*
|
||||
* Check if the algorithm is enabled
|
||||
*/
|
||||
if ((pInstance->Params.OperatingMode != LVDBE_OFF) ||
|
||||
(pInstance->bTransitionOnToOff == LVM_TRUE))
|
||||
/* DBE path is processed when DBE is ON or during On/Off transitions */
|
||||
if ((pInstance->Params.OperatingMode == LVDBE_ON)||
|
||||
(LVC_Mixer_GetCurrent(&pInstance->pData->BypassMixer.MixerStream[0])
|
||||
!=LVC_Mixer_GetTarget(&pInstance->pData->BypassMixer.MixerStream[0])))
|
||||
{
|
||||
|
||||
/*
|
||||
* Convert 16-bit samples to 32-bit and scale
|
||||
* (For a 16-bit implementation apply headroom loss here)
|
||||
*/
|
||||
Int16LShiftToInt32_16x32(pInput, /* Source 16-bit data */
|
||||
pScratch, /* Destination 32-bit data */
|
||||
(LVM_INT16)(2*NumSamples), /* Left and right */
|
||||
LVDBE_SCALESHIFT); /* Shift scale */
|
||||
Int16LShiftToInt32_16x32(pInput, /* Source 16-bit data */
|
||||
pScratch, /* Dest. 32-bit data */
|
||||
(LVM_INT16)(2*NumSamples), /* Left and right */
|
||||
LVDBE_SCALESHIFT); /* Shift scale */
|
||||
|
||||
|
||||
/*
|
||||
@@ -123,61 +131,54 @@ LVDBE_ReturnStatus_en LVDBE_Process(LVDBE_Handle_t hInstance,
|
||||
*/
|
||||
if (pInstance->Params.HPFSelect == LVDBE_HPF_ON)
|
||||
{
|
||||
BQ_2I_D32F32C30_TRC_WRA_01(&pInstance->pCoef->HPFInstance, /* Filter instance */
|
||||
(LVM_INT32 *)pScratch, /* Source */
|
||||
(LVM_INT32 *)pScratch, /* Destination */
|
||||
(LVM_INT16)NumSamples); /* Number of samples */
|
||||
BQ_2I_D32F32C30_TRC_WRA_01(&pInstance->pCoef->HPFInstance,/* Filter instance */
|
||||
(LVM_INT32 *)pScratch, /* Source */
|
||||
(LVM_INT32 *)pScratch, /* Destination */
|
||||
(LVM_INT16)NumSamples); /* Number of samples */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create the mono stream
|
||||
*/
|
||||
From2iToMono_32(pScratch, /* Stereo source */
|
||||
pMono, /* Mono destination */
|
||||
(LVM_INT16)NumSamples); /* Number of samples */
|
||||
From2iToMono_32(pScratch, /* Stereo source */
|
||||
pMono, /* Mono destination */
|
||||
(LVM_INT16)NumSamples); /* Number of samples */
|
||||
|
||||
|
||||
/*
|
||||
* Apply the band pass filter
|
||||
*/
|
||||
BP_1I_D32F32C30_TRC_WRA_02(&pInstance->pCoef->BPFInstance, /* Filter instance */
|
||||
(LVM_INT32 *)pMono, /* Source */
|
||||
(LVM_INT32 *)pMono, /* Destination */
|
||||
(LVM_INT16)NumSamples); /* Number of samples */
|
||||
BP_1I_D32F32C30_TRC_WRA_02(&pInstance->pCoef->BPFInstance, /* Filter instance */
|
||||
(LVM_INT32 *)pMono, /* Source */
|
||||
(LVM_INT32 *)pMono, /* Destination */
|
||||
(LVM_INT16)NumSamples); /* Number of samples */
|
||||
|
||||
|
||||
/*
|
||||
* Apply the AGC and mix
|
||||
*/
|
||||
AGC_MIX_VOL_2St1Mon_D32_WRA(&pInstance->pData->AGCInstance, /* Instance pointer */
|
||||
pScratch, /* Stereo source */
|
||||
pMono, /* Mono band pass source */
|
||||
pScratch, /* Stereo destination */
|
||||
NumSamples); /* Number of samples */
|
||||
|
||||
if(pInstance->bTransitionOnToOff == LVM_TRUE)
|
||||
{
|
||||
if ((pInstance->pData->AGCInstance.AGC_Gain == pInstance->pData->AGCInstance.AGC_Target)&&
|
||||
(pInstance->pData->AGCInstance.AGC_Gain == 0))
|
||||
{
|
||||
pInstance->bTransitionOnToOff = LVM_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AGC_MIX_VOL_2St1Mon_D32_WRA(&pInstance->pData->AGCInstance, /* Instance pointer */
|
||||
pScratch, /* Stereo source */
|
||||
pMono, /* Mono band pass source */
|
||||
pScratch, /* Stereo destination */
|
||||
NumSamples); /* Number of samples */
|
||||
|
||||
/*
|
||||
* Convert 32-bit samples to 16-bit and saturate
|
||||
* (Not required for 16-bit implemenations)
|
||||
*/
|
||||
Int32RShiftToInt16_Sat_32x16(pScratch, /* Source 32-bit data */
|
||||
pOutData, /* Destination 16-bit data */
|
||||
(LVM_INT16)(2*NumSamples), /* Left and right */
|
||||
LVDBE_SCALESHIFT); /* Shift scale */
|
||||
Int32RShiftToInt16_Sat_32x16(pScratch, /* Source 32-bit data */
|
||||
(LVM_INT16 *)pScratch, /* Dest. 16-bit data */
|
||||
(LVM_INT16)(2*NumSamples), /* Left and right */
|
||||
LVDBE_SCALESHIFT); /* Shift scale */
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
/* Bypass Volume path is processed when DBE is OFF or during On/Off transitions */
|
||||
if ((pInstance->Params.OperatingMode == LVDBE_OFF)||
|
||||
(LVC_Mixer_GetCurrent(&pInstance->pData->BypassMixer.MixerStream[1])
|
||||
!=LVC_Mixer_GetTarget(&pInstance->pData->BypassMixer.MixerStream[1])))
|
||||
{
|
||||
|
||||
/*
|
||||
@@ -186,11 +187,20 @@ LVDBE_ReturnStatus_en LVDBE_Process(LVDBE_Handle_t hInstance,
|
||||
*/
|
||||
LVC_MixSoft_1St_D16C31_SAT(&pInstance->pData->BypassVolume,
|
||||
pInData,
|
||||
pOutData,
|
||||
(LVM_INT16)(2*NumSamples)); /* Left and right */
|
||||
pScratchVol,
|
||||
(LVM_INT16)(2*NumSamples)); /* Left and right */
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Mix DBE processed path and bypass volume path
|
||||
*/
|
||||
LVC_MixSoft_2St_D16C31_SAT(&pInstance->pData->BypassMixer,
|
||||
(LVM_INT16 *) pScratch,
|
||||
pScratchVol,
|
||||
pOutData,
|
||||
(LVM_INT16)(2*NumSamples));
|
||||
|
||||
return(LVDBE_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
/****************************************************************************************
|
||||
|
||||
$Author: nxp007753 $
|
||||
$Revision: 1316 $
|
||||
$Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $
|
||||
$Revision: 1331 $
|
||||
$Date: 2010-07-27 12:26:23 +0200 (Tue, 27 Jul 2010) $
|
||||
|
||||
*****************************************************************************************/
|
||||
|
||||
|
||||
321
media/libeffects/lvm/lib/Reverb/lib/LVREV.h
Executable file
321
media/libeffects/lvm/lib/Reverb/lib/LVREV.h
Executable file
@@ -0,0 +1,321 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2010 NXP Software
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/* Project:: */
|
||||
/* $Author: beq03888 $*/
|
||||
/* $Revision: 1204 $*/
|
||||
/* $Date: 2010-07-14 08:55:43 +0200 (Wed, 14 Jul 2010) $*/
|
||||
/* */
|
||||
/************************************************************************/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Header file for the application layer interface of the LVREV module */
|
||||
/* */
|
||||
/* This files includes all definitions, types, structures and function prototypes */
|
||||
/* required by the calling layer. All other types, structures and functions are */
|
||||
/* private. */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
#ifndef __LVREV_H__
|
||||
#define __LVREV_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Includes */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
#include "LVM_Types.h"
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Definitions */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
/* General */
|
||||
#define LVREV_BLOCKSIZE_MULTIPLE 1 /* Processing block size multiple */
|
||||
#define LVREV_MAX_T60 7000 /* Maximum decay time is 7000ms */
|
||||
|
||||
/* Memory table*/
|
||||
#define LVREV_NR_MEMORY_REGIONS 4 /* Number of memory regions */
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Types */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
/* Instance handle */
|
||||
typedef void *LVREV_Handle_t;
|
||||
|
||||
|
||||
/* Status return values */
|
||||
typedef enum
|
||||
{
|
||||
LVREV_SUCCESS = 0, /* Successful return from a routine */
|
||||
LVREV_NULLADDRESS = 1, /* NULL allocation address */
|
||||
LVREV_OUTOFRANGE = 2, /* Out of range control parameter */
|
||||
LVREV_INVALIDNUMSAMPLES = 3, /* Invalid number of samples */
|
||||
LVREV_RETURNSTATUS_DUMMY = LVM_MAXENUM
|
||||
} LVREV_ReturnStatus_en;
|
||||
|
||||
|
||||
/* Reverb delay lines */
|
||||
typedef enum
|
||||
{
|
||||
LVREV_DELAYLINES_1 = 1, /* One delay line */
|
||||
LVREV_DELAYLINES_2 = 2, /* Two delay lines */
|
||||
LVREV_DELAYLINES_4 = 4, /* Four delay lines */
|
||||
LVREV_DELAYLINES_DUMMY = LVM_MAXENUM
|
||||
} LVREV_NumDelayLines_en;
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Structures */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
/* Memory table containing the region definitions */
|
||||
typedef struct
|
||||
{
|
||||
LVM_MemoryRegion_st Region[LVREV_NR_MEMORY_REGIONS]; /* One definition for each region */
|
||||
} LVREV_MemoryTable_st;
|
||||
|
||||
|
||||
/* Control Parameter structure */
|
||||
typedef struct
|
||||
{
|
||||
/* General parameters */
|
||||
LVM_Mode_en OperatingMode; /* Operating mode */
|
||||
LVM_Fs_en SampleRate; /* Sample rate */
|
||||
LVM_Format_en SourceFormat; /* Source data format */
|
||||
|
||||
/* Parameters for REV */
|
||||
LVM_UINT16 Level; /* Level, 0 to 100 representing percentage of reverb */
|
||||
LVM_UINT16 LPF; /* Low pass filter, in Hz */
|
||||
LVM_UINT16 HPF; /* High pass filter, in Hz */
|
||||
LVM_UINT16 T60; /* Decay time constant, in ms */
|
||||
LVM_UINT16 Density; /* Echo density, 0 to 100 for minimum to maximum density */
|
||||
LVM_UINT16 Damping; /* Damping */
|
||||
LVM_UINT16 RoomSize; /* Simulated room size, 1 to 100 for minimum to maximum size */
|
||||
|
||||
} LVREV_ControlParams_st;
|
||||
|
||||
|
||||
/* Instance Parameter structure */
|
||||
typedef struct
|
||||
{
|
||||
/* General */
|
||||
LVM_UINT16 MaxBlockSize; /* Maximum processing block size */
|
||||
|
||||
/* Reverb */
|
||||
LVM_Format_en SourceFormat; /* Source data formats to support */
|
||||
LVREV_NumDelayLines_en NumDelays; /* The number of delay lines, 1, 2 or 4 */
|
||||
|
||||
} LVREV_InstanceParams_st;
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Function Prototypes */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION: LVREV_GetMemoryTable */
|
||||
/* */
|
||||
/* DESCRIPTION: */
|
||||
/* This function is used to obtain the LVREV module memory requirements to support */
|
||||
/* memory allocation. It can also be used to return the memory base address provided */
|
||||
/* during memory allocation to support freeing of memory when the LVREV module is no */
|
||||
/* longer required. It is called in two ways: */
|
||||
/* */
|
||||
/* hInstance = NULL Returns the memory requirements */
|
||||
/* hInstance = Instance handle Returns the memory requirements and allocated */
|
||||
/* base addresses. */
|
||||
/* */
|
||||
/* When this function is called with hInstance = NULL the memory base address pointers */
|
||||
/* will be NULL on return. */
|
||||
/* */
|
||||
/* When the function is called for freeing memory, hInstance = Instance Handle the */
|
||||
/* memory table returns the allocated memory and base addresses used during */
|
||||
/* initialisation. */
|
||||
/* */
|
||||
/* PARAMETERS: */
|
||||
/* hInstance Instance Handle */
|
||||
/* pMemoryTable Pointer to an empty memory table */
|
||||
/* pInstanceParams Pointer to the instance parameters */
|
||||
/* */
|
||||
/* RETURNS: */
|
||||
/* LVREV_SUCCESS Succeeded */
|
||||
/* LVREV_NULLADDRESS When pMemoryTable is NULL */
|
||||
/* LVREV_NULLADDRESS When requesting memory requirements and pInstanceParams */
|
||||
/* is NULL */
|
||||
/* */
|
||||
/* NOTES: */
|
||||
/* 1. This function may be interrupted by the LVREV_Process function */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
LVREV_ReturnStatus_en LVREV_GetMemoryTable(LVREV_Handle_t hInstance,
|
||||
LVREV_MemoryTable_st *pMemoryTable,
|
||||
LVREV_InstanceParams_st *pInstanceParams);
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION: LVREV_GetInstanceHandle */
|
||||
/* */
|
||||
/* DESCRIPTION: */
|
||||
/* This function is used to create a LVREV module instance. It returns the created */
|
||||
/* instance handle through phInstance. All parameters are set to invalid values, the */
|
||||
/* LVREV_SetControlParameters function must be called with a set of valid control */
|
||||
/* parameters before the LVREV_Process function can be called. */
|
||||
/* */
|
||||
/* The memory allocation must be provided by the application by filling in the memory */
|
||||
/* region base addresses in the memory table before calling this function. */
|
||||
/* */
|
||||
/* PARAMETERS: */
|
||||
/* phInstance Pointer to the instance handle */
|
||||
/* pMemoryTable Pointer to the memory definition table */
|
||||
/* pInstanceParams Pointer to the instance parameters */
|
||||
/* */
|
||||
/* RETURNS: */
|
||||
/* LVREV_SUCCESS Succeeded */
|
||||
/* LVREV_NULLADDRESS When phInstance or pMemoryTable or pInstanceParams is NULL */
|
||||
/* LVREV_NULLADDRESS When one of the memory regions has a NULL pointer */
|
||||
/* */
|
||||
/* NOTES: */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
LVREV_ReturnStatus_en LVREV_GetInstanceHandle(LVREV_Handle_t *phInstance,
|
||||
LVREV_MemoryTable_st *pMemoryTable,
|
||||
LVREV_InstanceParams_st *pInstanceParams);
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION: LVXX_GetControlParameters */
|
||||
/* */
|
||||
/* DESCRIPTION: */
|
||||
/* Request the LVREV module control parameters. The current parameter set is returned */
|
||||
/* via the parameter pointer. */
|
||||
/* */
|
||||
/* PARAMETERS: */
|
||||
/* hInstance Instance handle */
|
||||
/* pControlParams Pointer to an empty parameter structure */
|
||||
/* */
|
||||
/* RETURNS: */
|
||||
/* LVREV_SUCCESS Succeeded */
|
||||
/* LVREV_NULLADDRESS When hInstance or pControlParams is NULL */
|
||||
/* */
|
||||
/* NOTES: */
|
||||
/* 1. This function may be interrupted by the LVREV_Process function */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
LVREV_ReturnStatus_en LVREV_GetControlParameters(LVREV_Handle_t hInstance,
|
||||
LVREV_ControlParams_st *pControlParams);
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION: LVREV_SetControlParameters */
|
||||
/* */
|
||||
/* DESCRIPTION: */
|
||||
/* Sets or changes the LVREV module parameters. */
|
||||
/* */
|
||||
/* PARAMETERS: */
|
||||
/* hInstance Instance handle */
|
||||
/* pNewParams Pointer to a parameter structure */
|
||||
/* */
|
||||
/* RETURNS: */
|
||||
/* LVREV_SUCCESS Succeeded */
|
||||
/* LVREV_NULLADDRESS When hInstance or pNewParams is NULL */
|
||||
/* */
|
||||
/* NOTES: */
|
||||
/* 1. This function may be interrupted by the LVREV_Process function */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
LVREV_ReturnStatus_en LVREV_SetControlParameters(LVREV_Handle_t hInstance,
|
||||
LVREV_ControlParams_st *pNewParams);
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION: LVREV_ClearAudioBuffers */
|
||||
/* */
|
||||
/* DESCRIPTION: */
|
||||
/* This function is used to clear the internal audio buffers of the module. */
|
||||
/* */
|
||||
/* PARAMETERS: */
|
||||
/* hInstance Instance handle */
|
||||
/* */
|
||||
/* RETURNS: */
|
||||
/* LVREV_SUCCESS Initialisation succeeded */
|
||||
/* LVREV_NULLADDRESS Instance is NULL */
|
||||
/* */
|
||||
/* NOTES: */
|
||||
/* 1. This function must not be interrupted by the LVREV_Process function */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
LVREV_ReturnStatus_en LVREV_ClearAudioBuffers(LVREV_Handle_t hInstance);
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION: LVREV_Process */
|
||||
/* */
|
||||
/* DESCRIPTION: */
|
||||
/* Process function for the LVREV module. */
|
||||
/* */
|
||||
/* PARAMETERS: */
|
||||
/* hInstance Instance handle */
|
||||
/* pInData Pointer to the input data */
|
||||
/* pOutData Pointer to the output data */
|
||||
/* NumSamples Number of samples in the input buffer */
|
||||
/* */
|
||||
/* RETURNS: */
|
||||
/* LVREV_SUCCESS Succeeded */
|
||||
/* LVREV_INVALIDNUMSAMPLES NumSamples was larger than the maximum block size */
|
||||
/* */
|
||||
/* NOTES: */
|
||||
/* 1. The input and output buffers must be 32-bit aligned */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
LVREV_ReturnStatus_en LVREV_Process(LVREV_Handle_t hInstance,
|
||||
const LVM_INT32 *pInData,
|
||||
LVM_INT32 *pOutData,
|
||||
const LVM_UINT16 NumSamples);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __LVREV_H__ */
|
||||
|
||||
/* End of file */
|
||||
656
media/libeffects/lvm/lib/Reverb/src/LVREV_ApplyNewSettings.c
Executable file
656
media/libeffects/lvm/lib/Reverb/src/LVREV_ApplyNewSettings.c
Executable file
@@ -0,0 +1,656 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2010 NXP Software
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Project:: */
|
||||
/* $Author: nxp007753 $ */
|
||||
/* $Revision: 1316 $ */
|
||||
/* $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $ */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Includes */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
#include "LVREV_Private.h"
|
||||
#include "Filter.h"
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION: LVREV_ApplyNewSettings */
|
||||
/* */
|
||||
/* DESCRIPTION: */
|
||||
/* Applies the new control parameters */
|
||||
/* */
|
||||
/* PARAMETERS: */
|
||||
/* pPrivate Pointer to the instance private parameters */
|
||||
/* */
|
||||
/* RETURNS: */
|
||||
/* LVREV_Success Succeeded */
|
||||
/* LVREV_NULLADDRESS When pPrivate is NULL */
|
||||
/* */
|
||||
/* NOTES: */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
LVREV_ReturnStatus_en LVREV_ApplyNewSettings (LVREV_Instance_st *pPrivate)
|
||||
{
|
||||
|
||||
LVM_Mode_en OperatingMode;
|
||||
LVM_INT32 NumberOfDelayLines;
|
||||
|
||||
|
||||
/* Check for NULL pointer */
|
||||
if(pPrivate == LVM_NULL)
|
||||
{
|
||||
return LVREV_NULLADDRESS;
|
||||
}
|
||||
|
||||
OperatingMode = pPrivate->NewParams.OperatingMode;
|
||||
|
||||
if(pPrivate->InstanceParams.NumDelays == LVREV_DELAYLINES_4)
|
||||
{
|
||||
NumberOfDelayLines = 4;
|
||||
}
|
||||
else if(pPrivate->InstanceParams.NumDelays == LVREV_DELAYLINES_2)
|
||||
{
|
||||
NumberOfDelayLines = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
NumberOfDelayLines = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the high pass filter coefficients
|
||||
*/
|
||||
if((pPrivate->NewParams.HPF != pPrivate->CurrentParams.HPF) ||
|
||||
(pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
|
||||
(pPrivate->bFirstControl == LVM_TRUE))
|
||||
{
|
||||
LVM_INT32 Omega;
|
||||
FO_C32_Coefs_t Coeffs;
|
||||
|
||||
Omega = LVM_GetOmega(pPrivate->NewParams.HPF, pPrivate->NewParams.SampleRate);
|
||||
LVM_FO_HPF(Omega, &Coeffs);
|
||||
FO_1I_D32F32Cll_TRC_WRA_01_Init( &pPrivate->pFastCoef->HPCoefs, &pPrivate->pFastData->HPTaps, &Coeffs);
|
||||
LoadConst_32(0,
|
||||
(void *)&pPrivate->pFastData->HPTaps, /* Destination Cast to void: no dereferencing in function*/
|
||||
sizeof(Biquad_1I_Order1_Taps_t)/sizeof(LVM_INT32));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Update the low pass filter coefficients
|
||||
*/
|
||||
if((pPrivate->NewParams.LPF != pPrivate->CurrentParams.LPF) ||
|
||||
(pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
|
||||
(pPrivate->bFirstControl == LVM_TRUE))
|
||||
{
|
||||
LVM_INT32 Omega;
|
||||
FO_C32_Coefs_t Coeffs;
|
||||
|
||||
|
||||
Coeffs.A0 = 0x7FFFFFFF;
|
||||
Coeffs.A1 = 0;
|
||||
Coeffs.B1 = 0;
|
||||
if(pPrivate->NewParams.LPF <= (LVM_FsTable[pPrivate->NewParams.SampleRate] >> 1))
|
||||
{
|
||||
Omega = LVM_GetOmega(pPrivate->NewParams.LPF, pPrivate->NewParams.SampleRate);
|
||||
|
||||
/*
|
||||
* Do not apply filter if w =2*pi*fc/fs >= 2.9
|
||||
*/
|
||||
if(Omega<=LVREV_2_9_INQ29)
|
||||
{
|
||||
LVM_FO_LPF(Omega, &Coeffs);
|
||||
}
|
||||
}
|
||||
FO_1I_D32F32Cll_TRC_WRA_01_Init( &pPrivate->pFastCoef->LPCoefs, &pPrivate->pFastData->LPTaps, &Coeffs);
|
||||
LoadConst_32(0,
|
||||
(void *)&pPrivate->pFastData->LPTaps, /* Destination Cast to void: no dereferencing in function*/
|
||||
sizeof(Biquad_1I_Order1_Taps_t)/sizeof(LVM_INT32));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Calculate the room size parameter
|
||||
*/
|
||||
if( pPrivate->NewParams.RoomSize != pPrivate->CurrentParams.RoomSize)
|
||||
{
|
||||
/* Room size range is 10ms to 200ms
|
||||
* 0% -- 10ms
|
||||
* 50% -- 65ms
|
||||
* 100% -- 120ms
|
||||
*/
|
||||
pPrivate->RoomSizeInms = 10 + (((pPrivate->NewParams.RoomSize*11) + 5)/10);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Update the T delay number of samples and the all pass delay number of samples
|
||||
*/
|
||||
if( (pPrivate->NewParams.RoomSize != pPrivate->CurrentParams.RoomSize) ||
|
||||
(pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
|
||||
(pPrivate->bFirstControl == LVM_TRUE))
|
||||
{
|
||||
|
||||
LVM_UINT32 Temp;
|
||||
LVM_INT32 APDelaySize;
|
||||
LVM_INT32 Fs = LVM_GetFsFromTable(pPrivate->NewParams.SampleRate);
|
||||
LVM_UINT32 DelayLengthSamples = (LVM_UINT32)(Fs * pPrivate->RoomSizeInms);
|
||||
LVM_INT16 i;
|
||||
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};
|
||||
LVM_INT16 MaxT_Delay[] = {LVREV_MAX_T0_DELAY, LVREV_MAX_T1_DELAY, LVREV_MAX_T2_DELAY, LVREV_MAX_T3_DELAY};
|
||||
LVM_INT16 MaxAP_Delay[] = {LVREV_MAX_AP0_DELAY, LVREV_MAX_AP1_DELAY, LVREV_MAX_AP2_DELAY, LVREV_MAX_AP3_DELAY};
|
||||
|
||||
|
||||
/*
|
||||
* For each delay line
|
||||
*/
|
||||
for (i=0; i<NumberOfDelayLines; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
LVM_INT32 Temp1; /* to avoid QAC warning on type conversion */
|
||||
LVM_INT32 Temp2; /* to avoid QAC warning on type conversion */
|
||||
|
||||
Temp2=(LVM_INT32)DelayLengthSamples;
|
||||
MUL32x16INTO32(Temp2, ScaleTable[i], Temp1, 15)
|
||||
Temp=(LVM_UINT32)Temp1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Temp = DelayLengthSamples;
|
||||
}
|
||||
APDelaySize = Temp / 1500;
|
||||
|
||||
|
||||
/*
|
||||
* Set the fixed delay
|
||||
*/
|
||||
Temp = (MaxT_Delay[i] - MaxAP_Delay[i]) * Fs / 48000;
|
||||
pPrivate->Delay_AP[i] = pPrivate->T[i] - Temp;
|
||||
|
||||
|
||||
/*
|
||||
* Set the tap selection
|
||||
*/
|
||||
if (pPrivate->AB_Selection)
|
||||
{
|
||||
/* Smooth from tap A to tap B */
|
||||
pPrivate->pOffsetB[i] = &pPrivate->pDelay_T[i][pPrivate->T[i] - Temp - APDelaySize];
|
||||
pPrivate->B_DelaySize[i] = APDelaySize;
|
||||
pPrivate->Mixer_APTaps[i].Target1 = 0;
|
||||
pPrivate->Mixer_APTaps[i].Target2 = 0x7fffffff;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Smooth from tap B to tap A */
|
||||
pPrivate->pOffsetA[i] = &pPrivate->pDelay_T[i][pPrivate->T[i] - Temp - APDelaySize];
|
||||
pPrivate->A_DelaySize[i] = APDelaySize;
|
||||
pPrivate->Mixer_APTaps[i].Target2 = 0;
|
||||
pPrivate->Mixer_APTaps[i].Target1 = 0x7fffffff;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the maximum block size to the smallest delay size
|
||||
*/
|
||||
pPrivate->MaxBlkLen = Temp;
|
||||
if (pPrivate->MaxBlkLen > pPrivate->A_DelaySize[i])
|
||||
{
|
||||
pPrivate->MaxBlkLen = pPrivate->A_DelaySize[i];
|
||||
}
|
||||
if (pPrivate->MaxBlkLen > pPrivate->B_DelaySize[i])
|
||||
{
|
||||
pPrivate->MaxBlkLen = pPrivate->B_DelaySize[i];
|
||||
}
|
||||
}
|
||||
if (pPrivate->AB_Selection)
|
||||
{
|
||||
pPrivate->AB_Selection = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pPrivate->AB_Selection = 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Limit the maximum block length
|
||||
*/
|
||||
pPrivate->MaxBlkLen=pPrivate->MaxBlkLen-2; /* Just as a precausion, but no problem if we remove this line */
|
||||
if(pPrivate->MaxBlkLen > pPrivate->InstanceParams.MaxBlockSize)
|
||||
{
|
||||
pPrivate->MaxBlkLen = (LVM_INT32)pPrivate->InstanceParams.MaxBlockSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Update the low pass filter coefficient
|
||||
*/
|
||||
if( (pPrivate->NewParams.Damping != pPrivate->CurrentParams.Damping) ||
|
||||
(pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
|
||||
(pPrivate->bFirstControl == LVM_TRUE))
|
||||
{
|
||||
|
||||
LVM_INT32 Temp;
|
||||
LVM_INT32 Omega;
|
||||
FO_C32_Coefs_t Coeffs;
|
||||
LVM_INT16 i;
|
||||
LVM_INT16 Damping = (LVM_INT16)((pPrivate->NewParams.Damping * 100) + 1000);
|
||||
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};
|
||||
|
||||
|
||||
/*
|
||||
* For each filter
|
||||
*/
|
||||
for (i=0; i<NumberOfDelayLines; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
MUL32x16INTO32(ScaleTable[i], Damping, Temp, 15)
|
||||
}
|
||||
else
|
||||
{
|
||||
Temp = Damping;
|
||||
}
|
||||
if(Temp <= (LVM_FsTable[pPrivate->NewParams.SampleRate] >> 1))
|
||||
{
|
||||
Omega = LVM_GetOmega((LVM_UINT16)Temp, pPrivate->NewParams.SampleRate);
|
||||
LVM_FO_LPF(Omega, &Coeffs);
|
||||
}
|
||||
else
|
||||
{
|
||||
Coeffs.A0 = 0x7FF00000;
|
||||
Coeffs.A1 = 0;
|
||||
Coeffs.B1 = 0;
|
||||
}
|
||||
FO_1I_D32F32Cll_TRC_WRA_01_Init(&pPrivate->pFastCoef->RevLPCoefs[i], &pPrivate->pFastData->RevLPTaps[i], &Coeffs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Update All-pass filter mixer time constants
|
||||
*/
|
||||
if( (pPrivate->NewParams.RoomSize != pPrivate->CurrentParams.RoomSize) ||
|
||||
(pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
|
||||
(pPrivate->NewParams.Density != pPrivate->CurrentParams.Density))
|
||||
{
|
||||
LVM_INT16 i;
|
||||
LVM_INT32 Alpha = (LVM_INT32)LVM_Mixer_TimeConstant(LVREV_ALLPASS_TC, LVM_GetFsFromTable(pPrivate->NewParams.SampleRate), 1);
|
||||
LVM_INT32 AlphaTap = (LVM_INT32)LVM_Mixer_TimeConstant(LVREV_ALLPASS_TAP_TC, LVM_GetFsFromTable(pPrivate->NewParams.SampleRate), 1);
|
||||
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
pPrivate->Mixer_APTaps[i].Alpha1 = AlphaTap;
|
||||
pPrivate->Mixer_APTaps[i].Alpha2 = AlphaTap;
|
||||
pPrivate->Mixer_SGFeedback[i].Alpha = Alpha;
|
||||
pPrivate->Mixer_SGFeedforward[i].Alpha = Alpha;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Update the feed back gain
|
||||
*/
|
||||
if( (pPrivate->NewParams.RoomSize != pPrivate->CurrentParams.RoomSize) ||
|
||||
(pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
|
||||
(pPrivate->NewParams.T60 != pPrivate->CurrentParams.T60) ||
|
||||
(pPrivate->bFirstControl == LVM_TRUE))
|
||||
{
|
||||
|
||||
LVM_INT32 G[4]; /* Feedback gain (Q7.24) */
|
||||
|
||||
if(pPrivate->NewParams.T60 == 0)
|
||||
{
|
||||
G[3] = 0;
|
||||
G[2] = 0;
|
||||
G[1] = 0;
|
||||
G[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
LVM_INT32 Temp1;
|
||||
LVM_INT32 Temp2;
|
||||
LVM_INT16 i;
|
||||
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};
|
||||
|
||||
|
||||
/*
|
||||
* For each delay line
|
||||
*/
|
||||
for (i=0; i<NumberOfDelayLines; i++)
|
||||
{
|
||||
Temp1 = (3 * pPrivate->RoomSizeInms * ScaleTable[i]) / pPrivate->NewParams.T60;
|
||||
if(Temp1 >= (4 << 15))
|
||||
{
|
||||
G[i] = 0;
|
||||
}
|
||||
else if((Temp1 >= (2 << 15)))
|
||||
{
|
||||
Temp2 = LVM_Power10(-(Temp1 << 14));
|
||||
Temp1 = LVM_Power10(-(Temp1 << 14));
|
||||
MUL32x32INTO32(Temp1,Temp2,Temp1,24)
|
||||
}
|
||||
else
|
||||
{
|
||||
Temp1 = LVM_Power10(-(Temp1 << 15));
|
||||
}
|
||||
if (NumberOfDelayLines == 1)
|
||||
{
|
||||
G[i] = Temp1;
|
||||
}
|
||||
else
|
||||
{
|
||||
LVM_INT32 TempG;
|
||||
MUL32x16INTO32(Temp1,ONE_OVER_SQRT_TWO,TempG,15)
|
||||
G[i]=TempG;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up the feedback mixers for four delay lines */
|
||||
pPrivate->FeedbackMixer[0].Target=G[0]<<7;
|
||||
pPrivate->FeedbackMixer[1].Target=G[1]<<7;
|
||||
pPrivate->FeedbackMixer[2].Target=G[2]<<7;
|
||||
pPrivate->FeedbackMixer[3].Target=G[3]<<7;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Calculate the gain correction
|
||||
*/
|
||||
if((pPrivate->NewParams.RoomSize != pPrivate->CurrentParams.RoomSize) ||
|
||||
(pPrivate->NewParams.Level != pPrivate->CurrentParams.Level) ||
|
||||
(pPrivate->NewParams.T60 != pPrivate->CurrentParams.T60) )
|
||||
{
|
||||
LVM_INT32 Index=0;
|
||||
LVM_INT32 i=0;
|
||||
LVM_INT32 Gain=0;
|
||||
LVM_INT32 RoomSize=0;
|
||||
LVM_INT32 T60;
|
||||
LVM_INT32 Coefs[5];
|
||||
|
||||
if(pPrivate->NewParams.RoomSize==0)
|
||||
{
|
||||
RoomSize=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
RoomSize=(LVM_INT32)pPrivate->NewParams.RoomSize;
|
||||
}
|
||||
|
||||
if(pPrivate->NewParams.T60<100)
|
||||
{
|
||||
T60 = 100 * LVREV_T60_SCALE;
|
||||
}
|
||||
else
|
||||
{
|
||||
T60 = pPrivate->NewParams.T60 * LVREV_T60_SCALE;
|
||||
}
|
||||
|
||||
/* Find the nearest room size in table */
|
||||
for(i=0;i<24;i++)
|
||||
{
|
||||
if(RoomSize<= LVREV_GainPolyTable[i][0])
|
||||
{
|
||||
Index=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(RoomSize==LVREV_GainPolyTable[Index][0])
|
||||
{
|
||||
/* Take table values if the room size is in table */
|
||||
for(i=1;i<5;i++)
|
||||
{
|
||||
Coefs[i-1]=LVREV_GainPolyTable[Index][i];
|
||||
}
|
||||
Coefs[4]=0;
|
||||
Gain=LVM_Polynomial(3,Coefs,T60); /* Q.24 result */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Interpolate the gain between nearest room sizes */
|
||||
|
||||
LVM_INT32 Gain1,Gain2;
|
||||
LVM_INT32 Tot_Dist,Dist;
|
||||
|
||||
Tot_Dist=LVREV_GainPolyTable[Index][0]-LVREV_GainPolyTable[Index-1][0];
|
||||
Dist=RoomSize-LVREV_GainPolyTable[Index-1][0];
|
||||
|
||||
|
||||
/* Get gain for first */
|
||||
for(i=1;i<5;i++)
|
||||
{
|
||||
Coefs[i-1]=LVREV_GainPolyTable[Index-1][i];
|
||||
}
|
||||
Coefs[4]=0;
|
||||
|
||||
Gain1=LVM_Polynomial(3,Coefs,T60); /* Q.24 result */
|
||||
|
||||
/* Get gain for second */
|
||||
for(i=1;i<5;i++)
|
||||
{
|
||||
Coefs[i-1]=LVREV_GainPolyTable[Index][i];
|
||||
}
|
||||
Coefs[4]=0;
|
||||
|
||||
Gain2=LVM_Polynomial(3,Coefs,T60); /* Q.24 result */
|
||||
|
||||
/* Linear Interpolate the gain */
|
||||
Gain = Gain1+ (((Gain2-Gain1)*Dist)/(Tot_Dist));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the inverse of gain: Q.15
|
||||
* Gain is mostly above one except few cases, take only gains above 1
|
||||
*/
|
||||
if(Gain < 16777216L)
|
||||
{
|
||||
pPrivate->Gain= 32767;
|
||||
}
|
||||
else
|
||||
{
|
||||
pPrivate->Gain=(LVM_INT16)(LVM_MAXINT_32/(Gain>>8));
|
||||
}
|
||||
|
||||
|
||||
Index=((32767*100)/(100+pPrivate->NewParams.Level));
|
||||
pPrivate->Gain=(LVM_INT16)((pPrivate->Gain*Index)>>15);
|
||||
pPrivate->GainMixer.Target = pPrivate->Gain*Index;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Update the all pass comb filter coefficient
|
||||
*/
|
||||
if( (pPrivate->NewParams.Density != pPrivate->CurrentParams.Density) ||
|
||||
(pPrivate->bFirstControl == LVM_TRUE))
|
||||
{
|
||||
LVM_INT16 i;
|
||||
LVM_INT32 b = pPrivate->NewParams.Density * LVREV_B_8_on_1000;
|
||||
|
||||
for (i=0;i<4; i++)
|
||||
{
|
||||
pPrivate->Mixer_SGFeedback[i].Target = b;
|
||||
pPrivate->Mixer_SGFeedforward[i].Target = b;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Update the bypass mixer time constant
|
||||
*/
|
||||
if((pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
|
||||
(pPrivate->NewParams.SourceFormat != pPrivate->CurrentParams.SourceFormat) ||
|
||||
(pPrivate->bFirstControl == LVM_TRUE))
|
||||
{
|
||||
LVM_UINT16 NumChannels = 1; /* Assume MONO format */
|
||||
LVM_INT32 Alpha;
|
||||
|
||||
Alpha = (LVM_INT32)LVM_Mixer_TimeConstant(LVREV_FEEDBACKMIXER_TC, LVM_GetFsFromTable(pPrivate->NewParams.SampleRate), NumChannels);
|
||||
pPrivate->FeedbackMixer[0].Alpha=Alpha;
|
||||
pPrivate->FeedbackMixer[1].Alpha=Alpha;
|
||||
pPrivate->FeedbackMixer[2].Alpha=Alpha;
|
||||
pPrivate->FeedbackMixer[3].Alpha=Alpha;
|
||||
|
||||
if (pPrivate->NewParams.SourceFormat != LVM_MONO)
|
||||
{
|
||||
/* Stereo or Mono-in-Stereo format data */
|
||||
NumChannels = 2;
|
||||
}
|
||||
pPrivate->BypassMixer.Alpha1 = (LVM_INT32)LVM_Mixer_TimeConstant(LVREV_BYPASSMIXER_TC, LVM_GetFsFromTable(pPrivate->NewParams.SampleRate), NumChannels);
|
||||
pPrivate->BypassMixer.Alpha2 = pPrivate->BypassMixer.Alpha1;
|
||||
pPrivate->GainMixer.Alpha = pPrivate->BypassMixer.Alpha1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Update the bypass mixer targets
|
||||
*/
|
||||
if( (pPrivate->NewParams.Level != pPrivate->CurrentParams.Level) &&
|
||||
(pPrivate->NewParams.OperatingMode == LVM_MODE_ON))
|
||||
{
|
||||
pPrivate->BypassMixer.Target2 = ((LVM_INT32)(pPrivate->NewParams.Level * 32767)/100)<<16;
|
||||
pPrivate->BypassMixer.Target1 = LVREV_HEADROOM << 16;
|
||||
if ((pPrivate->NewParams.Level == 0) && (pPrivate->bFirstControl == LVM_FALSE))
|
||||
{
|
||||
pPrivate->BypassMixer.CallbackSet2 = LVM_TRUE;
|
||||
}
|
||||
if (pPrivate->NewParams.Level != 0)
|
||||
{
|
||||
pPrivate->bDisableReverb = LVM_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(pPrivate->NewParams.OperatingMode != pPrivate->CurrentParams.OperatingMode)
|
||||
{
|
||||
if(pPrivate->NewParams.OperatingMode == LVM_MODE_ON)
|
||||
{
|
||||
pPrivate->BypassMixer.Target2 = ((LVM_INT32)(pPrivate->NewParams.Level * 32767)/100)<<16;
|
||||
pPrivate->BypassMixer.Target1 = LVREV_HEADROOM << 16;
|
||||
|
||||
pPrivate->BypassMixer.CallbackSet2 = LVM_FALSE;
|
||||
OperatingMode = LVM_MODE_ON;
|
||||
if (pPrivate->NewParams.Level == 0)
|
||||
{
|
||||
pPrivate->bDisableReverb = LVM_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
pPrivate->bDisableReverb = LVM_FALSE;
|
||||
}
|
||||
}
|
||||
else if (pPrivate->bFirstControl == LVM_FALSE)
|
||||
{
|
||||
pPrivate->BypassMixer.Target2 = 0x00000000;
|
||||
pPrivate->BypassMixer.Target1 = 0x7FFFFFFF;
|
||||
pPrivate->BypassMixer.CallbackSet2 = LVM_TRUE;
|
||||
pPrivate->GainMixer.Target = 0x03FFFFFF;
|
||||
OperatingMode = LVM_MODE_ON;
|
||||
}
|
||||
else
|
||||
{
|
||||
OperatingMode = LVM_MODE_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* If it is the first call to ApplyNew settings force the current to the target to begin immediate playback of the effect
|
||||
*/
|
||||
if(pPrivate->bFirstControl == LVM_TRUE)
|
||||
{
|
||||
pPrivate->BypassMixer.Current1 = pPrivate->BypassMixer.Target1;
|
||||
pPrivate->BypassMixer.Current2 = pPrivate->BypassMixer.Target2;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Copy the new parameters
|
||||
*/
|
||||
pPrivate->CurrentParams = pPrivate->NewParams;
|
||||
pPrivate->CurrentParams.OperatingMode = OperatingMode;
|
||||
|
||||
|
||||
/*
|
||||
* Update flag
|
||||
*/
|
||||
if(pPrivate->bFirstControl == LVM_TRUE)
|
||||
{
|
||||
pPrivate->bFirstControl = LVM_FALSE;
|
||||
}
|
||||
|
||||
|
||||
return LVREV_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION: BypassMixer_Callback */
|
||||
/* */
|
||||
/* DESCRIPTION: */
|
||||
/* Controls the On to Off operating mode transition */
|
||||
/* */
|
||||
/* PARAMETERS: */
|
||||
/* pPrivate Pointer to the instance private parameters */
|
||||
/* */
|
||||
/* RETURNS: */
|
||||
/* LVREV_Success Succeeded */
|
||||
/* LVREV_NULLADDRESS When pPrivate is NULL */
|
||||
/* */
|
||||
/* NOTES: */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
LVM_INT32 BypassMixer_Callback (void *pCallbackData,
|
||||
void *pGeneralPurpose,
|
||||
LVM_INT16 GeneralPurpose )
|
||||
{
|
||||
|
||||
LVREV_Instance_st *pLVREV_Private = (LVREV_Instance_st *)pCallbackData;
|
||||
|
||||
|
||||
/*
|
||||
* Avoid build warnings
|
||||
*/
|
||||
(void)pGeneralPurpose;
|
||||
(void)GeneralPurpose;
|
||||
|
||||
|
||||
/*
|
||||
* Turn off
|
||||
*/
|
||||
pLVREV_Private->CurrentParams.OperatingMode = LVM_MODE_OFF;
|
||||
pLVREV_Private->bDisableReverb = LVM_TRUE;
|
||||
LVREV_ClearAudioBuffers((LVREV_Handle_t)pCallbackData);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* End of file */
|
||||
|
||||
113
media/libeffects/lvm/lib/Reverb/src/LVREV_ClearAudioBuffers.c
Executable file
113
media/libeffects/lvm/lib/Reverb/src/LVREV_ClearAudioBuffers.c
Executable file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2010 NXP Software
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Project:: */
|
||||
/* $Author: nxp007753 $ */
|
||||
/* $Revision: 1316 $ */
|
||||
/* $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $ */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Includes */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
#include "LVREV_Private.h"
|
||||
#include "VectorArithmetic.h"
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION: LVREV_ClearAudioBuffers */
|
||||
/* */
|
||||
/* DESCRIPTION: */
|
||||
/* This function is used to clear the internal audio buffers of the module. */
|
||||
/* */
|
||||
/* PARAMETERS: */
|
||||
/* hInstance Instance handle */
|
||||
/* */
|
||||
/* RETURNS: */
|
||||
/* LVREV_SUCCESS Initialisation succeeded */
|
||||
/* LVREV_NULLADDRESS Instance is NULL */
|
||||
/* */
|
||||
/* NOTES: */
|
||||
/* 1. This function must not be interrupted by the LVM_Process function */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
LVREV_ReturnStatus_en LVREV_ClearAudioBuffers(LVREV_Handle_t hInstance)
|
||||
{
|
||||
|
||||
LVREV_Instance_st *pLVREV_Private = (LVREV_Instance_st *)hInstance;
|
||||
|
||||
|
||||
/*
|
||||
* Check for error conditions
|
||||
*/
|
||||
/* Check for NULL pointers */
|
||||
if(hInstance == LVM_NULL)
|
||||
{
|
||||
return LVREV_NULLADDRESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear all filter tap data, delay-lines and other signal related data
|
||||
*/
|
||||
|
||||
|
||||
LoadConst_32(0,
|
||||
(void *)&pLVREV_Private->pFastData->HPTaps, /* Destination Cast to void: no dereferencing in function*/
|
||||
2);
|
||||
LoadConst_32(0,
|
||||
(void *)&pLVREV_Private->pFastData->LPTaps, /* Destination Cast to void: no dereferencing in function*/
|
||||
2);
|
||||
|
||||
if((LVM_UINT16)pLVREV_Private->InstanceParams.NumDelays == LVREV_DELAYLINES_4)
|
||||
{
|
||||
LoadConst_32(0, (LVM_INT32 *)&pLVREV_Private->pFastData->RevLPTaps[3], 2);
|
||||
LoadConst_32(0, (LVM_INT32 *)&pLVREV_Private->pFastData->RevLPTaps[2], 2);
|
||||
LoadConst_32(0, (LVM_INT32 *)&pLVREV_Private->pFastData->RevLPTaps[1], 2);
|
||||
LoadConst_32(0, (LVM_INT32 *)&pLVREV_Private->pFastData->RevLPTaps[0], 2);
|
||||
|
||||
LoadConst_32(0,pLVREV_Private->pDelay_T[3], (LVM_INT16)LVREV_MAX_T3_DELAY);
|
||||
LoadConst_32(0,pLVREV_Private->pDelay_T[2], (LVM_INT16)LVREV_MAX_T2_DELAY);
|
||||
LoadConst_32(0,pLVREV_Private->pDelay_T[1], (LVM_INT16)LVREV_MAX_T1_DELAY);
|
||||
LoadConst_32(0,pLVREV_Private->pDelay_T[0], (LVM_INT16)LVREV_MAX_T0_DELAY);
|
||||
|
||||
}
|
||||
|
||||
if((LVM_UINT16)pLVREV_Private->InstanceParams.NumDelays >= LVREV_DELAYLINES_2)
|
||||
{
|
||||
LoadConst_32(0, (LVM_INT32 *)&pLVREV_Private->pFastData->RevLPTaps[1], 2);
|
||||
LoadConst_32(0, (LVM_INT32 *)&pLVREV_Private->pFastData->RevLPTaps[0], 2);
|
||||
|
||||
LoadConst_32(0,pLVREV_Private->pDelay_T[1], (LVM_INT16)LVREV_MAX_T1_DELAY);
|
||||
LoadConst_32(0,pLVREV_Private->pDelay_T[0], (LVM_INT16)LVREV_MAX_T0_DELAY);
|
||||
}
|
||||
|
||||
if((LVM_UINT16)pLVREV_Private->InstanceParams.NumDelays >= LVREV_DELAYLINES_1)
|
||||
{
|
||||
LoadConst_32(0, (LVM_INT32 *)&pLVREV_Private->pFastData->RevLPTaps[0], 2);
|
||||
LoadConst_32(0,pLVREV_Private->pDelay_T[0], (LVM_INT16)LVREV_MAX_T0_DELAY);
|
||||
}
|
||||
|
||||
return LVREV_SUCCESS;
|
||||
}
|
||||
|
||||
/* End of file */
|
||||
78
media/libeffects/lvm/lib/Reverb/src/LVREV_GetControlParameters.c
Executable file
78
media/libeffects/lvm/lib/Reverb/src/LVREV_GetControlParameters.c
Executable file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2010 NXP Software
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Project:: */
|
||||
/* $Author: nxp27078 $*/
|
||||
/* $Revision: 762 $*/
|
||||
/* $Date: 2010-06-11 14:50:33 +0200 (Fri, 11 Jun 2010) $*/
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Includes */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
#include "LVREV_Private.h"
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION: LVREV_GetControlParameters */
|
||||
/* */
|
||||
/* DESCRIPTION: */
|
||||
/* Request the LVREV module control parameters. The current parameter set is returned */
|
||||
/* via the parameter pointer. */
|
||||
/* */
|
||||
/* PARAMETERS: */
|
||||
/* hInstance Instance handle */
|
||||
/* pControlParams Pointer to an empty parameter structure */
|
||||
/* */
|
||||
/* RETURNS: */
|
||||
/* LVREV_Success Succeeded */
|
||||
/* LVREV_NULLADDRESS When hInstance or pControlParams is NULL */
|
||||
/* */
|
||||
/* NOTES: */
|
||||
/* 1. This function may be interrupted by the LVREV_Process function */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
LVREV_ReturnStatus_en LVREV_GetControlParameters(LVREV_Handle_t hInstance,
|
||||
LVREV_ControlParams_st *pControlParams)
|
||||
{
|
||||
|
||||
LVREV_Instance_st *pLVREV_Private = (LVREV_Instance_st *)hInstance;
|
||||
|
||||
|
||||
/*
|
||||
* Check for error conditions
|
||||
*/
|
||||
if((hInstance == LVM_NULL) || (pControlParams == LVM_NULL))
|
||||
{
|
||||
return LVREV_NULLADDRESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the current parameters
|
||||
*/
|
||||
*pControlParams = pLVREV_Private->NewParams;
|
||||
|
||||
return LVREV_SUCCESS;
|
||||
}
|
||||
|
||||
/* End of file */
|
||||
331
media/libeffects/lvm/lib/Reverb/src/LVREV_GetInstanceHandle.c
Executable file
331
media/libeffects/lvm/lib/Reverb/src/LVREV_GetInstanceHandle.c
Executable file
@@ -0,0 +1,331 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2010 NXP Software
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Project:: */
|
||||
/* $Author: nxp007753 $ */
|
||||
/* $Revision: 1316 $ */
|
||||
/* $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $ */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Includes */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
#include "LVREV_Private.h"
|
||||
#include "InstAlloc.h"
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION: LVREV_GetInstanceHandle */
|
||||
/* */
|
||||
/* DESCRIPTION: */
|
||||
/* This function is used to create a LVREV module instance. It returns the created */
|
||||
/* instance handle through phInstance. All parameters are set to their default, */
|
||||
/* inactive state. */
|
||||
/* */
|
||||
/* PARAMETERS: */
|
||||
/* phInstance pointer to the instance handle */
|
||||
/* pMemoryTable Pointer to the memory definition table */
|
||||
/* pInstanceParams Pointer to the instance parameters */
|
||||
/* */
|
||||
/* RETURNS: */
|
||||
/* LVREV_SUCCESS Succeeded */
|
||||
/* LVREV_NULLADDRESS When phInstance or pMemoryTable or pInstanceParams is NULL */
|
||||
/* LVREV_NULLADDRESS When one of the memory regions has a NULL pointer */
|
||||
/* */
|
||||
/* NOTES: */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
LVREV_ReturnStatus_en LVREV_GetInstanceHandle(LVREV_Handle_t *phInstance,
|
||||
LVREV_MemoryTable_st *pMemoryTable,
|
||||
LVREV_InstanceParams_st *pInstanceParams)
|
||||
{
|
||||
|
||||
INST_ALLOC SlowData;
|
||||
INST_ALLOC FastData;
|
||||
INST_ALLOC FastCoef;
|
||||
INST_ALLOC Temporary;
|
||||
LVREV_Instance_st *pLVREV_Private;
|
||||
LVM_INT16 i;
|
||||
LVM_UINT16 MaxBlockSize;
|
||||
|
||||
|
||||
/*
|
||||
* Check for error conditions
|
||||
*/
|
||||
/* Check for NULL pointers */
|
||||
if((phInstance == LVM_NULL) || (pMemoryTable == LVM_NULL) || (pInstanceParams == LVM_NULL))
|
||||
{
|
||||
return LVREV_NULLADDRESS;
|
||||
}
|
||||
/* Check the memory table for NULL pointers */
|
||||
for (i = 0; i < LVREV_NR_MEMORY_REGIONS; i++)
|
||||
{
|
||||
if (pMemoryTable->Region[i].Size!=0)
|
||||
{
|
||||
if (pMemoryTable->Region[i].pBaseAddress==LVM_NULL)
|
||||
{
|
||||
return(LVREV_NULLADDRESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check all instance parameters are in range
|
||||
*/
|
||||
/* Check for a non-zero block size */
|
||||
if (pInstanceParams->MaxBlockSize == 0)
|
||||
{
|
||||
return LVREV_OUTOFRANGE;
|
||||
}
|
||||
|
||||
/* Check for a valid number of delay lines */
|
||||
if ((pInstanceParams->NumDelays != LVREV_DELAYLINES_1)&&
|
||||
(pInstanceParams->NumDelays != LVREV_DELAYLINES_2)&&
|
||||
(pInstanceParams->NumDelays != LVREV_DELAYLINES_4))
|
||||
{
|
||||
return LVREV_OUTOFRANGE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialise the InstAlloc instances
|
||||
*/
|
||||
InstAlloc_Init(&SlowData, pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress);
|
||||
InstAlloc_Init(&FastData, pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress);
|
||||
InstAlloc_Init(&FastCoef, pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress);
|
||||
InstAlloc_Init(&Temporary, pMemoryTable->Region[LVM_TEMPORARY_FAST].pBaseAddress);
|
||||
|
||||
/*
|
||||
* Zero all memory regions
|
||||
*/
|
||||
LoadConst_16(0, (LVM_INT16 *)pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress, (LVM_INT16)((pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].Size)/sizeof(LVM_INT16)));
|
||||
LoadConst_16(0, (LVM_INT16 *)pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress, (LVM_INT16)((pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].Size)/sizeof(LVM_INT16)));
|
||||
LoadConst_16(0, (LVM_INT16 *)pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress, (LVM_INT16)((pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].Size)/sizeof(LVM_INT16)));
|
||||
LoadConst_16(0, (LVM_INT16 *)pMemoryTable->Region[LVM_TEMPORARY_FAST].pBaseAddress, (LVM_INT16)((pMemoryTable->Region[LVM_TEMPORARY_FAST].Size)/sizeof(LVM_INT16)));
|
||||
|
||||
/*
|
||||
* Set the instance handle if not already initialised
|
||||
*/
|
||||
if (*phInstance == LVM_NULL)
|
||||
{
|
||||
*phInstance = InstAlloc_AddMember(&SlowData, sizeof(LVREV_Instance_st));
|
||||
}
|
||||
pLVREV_Private =(LVREV_Instance_st *)*phInstance;
|
||||
pLVREV_Private->MemoryTable = *pMemoryTable;
|
||||
|
||||
if(pInstanceParams->NumDelays ==LVREV_DELAYLINES_4)
|
||||
{
|
||||
MaxBlockSize = LVREV_MAX_AP3_DELAY;
|
||||
}
|
||||
else if(pInstanceParams->NumDelays ==LVREV_DELAYLINES_2)
|
||||
{
|
||||
MaxBlockSize = LVREV_MAX_AP1_DELAY;
|
||||
}
|
||||
else
|
||||
{
|
||||
MaxBlockSize = LVREV_MAX_AP0_DELAY;
|
||||
}
|
||||
|
||||
if(MaxBlockSize>pInstanceParams->MaxBlockSize)
|
||||
{
|
||||
MaxBlockSize=pInstanceParams->MaxBlockSize;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the data, coefficient and temporary memory pointers
|
||||
*/
|
||||
pLVREV_Private->pFastData = InstAlloc_AddMember(&FastData, sizeof(LVREV_FastData_st)); /* Fast data memory base address */
|
||||
|
||||
if(pInstanceParams->NumDelays == LVREV_DELAYLINES_4)
|
||||
{
|
||||
pLVREV_Private->pDelay_T[3] = InstAlloc_AddMember(&FastData, LVREV_MAX_T3_DELAY * sizeof(LVM_INT32));
|
||||
pLVREV_Private->pDelay_T[2] = InstAlloc_AddMember(&FastData, LVREV_MAX_T2_DELAY * sizeof(LVM_INT32));
|
||||
pLVREV_Private->pDelay_T[1] = InstAlloc_AddMember(&FastData, LVREV_MAX_T1_DELAY * sizeof(LVM_INT32));
|
||||
pLVREV_Private->pDelay_T[0] = InstAlloc_AddMember(&FastData, LVREV_MAX_T0_DELAY * sizeof(LVM_INT32));
|
||||
|
||||
for( i = 0; i < 4; i++)
|
||||
{
|
||||
pLVREV_Private->pScratchDelayLine[i] = InstAlloc_AddMember(&Temporary, sizeof(LVM_INT32) * MaxBlockSize); /* Scratch for each delay line output */
|
||||
}
|
||||
|
||||
LoadConst_32(0,pLVREV_Private->pDelay_T[3] ,(LVM_INT16)LVREV_MAX_T3_DELAY);
|
||||
LoadConst_32(0,pLVREV_Private->pDelay_T[2] ,(LVM_INT16)LVREV_MAX_T2_DELAY);
|
||||
LoadConst_32(0,pLVREV_Private->pDelay_T[1] ,(LVM_INT16)LVREV_MAX_T1_DELAY);
|
||||
LoadConst_32(0,pLVREV_Private->pDelay_T[0] ,(LVM_INT16)LVREV_MAX_T0_DELAY);
|
||||
}
|
||||
|
||||
if(pInstanceParams->NumDelays == LVREV_DELAYLINES_2)
|
||||
{
|
||||
pLVREV_Private->pDelay_T[1] = InstAlloc_AddMember(&FastData, LVREV_MAX_T1_DELAY * sizeof(LVM_INT32));
|
||||
pLVREV_Private->pDelay_T[0] = InstAlloc_AddMember(&FastData, LVREV_MAX_T0_DELAY * sizeof(LVM_INT32));
|
||||
|
||||
for( i = 0; i < 2; i++)
|
||||
{
|
||||
pLVREV_Private->pScratchDelayLine[i] = InstAlloc_AddMember(&Temporary, sizeof(LVM_INT32) * MaxBlockSize); /* Scratch for each delay line output */
|
||||
}
|
||||
|
||||
LoadConst_32(0,pLVREV_Private->pDelay_T[1] , (LVM_INT16)LVREV_MAX_T1_DELAY);
|
||||
LoadConst_32(0,pLVREV_Private->pDelay_T[0] , (LVM_INT16)LVREV_MAX_T0_DELAY);
|
||||
}
|
||||
|
||||
if(pInstanceParams->NumDelays == LVREV_DELAYLINES_1)
|
||||
{
|
||||
pLVREV_Private->pDelay_T[0] = InstAlloc_AddMember(&FastData, LVREV_MAX_T0_DELAY * sizeof(LVM_INT32));
|
||||
|
||||
for( i = 0; i < 1; i++)
|
||||
{
|
||||
pLVREV_Private->pScratchDelayLine[i] = InstAlloc_AddMember(&Temporary, sizeof(LVM_INT32) * MaxBlockSize); /* Scratch for each delay line output */
|
||||
}
|
||||
|
||||
LoadConst_32(0,pLVREV_Private->pDelay_T[0] , (LVM_INT16)LVREV_MAX_T0_DELAY);
|
||||
}
|
||||
|
||||
/* All-pass delay buffer addresses and sizes */
|
||||
pLVREV_Private->T[0] = LVREV_MAX_T0_DELAY;
|
||||
pLVREV_Private->T[1] = LVREV_MAX_T1_DELAY;
|
||||
pLVREV_Private->T[2] = LVREV_MAX_T2_DELAY;
|
||||
pLVREV_Private->T[3] = LVREV_MAX_T3_DELAY;
|
||||
pLVREV_Private->AB_Selection = 1; /* Select smoothing A to B */
|
||||
|
||||
|
||||
pLVREV_Private->pFastCoef = InstAlloc_AddMember(&FastCoef, sizeof(LVREV_FastCoef_st)); /* Fast coefficient memory base address */
|
||||
pLVREV_Private->pScratch = InstAlloc_AddMember(&Temporary, sizeof(LVM_INT32) * MaxBlockSize); /* General purpose scratch */
|
||||
pLVREV_Private->pInputSave = InstAlloc_AddMember(&Temporary, 2 * sizeof(LVM_INT32) * MaxBlockSize); /* Mono->stereo input save for end mix */
|
||||
LoadConst_32(0, pLVREV_Private->pInputSave, (LVM_INT16)(MaxBlockSize*2));
|
||||
|
||||
|
||||
/*
|
||||
* Save the instance parameters in the instance structure
|
||||
*/
|
||||
pLVREV_Private->InstanceParams = *pInstanceParams;
|
||||
|
||||
|
||||
/*
|
||||
* Set the parameters to invalid
|
||||
*/
|
||||
pLVREV_Private->CurrentParams.SampleRate = LVM_FS_INVALID;
|
||||
pLVREV_Private->CurrentParams.OperatingMode = LVM_MODE_DUMMY;
|
||||
pLVREV_Private->CurrentParams.SourceFormat = LVM_SOURCE_DUMMY;
|
||||
|
||||
pLVREV_Private->bControlPending = LVM_FALSE;
|
||||
pLVREV_Private->bFirstControl = LVM_TRUE;
|
||||
pLVREV_Private->bDisableReverb = LVM_FALSE;
|
||||
|
||||
|
||||
/*
|
||||
* Set mixer parameters
|
||||
*/
|
||||
pLVREV_Private->BypassMixer.CallbackParam2 = 0;
|
||||
pLVREV_Private->BypassMixer.pCallbackHandle2 = pLVREV_Private;
|
||||
pLVREV_Private->BypassMixer.pGeneralPurpose2 = LVM_NULL;
|
||||
pLVREV_Private->BypassMixer.pCallBack2 = BypassMixer_Callback;
|
||||
pLVREV_Private->BypassMixer.CallbackSet2 = LVM_FALSE;
|
||||
pLVREV_Private->BypassMixer.Current2 = 0;
|
||||
pLVREV_Private->BypassMixer.Target2 = 0;
|
||||
pLVREV_Private->BypassMixer.CallbackParam1 = 0;
|
||||
pLVREV_Private->BypassMixer.pCallbackHandle1 = LVM_NULL;
|
||||
pLVREV_Private->BypassMixer.pGeneralPurpose1 = LVM_NULL;
|
||||
pLVREV_Private->BypassMixer.pCallBack1 = LVM_NULL;
|
||||
pLVREV_Private->BypassMixer.CallbackSet1 = LVM_FALSE;
|
||||
pLVREV_Private->BypassMixer.Current1 = 0x7fffffff;
|
||||
pLVREV_Private->BypassMixer.Target1 = 0x7fffffff;
|
||||
|
||||
pLVREV_Private->RoomSizeInms = 100; // 100 msec
|
||||
|
||||
|
||||
/*
|
||||
* Set the output gain mixer parameters
|
||||
*/
|
||||
pLVREV_Private->GainMixer.CallbackParam = 0;
|
||||
pLVREV_Private->GainMixer.pCallbackHandle = LVM_NULL;
|
||||
pLVREV_Private->GainMixer.pGeneralPurpose = LVM_NULL;
|
||||
pLVREV_Private->GainMixer.pCallBack = LVM_NULL;
|
||||
pLVREV_Private->GainMixer.CallbackSet = LVM_FALSE;
|
||||
pLVREV_Private->GainMixer.Current = 0x03ffffff;
|
||||
pLVREV_Private->GainMixer.Target = 0x03ffffff;
|
||||
|
||||
|
||||
/*
|
||||
* Set the All-Pass Filter mixers
|
||||
*/
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
pLVREV_Private->pOffsetA[i] = pLVREV_Private->pDelay_T[i];
|
||||
pLVREV_Private->pOffsetB[i] = pLVREV_Private->pDelay_T[i];
|
||||
/* Delay tap selection mixer */
|
||||
pLVREV_Private->Mixer_APTaps[i].CallbackParam2 = 0;
|
||||
pLVREV_Private->Mixer_APTaps[i].pCallbackHandle2 = LVM_NULL;
|
||||
pLVREV_Private->Mixer_APTaps[i].pGeneralPurpose2 = LVM_NULL;
|
||||
pLVREV_Private->Mixer_APTaps[i].pCallBack2 = LVM_NULL;
|
||||
pLVREV_Private->Mixer_APTaps[i].CallbackSet2 = LVM_FALSE;
|
||||
pLVREV_Private->Mixer_APTaps[i].Current2 = 0;
|
||||
pLVREV_Private->Mixer_APTaps[i].Target2 = 0;
|
||||
pLVREV_Private->Mixer_APTaps[i].CallbackParam1 = 0;
|
||||
pLVREV_Private->Mixer_APTaps[i].pCallbackHandle1 = LVM_NULL;
|
||||
pLVREV_Private->Mixer_APTaps[i].pGeneralPurpose1 = LVM_NULL;
|
||||
pLVREV_Private->Mixer_APTaps[i].pCallBack1 = LVM_NULL;
|
||||
pLVREV_Private->Mixer_APTaps[i].CallbackSet1 = LVM_FALSE;
|
||||
pLVREV_Private->Mixer_APTaps[i].Current1 = 0;
|
||||
pLVREV_Private->Mixer_APTaps[i].Target1 = 0x7fffffff;
|
||||
/* Feedforward mixer */
|
||||
pLVREV_Private->Mixer_SGFeedforward[i].CallbackParam = 0;
|
||||
pLVREV_Private->Mixer_SGFeedforward[i].pCallbackHandle = LVM_NULL;
|
||||
pLVREV_Private->Mixer_SGFeedforward[i].pGeneralPurpose = LVM_NULL;
|
||||
pLVREV_Private->Mixer_SGFeedforward[i].pCallBack = LVM_NULL;
|
||||
pLVREV_Private->Mixer_SGFeedforward[i].CallbackSet = LVM_FALSE;
|
||||
pLVREV_Private->Mixer_SGFeedforward[i].Current = 0;
|
||||
pLVREV_Private->Mixer_SGFeedforward[i].Target = 0;
|
||||
/* Feedback mixer */
|
||||
pLVREV_Private->Mixer_SGFeedback[i].CallbackParam = 0;
|
||||
pLVREV_Private->Mixer_SGFeedback[i].pCallbackHandle = LVM_NULL;
|
||||
pLVREV_Private->Mixer_SGFeedback[i].pGeneralPurpose = LVM_NULL;
|
||||
pLVREV_Private->Mixer_SGFeedback[i].pCallBack = LVM_NULL;
|
||||
pLVREV_Private->Mixer_SGFeedback[i].CallbackSet = LVM_FALSE;
|
||||
pLVREV_Private->Mixer_SGFeedback[i].Current = 0;
|
||||
pLVREV_Private->Mixer_SGFeedback[i].Target = 0;
|
||||
/* Feedback gain mixer */
|
||||
pLVREV_Private->FeedbackMixer[i].CallbackParam = 0;
|
||||
pLVREV_Private->FeedbackMixer[i].pCallbackHandle = LVM_NULL;
|
||||
pLVREV_Private->FeedbackMixer[i].pGeneralPurpose = LVM_NULL;
|
||||
pLVREV_Private->FeedbackMixer[i].pCallBack = LVM_NULL;
|
||||
pLVREV_Private->FeedbackMixer[i].CallbackSet = LVM_FALSE;
|
||||
pLVREV_Private->FeedbackMixer[i].Current = 0;
|
||||
pLVREV_Private->FeedbackMixer[i].Target = 0;
|
||||
}
|
||||
/* Delay tap index */
|
||||
pLVREV_Private->A_DelaySize[0] = LVREV_MAX_AP0_DELAY;
|
||||
pLVREV_Private->B_DelaySize[0] = LVREV_MAX_AP0_DELAY;
|
||||
pLVREV_Private->A_DelaySize[1] = LVREV_MAX_AP1_DELAY;
|
||||
pLVREV_Private->B_DelaySize[1] = LVREV_MAX_AP1_DELAY;
|
||||
pLVREV_Private->A_DelaySize[2] = LVREV_MAX_AP2_DELAY;
|
||||
pLVREV_Private->B_DelaySize[2] = LVREV_MAX_AP2_DELAY;
|
||||
pLVREV_Private->A_DelaySize[3] = LVREV_MAX_AP3_DELAY;
|
||||
pLVREV_Private->B_DelaySize[3] = LVREV_MAX_AP3_DELAY;
|
||||
|
||||
|
||||
LVREV_ClearAudioBuffers(*phInstance);
|
||||
|
||||
return LVREV_SUCCESS;
|
||||
}
|
||||
|
||||
/* End of file */
|
||||
254
media/libeffects/lvm/lib/Reverb/src/LVREV_GetMemoryTable.c
Executable file
254
media/libeffects/lvm/lib/Reverb/src/LVREV_GetMemoryTable.c
Executable file
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2010 NXP Software
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Project:: */
|
||||
/* $Author: beq07716 $*/
|
||||
/* $Revision: 1007 $*/
|
||||
/* $Date: 2010-06-28 14:06:36 +0200 (Mon, 28 Jun 2010) $*/
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Includes */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
#include "LVREV_Private.h"
|
||||
#include "InstAlloc.h"
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION: LVREV_GetMemoryTable */
|
||||
/* */
|
||||
/* DESCRIPTION: */
|
||||
/* This function is used for memory allocation and free. It can be called in */
|
||||
/* two ways: */
|
||||
/* */
|
||||
/* hInstance = NULL Returns the memory requirements */
|
||||
/* hInstance = Instance handle Returns the memory requirements and allocated */
|
||||
/* base addresses. */
|
||||
/* */
|
||||
/* When this function is called for memory allocation (hInstance=NULL) the memory */
|
||||
/* base address pointers are NULL on return. */
|
||||
/* */
|
||||
/* When the function is called for free (hInstance = Instance Handle) the memory */
|
||||
/* table returns the allocated memory and base addresses used during initialisation. */
|
||||
/* */
|
||||
/* PARAMETERS: */
|
||||
/* hInstance Instance Handle */
|
||||
/* pMemoryTable Pointer to an empty memory table */
|
||||
/* pInstanceParams Pointer to the instance parameters */
|
||||
/* */
|
||||
/* RETURNS: */
|
||||
/* LVREV_Success Succeeded */
|
||||
/* LVREV_NULLADDRESS When pMemoryTable is NULL */
|
||||
/* LVREV_NULLADDRESS When requesting memory requirements and pInstanceParams */
|
||||
/* is NULL */
|
||||
/* */
|
||||
/* NOTES: */
|
||||
/* 1. This function may be interrupted by the LVREV_Process function */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
LVREV_ReturnStatus_en LVREV_GetMemoryTable(LVREV_Handle_t hInstance,
|
||||
LVREV_MemoryTable_st *pMemoryTable,
|
||||
LVREV_InstanceParams_st *pInstanceParams)
|
||||
{
|
||||
|
||||
INST_ALLOC SlowData;
|
||||
INST_ALLOC FastData;
|
||||
INST_ALLOC FastCoef;
|
||||
INST_ALLOC Temporary;
|
||||
LVM_INT16 i;
|
||||
LVM_UINT16 MaxBlockSize;
|
||||
|
||||
|
||||
/*
|
||||
* Check for error conditions
|
||||
*/
|
||||
/* Check for NULL pointer */
|
||||
if (pMemoryTable == LVM_NULL)
|
||||
{
|
||||
return(LVREV_NULLADDRESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check all instance parameters are in range
|
||||
*/
|
||||
if (pInstanceParams != LVM_NULL)
|
||||
{
|
||||
/*
|
||||
* Call for memory allocation, so check the parameters
|
||||
*/
|
||||
/* Check for a non-zero block size */
|
||||
if (pInstanceParams->MaxBlockSize == 0)
|
||||
{
|
||||
return LVREV_OUTOFRANGE;
|
||||
}
|
||||
|
||||
/* Check for a valid number of delay lines */
|
||||
if ((pInstanceParams->NumDelays != LVREV_DELAYLINES_1) &&
|
||||
(pInstanceParams->NumDelays != LVREV_DELAYLINES_2) &&
|
||||
(pInstanceParams->NumDelays != LVREV_DELAYLINES_4))
|
||||
{
|
||||
return LVREV_OUTOFRANGE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialise the InstAlloc instances
|
||||
*/
|
||||
InstAlloc_Init(&SlowData, (void *)LVM_NULL);
|
||||
InstAlloc_Init(&FastData, (void *)LVM_NULL);
|
||||
InstAlloc_Init(&FastCoef, (void *)LVM_NULL);
|
||||
InstAlloc_Init(&Temporary, (void *)LVM_NULL);
|
||||
|
||||
|
||||
/*
|
||||
* Fill in the memory table
|
||||
*/
|
||||
if (hInstance == LVM_NULL)
|
||||
{
|
||||
/*
|
||||
* Check for null pointers
|
||||
*/
|
||||
if (pInstanceParams == LVM_NULL)
|
||||
{
|
||||
return(LVREV_NULLADDRESS);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Select the maximum internal block size
|
||||
*/
|
||||
if(pInstanceParams->NumDelays ==LVREV_DELAYLINES_4)
|
||||
{
|
||||
MaxBlockSize = LVREV_MAX_AP3_DELAY;
|
||||
}
|
||||
else if(pInstanceParams->NumDelays ==LVREV_DELAYLINES_2)
|
||||
{
|
||||
MaxBlockSize = LVREV_MAX_AP1_DELAY;
|
||||
}
|
||||
else
|
||||
{
|
||||
MaxBlockSize = LVREV_MAX_AP0_DELAY;
|
||||
}
|
||||
|
||||
if(MaxBlockSize>pInstanceParams->MaxBlockSize)
|
||||
{
|
||||
MaxBlockSize=pInstanceParams->MaxBlockSize;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Slow data memory
|
||||
*/
|
||||
InstAlloc_AddMember(&SlowData, sizeof(LVREV_Instance_st));
|
||||
pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].Size = InstAlloc_GetTotal(&SlowData);
|
||||
pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].Type = LVM_PERSISTENT_SLOW_DATA;
|
||||
pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress = LVM_NULL;
|
||||
|
||||
|
||||
/*
|
||||
* Persistent fast data memory
|
||||
*/
|
||||
InstAlloc_AddMember(&FastData, sizeof(LVREV_FastData_st));
|
||||
if(pInstanceParams->NumDelays == LVREV_DELAYLINES_4)
|
||||
{
|
||||
InstAlloc_AddMember(&FastData, LVREV_MAX_T3_DELAY * sizeof(LVM_INT32));
|
||||
InstAlloc_AddMember(&FastData, LVREV_MAX_T2_DELAY * sizeof(LVM_INT32));
|
||||
InstAlloc_AddMember(&FastData, LVREV_MAX_T1_DELAY * sizeof(LVM_INT32));
|
||||
InstAlloc_AddMember(&FastData, LVREV_MAX_T0_DELAY * sizeof(LVM_INT32));
|
||||
}
|
||||
|
||||
if(pInstanceParams->NumDelays == LVREV_DELAYLINES_2)
|
||||
{
|
||||
InstAlloc_AddMember(&FastData, LVREV_MAX_T1_DELAY * sizeof(LVM_INT32));
|
||||
InstAlloc_AddMember(&FastData, LVREV_MAX_T0_DELAY * sizeof(LVM_INT32));
|
||||
}
|
||||
|
||||
if(pInstanceParams->NumDelays == LVREV_DELAYLINES_1)
|
||||
{
|
||||
InstAlloc_AddMember(&FastData, LVREV_MAX_T0_DELAY * sizeof(LVM_INT32));
|
||||
}
|
||||
|
||||
pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].Size = InstAlloc_GetTotal(&FastData);
|
||||
pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].Type = LVM_PERSISTENT_FAST_DATA;
|
||||
pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress = LVM_NULL;
|
||||
|
||||
|
||||
/*
|
||||
* Persistent fast coefficient memory
|
||||
*/
|
||||
InstAlloc_AddMember(&FastCoef, sizeof(LVREV_FastCoef_st));
|
||||
pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].Size = InstAlloc_GetTotal(&FastCoef);
|
||||
pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].Type = LVM_PERSISTENT_FAST_COEF;
|
||||
pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress = LVM_NULL;
|
||||
|
||||
|
||||
/*
|
||||
* Temporary fast memory
|
||||
*/
|
||||
InstAlloc_AddMember(&Temporary, sizeof(LVM_INT32) * MaxBlockSize); /* General purpose scratch memory */
|
||||
InstAlloc_AddMember(&Temporary, 2*sizeof(LVM_INT32) * MaxBlockSize); /* Mono->stereo input saved for end mix */
|
||||
|
||||
if(pInstanceParams->NumDelays == LVREV_DELAYLINES_4)
|
||||
{
|
||||
for(i=0; i<4; i++)
|
||||
{
|
||||
InstAlloc_AddMember(&Temporary, sizeof(LVM_INT32) * MaxBlockSize); /* A Scratch buffer for each delay line */
|
||||
}
|
||||
}
|
||||
|
||||
if(pInstanceParams->NumDelays == LVREV_DELAYLINES_2)
|
||||
{
|
||||
for(i=0; i<2; i++)
|
||||
{
|
||||
InstAlloc_AddMember(&Temporary, sizeof(LVM_INT32) * MaxBlockSize); /* A Scratch buffer for each delay line */
|
||||
}
|
||||
}
|
||||
|
||||
if(pInstanceParams->NumDelays == LVREV_DELAYLINES_1)
|
||||
{
|
||||
for(i=0; i<1; i++)
|
||||
{
|
||||
InstAlloc_AddMember(&Temporary, sizeof(LVM_INT32) * MaxBlockSize); /* A Scratch buffer for each delay line */
|
||||
}
|
||||
}
|
||||
|
||||
pMemoryTable->Region[LVM_TEMPORARY_FAST].Size = InstAlloc_GetTotal(&Temporary);
|
||||
pMemoryTable->Region[LVM_TEMPORARY_FAST].Type = LVM_TEMPORARY_FAST;
|
||||
pMemoryTable->Region[LVM_TEMPORARY_FAST].pBaseAddress = LVM_NULL;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
LVREV_Instance_st *pLVREV_Private = (LVREV_Instance_st *)hInstance;
|
||||
|
||||
|
||||
/*
|
||||
* Read back memory allocation table
|
||||
*/
|
||||
*pMemoryTable = pLVREV_Private->MemoryTable;
|
||||
}
|
||||
|
||||
|
||||
return(LVREV_SUCCESS);
|
||||
}
|
||||
|
||||
/* End of file */
|
||||
198
media/libeffects/lvm/lib/Reverb/src/LVREV_Private.h
Executable file
198
media/libeffects/lvm/lib/Reverb/src/LVREV_Private.h
Executable file
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2010 NXP Software
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Project:: */
|
||||
/* $Author: nxp007753 $ */
|
||||
/* $Revision: 1316 $ */
|
||||
/* $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $ */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
#ifndef __LVREV_PRIVATE_H__
|
||||
#define __LVREV_PRIVATE_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Includes */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
#include "LVREV.h"
|
||||
#include "LVREV_Tables.h"
|
||||
#include "BIQUAD.h"
|
||||
#include "Filter.h"
|
||||
#include "VectorArithmetic.h"
|
||||
#include "Mixer.h"
|
||||
#include "LVM_Macros.h"
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Defines */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
/* General */
|
||||
#define ONE_OVER_SQRT_TWO 23170 /* 1/sqrt(2) * 2^15 */
|
||||
#define LVREV_B_8_on_1000 17179869 /* 0.8 * 2^31 */
|
||||
#define LVREV_HEADROOM 8192 /* -12dB * 2^15 */
|
||||
#define LVREV_2_9_INQ29 1583769190L /* 2.9 in Q29 format */
|
||||
#define LVREV_MIN3DB 0x5A82 /* -3dB in Q15 format */
|
||||
|
||||
/* Intenal constants */
|
||||
#define LVREV_LP_Poly_Order 4
|
||||
#define LVREV_LP_Poly_Shift 5
|
||||
#define LVREV_T_3_Power_0_on_4 32768
|
||||
#define LVREV_T_3_Power_1_on_4 43125
|
||||
#define LVREV_T_3_Power_2_on_4 56755
|
||||
#define LVREV_T_3_Power_3_on_4 74694
|
||||
#define LVREV_T60_SCALE 306774 /*(32767/7000)<<16 */
|
||||
#define LVREV_T_3_Power_minus0_on_4 32767 /* 3^(-0/4) * 2^15 */
|
||||
#define LVREV_T_3_Power_minus1_on_4 24898 /* 3^(-1/4) * 2^15 */
|
||||
#define LVREV_T_3_Power_minus2_on_4 18919 /* 3^(-2/4) * 2^15 */
|
||||
#define LVREV_T_3_Power_minus3_on_4 14375 /* 3^(-3/4) * 2^15 */
|
||||
#define LVREV_MAX_T3_DELAY 2527 /* ((48000 * 120 * LVREV_T_3_Power_minus3_on_4) >> 15) / 1000 */
|
||||
#define LVREV_MAX_T2_DELAY 3326 /* ((48000 * 120 * LVREV_T_3_Power_minus2_on_4) >> 15) / 1000 */
|
||||
#define LVREV_MAX_T1_DELAY 4377 /* ((48000 * 120 * LVREV_T_3_Power_minus1_on_4) >> 15) / 1000 */
|
||||
#define LVREV_MAX_T0_DELAY 5760 /* ((48000 * 120 * LVREV_T_3_Power_minus0_on_4) >> 15) / 1000 */
|
||||
#define LVREV_MAX_AP3_DELAY 1685 /* ((48000 * 120 * LVREV_T_3_Power_minus3_on_4) >> 15) / 1500 */
|
||||
#define LVREV_MAX_AP2_DELAY 2218 /* ((48000 * 120 * LVREV_T_3_Power_minus2_on_4) >> 15) / 1500 */
|
||||
#define LVREV_MAX_AP1_DELAY 2918 /* ((48000 * 120 * LVREV_T_3_Power_minus1_on_4) >> 15) / 1500 */
|
||||
#define LVREV_MAX_AP0_DELAY 3840 /* ((48000 * 120 * LVREV_T_3_Power_minus0_on_4) >> 15) / 1500 */
|
||||
#define LVREV_BYPASSMIXER_TC 1000 /* Bypass mixer time constant*/
|
||||
#define LVREV_ALLPASS_TC 1000 /* All-pass filter time constant */
|
||||
#define LVREV_ALLPASS_TAP_TC 10000 /* All-pass filter dely tap change */
|
||||
#define LVREV_FEEDBACKMIXER_TC 100 /* Feedback mixer time constant*/
|
||||
#define LVREV_OUTPUTGAIN_SHIFT 5 /* Bits shift for output gain correction */
|
||||
|
||||
/* Parameter limits */
|
||||
#define LVREV_NUM_FS 9 /* Number of supported sample rates */
|
||||
#define LVREV_MAXBLKSIZE_LIMIT 64 /* Maximum block size low limit */
|
||||
#define LVREV_MAX_LEVEL 100 /* Maximum level, 100% */
|
||||
#define LVREV_MIN_LPF_CORNER 50 /* Low pass filter limits */
|
||||
#define LVREV_MAX_LPF_CORNER 23999
|
||||
#define LVREV_MIN_HPF_CORNER 20 /* High pass filrer limits */
|
||||
#define LVREV_MAX_HPF_CORNER 1000
|
||||
#define LVREV_MAX_T60 7000 /* Maximum T60 time in ms */
|
||||
#define LVREV_MAX_DENSITY 100 /* Maximum density, 100% */
|
||||
#define LVREV_MAX_DAMPING 100 /* Maximum damping, 100% */
|
||||
#define LVREV_MAX_ROOMSIZE 100 /* Maximum room size, 100% */
|
||||
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Structures */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
/* Fast data structure */
|
||||
typedef struct
|
||||
{
|
||||
|
||||
Biquad_1I_Order1_Taps_t HPTaps; /* High pass filter taps */
|
||||
Biquad_1I_Order1_Taps_t LPTaps; /* Low pass filter taps */
|
||||
Biquad_1I_Order1_Taps_t RevLPTaps[4]; /* Reverb low pass filters taps */
|
||||
|
||||
} LVREV_FastData_st;
|
||||
|
||||
|
||||
/* Fast coefficient structure */
|
||||
typedef struct
|
||||
{
|
||||
|
||||
Biquad_Instance_t HPCoefs; /* High pass filter coefficients */
|
||||
Biquad_Instance_t LPCoefs; /* Low pass filter coefficients */
|
||||
Biquad_Instance_t RevLPCoefs[4]; /* Reverb low pass filters coefficients */
|
||||
|
||||
} LVREV_FastCoef_st;
|
||||
|
||||
|
||||
/* Instance parameter structure */
|
||||
typedef struct
|
||||
{
|
||||
/* General */
|
||||
LVREV_InstanceParams_st InstanceParams; /* Initialisation time instance parameters */
|
||||
LVREV_MemoryTable_st MemoryTable; /* Memory table */
|
||||
LVREV_ControlParams_st CurrentParams; /* Parameters being used */
|
||||
LVREV_ControlParams_st NewParams; /* New parameters from the calling application */
|
||||
LVM_CHAR bControlPending; /* Flag to indicate new parameters are available */
|
||||
LVM_CHAR bFirstControl; /* Flag to indicate that the control function is called for the first time */
|
||||
LVM_CHAR bDisableReverb; /* Flag to indicate that the mix level is 0% and the reverb can be disabled */
|
||||
LVM_INT32 RoomSizeInms; /* Room size in msec */
|
||||
LVM_INT32 MaxBlkLen; /* Maximum block size for internal processing */
|
||||
|
||||
/* Aligned memory pointers */
|
||||
LVREV_FastData_st *pFastData; /* Fast data memory base address */
|
||||
LVREV_FastCoef_st *pFastCoef; /* Fast coefficient memory base address */
|
||||
LVM_INT32 *pScratchDelayLine[4]; /* Delay line scratch memory */
|
||||
LVM_INT32 *pScratch; /* Multi ussge scratch */
|
||||
LVM_INT32 *pInputSave; /* Reverb block input save for dry/wet mixing*/
|
||||
|
||||
/* Feedback matrix */
|
||||
Mix_1St_Cll_t FeedbackMixer[4]; /* Mixer for Pop and Click Supression caused by feedback Gain */
|
||||
|
||||
/* All-Pass Filter */
|
||||
LVM_INT32 T[4]; /* Maximum delay size of buffer */
|
||||
LVM_INT32 *pDelay_T[4]; /* Pointer to delay buffers */
|
||||
LVM_INT32 Delay_AP[4]; /* Offset to AP delay buffer start */
|
||||
LVM_INT16 AB_Selection; /* Smooth from tap A to B when 1 otherwise B to A */
|
||||
LVM_INT32 A_DelaySize[4]; /* A delay length in samples */
|
||||
LVM_INT32 B_DelaySize[4]; /* B delay length in samples */
|
||||
LVM_INT32 *pOffsetA[4]; /* Offset for the A delay tap */
|
||||
LVM_INT32 *pOffsetB[4]; /* Offset for the B delay tap */
|
||||
Mix_2St_Cll_t Mixer_APTaps[4]; /* Smoothed AP delay mixer */
|
||||
Mix_1St_Cll_t Mixer_SGFeedback[4]; /* Smoothed SAfeedback gain */
|
||||
Mix_1St_Cll_t Mixer_SGFeedforward[4]; /* Smoothed AP feedforward gain */
|
||||
|
||||
/* Output gain */
|
||||
Mix_2St_Cll_t BypassMixer; /* Dry/wet mixer */
|
||||
LVM_INT16 Gain; /* Gain applied to output to maintain average signal power */
|
||||
Mix_1St_Cll_t GainMixer; /* Gain smoothing */
|
||||
|
||||
} LVREV_Instance_st;
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Function prototypes */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
LVREV_ReturnStatus_en LVREV_ApplyNewSettings(LVREV_Instance_st *pPrivate);
|
||||
|
||||
void ReverbBlock(LVM_INT32 *pInput,
|
||||
LVM_INT32 *pOutput,
|
||||
LVREV_Instance_st *pPrivate,
|
||||
LVM_UINT16 NumSamples);
|
||||
|
||||
LVM_INT32 BypassMixer_Callback(void *pCallbackData,
|
||||
void *pGeneralPurpose,
|
||||
LVM_INT16 GeneralPurpose );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /** __LVREV_PRIVATE_H__ **/
|
||||
|
||||
/* End of file */
|
||||
550
media/libeffects/lvm/lib/Reverb/src/LVREV_Process.c
Executable file
550
media/libeffects/lvm/lib/Reverb/src/LVREV_Process.c
Executable file
@@ -0,0 +1,550 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2010 NXP Software
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Project:: */
|
||||
/* $Author: nxp007753 $ */
|
||||
/* $Revision: 1316 $ */
|
||||
/* $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $ */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Includes */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
#include "LVREV_Private.h"
|
||||
#include "VectorArithmetic.h"
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION: LVREV_Process */
|
||||
/* */
|
||||
/* DESCRIPTION: */
|
||||
/* Process function for the LVREV module. */
|
||||
/* */
|
||||
/* PARAMETERS: */
|
||||
/* hInstance Instance handle */
|
||||
/* pInData Pointer to the input data */
|
||||
/* pOutData Pointer to the output data */
|
||||
/* NumSamples Number of samples in the input buffer */
|
||||
/* */
|
||||
/* RETURNS: */
|
||||
/* LVREV_Success Succeeded */
|
||||
/* LVREV_INVALIDNUMSAMPLES NumSamples was larger than the maximum block size */
|
||||
/* LVREV_NULLADDRESS When one of hInstance, pInData or pOutData is NULL */
|
||||
/* */
|
||||
/* NOTES: */
|
||||
/* 1. The input and output buffers must be 32-bit aligned */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
LVREV_ReturnStatus_en LVREV_Process(LVREV_Handle_t hInstance,
|
||||
const LVM_INT32 *pInData,
|
||||
LVM_INT32 *pOutData,
|
||||
const LVM_UINT16 NumSamples)
|
||||
{
|
||||
LVREV_Instance_st *pLVREV_Private = (LVREV_Instance_st *)hInstance;
|
||||
LVM_INT32 *pInput = (LVM_INT32 *)pInData;
|
||||
LVM_INT32 *pOutput = pOutData;
|
||||
LVM_INT32 SamplesToProcess, RemainingSamples, format;
|
||||
|
||||
/*
|
||||
* Check for error conditions
|
||||
*/
|
||||
|
||||
/* Check for NULL pointers */
|
||||
if((hInstance == LVM_NULL) || (pInData == LVM_NULL) || (pOutData == LVM_NULL))
|
||||
{
|
||||
return LVREV_NULLADDRESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Apply the new controls settings if required
|
||||
*/
|
||||
if(pLVREV_Private->bControlPending == LVM_TRUE)
|
||||
{
|
||||
LVREV_ReturnStatus_en errorCode;
|
||||
|
||||
/*
|
||||
* Clear the pending flag and update the control settings
|
||||
*/
|
||||
pLVREV_Private->bControlPending = LVM_FALSE;
|
||||
|
||||
errorCode = LVREV_ApplyNewSettings (pLVREV_Private);
|
||||
|
||||
if(errorCode != LVREV_SUCCESS)
|
||||
{
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Trap the case where the number of samples is zero.
|
||||
*/
|
||||
if (NumSamples == 0)
|
||||
{
|
||||
return LVREV_SUCCESS;
|
||||
}
|
||||
|
||||
RemainingSamples = (LVM_INT32)NumSamples;
|
||||
|
||||
format = 1;
|
||||
if (pLVREV_Private->CurrentParams.SourceFormat != LVM_MONO)
|
||||
{
|
||||
format = 2;
|
||||
}
|
||||
|
||||
while (RemainingSamples!=0)
|
||||
{
|
||||
/*
|
||||
* If OFF copy and reformat the data as necessary
|
||||
*/
|
||||
if (pLVREV_Private->CurrentParams.OperatingMode == LVM_MODE_OFF)
|
||||
{
|
||||
if((pInput != pOutput) || (pLVREV_Private->CurrentParams.SourceFormat == LVM_MONO))
|
||||
{
|
||||
/*
|
||||
* Copy the data to the output buffer
|
||||
*/
|
||||
|
||||
if (pLVREV_Private->CurrentParams.SourceFormat != LVM_MONO)
|
||||
{
|
||||
RemainingSamples = (RemainingSamples << 1); /* Stereo data */
|
||||
}
|
||||
|
||||
Copy_16((LVM_INT16 *)pInput,
|
||||
(LVM_INT16 *)pOutput,
|
||||
(LVM_INT16)(RemainingSamples << 1));
|
||||
}
|
||||
|
||||
RemainingSamples = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Process the data
|
||||
*/
|
||||
else
|
||||
{
|
||||
|
||||
if(RemainingSamples > pLVREV_Private->MaxBlkLen)
|
||||
{
|
||||
SamplesToProcess = pLVREV_Private->MaxBlkLen;
|
||||
RemainingSamples = (LVM_INT16)(RemainingSamples - SamplesToProcess);
|
||||
}
|
||||
else
|
||||
{
|
||||
SamplesToProcess = RemainingSamples;
|
||||
RemainingSamples = 0;
|
||||
}
|
||||
|
||||
ReverbBlock(pInput, pOutput, pLVREV_Private, (LVM_UINT16)SamplesToProcess);
|
||||
|
||||
pInput = (LVM_INT32 *)(pInput +(SamplesToProcess*format));
|
||||
pOutput = (LVM_INT32 *)(pOutput+(SamplesToProcess*format));
|
||||
}
|
||||
}
|
||||
|
||||
return LVREV_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION: ReverbBlock */
|
||||
/* */
|
||||
/* DESCRIPTION: */
|
||||
/* Process function for the LVREV module. */
|
||||
/* */
|
||||
/* PARAMETERS: */
|
||||
/* hInstance Instance handle */
|
||||
/* pInData Pointer to the input data */
|
||||
/* pOutData Pointer to the output data */
|
||||
/* NumSamples Number of samples in the input buffer */
|
||||
/* */
|
||||
/* RETURNS: */
|
||||
/* LVREV_Success Succeeded */
|
||||
/* LVREV_INVALIDNUMSAMPLES NumSamples was larger than the maximum block size */
|
||||
/* LVREV_NULLADDRESS When one of hInstance, pInData or pOutData is NULL */
|
||||
/* */
|
||||
/* NOTES: */
|
||||
/* 1. The input and output buffers must be 32-bit aligned */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
void ReverbBlock(LVM_INT32 *pInput, LVM_INT32 *pOutput, LVREV_Instance_st *pPrivate, LVM_UINT16 NumSamples)
|
||||
{
|
||||
LVM_INT16 j, size;
|
||||
LVM_INT32 *pDelayLine;
|
||||
LVM_INT32 *pDelayLineInput = pPrivate->pScratch;
|
||||
LVM_INT32 *pScratch = pPrivate->pScratch;
|
||||
LVM_INT32 *pIn;
|
||||
LVM_INT32 *pTemp = pPrivate->pInputSave;
|
||||
LVM_INT32 NumberOfDelayLines;
|
||||
|
||||
/******************************************************************************
|
||||
* All calculations will go into the buffer pointed to by pTemp, this will *
|
||||
* then be mixed with the original input to create the final output. *
|
||||
* *
|
||||
* When INPLACE processing is selected this must be a temporary buffer and *
|
||||
* hence this is the worst case, so for simplicity this will ALWAYS be so *
|
||||
* *
|
||||
* The input buffer will remain untouched until the output of the mixer if *
|
||||
* INPLACE processing is selected. *
|
||||
* *
|
||||
* The temp buffer will always be NumSamples in size regardless of MONO or *
|
||||
* STEREO input. In the case of stereo input all processing is done in MONO *
|
||||
* and the final output is converted to STEREO after the mixer *
|
||||
******************************************************************************/
|
||||
|
||||
if(pPrivate->InstanceParams.NumDelays == LVREV_DELAYLINES_4 )
|
||||
{
|
||||
NumberOfDelayLines = 4;
|
||||
}
|
||||
else if(pPrivate->InstanceParams.NumDelays == LVREV_DELAYLINES_2 )
|
||||
{
|
||||
NumberOfDelayLines = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
NumberOfDelayLines = 1;
|
||||
}
|
||||
|
||||
if(pPrivate->CurrentParams.SourceFormat == LVM_MONO)
|
||||
{
|
||||
pIn = pInput;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Stereo to mono conversion
|
||||
*/
|
||||
|
||||
From2iToMono_32( pInput,
|
||||
pTemp,
|
||||
(LVM_INT16)NumSamples);
|
||||
|
||||
pIn = pTemp;
|
||||
}
|
||||
|
||||
Mult3s_32x16(pIn,
|
||||
(LVM_INT16)LVREV_HEADROOM,
|
||||
pTemp,
|
||||
(LVM_INT16)NumSamples);
|
||||
|
||||
/*
|
||||
* High pass filter
|
||||
*/
|
||||
FO_1I_D32F32C31_TRC_WRA_01( &pPrivate->pFastCoef->HPCoefs,
|
||||
pTemp,
|
||||
pTemp,
|
||||
(LVM_INT16)NumSamples);
|
||||
/*
|
||||
* Low pass filter
|
||||
*/
|
||||
FO_1I_D32F32C31_TRC_WRA_01( &pPrivate->pFastCoef->LPCoefs,
|
||||
pTemp,
|
||||
pTemp,
|
||||
(LVM_INT16)NumSamples);
|
||||
|
||||
/*
|
||||
* Process all delay lines
|
||||
*/
|
||||
|
||||
for(j = 0; j < NumberOfDelayLines; j++)
|
||||
{
|
||||
pDelayLine = pPrivate->pScratchDelayLine[j];
|
||||
|
||||
/*
|
||||
* All-pass filter with pop and click suppression
|
||||
*/
|
||||
/* Get the smoothed, delayed output. Put it in the output buffer */
|
||||
MixSoft_2St_D32C31_SAT(&pPrivate->Mixer_APTaps[j],
|
||||
pPrivate->pOffsetA[j],
|
||||
pPrivate->pOffsetB[j],
|
||||
pDelayLine,
|
||||
(LVM_INT16)NumSamples);
|
||||
/* Re-align the all pass filter delay buffer and copying the fixed delay data to the AP delay in the process */
|
||||
Copy_16((LVM_INT16 *)&pPrivate->pDelay_T[j][NumSamples],
|
||||
(LVM_INT16 *)pPrivate->pDelay_T[j],
|
||||
(LVM_INT16)((pPrivate->T[j]-NumSamples) << 1)); /* 32-bit data */
|
||||
/* Apply the smoothed feedback and save to fixed delay input (currently empty) */
|
||||
MixSoft_1St_D32C31_WRA(&pPrivate->Mixer_SGFeedback[j],
|
||||
pDelayLine,
|
||||
&pPrivate->pDelay_T[j][pPrivate->T[j]-NumSamples],
|
||||
(LVM_INT16)NumSamples);
|
||||
/* Sum into the AP delay line */
|
||||
Mac3s_Sat_32x16(&pPrivate->pDelay_T[j][pPrivate->T[j]-NumSamples],
|
||||
-0x7fff, /* Invert since the feedback coefficient is negative */
|
||||
&pPrivate->pDelay_T[j][pPrivate->Delay_AP[j]-NumSamples],
|
||||
(LVM_INT16)NumSamples);
|
||||
/* Apply smoothed feedforward sand save to fixed delay input (currently empty) */
|
||||
MixSoft_1St_D32C31_WRA(&pPrivate->Mixer_SGFeedforward[j],
|
||||
&pPrivate->pDelay_T[j][pPrivate->Delay_AP[j]-NumSamples],
|
||||
&pPrivate->pDelay_T[j][pPrivate->T[j]-NumSamples],
|
||||
(LVM_INT16)NumSamples);
|
||||
/* Sum into the AP output */
|
||||
Mac3s_Sat_32x16(&pPrivate->pDelay_T[j][pPrivate->T[j]-NumSamples],
|
||||
0x7fff,
|
||||
pDelayLine,
|
||||
(LVM_INT16)NumSamples);
|
||||
|
||||
/*
|
||||
* Feedback gain
|
||||
*/
|
||||
MixSoft_1St_D32C31_WRA(&pPrivate->FeedbackMixer[j], pDelayLine, pDelayLine, NumSamples);
|
||||
|
||||
/*
|
||||
* Low pass filter
|
||||
*/
|
||||
FO_1I_D32F32C31_TRC_WRA_01( &pPrivate->pFastCoef->RevLPCoefs[j],
|
||||
pDelayLine,
|
||||
pDelayLine,
|
||||
(LVM_INT16)NumSamples);
|
||||
}
|
||||
|
||||
/*
|
||||
* Apply rotation matrix and delay samples
|
||||
*/
|
||||
for(j = 0; j < NumberOfDelayLines; j++)
|
||||
{
|
||||
|
||||
Copy_16( (LVM_INT16*)(pTemp),
|
||||
(LVM_INT16*)(pDelayLineInput),
|
||||
(LVM_INT16)(NumSamples << 1));
|
||||
|
||||
/*
|
||||
* Rotation matrix mix
|
||||
*/
|
||||
switch(j)
|
||||
{
|
||||
case 3:
|
||||
/*
|
||||
* Add delay line 1 and 2 contribution
|
||||
*/
|
||||
Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[1], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
|
||||
Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[2], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
|
||||
|
||||
break;
|
||||
case 2:
|
||||
|
||||
/*
|
||||
* Add delay line 0 and 3 contribution
|
||||
*/
|
||||
Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[0], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
|
||||
Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[3], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
|
||||
|
||||
break;
|
||||
case 1:
|
||||
if(pPrivate->InstanceParams.NumDelays == LVREV_DELAYLINES_4)
|
||||
{
|
||||
/*
|
||||
* Add delay line 0 and 3 contribution
|
||||
*/
|
||||
Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[0], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
|
||||
Add2_Sat_32x32(pPrivate->pScratchDelayLine[3], pDelayLineInput, (LVM_INT16)NumSamples);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Add delay line 0 and 1 contribution
|
||||
*/
|
||||
Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[0], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
|
||||
Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[1], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
|
||||
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
if(pPrivate->InstanceParams.NumDelays == LVREV_DELAYLINES_4)
|
||||
{
|
||||
/*
|
||||
* Add delay line 1 and 2 contribution
|
||||
*/
|
||||
Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[1], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
|
||||
Add2_Sat_32x32(pPrivate->pScratchDelayLine[2], pDelayLineInput, (LVM_INT16)NumSamples);
|
||||
|
||||
}
|
||||
else if(pPrivate->InstanceParams.NumDelays == LVREV_DELAYLINES_2)
|
||||
{
|
||||
/*
|
||||
* Add delay line 0 and 1 contribution
|
||||
*/
|
||||
Add2_Sat_32x32(pPrivate->pScratchDelayLine[0], pDelayLineInput, (LVM_INT16)NumSamples);
|
||||
Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[1], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Add delay line 0 contribution
|
||||
*/
|
||||
|
||||
/* SOURCE DESTINATION*/
|
||||
Add2_Sat_32x32(pPrivate->pScratchDelayLine[0], pDelayLineInput, (LVM_INT16)NumSamples);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Delay samples
|
||||
*/
|
||||
Copy_16((LVM_INT16 *)pDelayLineInput,
|
||||
(LVM_INT16 *)&pPrivate->pDelay_T[j][pPrivate->T[j]-NumSamples],
|
||||
(LVM_INT16)(NumSamples << 1)); /* 32-bit data */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create stereo output
|
||||
*/
|
||||
switch(pPrivate->InstanceParams.NumDelays)
|
||||
{
|
||||
case LVREV_DELAYLINES_4:
|
||||
Add2_Sat_32x32(pPrivate->pScratchDelayLine[3],
|
||||
pPrivate->pScratchDelayLine[0],
|
||||
(LVM_INT16)NumSamples);
|
||||
Add2_Sat_32x32(pPrivate->pScratchDelayLine[2],
|
||||
pPrivate->pScratchDelayLine[1],
|
||||
(LVM_INT16)NumSamples);
|
||||
|
||||
if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
|
||||
{
|
||||
JoinTo2i_32x32(pPrivate->pScratchDelayLine[0],
|
||||
pPrivate->pScratchDelayLine[1],
|
||||
pTemp,
|
||||
(LVM_INT16)NumSamples);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Add2_Sat_32x32(pPrivate->pScratchDelayLine[1],
|
||||
pPrivate->pScratchDelayLine[0],
|
||||
(LVM_INT16)NumSamples);
|
||||
|
||||
/*Apply 3-dB gain in-order to compensate for the gain change in stereo mode*/
|
||||
Mult3s_32x16(pPrivate->pScratchDelayLine[0],
|
||||
LVREV_MIN3DB,
|
||||
pTemp,
|
||||
(LVM_INT16)NumSamples);
|
||||
}
|
||||
break;
|
||||
case LVREV_DELAYLINES_2:
|
||||
|
||||
Copy_16( (LVM_INT16*)pPrivate->pScratchDelayLine[1],
|
||||
(LVM_INT16*)pScratch,
|
||||
(LVM_INT16)(NumSamples << 1));
|
||||
|
||||
|
||||
|
||||
if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
|
||||
{
|
||||
|
||||
Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[0],
|
||||
-0x8000,
|
||||
pScratch,
|
||||
(LVM_INT16)NumSamples);
|
||||
}
|
||||
|
||||
Add2_Sat_32x32(pPrivate->pScratchDelayLine[1],
|
||||
pPrivate->pScratchDelayLine[0],
|
||||
(LVM_INT16)NumSamples);
|
||||
|
||||
|
||||
if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
|
||||
{
|
||||
JoinTo2i_32x32(pPrivate->pScratchDelayLine[0],
|
||||
pScratch,
|
||||
pTemp,
|
||||
(LVM_INT16)NumSamples);
|
||||
}
|
||||
else
|
||||
{
|
||||
Copy_16( (LVM_INT16*)pPrivate->pScratchDelayLine[0],
|
||||
(LVM_INT16*)pTemp,
|
||||
(LVM_INT16)(NumSamples << 1));
|
||||
|
||||
}
|
||||
break;
|
||||
case LVREV_DELAYLINES_1:
|
||||
if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
|
||||
{
|
||||
|
||||
MonoTo2I_32(pPrivate->pScratchDelayLine[0],
|
||||
pTemp,
|
||||
(LVM_INT16)NumSamples);
|
||||
}
|
||||
else
|
||||
{
|
||||
pTemp = pPrivate->pScratchDelayLine[0];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Dry/wet mixer
|
||||
*/
|
||||
if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
|
||||
{
|
||||
size = (LVM_INT16)(NumSamples << 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
size = (LVM_INT16)NumSamples;
|
||||
}
|
||||
|
||||
MixSoft_2St_D32C31_SAT(&pPrivate->BypassMixer,
|
||||
pInput,
|
||||
pTemp,
|
||||
pOutput,
|
||||
size);
|
||||
|
||||
/* Apply Gain*/
|
||||
if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
|
||||
{
|
||||
size = (LVM_INT16)(NumSamples << 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
size = (LVM_INT16)NumSamples;
|
||||
}
|
||||
|
||||
Shift_Sat_v32xv32 (LVREV_OUTPUTGAIN_SHIFT,
|
||||
pOutput,
|
||||
pOutput,
|
||||
size);
|
||||
|
||||
MixSoft_1St_D32C31_WRA(&pPrivate->GainMixer,
|
||||
pOutput,
|
||||
pOutput,
|
||||
size);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* End of file */
|
||||
|
||||
128
media/libeffects/lvm/lib/Reverb/src/LVREV_SetControlParameters.c
Executable file
128
media/libeffects/lvm/lib/Reverb/src/LVREV_SetControlParameters.c
Executable file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2010 NXP Software
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Project:: */
|
||||
/* $Author: nxp007753 $ */
|
||||
/* $Revision: 1316 $ */
|
||||
/* $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $ */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Includes */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
#include "LVREV_Private.h"
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION: LVREV_SetControlParameters */
|
||||
/* */
|
||||
/* DESCRIPTION: */
|
||||
/* Sets or changes the LVREV module parameters. */
|
||||
/* */
|
||||
/* PARAMETERS: */
|
||||
/* hInstance Instance handle */
|
||||
/* pNewParams Pointer to a parameter structure */
|
||||
/* */
|
||||
/* RETURNS: */
|
||||
/* LVM_Success Succeeded */
|
||||
/* LVREV_NULLADDRESS When hInstance or pNewParams is NULL */
|
||||
/* LVREV_OUTOFRANGE When any of the new parameters is out of range */
|
||||
/* */
|
||||
/* NOTES: */
|
||||
/* 1. This function may be interrupted by the LVREV_Process function */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
LVREV_ReturnStatus_en LVREV_SetControlParameters(LVREV_Handle_t hInstance,
|
||||
LVREV_ControlParams_st *pNewParams)
|
||||
{
|
||||
|
||||
LVREV_Instance_st *pLVREV_Private = (LVREV_Instance_st *)hInstance;
|
||||
|
||||
|
||||
/*
|
||||
* Check for error conditions
|
||||
*/
|
||||
if((hInstance == LVM_NULL) || (pNewParams == LVM_NULL))
|
||||
{
|
||||
return LVREV_NULLADDRESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check all new control parameters are in range
|
||||
*/
|
||||
if( ((pNewParams->OperatingMode != LVM_MODE_OFF) && (pNewParams->OperatingMode != LVM_MODE_ON)) ||
|
||||
((pNewParams->SampleRate != LVM_FS_8000) && (pNewParams->SampleRate != LVM_FS_11025) && (pNewParams->SampleRate != LVM_FS_12000) &&
|
||||
(pNewParams->SampleRate != LVM_FS_16000) && (pNewParams->SampleRate != LVM_FS_22050) && (pNewParams->SampleRate != LVM_FS_24000) &&
|
||||
(pNewParams->SampleRate != LVM_FS_32000) && (pNewParams->SampleRate != LVM_FS_44100) && (pNewParams->SampleRate != LVM_FS_48000)) ||
|
||||
((pNewParams->SourceFormat != LVM_STEREO) && (pNewParams->SourceFormat != LVM_MONOINSTEREO) && (pNewParams->SourceFormat != LVM_MONO)) )
|
||||
{
|
||||
return (LVREV_OUTOFRANGE);
|
||||
}
|
||||
|
||||
|
||||
if (pNewParams->Level > LVREV_MAX_LEVEL)
|
||||
{
|
||||
return LVREV_OUTOFRANGE;
|
||||
}
|
||||
|
||||
if ((pNewParams->LPF < LVREV_MIN_LPF_CORNER) || (pNewParams->LPF > LVREV_MAX_LPF_CORNER))
|
||||
{
|
||||
return LVREV_OUTOFRANGE;
|
||||
}
|
||||
|
||||
if ((pNewParams->HPF < LVREV_MIN_HPF_CORNER) || (pNewParams->HPF > LVREV_MAX_HPF_CORNER))
|
||||
{
|
||||
return LVREV_OUTOFRANGE;
|
||||
}
|
||||
|
||||
if (pNewParams->T60 > LVREV_MAX_T60)
|
||||
{
|
||||
return LVREV_OUTOFRANGE;
|
||||
}
|
||||
|
||||
if (pNewParams->Density > LVREV_MAX_DENSITY)
|
||||
{
|
||||
return LVREV_OUTOFRANGE;
|
||||
}
|
||||
|
||||
if (pNewParams->Damping > LVREV_MAX_DAMPING)
|
||||
{
|
||||
return LVREV_OUTOFRANGE;
|
||||
}
|
||||
|
||||
if (pNewParams->RoomSize > LVREV_MAX_ROOMSIZE)
|
||||
{
|
||||
return LVREV_OUTOFRANGE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Copy the new parameters and set the flag to indicate they are available
|
||||
*/
|
||||
pLVREV_Private->NewParams = *pNewParams;
|
||||
pLVREV_Private->bControlPending = LVM_TRUE;
|
||||
|
||||
return LVREV_SUCCESS;
|
||||
}
|
||||
|
||||
/* End of file */
|
||||
108
media/libeffects/lvm/lib/Reverb/src/LVREV_Tables.c
Executable file
108
media/libeffects/lvm/lib/Reverb/src/LVREV_Tables.c
Executable file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2010 NXP Software
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Project:: */
|
||||
/* $Author: beq07716 $ */
|
||||
/* $Revision: 1011 $ */
|
||||
/* $Date: 2010-06-28 15:07:08 +0200 (Mon, 28 Jun 2010) $ */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Includes */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
#include "LVREV.h"
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Tables */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
/* Table with supported sampling rates. The table can be indexed using LVM_Fs_en */
|
||||
const LVM_UINT16 LVM_FsTable[] = {
|
||||
8000 ,
|
||||
11025,
|
||||
12000,
|
||||
16000,
|
||||
22050,
|
||||
24000,
|
||||
32000,
|
||||
44100,
|
||||
48000
|
||||
};
|
||||
|
||||
/* Table with supported sampling rates. The table can be indexed using LVM_Fs_en */
|
||||
LVM_UINT16 LVM_GetFsFromTable(LVM_Fs_en FsIndex){
|
||||
if (FsIndex > LVM_FS_48000)
|
||||
return 0;
|
||||
|
||||
return (LVM_FsTable[FsIndex]);
|
||||
}
|
||||
|
||||
/* In order to maintain consistant input and out put signal strengths
|
||||
output gain/attenuation is applied. This gain depends on T60 and Rooms
|
||||
size parameters. These polynomial coefficients are calculated experimentally.
|
||||
First value in the table is room size
|
||||
second value is A0
|
||||
third value is A1
|
||||
fourth value is A2
|
||||
fifth value is A3
|
||||
sixth value is A4
|
||||
|
||||
shift value is to be added array (to use LVM_Polynomial function)
|
||||
|
||||
The gain is calculated using variable x=(T60*32767/7000)*32768;
|
||||
|
||||
first values is used to get polynomial set for given room size,
|
||||
For room sizes which are not in the table, linear interpolation can be used.
|
||||
|
||||
*/
|
||||
|
||||
/* Normalizing output including Reverb Level part (only shift up)*/
|
||||
const LVM_INT32 LVREV_GainPolyTable[24][5]={{1,17547434,128867434,-120988896,50761228,},
|
||||
{2,18256869,172666902,-193169292,88345744,},
|
||||
{3,16591311,139250151,-149667234,66770059,},
|
||||
{4,17379977,170835131,-173579321,76278163,},
|
||||
{5,18963512,210364934,-228623519,103435022,},
|
||||
{6,17796318,135756417,-144084053,64327698,},
|
||||
{7,17454695,174593214,-187513064,85146582,},
|
||||
{8,17229257,140715570,-145790588,65361740,},
|
||||
{9,17000547,163195946,-176733969,79562130,},
|
||||
{10,16711699,142476304,-133339887,58366547,},
|
||||
{13,18108419,149223697,-161762020,74397589,},
|
||||
{15,16682043,124844884,-134284487,60082180,},
|
||||
{17,16627346,120936430,-121766674,53146421,},
|
||||
{20,17338325,125432694,-126616983,56534237,},
|
||||
{25,16489146,99218217,-94597467,40616506,},
|
||||
{30,15582373,84479043,-75365006,30952348,},
|
||||
{40,16000669,84896611,-75031127,30696306,},
|
||||
{50,15087054,71695031,-59349268,23279669,},
|
||||
{60,15830714,68672971,-58211201,23671158,},
|
||||
{70,15536061,66657972,-55901437,22560153,},
|
||||
{75,15013145,48179917,-24138354,5232074,},
|
||||
{80,15688738,50195036,-34206760,11515792,},
|
||||
{90,16003322,48323661,-35607378,13153872,},
|
||||
{100,15955223,48558201,-33706865,11715792,},
|
||||
};
|
||||
|
||||
/* End of file */
|
||||
|
||||
59
media/libeffects/lvm/lib/Reverb/src/LVREV_Tables.h
Executable file
59
media/libeffects/lvm/lib/Reverb/src/LVREV_Tables.h
Executable file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2010 NXP Software
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Project:: */
|
||||
/* $Author: beq07716 $ */
|
||||
/* $Revision: 773 $ */
|
||||
/* $Date: 2010-06-14 10:43:54 +0200 (Mon, 14 Jun 2010) $ */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
|
||||
#ifndef _LVREV_TABLES_H_
|
||||
#define _LVREV_TABLES_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Includes */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
#include "LVREV_Private.h"
|
||||
|
||||
/****************************************************************************************/
|
||||
/* */
|
||||
/* Definitions */
|
||||
/* */
|
||||
/****************************************************************************************/
|
||||
|
||||
extern const LVM_UINT16 LVM_FsTable[];
|
||||
extern LVM_UINT16 LVM_GetFsFromTable(LVM_Fs_en FsIndex);
|
||||
extern LVM_INT32 LVREV_GainPolyTable[24][5];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /** _LVREV_TABLES_H_ **/
|
||||
|
||||
/* End of file */
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
/************************************************************************************
|
||||
|
||||
$Author: beq06068 $
|
||||
$Revision: 1307 $
|
||||
$Date: 2010-07-22 17:41:25 +0200 (Thu, 22 Jul 2010) $
|
||||
$Author: nxp007753 $
|
||||
$Revision: 1331 $
|
||||
$Date: 2010-07-27 12:26:23 +0200 (Tue, 27 Jul 2010) $
|
||||
|
||||
*************************************************************************************/
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
/************************************************************************************
|
||||
|
||||
$Author: nxp007753 $
|
||||
$Revision: 1315 $
|
||||
$Date: 2010-07-23 11:52:08 +0200 (Fri, 23 Jul 2010) $
|
||||
$Revision: 1331 $
|
||||
$Date: 2010-07-27 12:26:23 +0200 (Tue, 27 Jul 2010) $
|
||||
|
||||
*************************************************************************************/
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
/************************************************************************************
|
||||
|
||||
$Author: beq06068 $
|
||||
$Revision: 1307 $
|
||||
$Date: 2010-07-22 17:41:25 +0200 (Thu, 22 Jul 2010) $
|
||||
$Author: nxp007753 $
|
||||
$Revision: 1331 $
|
||||
$Date: 2010-07-27 12:26:23 +0200 (Tue, 27 Jul 2010) $
|
||||
|
||||
*************************************************************************************/
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
/************************************************************************************
|
||||
|
||||
$Author: nxp007753 $
|
||||
$Revision: 1315 $
|
||||
$Date: 2010-07-23 11:52:08 +0200 (Fri, 23 Jul 2010) $
|
||||
$Revision: 1331 $
|
||||
$Date: 2010-07-27 12:26:23 +0200 (Tue, 27 Jul 2010) $
|
||||
|
||||
*************************************************************************************/
|
||||
|
||||
|
||||
@@ -34,3 +34,36 @@ LOCAL_C_INCLUDES += \
|
||||
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
# reverb wrapper
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_ARM_MODE := arm
|
||||
|
||||
LOCAL_SRC_FILES:= \
|
||||
Reverb/EffectReverb.cpp
|
||||
|
||||
LOCAL_MODULE:= libreverbwrapper
|
||||
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx
|
||||
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
|
||||
LOCAL_STATIC_LIBRARIES += libreverb
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libcutils \
|
||||
|
||||
ifeq ($(TARGET_SIMULATOR),true)
|
||||
LOCAL_LDLIBS += -ldl
|
||||
else
|
||||
LOCAL_SHARED_LIBRARIES += libdl
|
||||
endif
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(LOCAL_PATH)/Reverb \
|
||||
$(LOCAL_PATH)/../lib/Common/lib/ \
|
||||
$(LOCAL_PATH)/../lib/Reverb/lib/ \
|
||||
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
@@ -66,7 +66,9 @@ namespace {
|
||||
|
||||
// Flag to allow a one time init of global memory, only happens on first call ever
|
||||
int LvmInitFlag = LVM_FALSE;
|
||||
SessionContext GlobalSessionMemory[32];
|
||||
int LvmSessionsActive = 0;
|
||||
SessionContext GlobalSessionMemory[LVM_MAX_SESSIONS];
|
||||
int SessionIndex[LVM_MAX_SESSIONS];
|
||||
|
||||
// NXP SW BassBoost UUID
|
||||
const effect_descriptor_t gBassBoostDescriptor = {
|
||||
@@ -125,24 +127,24 @@ int LvmEffect_enable (EffectContext *pContext);
|
||||
int LvmEffect_disable (EffectContext *pContext);
|
||||
void LvmEffect_free (EffectContext *pContext);
|
||||
int Effect_configure (EffectContext *pContext, effect_config_t *pConfig);
|
||||
int BassBoost_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue);
|
||||
int BassBoost_setParameter (EffectContext *pContext, void *pParam, void *pValue);
|
||||
int BassBoost_getParameter (EffectContext *pContext,
|
||||
int32_t *pParam,
|
||||
void *pParam,
|
||||
size_t *pValueSize,
|
||||
void *pValue);
|
||||
int Virtualizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue);
|
||||
int Virtualizer_setParameter (EffectContext *pContext, void *pParam, void *pValue);
|
||||
int Virtualizer_getParameter (EffectContext *pContext,
|
||||
int32_t *pParam,
|
||||
void *pParam,
|
||||
size_t *pValueSize,
|
||||
void *pValue);
|
||||
int Equalizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue);
|
||||
int Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue);
|
||||
int Equalizer_getParameter (EffectContext *pContext,
|
||||
int32_t *pParam,
|
||||
void *pParam,
|
||||
size_t *pValueSize,
|
||||
void *pValue);
|
||||
int Volume_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue);
|
||||
int Volume_setParameter (EffectContext *pContext, void *pParam, void *pValue);
|
||||
int Volume_getParameter (EffectContext *pContext,
|
||||
int32_t *pParam,
|
||||
void *pParam,
|
||||
size_t *pValueSize,
|
||||
void *pValue);
|
||||
|
||||
@@ -189,6 +191,7 @@ extern "C" int EffectCreate(effect_uuid_t *uuid,
|
||||
int32_t ioId,
|
||||
effect_interface_t *pInterface){
|
||||
int ret;
|
||||
int sessionNo;
|
||||
int i;
|
||||
EffectContext *pContext = new EffectContext;
|
||||
|
||||
@@ -199,7 +202,7 @@ extern "C" int EffectCreate(effect_uuid_t *uuid,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if((sessionId < 0)||(sessionId >= LVM_MAX_SESSIONS)){
|
||||
if(sessionId < 0){
|
||||
LOGV("\tLVM_ERROR : EffectCreate sessionId is less than 0");
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -210,16 +213,41 @@ extern "C" int EffectCreate(effect_uuid_t *uuid,
|
||||
LvmGlobalBundle_init();
|
||||
}
|
||||
|
||||
LOGV("\tEffectCreate: There are %d LVM sessions acive\n", LvmSessionsActive);
|
||||
|
||||
// Find next available sessionNo
|
||||
for(i=0; i<LVM_MAX_SESSIONS; i++){
|
||||
if((SessionIndex[i] == -1)||(SessionIndex[i] == sessionId)){
|
||||
sessionNo = i;
|
||||
SessionIndex[i] = sessionId;
|
||||
LOGV("\tEffectCreate: Allocating SessionNo %d for SessionId %d\n", sessionNo,sessionId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(i==LVM_MAX_SESSIONS){
|
||||
LOGV("\tLVM_ERROR : Cannot find memory to allocate for current session");
|
||||
return -EINVAL;
|
||||
}
|
||||
// If this is the first create in this session
|
||||
if(GlobalSessionMemory[sessionId].bBundledEffectsEnabled == LVM_FALSE){
|
||||
LOGV("\tEffectCreate - This is the first effect in current session %d", sessionId);
|
||||
LOGV("\tEffectCreate - Setting up Bundled Effects Instance for session %d", sessionId);
|
||||
if(GlobalSessionMemory[sessionNo].bBundledEffectsEnabled == LVM_FALSE){
|
||||
LOGV("\tEffectCreate - This is the first effect in current sessionId %d sessionNo %d",
|
||||
sessionId, sessionNo);
|
||||
|
||||
GlobalSessionMemory[sessionId].bBundledEffectsEnabled = LVM_TRUE;
|
||||
GlobalSessionMemory[sessionId].pBundledContext = new BundledEffectContext;
|
||||
LvmSessionsActive++;
|
||||
|
||||
pContext->pBundledContext = GlobalSessionMemory[sessionId].pBundledContext;
|
||||
pContext->pBundledContext->SessionNo = sessionId;
|
||||
if(LvmSessionsActive >= LVM_MAX_SESSIONS){
|
||||
LOGV("\tLVM_ERROR : Number of active session is greater than LVM_MAX_SESSIONS (%d)",
|
||||
LVM_MAX_SESSIONS);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
GlobalSessionMemory[sessionNo].bBundledEffectsEnabled = LVM_TRUE;
|
||||
GlobalSessionMemory[sessionNo].pBundledContext = new BundledEffectContext;
|
||||
|
||||
pContext->pBundledContext = GlobalSessionMemory[sessionNo].pBundledContext;
|
||||
pContext->pBundledContext->SessionNo = sessionNo;
|
||||
pContext->pBundledContext->SessionId = sessionId;
|
||||
pContext->pBundledContext->hInstance = NULL;
|
||||
pContext->pBundledContext->bVolumeEnabled = LVM_FALSE;
|
||||
pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE;
|
||||
@@ -267,37 +295,39 @@ extern "C" int EffectCreate(effect_uuid_t *uuid,
|
||||
}
|
||||
}
|
||||
else{
|
||||
pContext->pBundledContext = GlobalSessionMemory[sessionId].pBundledContext;
|
||||
LOGV("\tEffectCreate - Assigning memory for previously created effect on sessionNo %d",
|
||||
sessionNo);
|
||||
pContext->pBundledContext =
|
||||
GlobalSessionMemory[sessionNo].pBundledContext;
|
||||
}
|
||||
|
||||
LOGV("\tEffectCreate - pBundledContext is %p", pContext->pBundledContext);
|
||||
|
||||
// Create each Effect
|
||||
if (memcmp(uuid, &gBassBoostDescriptor.uuid, sizeof(effect_uuid_t)) == 0){
|
||||
// Create Bass Boost
|
||||
LOGV("\tEffectCreate - Effect to be created is LVM_BASS_BOOST");
|
||||
GlobalSessionMemory[sessionId].bBassInstantiated = LVM_TRUE;
|
||||
GlobalSessionMemory[pContext->pBundledContext->SessionNo].bBassInstantiated = LVM_TRUE;
|
||||
|
||||
pContext->itfe = &gLvmEffectInterface;
|
||||
pContext->EffectType = LVM_BASS_BOOST;
|
||||
} else if (memcmp(uuid, &gVirtualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){
|
||||
// Create Virtualizer
|
||||
LOGV("\tEffectCreate - Effect to be created is LVM_VIRTUALIZER");
|
||||
GlobalSessionMemory[sessionId].bVirtualizerInstantiated = LVM_TRUE;
|
||||
GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVirtualizerInstantiated=LVM_TRUE;
|
||||
|
||||
pContext->itfe = &gLvmEffectInterface;
|
||||
pContext->EffectType = LVM_VIRTUALIZER;
|
||||
} else if (memcmp(uuid, &gEqualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){
|
||||
// Create Equalizer
|
||||
LOGV("\tEffectCreate - Effect to be created is LVM_EQUALIZER");
|
||||
GlobalSessionMemory[sessionId].bEqualizerInstantiated = LVM_TRUE;
|
||||
GlobalSessionMemory[pContext->pBundledContext->SessionNo].bEqualizerInstantiated = LVM_TRUE;
|
||||
|
||||
pContext->itfe = &gLvmEffectInterface;
|
||||
pContext->EffectType = LVM_EQUALIZER;
|
||||
} else if (memcmp(uuid, &gVolumeDescriptor.uuid, sizeof(effect_uuid_t)) == 0){
|
||||
// Create Volume
|
||||
LOGV("\tEffectCreate - Effect to be created is LVM_VOLUME");
|
||||
GlobalSessionMemory[sessionId].bVolumeInstantiated = LVM_TRUE;
|
||||
GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVolumeInstantiated = LVM_TRUE;
|
||||
|
||||
pContext->itfe = &gLvmEffectInterface;
|
||||
pContext->EffectType = LVM_VOLUME;
|
||||
@@ -316,6 +346,7 @@ extern "C" int EffectRelease(effect_interface_t interface){
|
||||
LOGV("\n\tEffectRelease start %p", interface);
|
||||
EffectContext * pContext = (EffectContext *)interface;
|
||||
|
||||
LOGV("\n\tEffectRelease start interface: %p, context %p", interface, pContext->pBundledContext);
|
||||
if (pContext == NULL){
|
||||
LOGV("\tLVM_ERROR : EffectRelease called with NULL pointer");
|
||||
return -EINVAL;
|
||||
@@ -349,13 +380,28 @@ extern "C" int EffectRelease(effect_interface_t interface){
|
||||
fclose(pContext->pBundledContext->PcmInPtr);
|
||||
fclose(pContext->pBundledContext->PcmOutPtr);
|
||||
#endif
|
||||
|
||||
LvmSessionsActive--;
|
||||
LOGV("\tEffectRelease: There are %d LVM sessions remaining\n", LvmSessionsActive);
|
||||
|
||||
// Clear the SessionIndex
|
||||
for(int i=0; i<LVM_MAX_SESSIONS; i++){
|
||||
if(SessionIndex[i] == pContext->pBundledContext->SessionId){
|
||||
SessionIndex[i] = -1;
|
||||
LOGV("\tEffectRelease: Clearing SessionIndex SessionNo %d for SessionId %d\n",
|
||||
i, pContext->pBundledContext->SessionId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LOGV("\tEffectRelease: All effects are no longer instantiated\n");
|
||||
GlobalSessionMemory[pContext->pBundledContext->SessionNo].bBundledEffectsEnabled =LVM_FALSE;
|
||||
GlobalSessionMemory[pContext->pBundledContext->SessionNo].pBundledContext = LVM_NULL;
|
||||
LOGV("\tEffectRelease: Freeing LVM Bundle memory\n");
|
||||
LvmEffect_free(pContext);
|
||||
LOGV("\tEffectRelease: Deleting LVM Bundle context\n");
|
||||
LOGV("\tEffectRelease: Deleting LVM Bundle context %p\n", pContext->pBundledContext);
|
||||
delete pContext->pBundledContext;
|
||||
pContext->pBundledContext = LVM_NULL;
|
||||
}
|
||||
// free the effect context for current effect
|
||||
delete pContext;
|
||||
@@ -374,6 +420,8 @@ void LvmGlobalBundle_init(){
|
||||
GlobalSessionMemory[i].bBassInstantiated = LVM_FALSE;
|
||||
GlobalSessionMemory[i].bVirtualizerInstantiated = LVM_FALSE;
|
||||
GlobalSessionMemory[i].pBundledContext = LVM_NULL;
|
||||
|
||||
SessionIndex[i] = -1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -505,6 +553,9 @@ int LvmBundle_init(EffectContext *pContext){
|
||||
params.SpeakerType = LVM_HEADPHONES;
|
||||
|
||||
pContext->pBundledContext->SampleRate = LVM_FS_44100;
|
||||
pContext->pBundledContext->SamplesToExitCountEq = 44100*2*2; // 2 secs Stereo
|
||||
pContext->pBundledContext->SamplesToExitCountBb = 44100*2*2; // 2 secs Stereo
|
||||
pContext->pBundledContext->SamplesToExitCountVirt = 44100*2*2; // 2 secs Stereo
|
||||
|
||||
/* Concert Sound parameters */
|
||||
params.VirtualizerOperatingMode = LVM_MODE_OFF;
|
||||
@@ -842,21 +893,27 @@ int Effect_configure(EffectContext *pContext, effect_config_t *pConfig){
|
||||
switch (pConfig->inputCfg.samplingRate) {
|
||||
case 8000:
|
||||
SampleRate = LVM_FS_8000;
|
||||
pContext->pBundledContext->SamplesPerSecond = 8000*2; // 2 secs Stereo
|
||||
break;
|
||||
case 16000:
|
||||
SampleRate = LVM_FS_16000;
|
||||
pContext->pBundledContext->SamplesPerSecond = 16000*2; // 2 secs Stereo
|
||||
break;
|
||||
case 22050:
|
||||
SampleRate = LVM_FS_22050;
|
||||
pContext->pBundledContext->SamplesPerSecond = 22050*2; // 2 secs Stereo
|
||||
break;
|
||||
case 32000:
|
||||
SampleRate = LVM_FS_32000;
|
||||
pContext->pBundledContext->SamplesPerSecond = 32000*2; // 2 secs Stereo
|
||||
break;
|
||||
case 44100:
|
||||
SampleRate = LVM_FS_44100;
|
||||
pContext->pBundledContext->SamplesPerSecond = 44100*2; // 2 secs Stereo
|
||||
break;
|
||||
case 48000:
|
||||
SampleRate = LVM_FS_48000;
|
||||
pContext->pBundledContext->SamplesPerSecond = 48000*2; // 2 secs Stereo
|
||||
break;
|
||||
default:
|
||||
LOGV("\tEffect_Configure invalid sampling rate %d", pConfig->inputCfg.samplingRate);
|
||||
@@ -881,6 +938,7 @@ int Effect_configure(EffectContext *pContext, effect_config_t *pConfig){
|
||||
|
||||
LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "Effect_configure")
|
||||
LOGV("\tEffect_configure Succesfully called LVM_SetControlParameters\n");
|
||||
pContext->pBundledContext->SampleRate = SampleRate;
|
||||
|
||||
}else{
|
||||
//LOGV("\tEffect_configure keep sampling rate at %d", SampleRate);
|
||||
@@ -1461,7 +1519,7 @@ int VolumeSetStereoPosition(EffectContext *pContext, int16_t position){
|
||||
LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */
|
||||
LVM_INT16 Balance = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
pContext->pBundledContext->positionSaved = position;
|
||||
Balance = VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved);
|
||||
@@ -1614,11 +1672,12 @@ int32_t VolumeEnableStereoPosition(EffectContext *pContext, uint32_t enabled){
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
int BassBoost_getParameter(EffectContext *pContext,
|
||||
int32_t *pParam,
|
||||
void *pParam,
|
||||
size_t *pValueSize,
|
||||
void *pValue){
|
||||
int status = 0;
|
||||
int32_t param = *pParam++;
|
||||
int32_t *pParamTemp = (int32_t *)pParam;
|
||||
int32_t param = *pParamTemp++;
|
||||
int32_t param2;
|
||||
char *name;
|
||||
|
||||
@@ -1685,13 +1744,14 @@ int BassBoost_getParameter(EffectContext *pContext,
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
int BassBoost_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){
|
||||
int BassBoost_setParameter (EffectContext *pContext, void *pParam, void *pValue){
|
||||
int status = 0;
|
||||
int16_t strength;
|
||||
int32_t *pParamTemp = (int32_t *)pParam;
|
||||
|
||||
//LOGV("\tBassBoost_setParameter start");
|
||||
|
||||
switch (*pParam){
|
||||
switch (*pParamTemp){
|
||||
case BASSBOOST_PARAM_STRENGTH:
|
||||
strength = *(int16_t *)pValue;
|
||||
//LOGV("\tBassBoost_setParameter() BASSBOOST_PARAM_STRENGTH value is %d", strength);
|
||||
@@ -1700,7 +1760,7 @@ int BassBoost_setParameter (EffectContext *pContext, int32_t *pParam, void *pVal
|
||||
//LOGV("\tBassBoost_setParameter() Called pBassBoost->BassSetStrength");
|
||||
break;
|
||||
default:
|
||||
LOGV("\tLVM_ERROR : BassBoost_setParameter() invalid param %d", *pParam);
|
||||
LOGV("\tLVM_ERROR : BassBoost_setParameter() invalid param %d", *pParamTemp);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1730,11 +1790,12 @@ int BassBoost_setParameter (EffectContext *pContext, int32_t *pParam, void *pVal
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
int Virtualizer_getParameter(EffectContext *pContext,
|
||||
int32_t *pParam,
|
||||
void *pParam,
|
||||
size_t *pValueSize,
|
||||
void *pValue){
|
||||
int status = 0;
|
||||
int32_t param = *pParam++;
|
||||
int32_t *pParamTemp = (int32_t *)pParam;
|
||||
int32_t param = *pParamTemp++;
|
||||
int32_t param2;
|
||||
char *name;
|
||||
|
||||
@@ -1802,13 +1863,15 @@ int Virtualizer_getParameter(EffectContext *pContext,
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
int Virtualizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){
|
||||
int Virtualizer_setParameter (EffectContext *pContext, void *pParam, void *pValue){
|
||||
int status = 0;
|
||||
int16_t strength;
|
||||
int32_t *pParamTemp = (int32_t *)pParam;
|
||||
int32_t param = *pParamTemp++;
|
||||
|
||||
//LOGV("\tVirtualizer_setParameter start");
|
||||
|
||||
switch (*pParam){
|
||||
switch (param){
|
||||
case VIRTUALIZER_PARAM_STRENGTH:
|
||||
strength = *(int16_t *)pValue;
|
||||
//LOGV("\tVirtualizer_setParameter() VIRTUALIZER_PARAM_STRENGTH value is %d", strength);
|
||||
@@ -1817,7 +1880,7 @@ int Virtualizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pV
|
||||
//LOGV("\tVirtualizer_setParameter() Called pVirtualizer->setStrength");
|
||||
break;
|
||||
default:
|
||||
LOGV("\tLVM_ERROR : Virtualizer_setParameter() invalid param %d", *pParam);
|
||||
LOGV("\tLVM_ERROR : Virtualizer_setParameter() invalid param %d", param);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1846,12 +1909,13 @@ int Virtualizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pV
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
int Equalizer_getParameter(EffectContext *pContext,
|
||||
int32_t *pParam,
|
||||
void *pParam,
|
||||
size_t *pValueSize,
|
||||
void *pValue){
|
||||
int status = 0;
|
||||
int bMute = 0;
|
||||
int32_t param = *pParam++;
|
||||
int32_t *pParamTemp = (int32_t *)pParam;
|
||||
int32_t param = *pParamTemp++;
|
||||
int32_t param2;
|
||||
char *name;
|
||||
|
||||
@@ -1924,7 +1988,7 @@ int Equalizer_getParameter(EffectContext *pContext,
|
||||
break;
|
||||
|
||||
case EQ_PARAM_BAND_LEVEL:
|
||||
param2 = *pParam;
|
||||
param2 = *pParamTemp;
|
||||
if (param2 >= FIVEBAND_NUMBANDS) {
|
||||
status = -EINVAL;
|
||||
break;
|
||||
@@ -1935,7 +1999,7 @@ int Equalizer_getParameter(EffectContext *pContext,
|
||||
break;
|
||||
|
||||
case EQ_PARAM_CENTER_FREQ:
|
||||
param2 = *pParam;
|
||||
param2 = *pParamTemp;
|
||||
if (param2 >= FIVEBAND_NUMBANDS) {
|
||||
status = -EINVAL;
|
||||
break;
|
||||
@@ -1946,7 +2010,7 @@ int Equalizer_getParameter(EffectContext *pContext,
|
||||
break;
|
||||
|
||||
case EQ_PARAM_BAND_FREQ_RANGE:
|
||||
param2 = *pParam;
|
||||
param2 = *pParamTemp;
|
||||
if (param2 >= FIVEBAND_NUMBANDS) {
|
||||
status = -EINVAL;
|
||||
break;
|
||||
@@ -1957,7 +2021,7 @@ int Equalizer_getParameter(EffectContext *pContext,
|
||||
break;
|
||||
|
||||
case EQ_PARAM_GET_BAND:
|
||||
param2 = *pParam;
|
||||
param2 = *pParamTemp;
|
||||
*(uint16_t *)pValue = (uint16_t)EqualizerGetBand(pContext, param2);
|
||||
//LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d",
|
||||
// param2, *(int32_t *)pValue);
|
||||
@@ -1974,7 +2038,7 @@ int Equalizer_getParameter(EffectContext *pContext,
|
||||
break;
|
||||
|
||||
case EQ_PARAM_GET_PRESET_NAME:
|
||||
param2 = *pParam;
|
||||
param2 = *pParamTemp;
|
||||
if (param2 >= EqualizerGetNumPresets()) {
|
||||
//if (param2 >= 20) { // AGO FIX
|
||||
status = -EINVAL;
|
||||
@@ -2022,12 +2086,14 @@ int Equalizer_getParameter(EffectContext *pContext,
|
||||
// Outputs:
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
int Equalizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){
|
||||
int Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue){
|
||||
int status = 0;
|
||||
int32_t preset;
|
||||
int32_t band;
|
||||
int32_t level;
|
||||
int32_t param = *pParam++;
|
||||
int32_t *pParamTemp = (int32_t *)pParam;
|
||||
int32_t param = *pParamTemp++;
|
||||
|
||||
|
||||
//LOGV("\tEqualizer_setParameter start");
|
||||
switch (param) {
|
||||
@@ -2042,7 +2108,7 @@ int Equalizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pVal
|
||||
EqualizerSetPreset(pContext, preset);
|
||||
break;
|
||||
case EQ_PARAM_BAND_LEVEL:
|
||||
band = *pParam;
|
||||
band = *pParamTemp;
|
||||
level = (int32_t)(*(int16_t *)pValue);
|
||||
//LOGV("\tEqualizer_setParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", band, level);
|
||||
if (band >= FIVEBAND_NUMBANDS) {
|
||||
@@ -2102,13 +2168,13 @@ int Equalizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pVal
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
int Volume_getParameter(EffectContext *pContext,
|
||||
int32_t *pParam,
|
||||
void *pParam,
|
||||
size_t *pValueSize,
|
||||
void *pValue){
|
||||
int status = 0;
|
||||
int bMute = 0;
|
||||
int32_t param = *pParam++;
|
||||
int32_t param2;
|
||||
int32_t *pParamTemp = (int32_t *)pParam;
|
||||
int32_t param = *pParamTemp++;;
|
||||
char *name;
|
||||
|
||||
LOGV("\tVolume_getParameter start");
|
||||
@@ -2195,16 +2261,18 @@ int Volume_getParameter(EffectContext *pContext,
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
int Volume_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){
|
||||
int Volume_setParameter (EffectContext *pContext, void *pParam, void *pValue){
|
||||
int status = 0;
|
||||
int16_t level;
|
||||
int16_t position;
|
||||
uint32_t mute;
|
||||
uint32_t positionEnabled;
|
||||
int32_t *pParamTemp = (int32_t *)pParam;
|
||||
int32_t param = *pParamTemp++;
|
||||
|
||||
LOGV("\tVolume_setParameter start");
|
||||
|
||||
switch (*pParam){
|
||||
switch (param){
|
||||
case VOLUME_PARAM_LEVEL:
|
||||
level = *(int16_t *)pValue;
|
||||
LOGV("\tVolume_setParameter() VOLUME_PARAM_LEVEL value is %d", level);
|
||||
@@ -2237,7 +2305,7 @@ int Volume_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue)
|
||||
break;
|
||||
|
||||
default:
|
||||
LOGV("\tLVM_ERROR : Volume_setParameter() invalid param %d", *pParam);
|
||||
LOGV("\tLVM_ERROR : Volume_setParameter() invalid param %d", param);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2299,13 +2367,27 @@ extern "C" int Effect_process(effect_interface_t self,
|
||||
audio_buffer_t *inBuffer,
|
||||
audio_buffer_t *outBuffer){
|
||||
EffectContext * pContext = (EffectContext *) self;
|
||||
LVM_ControlParams_t ActiveParams; /* Current control Parameters */
|
||||
LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */
|
||||
int status = 0;
|
||||
int status2Sec = 0;
|
||||
int lvmStatus = 0;
|
||||
LVM_INT16 *in = (LVM_INT16 *)inBuffer->raw;
|
||||
LVM_INT16 *out = (LVM_INT16 *)outBuffer->raw;
|
||||
|
||||
//LOGV("\tEffect_process Start : Enabled = %d Called = %d",
|
||||
//pContext->pBundledContext->NumberEffectsEnabled,pContext->pBundledContext->NumberEffectsCalled);
|
||||
// LOGV("\tEffect_process Start : Samples left %d %d %d",
|
||||
// pContext->pBundledContext->SamplesToExitCountBb,
|
||||
// pContext->pBundledContext->SamplesToExitCountVirt,
|
||||
// pContext->pBundledContext->SamplesToExitCountEq);
|
||||
|
||||
// LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
|
||||
// LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeGetStereoPosition")
|
||||
// if(LvmStatus != LVM_SUCCESS) return -EINVAL;
|
||||
// LOGV("\tEffect_process Internal Operating Modes: BB %d VIRT %d EQ %d",
|
||||
// ActiveParams.BE_OperatingMode, ActiveParams.VirtualizerOperatingMode,
|
||||
// ActiveParams.EQNB_OperatingMode);
|
||||
|
||||
if (pContext == NULL){
|
||||
LOGV("\tLVM_ERROR : Effect_process() ERROR pContext == NULL");
|
||||
@@ -2319,23 +2401,44 @@ extern "C" int Effect_process(effect_interface_t self,
|
||||
}
|
||||
if ((pContext->pBundledContext->bBassEnabled == LVM_FALSE)&&
|
||||
(pContext->EffectType == LVM_BASS_BOOST)){
|
||||
LOGV("\tEffect_process() ERROR LVM_BASS_BOOST Effect is not enabled");
|
||||
//LOGV("\tEffect_process() LVM_BASS_BOOST Effect is not enabled");
|
||||
if(pContext->pBundledContext->SamplesToExitCountBb > 0){
|
||||
status2Sec = -ENODATA;
|
||||
pContext->pBundledContext->SamplesToExitCountBb -= outBuffer->frameCount * 2; // STEREO
|
||||
//LOGV("\tEffect_process: Waiting for 2 secs to turn off BASS_BOOST, %d samples left",
|
||||
// pContext->pBundledContext->SamplesToExitCountBb);
|
||||
} else {
|
||||
status = -ENODATA;
|
||||
}
|
||||
}
|
||||
if ((pContext->pBundledContext->bVolumeEnabled == LVM_FALSE)&&
|
||||
(pContext->EffectType == LVM_VOLUME)){
|
||||
LOGV("\tEffect_process() ERROR LVM_VOLUME Effect is not enabled");
|
||||
//LOGV("\tEffect_process() LVM_VOLUME Effect is not enabled");
|
||||
status = -ENODATA;
|
||||
}
|
||||
if ((pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE)&&
|
||||
(pContext->EffectType == LVM_EQUALIZER)){
|
||||
LOGV("\tEffect_process() ERROR LVM_EQUALIZER Effect is not enabled");
|
||||
status = -ENODATA;
|
||||
//LOGV("\tEffect_process() LVM_EQUALIZER Effect is not enabled");
|
||||
if(pContext->pBundledContext->SamplesToExitCountEq > 0){
|
||||
status2Sec = -ENODATA;
|
||||
pContext->pBundledContext->SamplesToExitCountEq -= outBuffer->frameCount * 2; // STEREO
|
||||
//LOGV("\tEffect_process: Waiting for 2 secs to turn off EQUALIZER, %d samples left",
|
||||
// pContext->pBundledContext->SamplesToExitCountEq);
|
||||
} else {
|
||||
status = -ENODATA;
|
||||
}
|
||||
}
|
||||
if ((pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE)&&
|
||||
(pContext->EffectType == LVM_VIRTUALIZER)){
|
||||
LOGV("\tEffect_process() ERROR LVM_VIRTUALIZER Effect is not enabled");
|
||||
status = -ENODATA;
|
||||
//LOGV("\tEffect_process() LVM_VIRTUALIZER Effect is not enabled");
|
||||
if(pContext->pBundledContext->SamplesToExitCountVirt > 0){
|
||||
status2Sec = -ENODATA;
|
||||
pContext->pBundledContext->SamplesToExitCountVirt -= outBuffer->frameCount * 2;// STEREO
|
||||
//LOGV("\tEffect_process: Waiting for 2 secs to turn off VIRTUALIZER, %d samples left",
|
||||
// pContext->pBundledContext->SamplesToExitCountVirt);
|
||||
} else {
|
||||
status = -ENODATA;
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the last frame of an effect process its output with no effect
|
||||
@@ -2352,7 +2455,7 @@ extern "C" int Effect_process(effect_interface_t self,
|
||||
}
|
||||
}
|
||||
|
||||
if(status != -ENODATA){
|
||||
if((status2Sec != -ENODATA)&&(status != -ENODATA)){
|
||||
pContext->pBundledContext->NumberEffectsCalled++;
|
||||
}
|
||||
|
||||
@@ -2496,7 +2599,7 @@ extern "C" int Effect_command(effect_interface_t self,
|
||||
int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
|
||||
|
||||
p->status = android::BassBoost_getParameter(pContext,
|
||||
(int32_t *)p->data,
|
||||
p->data,
|
||||
(size_t *)&p->vsize,
|
||||
p->data + voffset);
|
||||
|
||||
@@ -2527,7 +2630,7 @@ extern "C" int Effect_command(effect_interface_t self,
|
||||
int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
|
||||
|
||||
p->status = android::Virtualizer_getParameter(pContext,
|
||||
(int32_t *)p->data,
|
||||
(void *)p->data,
|
||||
(size_t *)&p->vsize,
|
||||
p->data + voffset);
|
||||
|
||||
@@ -2558,8 +2661,10 @@ extern "C" int Effect_command(effect_interface_t self,
|
||||
|
||||
int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
|
||||
|
||||
p->status = android::Equalizer_getParameter(pContext, (int32_t *)p->data, &p->vsize,
|
||||
p->data + voffset);
|
||||
p->status = android::Equalizer_getParameter(pContext,
|
||||
p->data,
|
||||
&p->vsize,
|
||||
p->data + voffset);
|
||||
|
||||
*replySize = sizeof(effect_param_t) + voffset + p->vsize;
|
||||
|
||||
@@ -2590,7 +2695,7 @@ extern "C" int Effect_command(effect_interface_t self,
|
||||
int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
|
||||
|
||||
p->status = android::Volume_getParameter(pContext,
|
||||
(int32_t *)p->data,
|
||||
(void *)p->data,
|
||||
(size_t *)&p->vsize,
|
||||
p->data + voffset);
|
||||
|
||||
@@ -2636,7 +2741,7 @@ extern "C" int Effect_command(effect_interface_t self,
|
||||
// cmdSize, sizeof(effect_param_t), p->psize, p->vsize );
|
||||
|
||||
*(int *)pReplyData = android::BassBoost_setParameter(pContext,
|
||||
(int32_t *)p->data,
|
||||
(void *)p->data,
|
||||
p->data + p->psize);
|
||||
}
|
||||
if(pContext->EffectType == LVM_VIRTUALIZER){
|
||||
@@ -2669,7 +2774,7 @@ extern "C" int Effect_command(effect_interface_t self,
|
||||
// cmdSize, sizeof(effect_param_t), p->psize, p->vsize );
|
||||
|
||||
*(int *)pReplyData = android::Virtualizer_setParameter(pContext,
|
||||
(int32_t *)p->data,
|
||||
(void *)p->data,
|
||||
p->data + p->psize);
|
||||
}
|
||||
if(pContext->EffectType == LVM_EQUALIZER){
|
||||
@@ -2689,7 +2794,7 @@ extern "C" int Effect_command(effect_interface_t self,
|
||||
effect_param_t *p = (effect_param_t *) pCmdData;
|
||||
|
||||
*(int *)pReplyData = android::Equalizer_setParameter(pContext,
|
||||
(int32_t *)p->data,
|
||||
(void *)p->data,
|
||||
p->data + p->psize);
|
||||
}
|
||||
if(pContext->EffectType == LVM_VOLUME){
|
||||
@@ -2711,14 +2816,14 @@ extern "C" int Effect_command(effect_interface_t self,
|
||||
effect_param_t *p = (effect_param_t *) pCmdData;
|
||||
|
||||
*(int *)pReplyData = android::Volume_setParameter(pContext,
|
||||
(int32_t *)p->data,
|
||||
(void *)p->data,
|
||||
p->data + p->psize);
|
||||
}
|
||||
//LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM end");
|
||||
} break;
|
||||
|
||||
case EFFECT_CMD_ENABLE:
|
||||
//LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE start");
|
||||
LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE start");
|
||||
if (pReplyData == NULL || *replySize != sizeof(int)){
|
||||
LOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_ENABLE: ERROR");
|
||||
return -EINVAL;
|
||||
@@ -2768,6 +2873,14 @@ extern "C" int Effect_command(effect_interface_t self,
|
||||
*(int *)pReplyData = 0;
|
||||
pContext->pBundledContext->NumberEffectsEnabled++;
|
||||
android::LvmEffect_enable(pContext);
|
||||
pContext->pBundledContext->SamplesToExitCountEq =
|
||||
(LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*1); // 0.1 secs Stereo
|
||||
pContext->pBundledContext->SamplesToExitCountBb =
|
||||
(LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*6); // 2 secs Stereo
|
||||
pContext->pBundledContext->SamplesToExitCountVirt =
|
||||
(LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*1); // 2 secs Stereo
|
||||
LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE Samples to Exit = %d",
|
||||
pContext->pBundledContext->SamplesToExitCountBb);
|
||||
//LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE NumberEffectsEnabled = %d",
|
||||
// pContext->pBundledContext->NumberEffectsEnabled);
|
||||
//LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE end");
|
||||
@@ -2906,11 +3019,8 @@ extern "C" int Effect_command(effect_interface_t self,
|
||||
}
|
||||
case EFFECT_CMD_SET_VOLUME:
|
||||
{
|
||||
int32_t channels = cmdSize/sizeof(int32_t);
|
||||
int32_t vol = *(int32_t *)pCmdData;
|
||||
int16_t vol_db;
|
||||
int16_t dB;
|
||||
int16_t vol_db_rnd;
|
||||
int32_t vol_ret[2] = {1<<24,1<<24}; // Apply no volume
|
||||
|
||||
// if pReplyData is NULL, VOL_CTRL is delegated to another effect
|
||||
|
||||
@@ -58,6 +58,7 @@ struct PresetConfig {
|
||||
struct BundledEffectContext{
|
||||
LVM_Handle_t hInstance; /* Instance handle */
|
||||
int SessionNo; /* Current session number */
|
||||
int SessionId; /* Current session id */
|
||||
bool bVolumeEnabled; /* Flag for Volume */
|
||||
bool bEqualizerEnabled; /* Flag for EQ */
|
||||
bool bBassEnabled; /* Flag for Bass */
|
||||
@@ -80,6 +81,10 @@ struct BundledEffectContext{
|
||||
bool bStereoPositionEnabled;
|
||||
int frameCount;
|
||||
LVM_Fs_en SampleRate;
|
||||
int SamplesPerSecond;
|
||||
int SamplesToExitCountEq;
|
||||
int SamplesToExitCountBb;
|
||||
int SamplesToExitCountVirt;
|
||||
#ifdef LVM_PCM
|
||||
FILE *PcmInPtr;
|
||||
FILE *PcmOutPtr;
|
||||
|
||||
1820
media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
Executable file
1820
media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
Executable file
File diff suppressed because it is too large
Load Diff
38
media/libeffects/lvm/wrapper/Reverb/EffectReverb.h
Executable file
38
media/libeffects/lvm/wrapper/Reverb/EffectReverb.h
Executable file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_EFFECTREVERB_H_
|
||||
#define ANDROID_EFFECTREVERB_H_
|
||||
|
||||
#include <media/EffectEnvironmentalReverbApi.h>
|
||||
#include <media/EffectPresetReverbApi.h>
|
||||
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct _LPFPair_t
|
||||
{
|
||||
int16_t Room_HF;
|
||||
int16_t LPF;
|
||||
} LPFPair_t;
|
||||
#if __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
|
||||
#endif /*ANDROID_EFFECTREVERB_H_*/
|
||||
Reference in New Issue
Block a user