Mercurial > audlegacy
annotate audacious/iir.c @ 1938:1d9c1026d9f8 trunk
[svn] - DoubleSize support.
This has bugs, the most notable one being that DoubleSize only works
right if you restart the player.
The second bug is rather obvious too. No osmosis skinengine. No
TinyPlayer. Classic-esque skinengine only. This is because the
doublesize algorithm hates you and wants you to go die in a fire.
author | nenolod |
---|---|
date | Sun, 05 Nov 2006 04:43:16 -0800 |
parents | 67cd014f35a2 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 * PCM time-domain equalizer | |
3 * | |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
4 * Copyright (C) 2002-2005 Felipe Rivera <liebremx at users sourceforge net> |
0 | 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 * | |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
20 * $Id: iir.c,v 1.15 2005/10/17 01:57:59 liebremx Exp $ |
0 | 21 */ |
22 | |
23 #include <math.h> | |
24 #include "iir.h" | |
25 | |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
26 /* Coefficients */ |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
27 sIIRCoefficients *iir_cf; |
0 | 28 |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
29 /* Volume gain |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
30 * values should be between 0.0 and 1.0 |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
31 * Use the preamp from XMMS for now |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
32 * */ |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
33 float preamp[EQ_CHANNELS]; |
0 | 34 |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
35 #ifdef BENCHMARK |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
36 #include "benchmark.h" |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
37 double timex = 0.0; |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
38 int count = 0; |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
39 unsigned int blength = 0; |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
40 #endif |
0 | 41 |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
42 /* |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
43 * Global vars |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
44 */ |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
45 gint rate; |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
46 int band_count; |
0 | 47 |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
48 void set_preamp(gint chn, float val) |
0 | 49 { |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
50 preamp[chn] = val; |
0 | 51 } |
52 | |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
53 /* Init the filters */ |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
54 void init_iir() |
0 | 55 { |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
56 calc_coeffs(); |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
57 #if 0 |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
58 band_count = cfg.band_num; |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
59 #endif |
348
f74bdb82f0a0
[svn] a lot of EQ tweaks, but the preamp still does not work right
nenolod
parents:
0
diff
changeset
|
60 |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
61 band_count = 10; |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
62 |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
63 rate = 44100; |
0 | 64 |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
65 iir_cf = get_coeffs(&band_count, rate, TRUE); |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
66 clean_history(); |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
67 } |
0 | 68 |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
69 #ifdef ARCH_X86 |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
70 /* Round function provided by Frank Klemm which saves around 100K |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
71 * CPU cycles in my PIII for each call to the IIR function with 4K samples |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
72 */ |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
73 __inline__ int round_trick(float floatvalue_to_round) |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
74 { |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
75 float floattmp ; |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
76 int rounded_value ; |
0 | 77 |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
78 floattmp = (int) 0x00FD8000L + (floatvalue_to_round); |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
79 rounded_value = *(int*)(&floattmp) - (int)0x4B7D8000L; |
0 | 80 |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
81 if ( rounded_value != (short) rounded_value ) |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
82 rounded_value = ( rounded_value >> 31 ) ^ 0x7FFF; |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
83 return rounded_value; |
0 | 84 } |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
348
diff
changeset
|
85 #endif |