annotate src/modplug/snd_flt.cxx @ 2898:471b12137183

fix compile
author Andrew O. Shadoura <bugzilla@tut.by>
date Wed, 13 Aug 2008 12:40:52 +0300
parents 107c1fed3d92
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1 /*
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2 * This source code is public domain.
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
3 *
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
4 * Authors: Olivier Lapicque <olivierl@jps.net>
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
5 */
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
6
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
7 #include "stdafx.h"
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
8 #include "sndfile.h"
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
9
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
10 // AWE32: cutoff = reg[0-255] * 31.25 + 100 -> [100Hz-8060Hz]
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
11 // EMU10K1 docs: cutoff = reg[0-127]*62+100
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
12
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
13 #ifndef NO_FILTER
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
14
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
15 static int filter_cutoff[] = {
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
16 130, 132, 134, 136, 138, 140, 142, 144,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
17 146, 148, 151, 153, 155, 157, 160, 162,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
18 164, 167, 169, 172, 174, 177, 179, 182,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
19 184, 187, 190, 193, 195, 198, 201, 204,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
20 207, 210, 213, 216, 220, 223, 226, 229,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
21 233, 236, 239, 243, 246, 250, 254, 257,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
22 261, 265, 269, 273, 277, 281, 285, 289,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
23 293, 297, 302, 306, 311, 315, 320, 324,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
24 329, 334, 339, 344, 349, 354, 359, 364,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
25 369, 375, 380, 386, 391, 397, 403, 409,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
26 415, 421, 427, 433, 440, 446, 452, 459,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
27 466, 472, 479, 486, 493, 501, 508, 515,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
28 523, 530, 538, 546, 554, 562, 570, 578,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
29 587, 595, 604, 613, 622, 631, 640, 649,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
30 659, 668, 678, 688, 698, 708, 718, 729,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
31 739, 750, 761, 772, 783, 795, 806, 818,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
32 830, 842, 854, 867, 880, 892, 905, 918,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
33 932, 945, 959, 973, 987, 1002, 1016, 1031,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
34 1046, 1061, 1077, 1092, 1108, 1124, 1141, 1157,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
35 1174, 1191, 1209, 1226, 1244, 1262, 1280, 1299,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
36 1318, 1337, 1357, 1376, 1396, 1417, 1437, 1458,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
37 1479, 1501, 1523, 1545, 1567, 1590, 1613, 1637,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
38 1661, 1685, 1709, 1734, 1760, 1785, 1811, 1837,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
39 1864, 1891, 1919, 1947, 1975, 2004, 2033, 2062,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
40 2093, 2123, 2154, 2185, 2217, 2249, 2282, 2315,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
41 2349, 2383, 2418, 2453, 2489, 2525, 2561, 2599,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
42 2637, 2675, 2714, 2753, 2793, 2834, 2875, 2917,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
43 2959, 3003, 3046, 3091, 3135, 3181, 3227, 3274,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
44 3322, 3370, 3419, 3469, 3520, 3571, 3623, 3675,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
45 3729, 3783, 3838, 3894, 3951, 4008, 4066, 4125,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
46 4186, 4246, 4308, 4371, 4434, 4499, 4564, 4631,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
47 4698, 4766, 4836, 4906, 4978, 5050, 5123, 5198
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
48 };
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
49 int dmpfac[] = {
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
50 131072, 128272, 125533, 122852, 120229, 117661, 115148, 112689,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
51 110283, 107928, 105623, 103367, 101160, 98999, 96885, 94816,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
52 92791, 90810, 88870, 86973, 85115, 83298, 81519, 79778,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
53 78074, 76407, 74775, 73178, 71615, 70086, 68589, 67125,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
54 65691, 64288, 62915, 61572, 60257, 58970, 57711, 56478,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
55 55272, 54092, 52937, 51806, 50700, 49617, 48557, 47520,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
56 46506, 45512, 44540, 43589, 42658, 41747, 40856, 39983,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
57 39130, 38294, 37476, 36676, 35893, 35126, 34376, 33642,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
58 32923, 32220, 31532, 30859, 30200, 29555, 28924, 28306,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
59 27701, 27110, 26531, 25964, 25410, 24867, 24336, 23816,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
60 23308, 22810, 22323, 21846, 21380, 20923, 20476, 20039,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
61 19611, 19192, 18782, 18381, 17989, 17604, 17228, 16861,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
62 16500, 16148, 15803, 15466, 15135, 14812, 14496, 14186,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
63 13883, 13587, 13297, 13013, 12735, 12463, 12197, 11936,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
64 11681, 11432, 11188, 10949, 10715, 10486, 10262, 10043,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
65 9829, 9619, 9413, 9212, 9015, 8823, 8634, 8450,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
66 8270, 8093, 7920, 7751, 7585, 7423, 7265, 7110,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
67 6958, 6809, 6664, 6522, 6382, 6246, 6113, 5982,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
68 5854, 5729, 5607, 5487, 5370, 5255, 5143, 5033,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
69 4926, 4820, 4718, 4617, 4518, 4422, 4327, 4235,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
70 4144, 4056, 3969, 3884, 3801, 3720, 3641, 3563,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
71 3487, 3412, 3340, 3268, 3198, 3130, 3063, 2998,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
72 2934, 2871, 2810, 2750, 2691, 2634, 2577, 2522,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
73 2468, 2416, 2364, 2314, 2264, 2216, 2169, 2122,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
74 2077, 2032, 1989, 1947, 1905, 1864, 1824, 1786,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
75 1747, 1710, 1674, 1638, 1603, 1569, 1535, 1502,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
76 1470, 1439, 1408, 1378, 1348, 1320, 1291, 1264,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
77 1237, 1210, 1185, 1159, 1135, 1110, 1087, 1063,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
78 1041, 1018, 997, 975, 955, 934, 914, 895,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
79 876, 857, 838, 821, 803, 786, 769, 753,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
80 737, 721, 705, 690, 676, 661, 647, 633,
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
81 620, 606, 593, 581, 568, 556, 544, 533
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
82 };
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
83
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
84
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
85 #include <math.h>
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
86
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
87
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
88 #define PI ((double)3.14159265358979323846)
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
89 // Simple 2-poles resonant filter
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
90 void CSoundFile::SetupChannelFilter(MODCHANNEL *pChn, BOOL bReset, int flt_modifier, int) const
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
91 //----------------------------------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
92 {
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
93 int cutoff = pChn->nCutOff * 2;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
94 cutoff *= (flt_modifier+256) / 2;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
95 cutoff /= 256;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
96 if (cutoff>=255) cutoff=255;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
97
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
98 int resonance = pChn->nResonance;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
99 if (resonance>=255) resonance=255;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
100
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
101 float fc = (float)filter_cutoff[cutoff];
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
102 float fs = (float)gdwMixingFreq;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
103 float fg, fb0, fb1;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
104 float d2, d, e;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
105
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
106 fc *= 3.14159265358979 * 2 / fs;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
107 d2 = ((float)dmpfac[resonance]) / 65536.0;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
108 d = (1.0 - d2) * fc;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
109
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
110 if (d > 2.0)
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
111 d = 2.0;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
112
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
113 d = (d2 - d) / fc;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
114 e = 1.0 / (fc * fc);
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
115
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
116 fg = 1.0 / (1 + d + e);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
117 fb0 = (d + e + e) / (1 + d + e);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
118 fb1 = -e / (1 + d + e);
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
119
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
120 pChn->nFilter_A0 = (double)fg;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
121 pChn->nFilter_B0 = (double)fb0;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
122 pChn->nFilter_B1 = (double)fb1;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
123
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
124 if (bReset) {
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
125 pChn->nFilter_Y1 = pChn->nFilter_Y2 = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
126 pChn->nFilter_Y3 = pChn->nFilter_Y4 = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
127 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
128 pChn->dwFlags |= CHN_FILTER;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
129 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
130 #endif // NO_FILTER