Updating osxbuild to work with OS X 10.7+/XCode 4.x.
[sox.git] / src / rate_half_fir.h
blob4fab4ffd95bfde4367efa9e0add8a6fe0729b0d3
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
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[-j] + input[j]) * 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 = 1;
30 sample_t sum = input[0] * COEFS[0];
31 CONVOLVE
32 assert(j == array_length(COEFS));
33 output[i] = sum;
35 fifo_read(&p->fifo, 2 * num_out, NULL);
37 #undef _
38 #undef COEFS
39 #undef CONVOLVE
40 #undef FUNCTION