Loading media/libeffects/lvm/lib/Reverb/src/LVREV_ApplyNewSettings.c +3 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading media/libeffects/lvm/lib/Reverb/src/LVREV_GetInstanceHandle.c +2 −2 Original line number Diff line number Diff line Loading @@ -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 Loading media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c +3 −1 Original line number Diff line number Diff line Loading @@ -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); } Loading media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp +4 −8 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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", Loading media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp +57 −27 Original line number Diff line number Diff line Loading @@ -152,6 +152,7 @@ struct ReverbContext{ bool preset; uint16_t curPreset; uint16_t nextPreset; int SamplesToExitCount; }; #define REVERB_DEFAULT_PRESET REVERB_PRESET_MEDIUMROOM Loading Loading @@ -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; } } Loading @@ -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; Loading @@ -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"); Loading Loading @@ -389,7 +397,7 @@ 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; Loading @@ -397,14 +405,11 @@ int process( LVM_INT16 *pIn, // 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 { } 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 Loading Loading @@ -437,8 +442,14 @@ 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 { 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 */ Loading @@ -446,34 +457,34 @@ int process( LVM_INT16 *pIn, frameCount); /* Number of samples to read */ } if (!pContext->auxiliary) { for (int i=0; i<frameCount*2; i++){ pContext->OutFrames32[i] += pContext->InFrames32[i]; } } 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 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; i<frameCount*2; i++){ for (int i=0; i<frameCount*2; i++){ //always stereo here pOut[i] = clamp16((int32_t)pOut[i] + (int32_t)OutFrames16[i]); } }else{ //LOGV("\tBuffer access is WRITE"); memcpy(pOut, OutFrames16, frameCount*sizeof(LVM_INT16)*2); // 2 is for stereo output memcpy(pOut, OutFrames16, frameCount*sizeof(LVM_INT16)*2); } return 0; Loading Loading @@ -560,6 +571,7 @@ int Reverb_configure(ReverbContext *pContext, effect_config_t *pConfig){ //LOGV("\tReverb_configure calling memcpy"); memcpy(&pContext->config, pConfig, sizeof(effect_config_t)); switch (pConfig->inputCfg.samplingRate) { case 8000: SampleRate = LVM_FS_8000; Loading Loading @@ -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 Loading Loading @@ -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", Loading Loading @@ -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; Loading Loading @@ -1769,9 +1786,13 @@ extern "C" int Reverb_process(effect_interface_t self, return -EINVAL; } if (pContext->bEnabled == LVM_FALSE){ LOGV("\tReverb_process() ERROR Effect is not enabled"); 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 */ status = process( (LVM_INT16 *)inBuffer->raw, Loading @@ -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"); Loading Loading @@ -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: " Loading Loading
media/libeffects/lvm/lib/Reverb/src/LVREV_ApplyNewSettings.c +3 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading
media/libeffects/lvm/lib/Reverb/src/LVREV_GetInstanceHandle.c +2 −2 Original line number Diff line number Diff line Loading @@ -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 Loading
media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c +3 −1 Original line number Diff line number Diff line Loading @@ -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); } Loading
media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp +4 −8 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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", Loading
media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp +57 −27 Original line number Diff line number Diff line Loading @@ -152,6 +152,7 @@ struct ReverbContext{ bool preset; uint16_t curPreset; uint16_t nextPreset; int SamplesToExitCount; }; #define REVERB_DEFAULT_PRESET REVERB_PRESET_MEDIUMROOM Loading Loading @@ -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; } } Loading @@ -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; Loading @@ -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"); Loading Loading @@ -389,7 +397,7 @@ 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; Loading @@ -397,14 +405,11 @@ int process( LVM_INT16 *pIn, // 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 { } 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 Loading Loading @@ -437,8 +442,14 @@ 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 { 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 */ Loading @@ -446,34 +457,34 @@ int process( LVM_INT16 *pIn, frameCount); /* Number of samples to read */ } if (!pContext->auxiliary) { for (int i=0; i<frameCount*2; i++){ pContext->OutFrames32[i] += pContext->InFrames32[i]; } } 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 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; i<frameCount*2; i++){ for (int i=0; i<frameCount*2; i++){ //always stereo here pOut[i] = clamp16((int32_t)pOut[i] + (int32_t)OutFrames16[i]); } }else{ //LOGV("\tBuffer access is WRITE"); memcpy(pOut, OutFrames16, frameCount*sizeof(LVM_INT16)*2); // 2 is for stereo output memcpy(pOut, OutFrames16, frameCount*sizeof(LVM_INT16)*2); } return 0; Loading Loading @@ -560,6 +571,7 @@ int Reverb_configure(ReverbContext *pContext, effect_config_t *pConfig){ //LOGV("\tReverb_configure calling memcpy"); memcpy(&pContext->config, pConfig, sizeof(effect_config_t)); switch (pConfig->inputCfg.samplingRate) { case 8000: SampleRate = LVM_FS_8000; Loading Loading @@ -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 Loading Loading @@ -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", Loading Loading @@ -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; Loading Loading @@ -1769,9 +1786,13 @@ extern "C" int Reverb_process(effect_interface_t self, return -EINVAL; } if (pContext->bEnabled == LVM_FALSE){ LOGV("\tReverb_process() ERROR Effect is not enabled"); 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 */ status = process( (LVM_INT16 *)inBuffer->raw, Loading @@ -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"); Loading Loading @@ -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: " Loading