Mercurial > hg > libxtract
comparison src/window.c @ 150:9283aaf1ffb8
implemented optimised FFT via the Accelerate framework. closes #5
author | Jamie Bullock <jamie@jamiebullock.com> |
---|---|
date | Wed, 09 Jan 2013 23:09:34 +0000 |
parents | baaa9d8b4d10 |
children | 826eb46b2f91 |
comparison
equal
deleted
inserted
replaced
149:0881cd514c9c | 150:9283aaf1ffb8 |
---|---|
54 | 54 |
55 int n; | 55 int n; |
56 const double M = N - 1; | 56 const double M = N - 1; |
57 | 57 |
58 for (n = 0; n < N; n++) | 58 for (n = 0; n < N; n++) |
59 window[n] = 0.53836 - (0.46164 * cos(2.0 * PI * (double)n / M)); | 59 window[n] = 0.53836 - (0.46164 * cos(2.0 * M_PI * (double)n / M)); |
60 | 60 |
61 } | 61 } |
62 | 62 |
63 void hann(double *window, const int N) | 63 void hann(double *window, const int N) |
64 { | 64 { |
65 | 65 |
66 int n; | 66 int n; |
67 const double M = N - 1; | 67 const double M = N - 1; |
68 | 68 |
69 for (n = 0; n < N; n++) | 69 for (n = 0; n < N; n++) |
70 window[n] = 0.5 * (1.0 - cos(2.0 * PI * (double)n / M)); | 70 window[n] = 0.5 * (1.0 - cos(2.0 * M_PI * (double)n / M)); |
71 | 71 |
72 } | 72 } |
73 | 73 |
74 void bartlett(double *window, const int N) | 74 void bartlett(double *window, const int N) |
75 { | 75 { |
105 | 105 |
106 for (n = 0; n < N; n++) | 106 for (n = 0; n < N; n++) |
107 { | 107 { |
108 | 108 |
109 term1 = a1 * fabs(n / M - 0.5); | 109 term1 = a1 * fabs(n / M - 0.5); |
110 term2 = a2 * cos(2.0 * PI * (double)n / M); | 110 term2 = a2 * cos(2.0 * M_PI * (double)n / M); |
111 | 111 |
112 window[n] = a0 - term1 - term2; | 112 window[n] = a0 - term1 - term2; |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
125 term2 = 0.0; | 125 term2 = 0.0; |
126 | 126 |
127 for (n = 0; n < N; n++) | 127 for (n = 0; n < N; n++) |
128 { | 128 { |
129 | 129 |
130 term1 = a1 * cos(2.0 * PI * (double)n / M); | 130 term1 = a1 * cos(2.0 * M_PI * (double)n / M); |
131 term2 = a2 * cos(4.0 * PI * (double)n / M); | 131 term2 = a2 * cos(4.0 * M_PI * (double)n / M); |
132 | 132 |
133 window[n] = a0 - term1 + term2; | 133 window[n] = a0 - term1 + term2; |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
191 term3 = 0.0; | 191 term3 = 0.0; |
192 | 192 |
193 for (n = 0; n < N; n++) | 193 for (n = 0; n < N; n++) |
194 { | 194 { |
195 | 195 |
196 term1 = a1 * cos(2.0 * PI * n / M); | 196 term1 = a1 * cos(2.0 * M_PI * n / M); |
197 term2 = a2 * cos(4.0 * PI * n / M); | 197 term2 = a2 * cos(4.0 * M_PI * n / M); |
198 term3 = a3 * cos(6.0 * PI * n / M); | 198 term3 = a3 * cos(6.0 * M_PI * n / M); |
199 | 199 |
200 window[n] = a0 - term1 + term2 - term3; | 200 window[n] = a0 - term1 + term2 - term3; |
201 } | 201 } |
202 } | 202 } |