aboutsummaryrefslogtreecommitdiffstats
path: root/common/alcomplex.h
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-12-12 19:21:00 +0100
committerSven Gothel <[email protected]>2019-12-12 19:21:00 +0100
commit4df06c6894b39af5bf4681c0acf0c1c080084c80 (patch)
tree2505eb6e3b5798db34033c4cac2d4613bf6bda44 /common/alcomplex.h
parent8915501ed02eac2b3bce9a7fc06cb1ab562901c3 (diff)
parentc0cf323e1d56ce605e90927324d2fdafcfbb564a (diff)
merge v1.20.0
Diffstat (limited to 'common/alcomplex.h')
-rw-r--r--common/alcomplex.h66
1 files changed, 10 insertions, 56 deletions
diff --git a/common/alcomplex.h b/common/alcomplex.h
index 2418ce78..12b86436 100644
--- a/common/alcomplex.h
+++ b/common/alcomplex.h
@@ -1,71 +1,25 @@
#ifndef ALCOMPLEX_H
#define ALCOMPLEX_H
-#include "AL/al.h"
+#include <complex>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct ALcomplex {
- ALdouble Real;
- ALdouble Imag;
-} ALcomplex;
-
-/** Addition of two complex numbers. */
-inline ALcomplex complex_add(ALcomplex a, ALcomplex b)
-{
- ALcomplex result;
-
- result.Real = a.Real + b.Real;
- result.Imag = a.Imag + b.Imag;
-
- return result;
-}
-
-/** Subtraction of two complex numbers. */
-inline ALcomplex complex_sub(ALcomplex a, ALcomplex b)
-{
- ALcomplex result;
-
- result.Real = a.Real - b.Real;
- result.Imag = a.Imag - b.Imag;
-
- return result;
-}
-
-/** Multiplication of two complex numbers. */
-inline ALcomplex complex_mult(ALcomplex a, ALcomplex b)
-{
- ALcomplex result;
-
- result.Real = a.Real*b.Real - a.Imag*b.Imag;
- result.Imag = a.Imag*b.Real + a.Real*b.Imag;
-
- return result;
-}
+#include "alspan.h"
/**
* Iterative implementation of 2-radix FFT (In-place algorithm). Sign = -1 is
- * FFT and 1 is iFFT (inverse). Fills FFTBuffer[0...FFTSize-1] with the
- * Discrete Fourier Transform (DFT) of the time domain data stored in
- * FFTBuffer[0...FFTSize-1]. FFTBuffer is an array of complex numbers, FFTSize
- * MUST BE power of two.
+ * FFT and 1 is iFFT (inverse). Fills the buffer with the Discrete Fourier
+ * Transform (DFT) of the time domain data stored in the buffer. The buffer is
+ * an array of complex numbers, and MUST BE power of two.
*/
-void complex_fft(ALcomplex *FFTBuffer, ALsizei FFTSize, ALdouble Sign);
+void complex_fft(const al::span<std::complex<double>> buffer, const double sign);
/**
* Calculate the complex helical sequence (discrete-time analytical signal) of
* the given input using the discrete Hilbert transform (In-place algorithm).
- * Fills Buffer[0...size-1] with the discrete-time analytical signal stored in
- * Buffer[0...size-1]. Buffer is an array of complex numbers, size MUST BE
- * power of two.
+ * Fills the buffer with the discrete-time analytical signal stored in the
+ * buffer. The buffer is an array of complex numbers and MUST BE power of two,
+ * and the imaginary components should be cleared to 0.
*/
-void complex_hilbert(ALcomplex *Buffer, ALsizei size);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+void complex_hilbert(const al::span<std::complex<double>> buffer);
#endif /* ALCOMPLEX_H */