From 2d3bf535004f7310fe04a4b5f46b6747cdb3c93f Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Thu, 2 Sep 2010 17:18:20 -0700 Subject: LVM release 1.08 delivery. - Changed bundle SamplesToExit to 0.1 secs - Added SamplesToExit to Revreb - Removed mixer from Core reverb Change-Id: I675ec22889f20ef35a0ac427600c2654111c397e --- .../lvm/lib/Reverb/src/LVREV_ApplyNewSettings.c | 6 +- .../lvm/lib/Reverb/src/LVREV_GetInstanceHandle.c | 4 +- .../lvm/lib/StereoWidening/src/LVCS_Control.c | 4 +- .../libeffects/lvm/wrapper/Bundle/EffectBundle.cpp | 12 ++-- .../libeffects/lvm/wrapper/Reverb/EffectReverb.cpp | 84 +++++++++++++++------- 5 files changed, 69 insertions(+), 41 deletions(-) (limited to 'media/libeffects/lvm') diff --git a/media/libeffects/lvm/lib/Reverb/src/LVREV_ApplyNewSettings.c b/media/libeffects/lvm/lib/Reverb/src/LVREV_ApplyNewSettings.c index 6a8b39b..9a40f68 100644 --- a/media/libeffects/lvm/lib/Reverb/src/LVREV_ApplyNewSettings.c +++ b/media/libeffects/lvm/lib/Reverb/src/LVREV_ApplyNewSettings.c @@ -526,7 +526,7 @@ LVREV_ReturnStatus_en LVREV_ApplyNewSettings (LVREV_Instance_st *pPrivate) (pPrivate->NewParams.OperatingMode == LVM_MODE_ON)) { pPrivate->BypassMixer.Target2 = ((LVM_INT32)(pPrivate->NewParams.Level * 32767)/100)<<16; - pPrivate->BypassMixer.Target1 = LVREV_HEADROOM << 16; + pPrivate->BypassMixer.Target1 = 0x00000000; if ((pPrivate->NewParams.Level == 0) && (pPrivate->bFirstControl == LVM_FALSE)) { pPrivate->BypassMixer.CallbackSet2 = LVM_TRUE; @@ -542,7 +542,7 @@ LVREV_ReturnStatus_en LVREV_ApplyNewSettings (LVREV_Instance_st *pPrivate) if(pPrivate->NewParams.OperatingMode == LVM_MODE_ON) { pPrivate->BypassMixer.Target2 = ((LVM_INT32)(pPrivate->NewParams.Level * 32767)/100)<<16; - pPrivate->BypassMixer.Target1 = LVREV_HEADROOM << 16; + pPrivate->BypassMixer.Target1 = 0x00000000; pPrivate->BypassMixer.CallbackSet2 = LVM_FALSE; OperatingMode = LVM_MODE_ON; @@ -558,7 +558,7 @@ LVREV_ReturnStatus_en LVREV_ApplyNewSettings (LVREV_Instance_st *pPrivate) else if (pPrivate->bFirstControl == LVM_FALSE) { pPrivate->BypassMixer.Target2 = 0x00000000; - pPrivate->BypassMixer.Target1 = 0x7FFFFFFF; + pPrivate->BypassMixer.Target1 = 0x00000000; pPrivate->BypassMixer.CallbackSet2 = LVM_TRUE; pPrivate->GainMixer.Target = 0x03FFFFFF; OperatingMode = LVM_MODE_ON; diff --git a/media/libeffects/lvm/lib/Reverb/src/LVREV_GetInstanceHandle.c b/media/libeffects/lvm/lib/Reverb/src/LVREV_GetInstanceHandle.c index c2b266a..ffa5138 100644 --- a/media/libeffects/lvm/lib/Reverb/src/LVREV_GetInstanceHandle.c +++ b/media/libeffects/lvm/lib/Reverb/src/LVREV_GetInstanceHandle.c @@ -238,8 +238,8 @@ LVREV_ReturnStatus_en LVREV_GetInstanceHandle(LVREV_Handle_t *phInsta pLVREV_Private->BypassMixer.pGeneralPurpose1 = LVM_NULL; pLVREV_Private->BypassMixer.pCallBack1 = LVM_NULL; pLVREV_Private->BypassMixer.CallbackSet1 = LVM_FALSE; - pLVREV_Private->BypassMixer.Current1 = 0x7fffffff; - pLVREV_Private->BypassMixer.Target1 = 0x7fffffff; + pLVREV_Private->BypassMixer.Current1 = 0x00000000; + pLVREV_Private->BypassMixer.Target1 = 0x00000000; pLVREV_Private->RoomSizeInms = 100; // 100 msec diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c index a3ba42b..ce6d410 100644 --- a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c +++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c @@ -202,7 +202,9 @@ LVCS_ReturnStatus_en LVCS_Control(LVCS_Handle_t hInstance, /* Set the reverb delay timeout */ if(pInstance->bInOperatingModeTransition != LVM_TRUE){ pInstance->bTimerDone = LVM_FALSE; - pInstance->TimerParams.TimeInMs = (LVM_INT16)(((pInstance->Reverberation.DelaySize << 2)/pInstance->TimerParams.SamplingRate) + 1); + pInstance->TimerParams.TimeInMs = + (LVM_INT16)(((pInstance->Reverberation.DelaySize << 2) + /pInstance->TimerParams.SamplingRate) + 1); LVM_Timer_Init ( &pInstance->TimerInstance, &pInstance->TimerParams); } diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp index 7297811..e86ed99 100644 --- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp +++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp @@ -275,7 +275,6 @@ extern "C" int EffectCreate(effect_uuid_t *uuid, pContext->pBundledContext->PcmInPtr = NULL; return -EINVAL; } - #endif /* Saved strength is used to return the exact strength that was used in the set to the get @@ -565,9 +564,6 @@ int LvmBundle_init(EffectContext *pContext){ params.SpeakerType = LVM_HEADPHONES; pContext->pBundledContext->SampleRate = LVM_FS_44100; - pContext->pBundledContext->SamplesToExitCountEq = 44100*2*2; // 2 secs Stereo - pContext->pBundledContext->SamplesToExitCountBb = 44100*2*2; // 2 secs Stereo - pContext->pBundledContext->SamplesToExitCountVirt = 44100*2*2; // 2 secs Stereo /* Concert Sound parameters */ params.VirtualizerOperatingMode = LVM_MODE_OFF; @@ -2431,7 +2427,7 @@ extern "C" int Effect_process(effect_interface_t self, 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", + //LOGV("\tEffect_process: Waiting to turn off BASS_BOOST, %d samples left", // pContext->pBundledContext->SamplesToExitCountBb); } else { status = -ENODATA; @@ -2897,11 +2893,11 @@ extern "C" int Effect_command(effect_interface_t self, pContext->pBundledContext->NumberEffectsEnabled++; android::LvmEffect_enable(pContext); pContext->pBundledContext->SamplesToExitCountEq = - (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*1); // 0.1 secs Stereo + (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1); // 0.1 secs Stereo pContext->pBundledContext->SamplesToExitCountBb = - (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*6); // 2 secs Stereo + (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1); // 0.1 secs Stereo pContext->pBundledContext->SamplesToExitCountVirt = - (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*1); // 2 secs Stereo + (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1); // 0.1 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", diff --git a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp index 10c3e92..45ef416 100755 --- a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp +++ b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp @@ -152,6 +152,7 @@ struct ReverbContext{ bool preset; uint16_t curPreset; uint16_t nextPreset; + int SamplesToExitCount; }; #define REVERB_DEFAULT_PRESET REVERB_PRESET_MEDIUMROOM @@ -212,6 +213,7 @@ extern "C" int EffectCreate(effect_uuid_t *uuid, desc = gDescriptors[i]; if (memcmp(uuid, &desc->uuid, sizeof(effect_uuid_t)) == 0) { + LOGV("\tEffectCreate - UUID matched Reverb type %d, UUID = %x", i, desc->uuid.timeLow); break; } } @@ -228,6 +230,9 @@ extern "C" int EffectCreate(effect_uuid_t *uuid, pContext->auxiliary = false; if ((desc->flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY){ pContext->auxiliary = true; + LOGV("\tEffectCreate - AUX"); + }else{ + LOGV("\tEffectCreate - INS"); } pContext->preset = false; @@ -236,6 +241,9 @@ extern "C" int EffectCreate(effect_uuid_t *uuid, // force reloading preset at first call to process() pContext->curPreset = REVERB_PRESET_LAST + 1; pContext->nextPreset = REVERB_DEFAULT_PRESET; + LOGV("\tEffectCreate - PRESET"); + }else{ + LOGV("\tEffectCreate - ENVIRONMENTAL"); } LOGV("\tEffectCreate - Calling Reverb_init"); @@ -389,22 +397,19 @@ int process( LVM_INT16 *pIn, int frameCount, ReverbContext *pContext){ - LVM_INT16 samplesPerFrame = 0; + LVM_INT16 samplesPerFrame = 1; LVREV_ReturnStatus_en LvmStatus = LVREV_SUCCESS; /* Function call status */ LVM_INT16 *OutFrames16; // Check that the input is either mono or stereo - if(pContext->config.inputCfg.channels == CHANNEL_STEREO){ + if (pContext->config.inputCfg.channels == CHANNEL_STEREO) { samplesPerFrame = 2; - } else if (pContext->config.inputCfg.channels == CHANNEL_MONO){ - samplesPerFrame = 1; - } else { + } else if (pContext->config.inputCfg.channels != CHANNEL_MONO) { LOGV("\tLVREV_ERROR : process invalid PCM format"); return -EINVAL; } - OutFrames16 = (LVM_INT16 *)pContext->OutFrames32; // Check for NULL pointers @@ -437,43 +442,49 @@ int process( LVM_INT16 *pIn, //pContext->config.outputCfg.channels, CHANNEL_STEREO); if (pContext->preset && pContext->curPreset == REVERB_PRESET_NONE) { - memset(pContext->OutFrames32, 0, frameCount * sizeof(LVM_INT32) * 2); + memset(pContext->OutFrames32, 0, frameCount * sizeof(LVM_INT32) * 2); //always stereo here } else { - /* Process the samples */ - LvmStatus = LVREV_Process(pContext->hInstance, /* Instance handle */ - pContext->InFrames32, /* Input buffer */ - pContext->OutFrames32, /* Output buffer */ - frameCount); /* Number of samples to read */ - } - - if (!pContext->auxiliary) { - for (int i=0; iOutFrames32[i] += pContext->InFrames32[i]; + if(pContext->bEnabled == LVM_FALSE && pContext->SamplesToExitCount > 0) { + memset(pContext->InFrames32, + 0, + frameCount * sizeof(LVM_INT32) * 2); //always stereo here } + + /* Process the samples */ + LvmStatus = LVREV_Process(pContext->hInstance, /* Instance handle */ + pContext->InFrames32, /* Input buffer */ + pContext->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; iOutFrames32[i]>>8); + if (pContext->auxiliary) { + for (int i=0; i < frameCount*2; i++) { //always stereo here + OutFrames16[i] = clamp16(pContext->OutFrames32[i]>>8); + } + } else { + for (int i=0; i < frameCount*2; i++) { //always stereo here + OutFrames16[i] = clamp16((pContext->OutFrames32[i]>>8) + (LVM_INT32)pIn[i]); + } } #ifdef LVM_PCM - fwrite(OutFrames16, frameCount*sizeof(LVM_INT16)*samplesPerFrame, 1, pContext->PcmOutPtr); + fwrite(OutFrames16, frameCount*sizeof(LVM_INT16)*2, 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; iconfig, pConfig, sizeof(effect_config_t)); + switch (pConfig->inputCfg.samplingRate) { case 8000: SampleRate = LVM_FS_8000; @@ -741,6 +753,8 @@ int Reverb_init(ReverbContext *pContext){ params.Damping = 21; params.RoomSize = 100; + pContext->SamplesToExitCount = (params.T60 * pContext->config.inputCfg.samplingRate)/1000; + /* 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 @@ -1082,7 +1096,8 @@ int16_t ReverbGetRoomLevel(ReverbContext *pContext){ //LOGV("\tReverbGetRoomLevel, Level = %d, pContext->SavedRoomLevel = %d, " // "pContext->SavedReverbLevel = %d, CombinedLevel = %d, level = %d", - //ActiveParams.Level, pContext->SavedRoomLevel, pContext->SavedReverbLevel, CombinedLevel, level); + // 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", @@ -1129,6 +1144,8 @@ void ReverbSetDecayTime(ReverbContext *pContext, uint32_t time){ LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetDecayTime") //LOGV("\tReverbSetDecayTime() just Set -> %d\n", ActiveParams.T60); + pContext->SamplesToExitCount = (ActiveParams.T60 * pContext->config.inputCfg.samplingRate)/1000; + //LOGV("\tReverbSetDecayTime() just Set SamplesToExitCount-> %d\n",pContext->SamplesToExitCount); pContext->SavedDecayTime = time; //LOGV("\tReverbSetDecayTime end"); return; @@ -1769,8 +1786,12 @@ extern "C" int Reverb_process(effect_interface_t self, return -EINVAL; } if (pContext->bEnabled == LVM_FALSE){ - LOGV("\tReverb_process() ERROR Effect is not enabled"); - return -ENODATA; + if( pContext->SamplesToExitCount > 0){ + pContext->SamplesToExitCount -= outBuffer->frameCount; + }else{ + LOGV("\tReverb_process() ERROR Effect is not enabled %d", pContext->SamplesToExitCount); + 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 */ @@ -1791,6 +1812,9 @@ extern "C" int Reverb_command(effect_interface_t self, void *pReplyData){ android::ReverbContext * pContext = (android::ReverbContext *) self; int retsize; + LVREV_ControlParams_st ActiveParams; /* Current control Parameters */ + LVREV_ReturnStatus_en LvmStatus=LVREV_SUCCESS; /* Function call status */ + if (pContext == NULL){ LOGV("\tLVM_ERROR : Reverb_command ERROR pContext == NULL"); @@ -1917,6 +1941,12 @@ extern "C" int Reverb_command(effect_interface_t self, } *(int *)pReplyData = 0; pContext->bEnabled = LVM_TRUE; + /* Get the current settings */ + LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams); + LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "EFFECT_CMD_ENABLE") + pContext->SamplesToExitCount = + (ActiveParams.T60 * pContext->config.inputCfg.samplingRate)/1000; + //LOGV("\tEFFECT_CMD_ENABLE SamplesToExitCount = %d", pContext->SamplesToExitCount); break; case EFFECT_CMD_DISABLE: //LOGV("\tReverb_command cmdCode Case: " @@ -1939,8 +1969,8 @@ extern "C" int Reverb_command(effect_interface_t self, 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"); + //LOGV("\tReverb_command cmdCode Case: " + // "EFFECT_CMD_SET_DEVICE/EFFECT_CMD_SET_VOLUME/EFFECT_CMD_SET_AUDIO_MODE start"); break; default: -- cgit v1.1