• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 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 
18 #ifndef OBOETESTER_EXPONENTIAL_SHAPE_H
19 #define OBOETESTER_EXPONENTIAL_SHAPE_H
20 
21 #include "flowgraph/FlowGraphNode.h"
22 
23 /**
24  * Generate a exponential sweep between min and max.
25  *
26  * The waveform is not band-limited so it will have aliasing artifacts at higher frequencies.
27  */
28 class ExponentialShape : public oboe::flowgraph::FlowGraphFilter {
29 public:
30     ExponentialShape();
31 
32     int32_t onProcess(int32_t numFrames) override;
33 
getMinimum()34     float getMinimum() const {
35         return mMinimum;
36     }
37 
38     /**
39      * The minimum and maximum should not span zero.
40      * They should both be positive or both negative.
41      *
42      * @param minimum
43      */
setMinimum(float minimum)44     void setMinimum(float minimum) {
45         mMinimum = minimum;
46         mRatio = mMaximum / mMinimum;
47     }
48 
getMaximum()49     float getMaximum() const {
50         return mMaximum;
51     }
52 
53     /**
54      * The minimum and maximum should not span zero.
55      * They should both be positive or both negative.
56      *
57      * @param maximum
58      */
setMaximum(float maximum)59     void setMaximum(float maximum) {
60         mMaximum = maximum;
61         mRatio = mMaximum / mMinimum;
62     }
63 
64 private:
65 float mMinimum = 0.0;
66 float mMaximum = 1.0;
67 float mRatio = 1.0;
68 };
69 
70 #endif //OBOETESTER_EXPONENTIAL_SHAPE_H
71