1 /* Effect: change sample rate  Copyright (c) 2008,12 robs@users.sourceforge.net
2  *
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.
7  *
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.
12  *
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
16  */
17 
18 static const sample_t half_fir_coefs_8[] = {
19   0.3115465451887802, -0.08734497241282892, 0.03681452335604365,
20   -0.01518925831569441, 0.005454118437408876, -0.001564400922162005,
21   0.0003181701445034203, -3.48001341225749e-5,
22 };
23 #define FUNCTION h8
24 #define CONVOLVE _ _ _ _ _ _ _ _
25 #define h8_l 8
26 #define COEFS half_fir_coefs_8
27 #include "rate_half_fir.h"
28 
29 static const sample_t half_fir_coefs_9[] = {
30   0.3122703613711853, -0.08922155288172305, 0.03913974805854332,
31   -0.01725059723447163, 0.006858970092378141, -0.002304518467568703,
32   0.0006096426006051062, -0.0001132393923815236, 1.119795386287666e-5,
33 };
34 #define FUNCTION h9
35 #define CONVOLVE _ _ _ _ _ _ _ _ _
36 #define h9_l 9
37 #define COEFS half_fir_coefs_9
38 #include "rate_half_fir.h"
39 
40 static const sample_t half_fir_coefs_10[] = {
41   0.3128545521327376, -0.09075671986104322, 0.04109637155154835,
42   -0.01906629512749895, 0.008184039342054333, -0.0030766775017262,
43   0.0009639607022414314, -0.0002358552746579827, 4.025184282444155e-5,
44   -3.629779111541012e-6,
45 };
46 #define FUNCTION h10
47 #define CONVOLVE _ _ _ _ _ _ _ _ _ _
48 #define h10_l 10
49 #define COEFS half_fir_coefs_10
50 #include "rate_half_fir.h"
51 
52 static const sample_t half_fir_coefs_11[] = {
53   0.3133358837508807, -0.09203588680609488, 0.04276515428384758,
54   -0.02067356614745591, 0.00942253142371517, -0.003856330993895144,
55   0.001363470684892284, -0.0003987400965541919, 9.058629923971627e-5,
56   -1.428553070915318e-5, 1.183455238783835e-6,
57 };
58 #define FUNCTION h11
59 #define CONVOLVE _ _ _ _ _ _ _ _ _ _ _
60 #define h11_l 11
61 #define COEFS half_fir_coefs_11
62 #include "rate_half_fir.h"
63 
64 static const sample_t half_fir_coefs_12[] = {
65   0.3137392991811407, -0.0931182192961332, 0.0442050575271454,
66   -0.02210391200618091, 0.01057473015666001, -0.00462766983973885,
67   0.001793630226239453, -0.0005961819959665878, 0.0001631475979359577,
68   -3.45557865639653e-5, 5.06188341942088e-6, -3.877010943315563e-7,
69 };
70 #define FUNCTION h12
71 #define CONVOLVE _ _ _ _ _ _ _ _ _ _ _ _
72 #define h12_l 12
73 #define COEFS half_fir_coefs_12
74 #include "rate_half_fir.h"
75 
76 static const sample_t half_fir_coefs_13[] = {
77   0.3140822554324578, -0.0940458550886253, 0.04545990399121566,
78   -0.02338339450796002, 0.01164429409071052, -0.005380686021429845,
79   0.002242915773871009, -0.000822047600000082, 0.0002572510962395222,
80   -6.607320708956279e-5, 1.309926399120154e-5, -1.790719575255006e-6,
81   1.27504961098836e-7,
82 };
83 #define FUNCTION h13
84 #define CONVOLVE _ _ _ _ _ _ _ _ _ _ _ _ _
85 #define h13_l 13
86 #define COEFS half_fir_coefs_13
87 #include "rate_half_fir.h"
88 
89 static struct {int num_coefs; stage_fn_t fn; float att;} const half_firs[] = {
90   { 8, h8 , 136.51},
91   { 9, h9 , 152.32},
92   {10, h10, 168.07},
93   {11, h11, 183.78},
94   {12, h12, 199.44},
95   {13, h13, 212.75},
96 };
97 
98 #define HI_PREC_CLOCK
99 
100 #define VAR_LENGTH p->n
101 #define VAR_CONVOLVE while (j < FIR_LENGTH) _
102 #define VAR_POLY_PHASE_BITS p->phase_bits
103 
104 #define FUNCTION vpoly0
105 #define FIR_LENGTH VAR_LENGTH
106 #define CONVOLVE VAR_CONVOLVE
107 #include "rate_poly_fir0.h"
108 
109 #define FUNCTION vpoly1
110 #define COEF_INTERP 1
111 #define PHASE_BITS VAR_POLY_PHASE_BITS
112 #define FIR_LENGTH VAR_LENGTH
113 #define CONVOLVE VAR_CONVOLVE
114 #include "rate_poly_fir.h"
115 
116 #define FUNCTION vpoly2
117 #define COEF_INTERP 2
118 #define PHASE_BITS VAR_POLY_PHASE_BITS
119 #define FIR_LENGTH VAR_LENGTH
120 #define CONVOLVE VAR_CONVOLVE
121 #include "rate_poly_fir.h"
122 
123 #define FUNCTION vpoly3
124 #define COEF_INTERP 3
125 #define PHASE_BITS VAR_POLY_PHASE_BITS
126 #define FIR_LENGTH VAR_LENGTH
127 #define CONVOLVE VAR_CONVOLVE
128 #include "rate_poly_fir.h"
129 
130 #undef HI_PREC_CLOCK
131 
132 #define U100_l 42
133 #define poly_fir_convolve_U100 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
134 #define FUNCTION U100_0
135 #define FIR_LENGTH U100_l
136 #define CONVOLVE poly_fir_convolve_U100
137 #include "rate_poly_fir0.h"
138 
139 #define u100_l 11
140 #define poly_fir_convolve_u100 _ _ _ _ _ _ _ _ _ _ _
141 #define FUNCTION u100_0
142 #define FIR_LENGTH u100_l
143 #define CONVOLVE poly_fir_convolve_u100
144 #include "rate_poly_fir0.h"
145 
146 #define FUNCTION u100_1
147 #define COEF_INTERP 1
148 #define PHASE_BITS 8
149 #define FIR_LENGTH u100_l
150 #define CONVOLVE poly_fir_convolve_u100
151 #include "rate_poly_fir.h"
152 #define u100_1_b 8
153 
154 #define FUNCTION u100_2
155 #define COEF_INTERP 2
156 #define PHASE_BITS 6
157 #define FIR_LENGTH u100_l
158 #define CONVOLVE poly_fir_convolve_u100
159 #include "rate_poly_fir.h"
160 #define u100_2_b 6
161 
162 typedef struct {float scalar; stage_fn_t fn;} poly_fir1_t;
163 typedef struct {float beta; poly_fir1_t interp[3];} poly_fir_t;
164 
165 static poly_fir_t const poly_firs[] = {
166   {-1, {{0, vpoly0}, { 7.2, vpoly1}, {5.0, vpoly2}}},
167   {-1, {{0, vpoly0}, { 9.4, vpoly1}, {6.7, vpoly2}}},
168   {-1, {{0, vpoly0}, {12.4, vpoly1}, {7.8, vpoly2}}},
169   {-1, {{0, vpoly0}, {13.6, vpoly1}, {9.3, vpoly2}}},
170   {-1, {{0, vpoly0}, {10.5, vpoly2}, {8.4, vpoly3}}},
171   {-1, {{0, vpoly0}, {11.85,vpoly2}, {9.0, vpoly3}}},
172 
173   {-1, {{0, vpoly0}, { 8.0, vpoly1}, {5.3, vpoly2}}},
174   {-1, {{0, vpoly0}, { 8.6, vpoly1}, {5.7, vpoly2}}},
175   {-1, {{0, vpoly0}, {10.6, vpoly1}, {6.75,vpoly2}}},
176   {-1, {{0, vpoly0}, {12.6, vpoly1}, {8.6, vpoly2}}},
177   {-1, {{0, vpoly0}, { 9.6, vpoly2}, {7.6, vpoly3}}},
178   {-1, {{0, vpoly0}, {11.4, vpoly2}, {8.65,vpoly3}}},
179 
180   {10.62, {{U100_l, U100_0}, {0, 0}, {0, 0}}},
181   {11.28, {{u100_l, u100_0}, {u100_1_b, u100_1}, {u100_2_b, u100_2}}},
182   {-1, {{0, vpoly0}, {   9, vpoly1}, {  6, vpoly2}}},
183   {-1, {{0, vpoly0}, {  11, vpoly1}, {  7, vpoly2}}},
184   {-1, {{0, vpoly0}, {  13, vpoly1}, {  8, vpoly2}}},
185   {-1, {{0, vpoly0}, {  10, vpoly2}, {  8, vpoly3}}},
186   {-1, {{0, vpoly0}, {  12, vpoly2}, {  9, vpoly3}}},
187 };
188