Add a comment about waiting to kill the event thread
[openal-soft.git] / common / alcomplex.h
blob2418ce78117ec4415d8ef3d3722f329737a87eed
1 #ifndef ALCOMPLEX_H
2 #define ALCOMPLEX_H
4 #include "AL/al.h"
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
11 typedef struct ALcomplex {
12 ALdouble Real;
13 ALdouble Imag;
14 } ALcomplex;
16 /** Addition of two complex numbers. */
17 inline ALcomplex complex_add(ALcomplex a, ALcomplex b)
19 ALcomplex result;
21 result.Real = a.Real + b.Real;
22 result.Imag = a.Imag + b.Imag;
24 return result;
27 /** Subtraction of two complex numbers. */
28 inline ALcomplex complex_sub(ALcomplex a, ALcomplex b)
30 ALcomplex result;
32 result.Real = a.Real - b.Real;
33 result.Imag = a.Imag - b.Imag;
35 return result;
38 /** Multiplication of two complex numbers. */
39 inline ALcomplex complex_mult(ALcomplex a, ALcomplex b)
41 ALcomplex result;
43 result.Real = a.Real*b.Real - a.Imag*b.Imag;
44 result.Imag = a.Imag*b.Real + a.Real*b.Imag;
46 return result;
49 /**
50 * Iterative implementation of 2-radix FFT (In-place algorithm). Sign = -1 is
51 * FFT and 1 is iFFT (inverse). Fills FFTBuffer[0...FFTSize-1] with the
52 * Discrete Fourier Transform (DFT) of the time domain data stored in
53 * FFTBuffer[0...FFTSize-1]. FFTBuffer is an array of complex numbers, FFTSize
54 * MUST BE power of two.
56 void complex_fft(ALcomplex *FFTBuffer, ALsizei FFTSize, ALdouble Sign);
58 /**
59 * Calculate the complex helical sequence (discrete-time analytical signal) of
60 * the given input using the discrete Hilbert transform (In-place algorithm).
61 * Fills Buffer[0...size-1] with the discrete-time analytical signal stored in
62 * Buffer[0...size-1]. Buffer is an array of complex numbers, size MUST BE
63 * power of two.
65 void complex_hilbert(ALcomplex *Buffer, ALsizei size);
67 #ifdef __cplusplus
68 } // extern "C"
69 #endif
71 #endif /* ALCOMPLEX_H */