diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2013-09-10 09:15:18 -0700 |
---|---|---|
committer | Jean-Michel Trivi <jmtrivi@google.com> | 2013-09-17 18:43:01 -0700 |
commit | 6cc3a9948b51193dfdcb0c3527d7f3d1ca38aa3c (patch) | |
tree | 5545a323750c07f0210f43f727e828ec7fa9f918 /media/libeffects/loudness/dsp/core/interpolator_linear.h | |
parent | 18f861404efc054da0a2ea6c582e293940f63bc8 (diff) | |
download | frameworks_av-6cc3a9948b51193dfdcb0c3527d7f3d1ca38aa3c.zip frameworks_av-6cc3a9948b51193dfdcb0c3527d7f3d1ca38aa3c.tar.gz frameworks_av-6cc3a9948b51193dfdcb0c3527d7f3d1ca38aa3c.tar.bz2 |
LoudnessEnhancer audio effect implementation
Implementation based on DRC effect, controlled by a
target gain.
The target gain is used to amplify the signal at
the input of the DRC, and to compute the knee
of the DRC.
Bug 8413913
Change-Id: I386d64793a9fa3f7218e053d6f0a99f6836c02bd
Diffstat (limited to 'media/libeffects/loudness/dsp/core/interpolator_linear.h')
-rw-r--r-- | media/libeffects/loudness/dsp/core/interpolator_linear.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/media/libeffects/loudness/dsp/core/interpolator_linear.h b/media/libeffects/loudness/dsp/core/interpolator_linear.h new file mode 100644 index 0000000..434698a --- /dev/null +++ b/media/libeffects/loudness/dsp/core/interpolator_linear.h @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2013 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 LE_FX_ENGINE_DSP_CORE_INTERPOLATOR_LINEAR_H_ +#define LE_FX_ENGINE_DSP_CORE_INTERPOLATOR_LINEAR_H_ + +#include <math.h> +#include "dsp/core/interpolator_base.h" + +namespace le_fx { + +namespace sigmod { + +// Linear interpolation class. +// +// The main functionality of this class is provided by it's base-class, so +// please refer to: InterpolatorBase +// +// Example: +// InterpolatorLinear<float> interp(x_data, y_data, data_length); +// for (int n = 0; n < data_length; n++) Y[n] = interp.Interpolate(X[n]); +// +template <typename T> +class InterpolatorLinear: public InterpolatorBase<T, InterpolatorLinear<T> > { + public: + InterpolatorLinear() { } + ~InterpolatorLinear() { } + + protected: + // Provides the main implementation of the linear interpolation algorithm. + // Assumes that: X[cached_index_] < x < X[cached_index_ + 1] + T MethodSpecificInterpolation(T x); + + // Pre-compute internal state_ parameters. + bool SetInternalState(); + + private: + friend class InterpolatorBase<T, InterpolatorLinear<T> >; + typedef InterpolatorBase<T, InterpolatorLinear<T> > BaseClass; + using BaseClass::status_; + using BaseClass::cached_index_; + using BaseClass::x_data_; + using BaseClass::y_data_; + using BaseClass::data_length_; + using BaseClass::state_; + + LE_FX_DISALLOW_COPY_AND_ASSIGN(InterpolatorLinear<T>); +}; + +template <typename T> +inline T InterpolatorLinear<T>::MethodSpecificInterpolation(T x) { + T dX = x_data_[cached_index_ + 1] - x_data_[cached_index_]; + T dY = y_data_[cached_index_ + 1] - y_data_[cached_index_]; + T dx = x - x_data_[cached_index_]; + return y_data_[cached_index_] + (dY * dx) / dX; +} + +template <typename T> +bool InterpolatorLinear<T>::SetInternalState() { + state_ = NULL; + return true; +} + +} // namespace sigmod + +} // namespace le_fx + +#endif // LE_FX_ENGINE_DSP_CORE_INTERPOLATOR_LINEAR_H_ |