1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <audio_effects/effect_loudnessenhancer.h> 20 21 #include "dsp/core/dynamic_range_compression.h" 22 #include "effect-impl/EffectContext.h" 23 24 namespace aidl::android::hardware::audio::effect { 25 26 enum LoudnessEnhancerState { 27 LOUDNESS_ENHANCER_STATE_UNINITIALIZED, 28 LOUDNESS_ENHANCER_STATE_INITIALIZED, 29 LOUDNESS_ENHANCER_STATE_ACTIVE, 30 }; 31 32 class LoudnessEnhancerContext final : public EffectContext { 33 public: 34 LoudnessEnhancerContext(int statusDepth, const Parameter::Common& common); 35 ~LoudnessEnhancerContext() = default; 36 37 RetCode enable() override; 38 RetCode disable() override; 39 40 RetCode setLeGain(int gainMb); getLeGain()41 int getLeGain() const { return mGain; } 42 43 IEffect::Status process(float* in, float* out, int samples); 44 45 private: 46 LoudnessEnhancerState mState = LOUDNESS_ENHANCER_STATE_UNINITIALIZED; 47 int mGain = LOUDNESS_ENHANCER_DEFAULT_TARGET_GAIN_MB; 48 // In this implementation, there is no coupling between the compression on the left and right 49 // channels 50 std::unique_ptr<le_fx::AdaptiveDynamicRangeCompression> mCompressor; 51 52 void init_params(); 53 }; 54 } // namespace aidl::android::hardware::audio::effect 55