• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright  2019 Google LLC
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  *     https://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 #ifndef ANDROID_FXLAB_OVERDRIVEDESCRIPTION_H
17 #define ANDROID_FXLAB_OVERDRIVEDESCRIPTION_H
18 
19 #include <limits>
20 #include <cmath>
21 #include <iterator>
22 
23 #include "EffectDescription.h"
24 #include "../SingleFunctionEffects.h"
25 #include "../DriveControl.h"
26 
27 namespace  Effect {
28 class OverdriveDescription : public EffectDescription<OverdriveDescription, 1> {
29 public:
getName()30     static constexpr std::string_view getName() {
31         return std::string_view("Overdrive");
32     }
33 
getCategory()34     static constexpr std::string_view getCategory() {
35         return std::string_view("Nonlinear");
36     }
37 
getParams()38     static constexpr std::array<ParamType, getNumParams()> getParams() {
39         return std::array<ParamType, getNumParams()>{
40             ParamType("Drive (db)", -10, 50, 0)
41         };
42     }
43 
44     template<class iter_type>
buildEffect(std::array<float,getNumParams ()> paramArr)45     static _ef<iter_type> buildEffect(std::array<float, getNumParams()> paramArr) {
46         double scale = pow(2.0, paramArr[0] / 10);
47         return DriveControl<iter_type> {SingleFunctionEffects::overdrive<iter_type>, scale};
48     }
49 };
50 }
51 #endif //ANDROID_FXLAB_OVERDRIVEDESCRIPTION_H
52