CUGL 1.3
Cornell University Game Library
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
CUDSPMath.h
1 //
2 // CUDSPMath.h
3 // Cornell University Game Library (CUGL)
4 //
5 // This class is represents a class of static methods for performing basic
6 // DSP calculations, like addition and multiplication. As with the DSP
7 // filters, this class supports vector optimizations for SSE and Neon 64.
8 // Our implementation is limited to 128-bit words. While 256-bit (e.g. AVX)
9 // are more performant, they are not better for DSP filters and so we keep
10 // the optimizations at the same level.
11 //
12 // CUGL MIT License:
13 // This software is provided 'as-is', without any express or implied
14 // warranty. In no event will the authors be held liable for any damages
15 // arising from the use of this software.
16 //
17 // Permission is granted to anyone to use this software for any purpose,
18 // including commercial applications, and to alter it and redistribute it
19 // freely, subject to the following restrictions:
20 //
21 // 1. The origin of this software must not be misrepresented; you must not
22 // claim that you wrote the original software. If you use this software
23 // in a product, an acknowledgment in the product documentation would be
24 // appreciated but is not required.
25 //
26 // 2. Altered source versions must be plainly marked as such, and must not
27 // be misrepresented as being the original software.
28 //
29 // 3. This notice may not be removed or altered from any source distribution.
30 //
31 // Author: Walker White
32 // Version: 10/11/18
33 //
34 #ifndef __CU_DSP_MATH_H__
35 #define __CU_DSP_MATH_H__
36 #include "../CUMathBase.h"
37 
38 namespace cugl {
39  namespace dsp {
40 
53 class DSPMath {
54 private:
58  DSPMath() {}
59 
63  ~DSPMath() {}
64 
65 
66 public:
68  static bool VECTORIZE;
69 
70 #pragma mark Arithmetic Methods
71 
83  static size_t add(float* input1, float* input2, float* output, size_t size);
84 
97  static size_t multiply(float* input1, float* input2, float* output, size_t size);
98 
111  static size_t scale(float* input, float scalar, float* output, size_t size);
112 
126  static size_t scale_add(float* input1, float* input2, float scalar, float* output, size_t size);
127 
128 #pragma mark Fade-In/Out Methods
129 
146  static size_t slide(float* input, float start, float end, float* output, size_t size);
147 
166  static size_t slide_add(float* input1, float* input2, float start, float end, float* output, size_t size);
167 
168 #pragma mark Clamp Methods
169 
179  static size_t clamp(float* data, float min, float max, size_t size);
180 
197  static size_t ease(float* data, float bound, float knee, size_t size);
198 
199  // TODO: Add convolution
200 
201 };
202  }
203 }
204 #endif /* __CU_DSP_MATH_H__ */
cugl::dsp::DSPMath::add
static size_t add(float *input1, float *input2, float *output, size_t size)
cugl::dsp::DSPMath::ease
static size_t ease(float *data, float bound, float knee, size_t size)
cugl::dsp::DSPMath::VECTORIZE
static bool VECTORIZE
Definition: CUDSPMath.h:68
cugl::dsp::DSPMath::clamp
static size_t clamp(float *data, float min, float max, size_t size)
cugl::dsp::DSPMath::scale_add
static size_t scale_add(float *input1, float *input2, float scalar, float *output, size_t size)
cugl::dsp::DSPMath::scale
static size_t scale(float *input, float scalar, float *output, size_t size)
cugl::dsp::DSPMath::slide_add
static size_t slide_add(float *input1, float *input2, float start, float end, float *output, size_t size)
cugl::dsp::DSPMath::slide
static size_t slide(float *input, float start, float end, float *output, size_t size)
cugl::dsp::DSPMath
Definition: CUDSPMath.h:53
cugl::dsp::DSPMath::multiply
static size_t multiply(float *input1, float *input2, float *output, size_t size)