Mercurial > audlegacy
comparison src/audacious/iir.c @ 2313:3149d4b1a9a9 trunk
[svn] - objective-make autodepend fixes
- move all sourcecode into src/ and adjust Makefiles accordingly
author | nenolod |
---|---|
date | Fri, 12 Jan 2007 11:43:40 -0800 |
parents | |
children | 3b6d316f8b09 |
comparison
equal
deleted
inserted
replaced
2312:e1a5a66fb9cc | 2313:3149d4b1a9a9 |
---|---|
1 /* | |
2 * PCM time-domain equalizer | |
3 * | |
4 * Copyright (C) 2002-2005 Felipe Rivera <liebremx at users sourceforge net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
19 * | |
20 * $Id: iir.c,v 1.15 2005/10/17 01:57:59 liebremx Exp $ | |
21 */ | |
22 | |
23 #include <math.h> | |
24 #include "iir.h" | |
25 | |
26 /* Coefficients */ | |
27 sIIRCoefficients *iir_cf; | |
28 | |
29 /* Volume gain | |
30 * values should be between 0.0 and 1.0 | |
31 * Use the preamp from XMMS for now | |
32 * */ | |
33 float preamp[EQ_CHANNELS]; | |
34 | |
35 #ifdef BENCHMARK | |
36 #include "benchmark.h" | |
37 double timex = 0.0; | |
38 int count = 0; | |
39 unsigned int blength = 0; | |
40 #endif | |
41 | |
42 /* | |
43 * Global vars | |
44 */ | |
45 gint rate; | |
46 int band_count; | |
47 | |
48 void set_preamp(gint chn, float val) | |
49 { | |
50 preamp[chn] = val; | |
51 } | |
52 | |
53 /* Init the filters */ | |
54 void init_iir() | |
55 { | |
56 calc_coeffs(); | |
57 #if 0 | |
58 band_count = cfg.band_num; | |
59 #endif | |
60 | |
61 band_count = 10; | |
62 | |
63 rate = 44100; | |
64 | |
65 iir_cf = get_coeffs(&band_count, rate, TRUE); | |
66 clean_history(); | |
67 } | |
68 | |
69 #ifdef ARCH_X86 | |
70 /* Round function provided by Frank Klemm which saves around 100K | |
71 * CPU cycles in my PIII for each call to the IIR function with 4K samples | |
72 */ | |
73 __inline__ int round_trick(float floatvalue_to_round) | |
74 { | |
75 float floattmp ; | |
76 int rounded_value ; | |
77 | |
78 floattmp = (int) 0x00FD8000L + (floatvalue_to_round); | |
79 rounded_value = *(int*)(&floattmp) - (int)0x4B7D8000L; | |
80 | |
81 if ( rounded_value != (short) rounded_value ) | |
82 rounded_value = ( rounded_value >> 31 ) ^ 0x7FFF; | |
83 return rounded_value; | |
84 } | |
85 #endif |