1 /* Effect: change sample rate Copyright (c) 2008 robs@users.sourceforge.net
3 * This library is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation; either version 2.1 of the License, or (at
6 * your option) any later version.
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
11 * General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 static const sample_t half_fir_coefs_25
[] = {
21 4.9866643051942178e-001, 3.1333582318860204e-001, 1.2567743716165585e-003,
22 -9.2035726038137103e-002, -1.0507348255277846e-003, 4.2764945027796687e-002,
23 7.7661461450703555e-004, -2.0673365323361139e-002, -5.0429677622613805e-004,
24 9.4223774565849357e-003, 2.8491539998284476e-004, -3.8562347294894628e-003,
25 -1.3803431143314762e-004, 1.3634218103234187e-003, 5.6110366313398705e-005,
26 -3.9872042837864422e-004, -1.8501044952475473e-005, 9.0580351350892191e-005,
27 4.6764104835321042e-006, -1.4284332593063177e-005, -8.1340436298087893e-007,
28 1.1833367010222812e-006, 7.3979325233687461e-008,
30 static const sample_t half_fir_coefs_low
[] = {
31 4.2759802493108773e-001, 3.0939308096100709e-001, 6.9285325719540158e-002,
32 -8.0642059355533674e-002, -6.0528749718348158e-002, 2.5228940037788555e-002,
33 4.7756850372993369e-002, 8.7463256642532057e-004, -3.3208422093026498e-002,
34 -1.3425983316344854e-002, 1.9188320662637096e-002, 1.7478840713827052e-002,
35 -7.5527851809344612e-003, -1.6145235261724403e-002, -6.3013968965413430e-004,
36 1.1965551091184719e-002, 5.1714613100614501e-003, -6.9898749683755968e-003,
37 -6.6150222806158742e-003, 2.6394681964090937e-003, 5.9365183404658526e-003,
38 3.5567920638016650e-004, -4.2031898513566123e-003, -1.8738555289555877e-003,
39 2.2991238738122328e-003, 2.2058519188488186e-003, -7.7796582498205363e-004,
40 -1.8212814627239918e-003, -1.4964619042558244e-004, 1.1706370821176716e-003,
41 5.3082071395224866e-004, -5.6771020453353900e-004, -5.4472363026668942e-004,
42 1.5914542178505357e-004, 3.8911127354338085e-004, 4.2076035174603683e-005,
43 -2.1015548483049000e-004, -9.5381290156278399e-005, 8.0903081108059553e-005,
44 7.5812875822003258e-005, -1.5004304266040688e-005, -3.9149443482028750e-005,
45 -6.0893901283459912e-006, 1.4040363940567877e-005, 4.9834316581482789e-006,
47 #define FUNCTION half_sample_25
48 #define CONVOLVE _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
49 #define COEFS half_fir_coefs_25
50 assert_static(!((array_length(COEFS
)- 1) & 1), HALF_FIR_LENGTH_25
);
51 #include "rate_half_fir.h"
52 #define FUNCTION half_sample_low
53 #define CONVOLVE _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
54 #define COEFS half_fir_coefs_low
55 assert_static(!((array_length(COEFS
)- 1) & 1), HALF_FIR_LENGTH_low
);
56 #include "rate_half_fir.h"
58 #define poly_fir_convolve_d100 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
59 #define FUNCTION d100_0
60 #define FIR_LENGTH d100_l
61 #define CONVOLVE poly_fir_convolve_d100
62 #include "rate_poly_fir0.h"
63 #define FUNCTION d100_1
66 #define FIR_LENGTH d100_l
67 #define CONVOLVE poly_fir_convolve_d100
68 #include "rate_poly_fir.h"
70 #define FUNCTION d100_2
73 #define FIR_LENGTH d100_l
74 #define CONVOLVE poly_fir_convolve_d100
75 #include "rate_poly_fir.h"
77 #define FUNCTION d100_3
80 #define FIR_LENGTH d100_l
81 #define CONVOLVE poly_fir_convolve_d100
82 #include "rate_poly_fir.h"
85 #define poly_fir_convolve_d120 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
86 #define FUNCTION d120_0
87 #define FIR_LENGTH d120_l
88 #define CONVOLVE poly_fir_convolve_d120
89 #include "rate_poly_fir0.h"
90 #define FUNCTION d120_1
93 #define FIR_LENGTH d120_l
94 #define CONVOLVE poly_fir_convolve_d120
95 #include "rate_poly_fir.h"
97 #define FUNCTION d120_2
100 #define FIR_LENGTH d120_l
101 #define CONVOLVE poly_fir_convolve_d120
102 #include "rate_poly_fir.h"
104 #define FUNCTION d120_3
105 #define COEF_INTERP 3
107 #define FIR_LENGTH d120_l
108 #define CONVOLVE poly_fir_convolve_d120
109 #include "rate_poly_fir.h"
112 #define poly_fir_convolve_d150 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
113 #define FUNCTION d150_0
114 #define FIR_LENGTH d150_l
115 #define CONVOLVE poly_fir_convolve_d150
116 #include "rate_poly_fir0.h"
117 #define FUNCTION d150_1
118 #define COEF_INTERP 1
119 #define PHASE_BITS 12
120 #define FIR_LENGTH d150_l
121 #define CONVOLVE poly_fir_convolve_d150
122 #include "rate_poly_fir.h"
124 #define FUNCTION d150_2
125 #define COEF_INTERP 2
126 #define PHASE_BITS 10
127 #define FIR_LENGTH d150_l
128 #define CONVOLVE poly_fir_convolve_d150
129 #include "rate_poly_fir.h"
131 #define FUNCTION d150_3
132 #define COEF_INTERP 3
134 #define FIR_LENGTH d150_l
135 #define CONVOLVE poly_fir_convolve_d150
136 #include "rate_poly_fir.h"
139 #define poly_fir_convolve_U100 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
140 #define FUNCTION U100_0
141 #define FIR_LENGTH U100_l
142 #define CONVOLVE poly_fir_convolve_U100
143 #include "rate_poly_fir0.h"
144 #define FUNCTION U100_1
145 #define COEF_INTERP 1
146 #define PHASE_BITS 10
147 #define FIR_LENGTH U100_l
148 #define CONVOLVE poly_fir_convolve_U100
149 #include "rate_poly_fir.h"
151 #define FUNCTION U100_2
152 #define COEF_INTERP 2
154 #define FIR_LENGTH U100_l
155 #define CONVOLVE poly_fir_convolve_U100
156 #include "rate_poly_fir.h"
158 #define FUNCTION U100_3
159 #define COEF_INTERP 3
161 #define FIR_LENGTH U100_l
162 #define CONVOLVE poly_fir_convolve_U100
163 #include "rate_poly_fir.h"
166 #define poly_fir_convolve_u100 _ _ _ _ _ _ _ _ _ _
167 #define FUNCTION u100_0
168 #define FIR_LENGTH u100_l
169 #define CONVOLVE poly_fir_convolve_u100
170 #include "rate_poly_fir0.h"
171 #define FUNCTION u100_1
172 #define COEF_INTERP 1
174 #define FIR_LENGTH u100_l
175 #define CONVOLVE poly_fir_convolve_u100
176 #include "rate_poly_fir.h"
178 #define FUNCTION u100_2
179 #define COEF_INTERP 2
181 #define FIR_LENGTH u100_l
182 #define CONVOLVE poly_fir_convolve_u100
183 #include "rate_poly_fir.h"
185 #define FUNCTION u100_3
186 #define COEF_INTERP 3
188 #define FIR_LENGTH u100_l
189 #define CONVOLVE poly_fir_convolve_u100
190 #include "rate_poly_fir.h"
193 #define poly_fir_convolve_u120 _ _ _ _ _ _ _ _ _ _ _ _ _ _
194 #define FUNCTION u120_0
195 #define FIR_LENGTH u120_l
196 #define CONVOLVE poly_fir_convolve_u120
197 #include "rate_poly_fir0.h"
198 #define FUNCTION u120_1
199 #define COEF_INTERP 1
200 #define PHASE_BITS 10
201 #define FIR_LENGTH u120_l
202 #define CONVOLVE poly_fir_convolve_u120
203 #include "rate_poly_fir.h"
205 #define FUNCTION u120_2
206 #define COEF_INTERP 2
208 #define FIR_LENGTH u120_l
209 #define CONVOLVE poly_fir_convolve_u120
210 #include "rate_poly_fir.h"
212 #define FUNCTION u120_3
213 #define COEF_INTERP 3
215 #define FIR_LENGTH u120_l
216 #define CONVOLVE poly_fir_convolve_u120
217 #include "rate_poly_fir.h"
220 #define poly_fir_convolve_u150 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
221 #define FUNCTION u150_0
222 #define FIR_LENGTH u150_l
223 #define CONVOLVE poly_fir_convolve_u150
224 #include "rate_poly_fir0.h"
225 #define FUNCTION u150_1
226 #define COEF_INTERP 1
227 #define PHASE_BITS 11
228 #define FIR_LENGTH u150_l
229 #define CONVOLVE poly_fir_convolve_u150
230 #include "rate_poly_fir.h"
232 #define FUNCTION u150_2
233 #define COEF_INTERP 2
235 #define FIR_LENGTH u150_l
236 #define CONVOLVE poly_fir_convolve_u150
237 #include "rate_poly_fir.h"
239 #define FUNCTION u150_3
240 #define COEF_INTERP 3
242 #define FIR_LENGTH u150_l
243 #define CONVOLVE poly_fir_convolve_u150
244 #include "rate_poly_fir.h"
246 typedef struct {int phase_bits
; stage_fn_t fn
;} poly_fir1_t
;
247 typedef struct {int num_coefs
; double pass
, stop
, att
; poly_fir1_t interp
[4];} poly_fir_t
;
248 static poly_fir_t
const poly_firs
[] = {
249 {d100_l
, .75,1.5, 108, {{0, d100_0
}, {d100_1_b
, d100_1
}, {d100_2_b
, d100_2
}, {d100_3_b
, d100_3
}}},
250 {d120_l
, 1, 1.5, 133, {{0, d120_0
}, {d120_1_b
, d120_1
}, {d120_2_b
, d120_2
}, {d120_3_b
, d120_3
}}},
251 {d150_l
, 1, 1.5, 165, {{0, d150_0
}, {d150_1_b
, d150_1
}, {d150_2_b
, d150_2
}, {d150_3_b
, d150_3
}}},
252 {U100_l
, .724, 1, 105, {{0, U100_0
}, {U100_1_b
, U100_1
}, {U100_2_b
, U100_2
}, {U100_3_b
, U100_3
}}},
253 {u100_l
, .3, 1.5, 107, {{0, u100_0
}, {u100_1_b
, u100_1
}, {u100_2_b
, u100_2
}, {u100_3_b
, u100_3
}}},
254 {u120_l
, .5, 1.5, 125, {{0, u120_0
}, {u120_1_b
, u120_1
}, {u120_2_b
, u120_2
}, {u120_3_b
, u120_3
}}},
255 {u150_l
, .5, 1.5, 174, {{0, u150_0
}, {u150_1_b
, u150_1
}, {u150_2_b
, u150_2
}, {u150_3_b
, u150_3
}}},