id3: fix COMM frame handling
[sox.git] / src / rate_half_fir.h
blob4327e6188e14360133aad83cab47eeabf8052f0d
1 /* Effect: change sample rate Copyright (c) 2008,12 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
18 /* Down-sample by a factor of 2 using a FIR with odd length (LEN).*/
19 /* Input must be preceded and followed by LEN >> 1 samples. */
21 #define _ sum += (input[-(2*j +1)] + input[(2*j +1)]) * COEFS[j], ++j;
22 static void FUNCTION(stage_t * p, fifo_t * output_fifo)
24 sample_t const * input = stage_read_p(p);
25 int i, num_out = (stage_occupancy(p) + 1) / 2;
26 sample_t * output = fifo_reserve(output_fifo, num_out);
28 for (i = 0; i < num_out; ++i, input += 2) {
29 int j = 0;
30 sample_t sum = input[0] * .5;
31 CONVOLVE
32 output[i] = sum;
34 fifo_read(&p->fifo, 2 * num_out, NULL);
36 #undef _
37 #undef COEFS
38 #undef CONVOLVE
39 #undef FUNCTION