199e53b86eebb605b70dd7591b89bf61a9414ed0eGlenn Kasten/*
265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * Copyright (C) 2013 The Android Open Source Project
365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian *
465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * Licensed under the Apache License, Version 2.0 (the "License");
565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * you may not use this file except in compliance with the License.
665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * You may obtain a copy of the License at
765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian *
865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian *      http://www.apache.org/licenses/LICENSE-2.0
965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian *
1065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * Unless required by applicable law or agreed to in writing, software
1165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * distributed under the License is distributed on an "AS IS" BASIS,
1265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * See the License for the specific language governing permissions and
1465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * limitations under the License.
1565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian */
1665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#ifndef LE_FX_ENGINE_DSP_CORE_DYNAMIC_RANGE_COMPRESSION_INL_H_
1765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#define LE_FX_ENGINE_DSP_CORE_DYNAMIC_RANGE_COMPRESSION_INL_H_
1865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
1965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#ifndef LOG_TAG
2065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#define LOG_TAG NULL
215b17c0b5b418c340d3e5201a72ee8c88c1755355Glenn Kasten#endif
2265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian//#define LOG_NDEBUG 0
2365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
2465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#include <log/log.h>
2565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
264ff14bae91075eb274eb1c2975982358946e7e63John Grossmannamespace le_fx {
274ff14bae91075eb274eb1c2975982358946e7e63John Grossman
28e762be91c3280d837b1d48455cba90459ced7511Mathias Agopianinline void AdaptiveDynamicRangeCompression::set_knee_threshold(float decibel) {
29e762be91c3280d837b1d48455cba90459ced7511Mathias Agopian  // Converts to 1og-base
3065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian  knee_threshold_in_decibel_ = decibel;
3165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian  knee_threshold_ = 0.1151292546497023061569109358970308676362037658691406250f *
3265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian      decibel + 10.39717719035538401328722102334722876548767089843750f;
3365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian}
34335787fe43596f38ea2fa50b24c54d0823a3fb1dGlenn Kasten
354ff14bae91075eb274eb1c2975982358946e7e63John Grossman
3665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopianinline void AdaptiveDynamicRangeCompression::set_knee_threshold_via_target_gain(
3765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    float target_gain) {
3865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian  const float decibel = target_gain_to_knee_threshold_.Interpolate(
3965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        target_gain);
4065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian  ALOGV("set_knee_threshold_via_target_gain: decibel =%.3fdB", decibel);
41799a70e7028a4d714436c3a744a775acfbd31aaeDima Zavin  set_knee_threshold(decibel);
4265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian}
4365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
445462fc9a38fa8c9dff434cd53fa5fb1782ae3042Mathias Agopian}  // namespace le_fx
455462fc9a38fa8c9dff434cd53fa5fb1782ae3042Mathias Agopian
465462fc9a38fa8c9dff434cd53fa5fb1782ae3042Mathias Agopian
4764760240f931714858a59c1579f07264d7182ba2Dima Zavin#endif  // LE_FX_ENGINE_DSP_CORE_DYNAMIC_RANGE_COMPRESSION_INL_H_
487394a4f358fa9908a9f0a7c954b65c399f4268e6Dima Zavin