YSE sound engine  1.0
cross platform sound engine
 All Classes Namespaces Functions Pages
math.hpp
1 /*
2  ==============================================================================
3 
4  math.h
5  Created: 31 Jan 2014 2:54:26pm
6  Author: yvan
7 
8  ==============================================================================
9 */
10 
11 #ifndef MATH_H_INCLUDED
12 #define MATH_H_INCLUDED
13 
14 #include "../headers/types.hpp"
15 #include "sample.hpp"
16 
17 namespace YSE {
18  namespace DSP {
19  // basic converters
20  Flt API MidiToFreq(Flt note);
21  Flt API FreqToMidi(Flt freq);
22 
23  // clip audio signal at low and high value
24  class API clip {
25  public:
26  // use from anywhere
27  clip& set(Flt low, Flt high);
28  clip& setLow(Flt low);
29  clip& setHigh(Flt high);
30  clip() : low(-1.0f), high(1.0f) {}
31 
32  // use in DSP
33  AUDIOBUFFER & operator()(AUDIOBUFFER & in);
34 
35  private:
36  aFlt low;
37  aFlt high;
38  sample buffer;
39  };
40 
41  // reciprocal square root good to 8 mantissa bits
42  // use in DSP only
43  class API rSqrt {
44  public:
45  AUDIOBUFFER & operator()(AUDIOBUFFER & in);
46  rSqrt();
47  private:
48  sample buffer;
49  };
50 
51  // square root good to 8 mantissa bits
52  // use in DSP only
53  class API sqrt {
54  public:
55  AUDIOBUFFER & operator()(AUDIOBUFFER & in);
56  sqrt();
57  private:
58  sample buffer;
59  };
60 
61  // calculates difference between signal and first exceeding integer
62  // use in DSP only
63  class API wrap {
64  public:
65  AUDIOBUFFER & operator()(AUDIOBUFFER & in);
66  private:
67  sample buffer;
68  };
69 
70  // use in DSP only
71  class API midiToFreq {
72  public:
73  AUDIOBUFFER & operator()(AUDIOBUFFER & in);
74  private:
75  sample buffer;
76  };
77 
78  // use in DSP only
79  class API freqToMidi {
80  public:
81  AUDIOBUFFER & operator()(AUDIOBUFFER & in);
82  private:
83  sample buffer;
84  };
85 
86  // use in DSP only
87  class API dbToRms {
88  public:
89  AUDIOBUFFER & operator()(AUDIOBUFFER & in);
90  private:
91  sample buffer;
92  };
93 
94  // use in DSP only
95  class API rmsToDb {
96  public:
97  AUDIOBUFFER & operator()(AUDIOBUFFER & in);
98  private:
99  sample buffer;
100  };
101 
102  // use in DSP only
103  class API dbToPow {
104  public:
105  AUDIOBUFFER & operator()(AUDIOBUFFER & in);
106  private:
107  sample buffer;
108  };
109 
110  // use in DSP only
111  class API powToDb {
112  public:
113  AUDIOBUFFER & operator()(AUDIOBUFFER & in);
114  private:
115  sample buffer;
116  };
117 
118  // use in DSP only
119  class API pow {
120  public:
121  AUDIOBUFFER & operator()(AUDIOBUFFER & in1, AUDIOBUFFER & in2);
122  private:
123  sample buffer;
124  };
125 
126  // use in DSP only
127  class API exp {
128  public:
129  AUDIOBUFFER & operator()(AUDIOBUFFER & in);
130  private:
131  sample buffer;
132  };
133 
134  // use in DSP only
135  class API log {
136  public:
137  AUDIOBUFFER & operator()(AUDIOBUFFER & in1, AUDIOBUFFER & in2);
138  private:
139  sample buffer;
140  };
141 
142  // use in DSP only
143  class API abs {
144  public:
145  AUDIOBUFFER & operator()(AUDIOBUFFER & in);
146  private:
147  sample buffer;
148  };
149  }
150 }
151 
152 #endif // MATH_H_INCLUDED