Add FS #10214. Initial commit of the original PDa code for the GSoC Pure Data plugin...
[kugel-rb.git] / apps / plugins / pdbox / PDa / src / m_fixed.h
blob4ccc121ac10aee4a4e46e5b9bcf8d336e740f6d3
1 #ifndef __M_FIXED_H__
2 #define __M_FIXED_H__
4 typedef int t_sample;
6 #define t_fixed int
7 #define fix1 18 /* (18) number of bits after comma */
10 #define fixfac ((float)(1<<fix1)) /* float factor (for scaling ftofix ..) */
13 /* fixed point multiplication and division */
15 #define mult(a,b) (long long)(((long long) (a) * (long long) (b))>>fix1)
16 #define idiv(a,b) ((((long long) (a) )<<fix1)/(long long) (b) )
18 /* conversion macros */
20 #define itofix(a) ((a) << fix1)
21 #define ftofix(a) ((t_fixed)( (a) *(double)fixfac + 0.5))
23 #define fixtof(a) ((double) (a) * 1./(fixfac-0.5))
24 #define fixtoi(a) ((a) >>fix1)
27 /* Not working !! */
29 #define fnum(a) ( (a) >>(fix1-16))
30 #define ffrac(a) (0)
33 /* mapping of fft functions */
35 #ifdef FIXEDPOINT
36 #define mayer_realifft imayer_realifft
37 #define mayer_realfft imayer_realfft
38 #define mayer_fft imayer_fft
39 #define mayer_ifft imayer_ifft
40 #endif
42 #ifdef FIXEDPOINT
43 #define SCALE16(x) (x>>(fix1-15))
44 #define SCALE32(x) (x<<(32-fix1))
45 #define INVSCALE16(x) (x<<8)
46 #else
47 #define SCALE16(x) (32767.*x)
48 #define SCALE32(x) (2147483648.*x)
49 #define INVSCALE16(x) ((float)3.051850e-05*x)
50 #endif
53 #endif
56 #ifndef __M_FIXED_H__
57 #define __M_FIXED_H__
59 typedef int t_sample;
61 #define t_fixed int
62 #define fix1 18 /* (18) number of bits after comma */
65 #define fixfac ((float)(1<<fix1)) /* float factor (for scaling ftofix ..) */
68 /* fixed point multiplication and division */
70 #define mult(a,b) (long long)(((long long) (a) * (long long) (b))>>fix1)
71 #define idiv(a,b) ((((long long) (a) )<<fix1)/(long long) (b) )
73 /* conversion macros */
75 #define itofix(a) ((a) << fix1)
76 #define ftofix(a) ((t_fixed)( (a) *(double)fixfac + 0.5))
78 #define fixtof(a) ((double) (a) * 1./(fixfac-0.5))
79 #define fixtoi(a) ((a) >>fix1)
82 /* Not working !! */
84 #define fnum(a) ( (a) >>(fix1-16))
85 #define ffrac(a) (0)
88 /* mapping of fft functions */
90 #ifdef FIXEDPOINT
91 #define mayer_realifft imayer_realifft
92 #define mayer_realfft imayer_realfft
93 #define mayer_fft imayer_fft
94 #define mayer_ifft imayer_ifft
95 #endif
97 #ifdef FIXEDPOINT
98 #define SCALE16(x) (x>>(fix1-15))
99 #define SCALE32(x) (x<<(32-fix1))
100 #define INVSCALE16(x) (x<<8)
101 #else
102 #define SCALE16(x) (32767.*x)
103 #define SCALE32(x) (2147483648.*x)
104 #define INVSCALE16(x) ((float)3.051850e-05*x)
105 #endif
108 #endif