LVM release 1.05 delivery

- Click have been removed from the HP filter activation in the BassBosst Effect.
- SessionId is now stored as a SessionNo
- Effects now stop being called after a delay
- Unix EOL fixed for .java and .xml
- Updated lines limited to 100 characters.
- Removed the remaining warnings from the wrapper code
- Added reverb

Change-Id: I03a2b3b5ee2286958f4901acc8d9b0daf9e2d7c6
diff --git a/media/libeffects/lvm/wrapper/Android.mk b/media/libeffects/lvm/wrapper/Android.mk
index 7855dcd..2e9b9b4 100644
--- a/media/libeffects/lvm/wrapper/Android.mk
+++ b/media/libeffects/lvm/wrapper/Android.mk
@@ -34,3 +34,36 @@
 
 
 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)
\ No newline at end of file
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
index bcd646a..798271e 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -66,7 +66,9 @@
 
 // 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_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 @@
                             int32_t             ioId,
                             effect_interface_t  *pInterface){
     int ret;
+    int sessionNo;
     int i;
     EffectContext *pContext = new EffectContext;
 
@@ -199,7 +202,7 @@
         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 @@
         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 @@
         }
     }
     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 @@
     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 @@
         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 @@
         GlobalSessionMemory[i].bBassInstantiated        = LVM_FALSE;
         GlobalSessionMemory[i].bVirtualizerInstantiated = LVM_FALSE;
         GlobalSessionMemory[i].pBundledContext          = LVM_NULL;
+
+        SessionIndex[i] = -1;
     }
     return;
 }
@@ -505,6 +553,9 @@
     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 @@
     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 @@
 
         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 @@
     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 @@
 //----------------------------------------------------------------------------
 
 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_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 @@
             //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 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_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 @@
             //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 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 @@
         break;
 
     case EQ_PARAM_BAND_LEVEL:
-        param2 = *pParam;
+        param2 = *pParamTemp;
         if (param2 >= FIVEBAND_NUMBANDS) {
             status = -EINVAL;
             break;
@@ -1935,7 +1999,7 @@
         break;
 
     case EQ_PARAM_CENTER_FREQ:
-        param2 = *pParam;
+        param2 = *pParamTemp;
         if (param2 >= FIVEBAND_NUMBANDS) {
             status = -EINVAL;
             break;
@@ -1946,7 +2010,7 @@
         break;
 
     case EQ_PARAM_BAND_FREQ_RANGE:
-        param2 = *pParam;
+        param2 = *pParamTemp;
         if (param2 >= FIVEBAND_NUMBANDS) {
             status = -EINVAL;
             break;
@@ -1957,7 +2021,7 @@
         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 @@
         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 @@
 // 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 @@
         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 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_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 @@
             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 @@
                               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 @@
     }
     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 @@
         }
     }
 
-    if(status != -ENODATA){
+    if((status2Sec != -ENODATA)&&(status != -ENODATA)){
         pContext->pBundledContext->NumberEffectsCalled++;
     }
 
@@ -2496,7 +2599,7 @@
                 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 @@
                 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 @@
 
                 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 @@
                 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 @@
                 //        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 @@
                 //        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 @@
                 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 @@
                 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 @@
             *(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 @@
         }
         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
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
index d009bf9..1bee974 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
@@ -58,6 +58,7 @@
 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 @@
     bool                            bStereoPositionEnabled;
     int                             frameCount;
     LVM_Fs_en                       SampleRate;
+    int                             SamplesPerSecond;
+    int                             SamplesToExitCountEq;
+    int                             SamplesToExitCountBb;
+    int                             SamplesToExitCountVirt;
     #ifdef LVM_PCM
     FILE                            *PcmInPtr;
     FILE                            *PcmOutPtr;
diff --git a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
new file mode 100755
index 0000000..2043e44
--- /dev/null
+++ b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
@@ -0,0 +1,1820 @@
+/*
+ * Copyright (C) 2010-2010 NXP Software
+ * Copyright (C) 2009 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.
+ */
+
+#define LOG_TAG "Reverb"
+#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
+#define LOG_NDEBUG 0
+
+#include <cutils/log.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include <new>
+#include <EffectReverb.h>
+#include <LVREV.h>
+
+#define MAX_NUM_BANDS           5
+#define MAX_CALL_SIZE           256
+#define LVREV_MAX_T60           7000
+#define LVREV_MAX_REVERB_LEVEL  2000
+
+//#define LVM_PCM
+
+// effect_interface_t interface implementation for reverb
+extern "C" const struct effect_interface_s gReverbInterface;
+
+#define LVM_ERROR_CHECK(LvmStatus, callingFunc, calledFunc){\
+        if (LvmStatus == LVREV_NULLADDRESS){\
+            LOGV("\tLVREV_ERROR : Parameter error - "\
+                    "null pointer returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\
+        }\
+        if (LvmStatus == LVREV_INVALIDNUMSAMPLES){\
+            LOGV("\tLVREV_ERROR : Parameter error - "\
+                    "bad number of samples returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\
+        }\
+        if (LvmStatus == LVREV_OUTOFRANGE){\
+            LOGV("\tLVREV_ERROR : Parameter error - "\
+                    "out of range returned by %s in %s\n", callingFunc, calledFunc);\
+        }\
+    }
+
+// Namespaces
+namespace android {
+namespace {
+
+/************************************************************************************/
+/*                                                                                  */
+/* Preset definitions                                                               */
+/*                                                                                  */
+/************************************************************************************/
+LVM_UINT16 RevPreset_Level[]    = {  32,   32,   32,   32,   32,    32,   32,   32,   32,   32};
+LVM_UINT16 RevPreset_LPF[]      = {1298, 1000, 5012, 3542, 3400, 23999, 2536, 1000, 1000, 1000};
+LVM_UINT16 RevPreset_HPF[]      = {  50,   50,   50,   50,   50,    50,   50,   50,   50,   50};
+LVM_UINT16 RevPreset_T60[]      = {1490,  500, 2310, 4230, 3920,  2910, 7000, 1490, 1490,  170};
+LVM_UINT16 RevPreset_Density[]  = { 100,  100,  100,  100,  100,   100,  100,  100,  100,  100};
+LVM_UINT16 RevPreset_Damping[]  = {  54,   10,   64,   59,   70,   100,   33,   54,   21,   10};
+LVM_UINT16 RevPreset_RoomSize[] = { 100,  100,  100,  100,  100,   100,  100,  100,  100,  100};
+
+/************************************************************************************/
+/*                                                                                  */
+/* Preset definitions                                                               */
+/*                                                                                  */
+/************************************************************************************/
+#define REV_PRESET_BATHROOM         0
+#define REV_PRESET_LIVINGROOM       1
+#define REV_PRESET_STONEROOM        2
+#define REV_PRESET_AUDITORIUM       3
+#define REV_PRESET_CONCERTHALL      4
+#define REV_PRESET_CAVE             5
+#define REV_PRESET_ARENA            6
+#define REV_PRESET_FOREST           7
+#define REV_PRESET_MOUNTAINS        8
+#define REV_PRESET_PADDEDCELL       9
+
+// NXP SW Reverb UUID
+const effect_descriptor_t gReverbDescriptor = {
+        { 0xc2e5d5f0, 0x94bd, 0x4763, 0x9cac, { 0x4e, 0x23, 0x4d, 0x06, 0x83, 0x9e } },
+        { 0x4a387fc0, 0x8ab3, 0x11df, 0x8bad, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
+        EFFECT_API_VERSION,
+        (EFFECT_FLAG_TYPE_AUXILIARY | EFFECT_FLAG_INSERT_LAST),
+        0, // TODO
+        1,
+        "Reverb",
+        "NXP Software Ltd.",
+};
+
+struct ReverbContext{
+    const struct effect_interface_s *itfe;
+    effect_config_t                 config;
+    LVREV_Handle_t                  hInstance;
+    int16_t                         SavedRoomLevel;
+    int16_t                         SavedHfLevel;
+    int16_t                         SavedDecayTime;
+    int16_t                         SavedDecayHfRatio;
+    int16_t                         SavedReverbLevel;
+    int16_t                         SavedDiffusion;
+    int16_t                         SavedDensity;
+    bool                            bEnabled;
+    #ifdef LVM_PCM
+    FILE                            *PcmInPtr;
+    FILE                            *PcmOutPtr;
+    #endif
+    LVM_Fs_en                       SampleRate;
+};
+
+//--- local function prototypes
+int  Reverb_init            (ReverbContext *pContext);
+void Reverb_free            (ReverbContext *pContext);
+int  Reverb_configure       (ReverbContext *pContext, effect_config_t *pConfig);
+int  Reverb_setParameter    (ReverbContext *pContext, void *pParam, void *pValue);
+int  Reverb_getParameter    (ReverbContext *pContext,
+                             void          *pParam,
+                             size_t        *pValueSize,
+                             void          *pValue);
+
+/* Effect Library Interface Implementation */
+extern "C" int EffectQueryNumberEffects(uint32_t *pNumEffects){
+    LOGV("\n\tEffectQueryNumberEffects start");
+    *pNumEffects = 1;
+    LOGV("\tEffectQueryNumberEffects creating %d effects", *pNumEffects);
+    LOGV("\tEffectQueryNumberEffects end\n");
+    return 0;
+}     /* end EffectQueryNumberEffects */
+
+extern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor){
+    LOGV("\n\tEffectQueryEffect start");
+    LOGV("\tEffectQueryEffect processing index %d", index);
+    if (pDescriptor == NULL){
+        LOGV("\tLVM_ERROR : EffectQueryEffect was passed NULL pointer");
+        return -EINVAL;
+    }
+    if (index > 0){
+        LOGV("\tLVM_ERROR : EffectQueryEffect index out of range %d", index);
+        return -ENOENT;
+    }
+    memcpy(pDescriptor, &gReverbDescriptor, sizeof(effect_descriptor_t));
+    LOGV("\tEffectQueryEffect end\n");
+    return 0;
+}     /* end EffectQueryEffect */
+
+extern "C" int EffectCreate(effect_uuid_t       *uuid,
+                            int32_t             sessionId,
+                            int32_t             ioId,
+                            effect_interface_t  *pInterface){
+    int ret;
+    int i;
+
+    LOGV("\t\nEffectCreate start");
+
+    if (pInterface == NULL || uuid == NULL){
+        LOGV("\tLVM_ERROR : EffectCreate() called with NULL pointer");
+        return -EINVAL;
+    }
+
+    if (memcmp(uuid, &gReverbDescriptor.uuid, sizeof(effect_uuid_t)) != 0){
+        LOGV("\tLVM_ERROR : EffectCreate() invalid UUID");
+        return -EINVAL;
+    }
+
+    ReverbContext *pContext = new ReverbContext;
+
+    pContext->itfe      = &gReverbInterface;
+    pContext->hInstance = NULL;
+
+    LOGV("\tEffectCreate - Calling Reverb_init");
+    ret = Reverb_init(pContext);
+
+    if (ret < 0){
+        LOGV("\tLVM_ERROR : EffectCreate() init failed");
+        delete pContext;
+        return ret;
+    }
+
+    *pInterface = (effect_interface_t)pContext;
+
+    #ifdef LVM_PCM
+    pContext->PcmInPtr = NULL;
+    pContext->PcmOutPtr = NULL;
+
+    pContext->PcmInPtr  = fopen("/data/tmp/reverb_pcm_in.pcm", "w");
+    pContext->PcmOutPtr = fopen("/data/tmp/reverb_pcm_out.pcm", "w");
+
+    if((pContext->PcmInPtr  == NULL)||
+       (pContext->PcmOutPtr == NULL)){
+       return -EINVAL;
+    }
+    #endif
+
+    LOGV("\tEffectCreate %p, size %d", pContext, sizeof(ReverbContext));
+    LOGV("\tEffectCreate end\n");
+    return 0;
+} /* end EffectCreate */
+
+extern "C" int EffectRelease(effect_interface_t interface){
+    ReverbContext * pContext = (ReverbContext *)interface;
+
+    LOGV("\tEffectRelease %p", interface);
+    if (pContext == NULL){
+        LOGV("\tLVM_ERROR : EffectRelease called with NULL pointer");
+        return -EINVAL;
+    }
+
+    #ifdef LVM_PCM
+    fclose(pContext->PcmInPtr);
+    fclose(pContext->PcmOutPtr);
+    #endif
+    Reverb_free(pContext);
+    delete pContext;
+    return 0;
+} /* end EffectRelease */
+
+/* local functions */
+#define CHECK_ARG(cond) {                     \
+    if (!(cond)) {                            \
+        LOGV("\tLVM_ERROR : Invalid argument: "#cond);      \
+        return -EINVAL;                       \
+    }                                         \
+}
+
+//----------------------------------------------------------------------------
+// MonoTo2I_32()
+//----------------------------------------------------------------------------
+// Purpose:
+//  Convert MONO to STEREO
+//
+//----------------------------------------------------------------------------
+
+void MonoTo2I_32( const LVM_INT32  *src,
+                        LVM_INT32  *dst,
+                        LVM_INT16 n)
+{
+   LVM_INT16 ii;
+   src += (n-1);
+   dst += ((n*2)-1);
+
+   for (ii = n; ii != 0; ii--)
+   {
+       *dst = *src;
+       dst--;
+
+       *dst = *src;
+       dst--;
+       src--;
+   }
+
+   return;
+}
+
+//----------------------------------------------------------------------------
+// From2iToMono_32()
+//----------------------------------------------------------------------------
+// Purpose:
+//  Convert STEREO to MONO
+//
+//----------------------------------------------------------------------------
+
+void From2iToMono_32( const LVM_INT32 *src,
+                            LVM_INT32 *dst,
+                            LVM_INT16 n)
+{
+   LVM_INT16 ii;
+   LVM_INT32 Temp;
+
+   for (ii = n; ii != 0; ii--)
+   {
+       Temp = (*src>>1);
+       src++;
+
+       Temp +=(*src>>1);
+       src++;
+
+       *dst = Temp;
+       dst++;
+   }
+
+   return;
+}
+//----------------------------------------------------------------------------
+// process()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the Reverb
+//
+// Inputs:
+//  pIn:        pointer to stereo/mono 16 bit input data
+//  pOut:       pointer to stereo 16 bit output data
+//  frameCount: Frames to process
+//  pContext:   effect engine context
+//  strength    strength to be applied
+//
+//  Outputs:
+//  pOut:       pointer to updated stereo 16 bit output data
+//
+//----------------------------------------------------------------------------
+
+int process( LVM_INT16     *pIn,
+             LVM_INT16     *pOut,
+             int           frameCount,
+             ReverbContext *pContext){
+
+    LVM_INT16               samplesPerFrame = 0;
+    LVREV_ReturnStatus_en   LvmStatus = LVREV_SUCCESS;              /* Function call status */
+
+    LVM_INT32 *InFrames32;
+    LVM_INT32 *OutFrames32;
+    LVM_INT16 *OutFrames16;
+
+
+    // Check that the input is either mono or stereo
+    if(pContext->config.inputCfg.channels == CHANNEL_STEREO){
+        samplesPerFrame = 2;
+    } else if (pContext->config.inputCfg.channels == CHANNEL_MONO){
+        samplesPerFrame = 1;
+    } else {
+        LOGV("\tLVREV_ERROR : process invalid PCM format");
+        return -EINVAL;
+    }
+
+    InFrames32  = (LVM_INT32 *)malloc(frameCount * sizeof(LVM_INT32) * 2);
+    OutFrames32 = (LVM_INT32 *)malloc(frameCount * sizeof(LVM_INT32) * 2);
+    OutFrames16 = (LVM_INT16 *)OutFrames32;
+
+    // Check for NULL pointers
+    if((InFrames32 == NULL)||(OutFrames32 == NULL)){
+        LOGV("\tLVREV_ERROR : process failed to allocate memory for temporary buffers ");
+        return -EINVAL;
+    }
+
+    #ifdef LVM_PCM
+    fwrite(pIn, frameCount*sizeof(LVM_INT16)*samplesPerFrame, 1, pContext->PcmInPtr);
+    fflush(pContext->PcmInPtr);
+    #endif
+
+    // Convert to Input 32 bits
+    for(int i=0; i<frameCount*samplesPerFrame; i++){
+        InFrames32[i] = (LVM_INT32)pIn[i]<<8;
+    }
+
+     // If the input was MONO, convert to STEREO
+    if(pContext->config.inputCfg.channels == CHANNEL_MONO){
+        //LOGV("\tConverting Output from MONO to STEREO");
+        MonoTo2I_32(InFrames32, InFrames32, frameCount);
+    }
+
+    //LOGV("\tProcess, frames: %d, InFormat: %d(MONO=%d), OutFormat: %d(STEREO=%d)",
+    //frameCount, pContext->config.inputCfg.channels, CHANNEL_MONO,
+    //pContext->config.outputCfg.channels, CHANNEL_STEREO);
+
+    /* Process the samples */
+    LvmStatus = LVREV_Process(pContext->hInstance,      /* Instance handle */
+                              InFrames32,               /* Input buffer */
+                              OutFrames32,              /* Output buffer */
+                              frameCount);              /* Number of samples to read */
+
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_Process", "process")
+    if(LvmStatus != LVREV_SUCCESS) return -EINVAL;
+
+    // Convert to 16 bits
+    for(int i=0; i<frameCount*2; i++){  // Always stereo
+        OutFrames16[i] = (LVM_INT16)(OutFrames32[i]>>8);
+    }
+
+    #ifdef LVM_PCM
+    fwrite(OutFrames16, frameCount*sizeof(LVM_INT16)*samplesPerFrame, 1, pContext->PcmOutPtr);
+    fflush(pContext->PcmOutPtr);
+    #endif
+
+    // Accumulate if required
+    if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){
+        //LOGV("\tBuffer access is ACCUMULATE");
+        for (int i=0; i<frameCount*2; i++){
+            pOut[i] +=  OutFrames16[i];
+        }
+    }else{
+        //LOGV("\tBuffer access is WRITE");
+        memcpy(pOut, OutFrames16, frameCount*sizeof(LVM_INT16)*2); // 2 is for stereo output
+    }
+
+    free(InFrames32);
+    free(OutFrames32);
+
+    return 0;
+}    /* end process */
+
+//----------------------------------------------------------------------------
+// Reverb_free()
+//----------------------------------------------------------------------------
+// Purpose: Free all memory associated with the Bundle.
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+void Reverb_free(ReverbContext *pContext){
+
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;         /* Function call status */
+    LVREV_ControlParams_st    params;                        /* Control Parameters */
+    LVREV_MemoryTable_st      MemTab;
+
+    /* Free the algorithm memory */
+    LvmStatus = LVREV_GetMemoryTable(pContext->hInstance,
+                                   &MemTab,
+                                   LVM_NULL);
+
+    LVM_ERROR_CHECK(LvmStatus, "LVM_GetMemoryTable", "Reverb_free")
+
+    for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){
+        if (MemTab.Region[i].Size != 0){
+            if (MemTab.Region[i].pBaseAddress != NULL){
+                LOGV("\tfree() - START freeing %ld bytes for region %u at %p\n",
+                        MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
+
+                free(MemTab.Region[i].pBaseAddress);
+
+                LOGV("\tfree() - END   freeing %ld bytes for region %u at %p\n",
+                        MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
+            }else{
+                LOGV("\tLVM_ERROR : free() - trying to free with NULL pointer %ld bytes "
+                        "for region %u at %p ERROR\n",
+                        MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
+            }
+        }
+    }
+}    /* end Reverb_free */
+
+//----------------------------------------------------------------------------
+// Reverb_configure()
+//----------------------------------------------------------------------------
+// Purpose: Set input and output audio configuration.
+//
+// Inputs:
+//  pContext:   effect engine context
+//  pConfig:    pointer to effect_config_t structure holding input and output
+//      configuration parameters
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+int Reverb_configure(ReverbContext *pContext, effect_config_t *pConfig){
+    LVM_Fs_en   SampleRate;
+    //LOGV("\tReverb_configure start");
+
+    CHECK_ARG(pContext != NULL);
+    CHECK_ARG(pConfig != NULL);
+
+    CHECK_ARG(pConfig->inputCfg.samplingRate == pConfig->outputCfg.samplingRate);
+    CHECK_ARG(pConfig->inputCfg.format == pConfig->outputCfg.format);
+    CHECK_ARG(pConfig->outputCfg.channels == CHANNEL_STEREO);
+    CHECK_ARG(pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE
+              || pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE);
+    CHECK_ARG(pConfig->inputCfg.format == SAMPLE_FORMAT_PCM_S15);
+
+    if(pConfig->inputCfg.samplingRate != 44100){
+        return -EINVAL;
+    }
+
+    //LOGV("\tReverb_configure calling memcpy");
+    memcpy(&pContext->config, pConfig, sizeof(effect_config_t));
+
+    switch (pConfig->inputCfg.samplingRate) {
+    case 8000:
+        SampleRate = LVM_FS_8000;
+        break;
+    case 16000:
+        SampleRate = LVM_FS_16000;
+        break;
+    case 22050:
+        SampleRate = LVM_FS_22050;
+        break;
+    case 32000:
+        SampleRate = LVM_FS_32000;
+        break;
+    case 44100:
+        SampleRate = LVM_FS_44100;
+        break;
+    case 48000:
+        SampleRate = LVM_FS_48000;
+        break;
+    default:
+        LOGV("\rReverb_Configure invalid sampling rate %d", pConfig->inputCfg.samplingRate);
+        return -EINVAL;
+    }
+
+    if(pContext->SampleRate != SampleRate){
+
+        LVREV_ControlParams_st    ActiveParams;
+        LVREV_ReturnStatus_en     LvmStatus = LVREV_SUCCESS;
+
+        //LOGV("\tReverb_configure change sampling rate to %d", SampleRate);
+
+        /* Get the current settings */
+        LvmStatus = LVREV_GetControlParameters(pContext->hInstance,
+                                         &ActiveParams);
+
+        LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "Reverb_configure")
+        if(LvmStatus != LVREV_SUCCESS) return -EINVAL;
+
+        LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
+
+        LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "Reverb_configure")
+        //LOGV("\tReverb_configure Succesfully called LVREV_SetControlParameters\n");
+
+    }else{
+        //LOGV("\tReverb_configure keep sampling rate at %d", SampleRate);
+    }
+
+    //LOGV("\tReverb_configure End");
+    return 0;
+}   /* end Reverb_configure */
+
+
+//----------------------------------------------------------------------------
+// Reverb_init()
+//----------------------------------------------------------------------------
+// Purpose: Initialize engine with default configuration
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+int Reverb_init(ReverbContext *pContext){
+    int status;
+    int channel_mode;
+
+    LOGV("\tReverb_init start %d", gReverbDescriptor.flags);
+
+    if((gReverbDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_INSERT){
+        LOGV("\tReverb_init EFFECT_FLAG_TYPE_INSERT");
+        channel_mode = CHANNEL_STEREO;
+    }
+    if((gReverbDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY ){
+        LOGV("\tReverb_init EFFECT_FLAG_TYPE_AUXILIARY");
+        channel_mode = CHANNEL_MONO;
+    }
+
+    CHECK_ARG(pContext != NULL);
+
+    if (pContext->hInstance != NULL){
+        Reverb_free(pContext);
+    }
+
+    pContext->config.inputCfg.accessMode                    = EFFECT_BUFFER_ACCESS_READ;
+    pContext->config.inputCfg.channels                      = channel_mode;
+    pContext->config.inputCfg.format                        = SAMPLE_FORMAT_PCM_S15;
+    pContext->config.inputCfg.samplingRate                  = 44100;
+    pContext->config.inputCfg.bufferProvider.getBuffer      = NULL;
+    pContext->config.inputCfg.bufferProvider.releaseBuffer  = NULL;
+    pContext->config.inputCfg.bufferProvider.cookie         = NULL;
+    pContext->config.inputCfg.mask                          = EFFECT_CONFIG_ALL;
+    pContext->config.outputCfg.accessMode                   = EFFECT_BUFFER_ACCESS_ACCUMULATE;
+    pContext->config.outputCfg.channels                     = CHANNEL_STEREO;
+    pContext->config.outputCfg.format                       = SAMPLE_FORMAT_PCM_S15;
+    pContext->config.outputCfg.samplingRate                 = 44100;
+    pContext->config.outputCfg.bufferProvider.getBuffer     = NULL;
+    pContext->config.outputCfg.bufferProvider.releaseBuffer = NULL;
+    pContext->config.outputCfg.bufferProvider.cookie        = NULL;
+    pContext->config.outputCfg.mask                         = EFFECT_CONFIG_ALL;
+
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;        /* Function call status */
+    LVREV_ControlParams_st    params;                         /* Control Parameters */
+    LVREV_InstanceParams_st   InstParams;                     /* Instance parameters */
+    LVREV_MemoryTable_st      MemTab;                         /* Memory allocation table */
+    bool                      bMallocFailure = LVM_FALSE;
+
+    /* Set the capabilities */
+    InstParams.MaxBlockSize  = MAX_CALL_SIZE;
+    InstParams.SourceFormat  = LVM_STEREO;
+    InstParams.NumDelays     = LVREV_DELAYLINES_4;
+
+    /* Allocate memory, forcing alignment */
+    LvmStatus = LVREV_GetMemoryTable(LVM_NULL,
+                                  &MemTab,
+                                  &InstParams);
+
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetMemoryTable", "Reverb_init")
+    if(LvmStatus != LVREV_SUCCESS) return -EINVAL;
+
+    LOGV("\tCreateInstance Succesfully called LVM_GetMemoryTable\n");
+
+    /* Allocate memory */
+    for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){
+        if (MemTab.Region[i].Size != 0){
+            MemTab.Region[i].pBaseAddress = malloc(MemTab.Region[i].Size);
+
+            if (MemTab.Region[i].pBaseAddress == LVM_NULL){
+                LOGV("\tLVREV_ERROR :Reverb_init CreateInstance Failed to allocate %ld bytes for region %u\n",
+                        MemTab.Region[i].Size, i );
+                bMallocFailure = LVM_TRUE;
+            }else{
+                LOGV("\tReverb_init CreateInstance allocate %ld bytes for region %u at %p\n",
+                        MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
+            }
+        }
+    }
+
+    /* If one or more of the memory regions failed to allocate, free the regions that were
+     * succesfully allocated and return with an error
+     */
+    if(bMallocFailure == LVM_TRUE){
+        for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){
+            if (MemTab.Region[i].pBaseAddress == LVM_NULL){
+                LOGV("\tLVM_ERROR :Reverb_init CreateInstance Failed to allocate %ld bytes for region %u"
+                     " - Not freeing\n", MemTab.Region[i].Size, i );
+            }else{
+                LOGV("\tLVM_ERROR :Reverb_init CreateInstance Failed: but allocated %ld bytes for region %u "
+                       "at %p- free\n", MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
+                free(MemTab.Region[i].pBaseAddress);
+            }
+        }
+        return -EINVAL;
+    }
+    LOGV("\tReverb_init CreateInstance Succesfully malloc'd memory\n");
+
+    /* Initialise */
+    pContext->hInstance = LVM_NULL;
+
+    /* Init sets the instance handle */
+    LvmStatus = LVREV_GetInstanceHandle(&pContext->hInstance,
+                                        &MemTab,
+                                        &InstParams);
+
+    LVM_ERROR_CHECK(LvmStatus, "LVM_GetInstanceHandle", "Reverb_init")
+    if(LvmStatus != LVREV_SUCCESS) return -EINVAL;
+
+    LOGV("\tReverb_init CreateInstance Succesfully called LVM_GetInstanceHandle\n");
+
+    /* Set the initial process parameters */
+    /* General parameters */
+    params.OperatingMode  = LVM_MODE_ON;
+    params.SampleRate     = LVM_FS_44100;
+    params.SourceFormat   = LVM_STEREO;
+
+    /* Reverb parameters */
+    params.Level          = 0;
+    params.LPF            = 23999;
+    params.HPF            = RevPreset_HPF[REV_PRESET_MOUNTAINS];
+    params.T60            = RevPreset_T60[REV_PRESET_MOUNTAINS];
+    params.Density        = RevPreset_Density[REV_PRESET_MOUNTAINS];
+    params.Damping        = RevPreset_Damping[REV_PRESET_MOUNTAINS];
+    params.RoomSize       = RevPreset_RoomSize[REV_PRESET_MOUNTAINS];
+
+    /* Saved strength is used to return the exact strength that was used in the set to the get
+     * because we map the original strength range of 0:1000 to 1:15, and this will avoid
+     * quantisation like effect when returning
+     */
+    pContext->SavedRoomLevel    = -6000;
+    pContext->SavedHfLevel      = 0;
+    pContext->bEnabled          = LVM_FALSE;
+    pContext->SavedDecayTime    = params.T60;
+    pContext->SavedDecayHfRatio = params.Damping*10;
+    pContext->SavedDensity      = params.RoomSize*10;
+    pContext->SavedDiffusion    = params.Density*10;
+    pContext->SavedReverbLevel  = -6000;
+
+    /* Activate the initial settings */
+    LvmStatus = LVREV_SetControlParameters(pContext->hInstance,
+                                         &params);
+
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "Reverb_init")
+    if(LvmStatus != LVREV_SUCCESS) return -EINVAL;
+
+    LOGV("\tReverb_init CreateInstance Succesfully called LVREV_SetControlParameters\n");
+    LOGV("\tReverb_init End");
+    return 0;
+}   /* end Reverb_init */
+
+//----------------------------------------------------------------------------
+// ReverbConvertLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+// Convert level from OpenSL ES format to LVM format
+//
+// Inputs:
+//  level       level to be applied
+//
+//----------------------------------------------------------------------------
+
+int16_t ReverbConvertLevel(int16_t level){
+    static int16_t LevelArray[101] =
+    {
+       -12000, -4000,  -3398,  -3046,  -2796,  -2603,  -2444,  -2310,  -2194,  -2092,
+       -2000,  -1918,  -1842,  -1773,  -1708,  -1648,  -1592,  -1540,  -1490,  -1443,
+       -1398,  -1356,  -1316,  -1277,  -1240,  -1205,  -1171,  -1138,  -1106,  -1076,
+       -1046,  -1018,  -990,   -963,   -938,   -912,   -888,   -864,   -841,   -818,
+       -796,   -775,   -754,   -734,   -714,   -694,   -675,   -656,   -638,   -620,
+       -603,   -585,   -568,   -552,   -536,   -520,   -504,   -489,   -474,   -459,
+       -444,   -430,   -416,   -402,   -388,   -375,   -361,   -348,   -335,   -323,
+       -310,   -298,   -286,   -274,   -262,   -250,   -239,   -228,   -216,   -205,
+       -194,   -184,   -173,   -162,   -152,   -142,   -132,   -121,   -112,   -102,
+       -92,    -82,    -73,    -64,    -54,    -45,    -36,    -27,    -18,    -9,
+       0
+    };
+    int16_t i;
+
+    for(i = 0; i < 101; i++)
+    {
+       if(level <= LevelArray[i])
+           break;
+    }
+    return i;
+}
+
+//----------------------------------------------------------------------------
+// ReverbConvertHFLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+// Convert level from OpenSL ES format to LVM format
+//
+// Inputs:
+//  level       level to be applied
+//
+//----------------------------------------------------------------------------
+
+int16_t ReverbConvertHfLevel(int16_t Hflevel){
+    int16_t i;
+
+    static LPFPair_t LPFArray[97] =
+    {   // Limit range to 50 for LVREV parameter range
+        {-10000, 50}, { -5000, 50 }, { -4000, 50},  { -3000, 158}, { -2000, 502},
+        {-1000, 1666},{ -900, 1897}, { -800, 2169}, { -700, 2496}, { -600, 2895},
+        {-500, 3400}, { -400, 4066}, { -300, 5011}, { -200, 6537}, { -100,  9826},
+        {-99, 9881 }, { -98, 9937 }, { -97, 9994 }, { -96, 10052}, { -95, 10111},
+        {-94, 10171}, { -93, 10231}, { -92, 10293}, { -91, 10356}, { -90, 10419},
+        {-89, 10484}, { -88, 10549}, { -87, 10616}, { -86, 10684}, { -85, 10753},
+        {-84, 10823}, { -83, 10895}, { -82, 10968}, { -81, 11042}, { -80, 11117},
+        {-79, 11194}, { -78, 11272}, { -77, 11352}, { -76, 11433}, { -75, 11516},
+        {-74, 11600}, { -73, 11686}, { -72, 11774}, { -71, 11864}, { -70, 11955},
+        {-69, 12049}, { -68, 12144}, { -67, 12242}, { -66, 12341}, { -65, 12443},
+        {-64, 12548}, { -63, 12654}, { -62, 12763}, { -61, 12875}, { -60, 12990},
+        {-59, 13107}, { -58, 13227}, { -57, 13351}, { -56, 13477}, { -55, 13607},
+        {-54, 13741}, { -53, 13878}, { -52, 14019}, { -51, 14164}, { -50, 14313},
+        {-49, 14467}, { -48, 14626}, { -47, 14789}, { -46, 14958}, { -45, 15132},
+        {-44, 15312}, { -43, 15498}, { -42, 15691}, { -41, 15890}, { -40, 16097},
+        {-39, 16311}, { -38, 16534}, { -37, 16766}, { -36, 17007}, { -35, 17259},
+        {-34, 17521}, { -33, 17795}, { -32, 18081}, { -31, 18381}, { -30, 18696},
+        {-29, 19027}, { -28, 19375}, { -27, 19742}, { -26, 20129}, { -25, 20540},
+        {-24, 20976}, { -23, 21439}, { -22, 21934}, { -21, 22463}, { -20, 23031},
+        {-19, 23643}, { -18, 23999}
+    };
+
+    for(i = 0; i < 96; i++)
+    {
+        if(Hflevel <= LPFArray[i].Room_HF)
+            break;
+    }
+    return LPFArray[i].LPF;
+}
+
+//----------------------------------------------------------------------------
+// ReverbSetRoomHfLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the HF level to the Reverb. Must first be converted to LVM format
+//
+// Inputs:
+//  pContext:   effect engine context
+//  level       level to be applied
+//
+//----------------------------------------------------------------------------
+
+void ReverbSetRoomHfLevel(ReverbContext *pContext, int16_t level){
+    //LOGV("\tReverbSetRoomHfLevel start (%d)", level);
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetRoomHfLevel")
+    //LOGV("\tReverbSetRoomHfLevel Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbSetRoomHfLevel() just Got -> %d\n", ActiveParams.LPF);
+
+    ActiveParams.LPF = ReverbConvertHfLevel(level);
+
+    /* Activate the initial settings */
+    LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetRoomHfLevel")
+    //LOGV("\tReverbSetRoomhfLevel() just Set -> %d\n", ActiveParams.LPF);
+    pContext->SavedHfLevel = level;
+    //LOGV("\tReverbSetHfRoomLevel end.. saving %d", pContext->SavedHfLevel);
+    return;
+}
+
+//----------------------------------------------------------------------------
+// ReverbGetRoomHfLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get the level applied to the Revervb. Must first be converted to LVM format
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+//----------------------------------------------------------------------------
+
+int16_t ReverbGetRoomHfLevel(ReverbContext *pContext){
+    int16_t level;
+    //LOGV("\tReverbGetRoomHfLevel start, saved level is %d", pContext->SavedHfLevel);
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetRoomHfLevel")
+    //LOGV("\tReverbGetRoomHfLevel Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbGetRoomHfLevel() just Got -> %d\n", ActiveParams.LPF);
+
+    level = ReverbConvertHfLevel(pContext->SavedHfLevel);
+
+    //LOGV("\tReverbGetRoomHfLevel() ActiveParams.LPFL %d, pContext->SavedHfLevel: %d, "
+    //     "converted level: %d\n", ActiveParams.LPF, pContext->SavedHfLevel, level);
+
+    if(ActiveParams.LPF != level){
+        LOGV("\tLVM_ERROR : (ignore at start up) ReverbGetRoomHfLevel() has wrong level -> %d %d\n",
+               ActiveParams.Level, level);
+    }
+
+    //LOGV("\tReverbGetRoomHfLevel end");
+    return pContext->SavedHfLevel;
+}
+
+//----------------------------------------------------------------------------
+// ReverbSetReverbLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the level to the Reverb. Must first be converted to LVM format
+//
+// Inputs:
+//  pContext:   effect engine context
+//  level       level to be applied
+//
+//----------------------------------------------------------------------------
+
+void ReverbSetReverbLevel(ReverbContext *pContext, int16_t level){
+    //LOGV("\n\tReverbSetReverbLevel start (%d)", level);
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+    LVM_INT32                 CombinedLevel;             // Sum of room and reverb level controls
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetReverbLevel")
+    //LOGV("\tReverbSetReverbLevel Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbSetReverbLevel just Got -> %d\n", ActiveParams.Level);
+
+    // needs to subtract max levels for both RoomLevel and ReverbLevel
+    CombinedLevel = (level + pContext->SavedRoomLevel)-LVREV_MAX_REVERB_LEVEL;
+    //LOGV("\tReverbSetReverbLevel() CombinedLevel is %d = %d + %d\n",
+    //      CombinedLevel, level, pContext->SavedRoomLevel);
+
+    ActiveParams.Level = ReverbConvertLevel(CombinedLevel);
+
+    //LOGV("\tReverbSetReverbLevel() Trying to set -> %d\n", ActiveParams.Level);
+
+    /* Activate the initial settings */
+    LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetReverbLevel")
+    //LOGV("\tReverbSetReverbLevel() just Set -> %d\n", ActiveParams.Level);
+
+    pContext->SavedReverbLevel = level;
+    //LOGV("\tReverbSetReverbLevel end pContext->SavedReverbLevel is %d\n\n",
+    //     pContext->SavedReverbLevel);
+    return;
+}
+
+//----------------------------------------------------------------------------
+// ReverbGetReverbLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get the level applied to the Revervb. Must first be converted to LVM format
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+//----------------------------------------------------------------------------
+
+int16_t ReverbGetReverbLevel(ReverbContext *pContext){
+    int16_t level;
+    //LOGV("\tReverbGetReverbLevel start");
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+    LVM_INT32                 CombinedLevel;             // Sum of room and reverb level controls
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetReverbLevel")
+    //LOGV("\tReverbGetReverbLevel Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbGetReverbLevel() just Got -> %d\n", ActiveParams.Level);
+
+    // needs to subtract max levels for both RoomLevel and ReverbLevel
+    CombinedLevel = (pContext->SavedReverbLevel + pContext->SavedRoomLevel)-LVREV_MAX_REVERB_LEVEL;
+
+    //LOGV("\tReverbGetReverbLevel() CombinedLevel is %d = %d + %d\n",
+    //CombinedLevel, pContext->SavedReverbLevel, pContext->SavedRoomLevel);
+    level = ReverbConvertLevel(CombinedLevel);
+
+    //LOGV("\tReverbGetReverbLevel(): ActiveParams.Level: %d, pContext->SavedReverbLevel: %d, "
+    //"pContext->SavedRoomLevel: %d, CombinedLevel: %d, converted level: %d\n",
+    //ActiveParams.Level, pContext->SavedReverbLevel,pContext->SavedRoomLevel, CombinedLevel,level);
+
+    if(ActiveParams.Level != level){
+        LOGV("\tLVM_ERROR : (ignore at start up) ReverbGetReverbLevel() has wrong level -> %d %d\n",
+                ActiveParams.Level, level);
+    }
+
+    //LOGV("\tReverbGetReverbLevel end\n");
+
+    return pContext->SavedReverbLevel;
+}
+
+//----------------------------------------------------------------------------
+// ReverbSetRoomLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the level to the Reverb. Must first be converted to LVM format
+//
+// Inputs:
+//  pContext:   effect engine context
+//  level       level to be applied
+//
+//----------------------------------------------------------------------------
+
+void ReverbSetRoomLevel(ReverbContext *pContext, int16_t level){
+    //LOGV("\tReverbSetRoomLevel start (%d)", level);
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+    LVM_INT32                 CombinedLevel;             // Sum of room and reverb level controls
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetRoomLevel")
+    //LOGV("\tReverbSetRoomLevel Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbSetRoomLevel() just Got -> %d\n", ActiveParams.Level);
+
+    // needs to subtract max levels for both RoomLevel and ReverbLevel
+    CombinedLevel = (level + pContext->SavedReverbLevel)-LVREV_MAX_REVERB_LEVEL;
+    ActiveParams.Level = ReverbConvertLevel(CombinedLevel);
+
+    /* Activate the initial settings */
+    LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetRoomLevel")
+    //LOGV("\tReverbSetRoomLevel() just Set -> %d\n", ActiveParams.Level);
+
+    pContext->SavedRoomLevel = level;
+    //LOGV("\tReverbSetRoomLevel end");
+    return;
+}
+
+//----------------------------------------------------------------------------
+// ReverbGetRoomLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get the level applied to the Revervb. Must first be converted to LVM format
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+//----------------------------------------------------------------------------
+
+int16_t ReverbGetRoomLevel(ReverbContext *pContext){
+    int16_t level;
+    //LOGV("\tReverbGetRoomLevel start");
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+    LVM_INT32                 CombinedLevel;             // Sum of room and reverb level controls
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetRoomLevel")
+    //LOGV("\tReverbGetRoomLevel Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbGetRoomLevel() just Got -> %d\n", ActiveParams.Level);
+
+    // needs to subtract max levels for both RoomLevel and ReverbLevel
+    CombinedLevel = (pContext->SavedRoomLevel + pContext->SavedReverbLevel-LVREV_MAX_REVERB_LEVEL);
+    level = ReverbConvertLevel(CombinedLevel);
+
+    //LOGV("\tReverbGetRoomLevel, Level = %d, pContext->SavedRoomLevel = %d, "
+    //     "pContext->SavedReverbLevel = %d, CombinedLevel = %d, level = %d",
+    //ActiveParams.Level, pContext->SavedRoomLevel, pContext->SavedReverbLevel, CombinedLevel, level);
+
+    if(ActiveParams.Level != level){
+        LOGV("\tLVM_ERROR : (ignore at start up) ReverbGetRoomLevel() has wrong level -> %d %d\n",
+              ActiveParams.Level, level);
+    }
+
+    //LOGV("\tReverbGetRoomLevel end");
+    return pContext->SavedRoomLevel;
+}
+
+//----------------------------------------------------------------------------
+// ReverbSetDecayTime()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the decay time to the Reverb.
+//
+// Inputs:
+//  pContext:   effect engine context
+//  time        decay to be applied
+//
+//----------------------------------------------------------------------------
+
+void ReverbSetDecayTime(ReverbContext *pContext, uint32_t time){
+    //LOGV("\tReverbSetDecayTime start (%d)", time);
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetDecayTime")
+    //LOGV("\tReverbSetDecayTime Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbSetDecayTime() just Got -> %d\n", ActiveParams.T60);
+
+    if (time <= LVREV_MAX_T60) {
+        ActiveParams.T60 = time;
+    }
+    else {
+        ActiveParams.T60 = LVREV_MAX_T60;
+    }
+
+    /* Activate the initial settings */
+    LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetDecayTime")
+    //LOGV("\tReverbSetDecayTime() just Set -> %d\n", ActiveParams.T60);
+
+    pContext->SavedDecayTime = time;
+    //LOGV("\tReverbSetDecayTime end");
+    return;
+}
+
+//----------------------------------------------------------------------------
+// ReverbGetDecayTime()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get the decay time applied to the Revervb.
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+//----------------------------------------------------------------------------
+
+int32_t ReverbGetDecayTime(ReverbContext *pContext){
+    //LOGV("\tReverbGetDecayTime start");
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetDecayTime")
+    //LOGV("\tReverbGetDecayTime Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbGetDecayTime() just Got -> %d\n", ActiveParams.T60);
+
+    if(ActiveParams.T60 != pContext->SavedDecayTime){
+        // This will fail if the decay time is set to more than 7000
+        LOGV("\tLVM_ERROR : ReverbGetDecayTime() has wrong level -> %d %d\n",
+         ActiveParams.T60, pContext->SavedDecayTime);
+    }
+
+    //LOGV("\tReverbGetDecayTime end");
+    return ActiveParams.T60;
+}
+
+//----------------------------------------------------------------------------
+// ReverbSetDecayHfRatio()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the HF decay ratio to the Reverb.
+//
+// Inputs:
+//  pContext:   effect engine context
+//  ratio       ratio to be applied
+//
+//----------------------------------------------------------------------------
+
+void ReverbSetDecayHfRatio(ReverbContext *pContext, int16_t ratio){
+    //LOGV("\tReverbSetDecayHfRatioe start (%d)", ratio);
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;   /* Function call status */
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetDecayHfRatio")
+    //LOGV("\tReverbSetDecayHfRatio Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbSetDecayHfRatio() just Got -> %d\n", ActiveParams.Damping);
+
+    ActiveParams.Damping = (LVM_INT16)(ratio/10);
+
+    /* Activate the initial settings */
+    LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetDecayHfRatio")
+    //LOGV("\tReverbSetDecayHfRatio() just Set -> %d\n", ActiveParams.Damping);
+
+    pContext->SavedDecayHfRatio = ratio;
+    //LOGV("\tReverbSetDecayHfRatio end");
+    return;
+}
+
+//----------------------------------------------------------------------------
+// ReverbGetDecayHfRatio()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get the HF decay ratio applied to the Revervb.
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+//----------------------------------------------------------------------------
+
+int32_t ReverbGetDecayHfRatio(ReverbContext *pContext){
+    //LOGV("\tReverbGetDecayHfRatio start");
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;   /* Function call status */
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetDecayHfRatio")
+    //LOGV("\tReverbGetDecayHfRatio Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbGetDecayHfRatio() just Got -> %d\n", ActiveParams.Damping);
+
+    if(ActiveParams.Damping != (LVM_INT16)(pContext->SavedDecayHfRatio / 10)){
+        LOGV("\tLVM_ERROR : ReverbGetDecayHfRatio() has wrong level -> %d %d\n",
+         ActiveParams.Damping, pContext->SavedDecayHfRatio);
+    }
+
+    //LOGV("\tReverbGetDecayHfRatio end");
+    return pContext->SavedDecayHfRatio;
+}
+
+//----------------------------------------------------------------------------
+// ReverbSetDiffusion()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the diffusion to the Reverb.
+//
+// Inputs:
+//  pContext:   effect engine context
+//  level        decay to be applied
+//
+//----------------------------------------------------------------------------
+
+void ReverbSetDiffusion(ReverbContext *pContext, int16_t level){
+    //LOGV("\tReverbSetDiffusion start (%d)", level);
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetDiffusion")
+    //LOGV("\tReverbSetDiffusion Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbSetDiffusion() just Got -> %d\n", ActiveParams.Density);
+
+    ActiveParams.Density = (LVM_INT16)(level/10);
+
+    /* Activate the initial settings */
+    LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetDiffusion")
+    //LOGV("\tReverbSetDiffusion() just Set -> %d\n", ActiveParams.Density);
+
+    pContext->SavedDiffusion = level;
+    //LOGV("\tReverbSetDiffusion end");
+    return;
+}
+
+//----------------------------------------------------------------------------
+// ReverbGetDiffusion()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get the decay time applied to the Revervb.
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+//----------------------------------------------------------------------------
+
+int32_t ReverbGetDiffusion(ReverbContext *pContext){
+    //LOGV("\tReverbGetDiffusion start");
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+    LVM_INT16                 Temp;
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetDiffusion")
+    //LOGV("\tReverbGetDiffusion Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbGetDiffusion just Got -> %d\n", ActiveParams.Density);
+
+    Temp = (LVM_INT16)(pContext->SavedDiffusion/10);
+
+    if(ActiveParams.Density != Temp){
+        LOGV("\tLVM_ERROR : ReverbGetDiffusion invalid value %d %d", Temp, ActiveParams.Density);
+    }
+
+    //LOGV("\tReverbGetDiffusion end");
+    return pContext->SavedDiffusion;
+}
+
+//----------------------------------------------------------------------------
+// ReverbSetDensity()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the density level the Reverb.
+//
+// Inputs:
+//  pContext:   effect engine context
+//  level        decay to be applied
+//
+//----------------------------------------------------------------------------
+
+void ReverbSetDensity(ReverbContext *pContext, int16_t level){
+    //LOGV("\tReverbSetDensity start (%d)", level);
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetDensity")
+    //LOGV("\tReverbSetDensity Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbSetDensity just Got -> %d\n", ActiveParams.RoomSize);
+
+    ActiveParams.RoomSize = (LVM_INT16)(((level * 99) / 1000) + 1);
+
+    /* Activate the initial settings */
+    LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetDensity")
+    //LOGV("\tReverbSetDensity just Set -> %d\n", ActiveParams.RoomSize);
+
+    pContext->SavedDensity = level;
+    //LOGV("\tReverbSetDensity end");
+    return;
+}
+
+//----------------------------------------------------------------------------
+// ReverbGetDensity()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get the density level applied to the Revervb.
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+//----------------------------------------------------------------------------
+
+int32_t ReverbGetDensity(ReverbContext *pContext){
+    //LOGV("\tReverbGetDensity start");
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+    LVM_INT16                 Temp;
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetDensity")
+    //LOGV("\tReverbGetDensity Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbGetDensity() just Got -> %d\n", ActiveParams.RoomSize);
+
+
+    Temp = (LVM_INT16)(((pContext->SavedDensity * 99) / 1000) + 1);
+
+    if(Temp != ActiveParams.RoomSize){
+        LOGV("\tLVM_ERROR : ReverbGetDensity invalid value %d %d", Temp, ActiveParams.RoomSize);
+    }
+
+    //LOGV("\tReverbGetDensity end");
+    return pContext->SavedDensity;
+}
+
+//----------------------------------------------------------------------------
+// Reverb_getParameter()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get a Reverb parameter
+//
+// Inputs:
+//  pContext         - handle to instance data
+//  pParam           - pointer to parameter
+//  pValue           - pointer to variable to hold retrieved value
+//  pValueSize       - pointer to value size: maximum size as input
+//
+// Outputs:
+//  *pValue updated with parameter value
+//  *pValueSize updated with actual value size
+//
+//
+// Side Effects:
+//
+//----------------------------------------------------------------------------
+
+int Reverb_getParameter(ReverbContext *pContext,
+                        void          *pParam,
+                        size_t        *pValueSize,
+                        void          *pValue){
+    int status = 0;
+    int32_t *pParamTemp = (int32_t *)pParam;
+    int32_t param = *pParamTemp++;
+    char *name;
+    t_reverb_settings *pProperties;
+
+    //LOGV("\tReverb_getParameter start");
+
+    switch (param){
+        case REVERB_PARAM_ROOM_LEVEL:
+            if (*pValueSize != sizeof(int16_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize1 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(int16_t);
+            break;
+        case REVERB_PARAM_ROOM_HF_LEVEL:
+            if (*pValueSize != sizeof(int16_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize12 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(int16_t);
+            break;
+        case REVERB_PARAM_DECAY_TIME:
+            if (*pValueSize != sizeof(uint32_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize3 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(uint32_t);
+            break;
+        case REVERB_PARAM_DECAY_HF_RATIO:
+            if (*pValueSize != sizeof(int16_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize4 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(int16_t);
+            break;
+        case REVERB_PARAM_REFLECTIONS_LEVEL:
+            if (*pValueSize != sizeof(int16_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize5 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(int16_t);
+            break;
+        case REVERB_PARAM_REFLECTIONS_DELAY:
+            if (*pValueSize != sizeof(uint32_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize6 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(uint32_t);
+            break;
+        case REVERB_PARAM_REVERB_LEVEL:
+            if (*pValueSize != sizeof(int16_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize7 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(int16_t);
+            break;
+        case REVERB_PARAM_REVERB_DELAY:
+            if (*pValueSize != sizeof(uint32_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize8 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(uint32_t);
+            break;
+        case REVERB_PARAM_DIFFUSION:
+            if (*pValueSize != sizeof(int16_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize9 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(int16_t);
+            break;
+        case REVERB_PARAM_DENSITY:
+            if (*pValueSize != sizeof(int16_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize10 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(int16_t);
+            break;
+        case REVERB_PARAM_PROPERTIES:
+            if (*pValueSize != sizeof(t_reverb_settings)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize11 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(t_reverb_settings);
+            break;
+
+        default:
+            LOGV("\tLVM_ERROR : Reverb_getParameter() invalid param %d", param);
+            return -EINVAL;
+    }
+
+    pProperties = (t_reverb_settings *) pValue;
+
+    switch (param){
+        case REVERB_PARAM_PROPERTIES:
+            pProperties->roomLevel = ReverbGetRoomLevel(pContext);
+            pProperties->roomHFLevel = ReverbGetRoomHfLevel(pContext);
+            pProperties->decayTime = ReverbGetDecayTime(pContext);
+            pProperties->decayHFRatio = ReverbGetDecayHfRatio(pContext);
+            pProperties->reflectionsLevel = 0;
+            pProperties->reflectionsDelay = 0;
+            pProperties->reverbDelay = 0;
+            pProperties->reverbLevel = ReverbGetReverbLevel(pContext);
+            pProperties->diffusion = ReverbGetDiffusion(pContext);
+            pProperties->density = ReverbGetDensity(pContext);
+
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is roomLevel        %d",
+                pProperties->roomLevel);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is roomHFLevel      %d",
+                pProperties->roomHFLevel);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is decayTime        %d",
+                pProperties->decayTime);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is decayHFRatio     %d",
+                pProperties->decayHFRatio);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reflectionsLevel %d",
+                pProperties->reflectionsLevel);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reflectionsDelay %d",
+                pProperties->reflectionsDelay);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reverbDelay      %d",
+                pProperties->reverbDelay);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reverbLevel      %d",
+                pProperties->reverbLevel);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is diffusion        %d",
+                pProperties->diffusion);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is density          %d",
+                pProperties->density);
+            break;
+
+        case REVERB_PARAM_ROOM_LEVEL:
+            *(int16_t *)pValue = ReverbGetRoomLevel(pContext);
+
+            //LOGV("\tReverb_getParameter() REVERB_PARAM_ROOM_LEVEL Value is %d",
+            //        *(int16_t *)pValue);
+            break;
+        case REVERB_PARAM_ROOM_HF_LEVEL:
+            *(int16_t *)pValue = ReverbGetRoomHfLevel(pContext);
+
+            //LOGV("\tReverb_getParameter() REVERB_PARAM_ROOM_HF_LEVEL Value is %d",
+            //        *(int16_t *)pValue);
+            break;
+        case REVERB_PARAM_DECAY_TIME:
+            *(int32_t *)pValue = ReverbGetDecayTime(pContext);
+
+            //LOGV("\tReverb_getParameter() REVERB_PARAM_DECAY_TIME Value is %d",
+            //        *(int32_t *)pValue);
+            break;
+        case REVERB_PARAM_DECAY_HF_RATIO:
+            *(int16_t *)pValue = ReverbGetDecayHfRatio(pContext);
+
+            //LOGV("\tReverb_getParameter() REVERB_PARAM_DECAY_HF_RATION Value is %d",
+            //        *(int16_t *)pValue);
+            break;
+        case REVERB_PARAM_REVERB_LEVEL:
+             *(int16_t *)pValue = ReverbGetReverbLevel(pContext);
+
+            //LOGV("\tReverb_getParameter() REVERB_PARAM_REVERB_LEVEL Value is %d",
+            //        *(int16_t *)pValue);
+            break;
+        case REVERB_PARAM_DIFFUSION:
+            *(int16_t *)pValue = ReverbGetDiffusion(pContext);
+
+            //LOGV("\tReverb_getParameter() REVERB_PARAM_DECAY_DIFFUSION Value is %d",
+            //        *(int16_t *)pValue);
+            break;
+        case REVERB_PARAM_DENSITY:
+            *(uint16_t *)pValue = 0;
+            *(int16_t *)pValue = ReverbGetDensity(pContext);
+            //LOGV("\tReverb_getParameter() REVERB_PARAM_DENSITY Value is %d",
+            //        *(uint32_t *)pValue);
+            break;
+        case REVERB_PARAM_REFLECTIONS_LEVEL:
+            *(uint16_t *)pValue = 0;
+        case REVERB_PARAM_REFLECTIONS_DELAY:
+            *(uint32_t *)pValue = 0;
+        case REVERB_PARAM_REVERB_DELAY:
+            *(uint32_t *)pValue = 0;
+            break;
+
+        default:
+            LOGV("\tLVM_ERROR : Reverb_getParameter() invalid param %d", param);
+            status = -EINVAL;
+            break;
+    }
+
+    //LOGV("\tReverb_getParameter end");
+    return status;
+} /* end Reverb_getParameter */
+
+//----------------------------------------------------------------------------
+// Reverb_setParameter()
+//----------------------------------------------------------------------------
+// Purpose:
+// Set a Reverb parameter
+//
+// Inputs:
+//  pContext         - handle to instance data
+//  pParam           - pointer to parameter
+//  pValue           - pointer to value
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+int Reverb_setParameter (ReverbContext *pContext, void *pParam, void *pValue){
+    int status = 0;
+    int16_t level;
+    uint32_t time;
+    t_reverb_settings *pProperties;
+    int32_t *pParamTemp = (int32_t *)pParam;
+    int32_t param = *pParamTemp++;
+
+    //LOGV("\tReverb_setParameter start");
+
+    switch (param){
+        case REVERB_PARAM_PROPERTIES:
+            LOGV("\tReverb_setParameter() REVERB_PARAM_PROPERTIES");
+            pProperties = (t_reverb_settings *) pValue;
+            ReverbSetRoomLevel(pContext, pProperties->roomLevel);
+            ReverbSetRoomHfLevel(pContext, pProperties->roomHFLevel);
+            ReverbSetDecayTime(pContext, pProperties->decayTime);
+            ReverbSetDecayHfRatio(pContext, pProperties->decayHFRatio);
+            ReverbSetReverbLevel(pContext, pProperties->reverbLevel);
+            ReverbSetDiffusion(pContext, pProperties->diffusion);
+            ReverbSetDensity(pContext, pProperties->density);
+            break;
+        case REVERB_PARAM_ROOM_LEVEL:
+            level = *(int16_t *)pValue;
+            //LOGV("\tReverb_setParameter() REVERB_PARAM_ROOM_LEVEL value is %d", level);
+            //LOGV("\tReverb_setParameter() Calling ReverbSetRoomLevel");
+            ReverbSetRoomLevel(pContext, level);
+            //LOGV("\tReverb_setParameter() Called ReverbSetRoomLevel");
+           break;
+        case REVERB_PARAM_ROOM_HF_LEVEL:
+            level = *(int16_t *)pValue;
+            //LOGV("\tReverb_setParameter() REVERB_PARAM_ROOM_HF_LEVEL value is %d", level);
+            //LOGV("\tReverb_setParameter() Calling ReverbSetRoomHfLevel");
+            ReverbSetRoomHfLevel(pContext, level);
+            //LOGV("\tReverb_setParameter() Called ReverbSetRoomHfLevel");
+           break;
+        case REVERB_PARAM_DECAY_TIME:
+            time = *(uint32_t *)pValue;
+            //LOGV("\tReverb_setParameter() REVERB_PARAM_DECAY_TIME value is %d", time);
+            //LOGV("\tReverb_setParameter() Calling ReverbSetDecayTime");
+            ReverbSetDecayTime(pContext, time);
+            //LOGV("\tReverb_setParameter() Called ReverbSetDecayTime");
+           break;
+        case REVERB_PARAM_DECAY_HF_RATIO:
+            time = *(int16_t *)pValue;
+            //LOGV("\tReverb_setParameter() REVERB_PARAM_DECAY_HF_RATIO value is %d", time);
+            //LOGV("\tReverb_setParameter() Calling ReverbSetDecayHfRatio");
+            ReverbSetDecayHfRatio(pContext, time);
+            //LOGV("\tReverb_setParameter() Called ReverbSetDecayHfRatio");
+            break;
+         case REVERB_PARAM_REVERB_LEVEL:
+            level = *(int16_t *)pValue;
+            //LOGV("\tReverb_setParameter() REVERB_PARAM_REVERB_LEVEL value is %d", level);
+            //LOGV("\tReverb_setParameter() Calling ReverbSetReverbLevel");
+            ReverbSetReverbLevel(pContext, level);
+            //LOGV("\tReverb_setParameter() Called ReverbSetReverbLevel");
+           break;
+        case REVERB_PARAM_DIFFUSION:
+            time = *(int16_t *)pValue;
+            //LOGV("\tReverb_setParameter() REVERB_PARAM_DECAY_DIFFUSION value is %d", time);
+            //LOGV("\tReverb_setParameter() Calling ReverbSetDiffusion");
+            ReverbSetDiffusion(pContext, time);
+            //LOGV("\tReverb_setParameter() Called ReverbSetDiffusion");
+            break;
+        case REVERB_PARAM_DENSITY:
+            time = *(int16_t *)pValue;
+            //LOGV("\tReverb_setParameter() REVERB_PARAM_DECAY_DENSITY value is %d", time);
+            //LOGV("\tReverb_setParameter() Calling ReverbSetDensity");
+            ReverbSetDensity(pContext, time);
+            //LOGV("\tReverb_setParameter() Called ReverbSetDensity");
+            break;
+           break;
+        case REVERB_PARAM_REFLECTIONS_LEVEL:
+        case REVERB_PARAM_REFLECTIONS_DELAY:
+        case REVERB_PARAM_REVERB_DELAY:
+            break;
+        default:
+            LOGV("\tLVM_ERROR : Reverb_setParameter() invalid param %d", param);
+            break;
+    }
+
+    //LOGV("\tReverb_setParameter end");
+    return status;
+} /* end Reverb_setParameter */
+
+} // namespace
+} // namespace
+
+/* Effect Control Interface Implementation: Process */
+extern "C" int Reverb_process(effect_interface_t   self,
+                                 audio_buffer_t         *inBuffer,
+                                 audio_buffer_t         *outBuffer){
+    android::ReverbContext * pContext = (android::ReverbContext *) self;
+    int    status = 0;
+
+    if (pContext == NULL){
+        LOGV("\tLVM_ERROR : Reverb_process() ERROR pContext == NULL");
+        return -EINVAL;
+    }
+    if (inBuffer == NULL  || inBuffer->raw == NULL  ||
+            outBuffer == NULL || outBuffer->raw == NULL ||
+            inBuffer->frameCount != outBuffer->frameCount){
+        LOGV("\tLVM_ERROR : Reverb_process() ERROR NULL INPUT POINTER OR FRAME COUNT IS WRONG");
+        return -EINVAL;
+    }
+    if (pContext->bEnabled == LVM_FALSE){
+        LOGV("\tReverb_process() ERROR Effect is not enabled");
+        return -ENODATA;
+    }
+    //LOGV("\tReverb_process() Calling process with %d frames", outBuffer->frameCount);
+    /* Process all the available frames, block processing is handled internalLY by the LVM bundle */
+    status = process(    (LVM_INT16 *)inBuffer->raw,
+                         (LVM_INT16 *)outBuffer->raw,
+                                      outBuffer->frameCount,
+                                      pContext);
+
+    return status;
+}   /* end Reverb_process */
+
+/* Effect Control Interface Implementation: Command */
+extern "C" int Reverb_command(effect_interface_t  self,
+                              uint32_t            cmdCode,
+                              uint32_t            cmdSize,
+                              void                *pCmdData,
+                              uint32_t            *replySize,
+                              void                *pReplyData){
+    android::ReverbContext * pContext = (android::ReverbContext *) self;
+    int retsize;
+
+    if (pContext == NULL){
+        LOGV("\tLVM_ERROR : Reverb_command ERROR pContext == NULL");
+        return -EINVAL;
+    }
+
+    //LOGV("\tReverb_command INPUTS are: command %d cmdSize %d",cmdCode, cmdSize);
+
+    switch (cmdCode){
+        case EFFECT_CMD_INIT:
+            //LOGV("\tReverb_command cmdCode Case: "
+            //        "EFFECT_CMD_INIT start");
+
+            if (pReplyData == NULL || *replySize != sizeof(int)){
+                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                        "EFFECT_CMD_INIT: ERROR");
+                return -EINVAL;
+            }
+            *(int *) pReplyData = 0;
+            break;
+
+        case EFFECT_CMD_CONFIGURE:
+            //LOGV("\tReverb_command cmdCode Case: "
+            //        "EFFECT_CMD_CONFIGURE start");
+            if (pCmdData    == NULL||
+                cmdSize     != sizeof(effect_config_t)||
+                pReplyData  == NULL||
+                *replySize  != sizeof(int)){
+                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                        "EFFECT_CMD_CONFIGURE: ERROR");
+                return -EINVAL;
+            }
+            *(int *) pReplyData = Reverb_configure(pContext, (effect_config_t *) pCmdData);
+            break;
+
+        case EFFECT_CMD_RESET:
+            //LOGV("\tReverb_command cmdCode Case: "
+            //        "EFFECT_CMD_RESET start");
+            Reverb_configure(pContext, &pContext->config);
+            break;
+
+        case EFFECT_CMD_GET_PARAM:{
+            //LOGV("\tReverb_command cmdCode Case: "
+            //        "EFFECT_CMD_GET_PARAM start");
+            if (pCmdData == NULL ||
+                    cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
+                    pReplyData == NULL ||
+                    *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){
+                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                        "EFFECT_CMD_GET_PARAM: ERROR");
+                return -EINVAL;
+            }
+            effect_param_t *p = (effect_param_t *)pCmdData;
+
+            memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize);
+
+            p = (effect_param_t *)pReplyData;
+
+            int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
+
+            p->status = android::Reverb_getParameter(pContext,
+                                                         (void *)p->data,
+                                                         (size_t  *)&p->vsize,
+                                                          p->data + voffset);
+
+            *replySize = sizeof(effect_param_t) + voffset + p->vsize;
+
+            //LOGV("\tReverb_command EFFECT_CMD_GET_PARAM "
+            //        "*pCmdData %d, *replySize %d, *pReplyData %d ",
+            //        *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
+            //        *replySize,
+            //        *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset));
+
+        } break;
+        case EFFECT_CMD_SET_PARAM:{
+
+            //LOGV("\tReverb_command cmdCode Case: "
+            //        "EFFECT_CMD_SET_PARAM start");
+            //LOGV("\tReverb_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ",
+            //        *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
+            //        *replySize,
+            //        *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t)));
+
+            if (pCmdData == NULL || (cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)))
+                    || pReplyData == NULL || *replySize != (int)sizeof(int32_t)) {
+                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                        "EFFECT_CMD_SET_PARAM: ERROR");
+                return -EINVAL;
+            }
+
+            effect_param_t *p = (effect_param_t *) pCmdData;
+
+            if (p->psize != sizeof(int32_t)){
+                LOGV("\t4LVM_ERROR : Reverb_command cmdCode Case: "
+                        "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)");
+                return -EINVAL;
+            }
+
+            //LOGV("\tn5Reverb_command cmdSize is %d\n"
+            //        "\tsizeof(effect_param_t) is  %d\n"
+            //        "\tp->psize is %d\n"
+            //        "\tp->vsize is %d"
+            //        "\n",
+            //        cmdSize, sizeof(effect_param_t), p->psize, p->vsize );
+
+            *(int *)pReplyData = android::Reverb_setParameter(pContext,
+                                                             (void *)p->data,
+                                                              p->data + p->psize);
+        } break;
+
+        case EFFECT_CMD_ENABLE:
+            //LOGV("\tReverb_command cmdCode Case: "
+            //        "EFFECT_CMD_ENABLE start");
+
+            if (pReplyData == NULL || *replySize != sizeof(int)){
+                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                        "EFFECT_CMD_ENABLE: ERROR");
+                return -EINVAL;
+            }
+            if(pContext->bEnabled == LVM_TRUE){
+                 LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                         "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled");
+                 return -EINVAL;
+             }
+            *(int *)pReplyData = 0;
+            pContext->bEnabled = LVM_TRUE;
+            break;
+        case EFFECT_CMD_DISABLE:
+            //LOGV("\tReverb_command cmdCode Case: "
+            //        "EFFECT_CMD_DISABLE start");
+
+            if (pReplyData == NULL || *replySize != sizeof(int)){
+                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                        "EFFECT_CMD_DISABLE: ERROR");
+                return -EINVAL;
+            }
+            if(pContext->bEnabled == LVM_FALSE){
+                 LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                         "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled");
+                 return -EINVAL;
+             }
+            *(int *)pReplyData = 0;
+            pContext->bEnabled = LVM_FALSE;
+            break;
+
+        case EFFECT_CMD_SET_DEVICE:
+        case EFFECT_CMD_SET_VOLUME:
+        case EFFECT_CMD_SET_AUDIO_MODE:
+            //LOGV("\tReverb_command cmdCode Case: "
+            //        "EFFECT_CMD_SET_DEVICE/EFFECT_CMD_SET_VOLUME/EFFECT_CMD_SET_AUDIO_MODE start");
+            break;
+
+        default:
+            LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                    "DEFAULT start %d ERROR",cmdCode);
+            return -EINVAL;
+    }
+
+    //LOGV("\tReverb_command end\n\n");
+    return 0;
+}    /* end Reverb_command */
+
+// effect_interface_t interface implementation for Reverb effect
+const struct effect_interface_s gReverbInterface = {
+    Reverb_process,
+    Reverb_command
+};    /* end gReverbInterface */
+
diff --git a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.h b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.h
new file mode 100755
index 0000000..1ab423f
--- /dev/null
+++ b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.h
@@ -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_*/