Debian Codegraph @

ext/psmplug/snd_flt.cpp

raw symbols SCIP
1 /*
2 * This source code is public domain.
3 *
4 * Authors: Olivier Lapicque <[email protected]>
5 */
6
7 #include "stdafx.h"cxx . . $ `<file>/ext/psmplug/stdafx.h`/
8 #include "sndfile.h"cxx . . $ `<file>/ext/psmplug/sndfile.h`/
9
10 // AWE32: cutoff = reg[0-255] * 31.25 + 100 -> [100Hz-8060Hz]
11 // EMU10K1 docs: cutoff = reg[0-127]*62+100
12 #define FILTER_PRECISIONcxx . . $ `ext/psmplug/snd_flt.cpp:12:9`! 8192
13
14 #ifndef NO_FILTER
15
16 #include <math.h>
17
18 DWORDcxx . . $ DWORD# CSoundFilecxx . . $ CSoundFile#::CutOffToFrequencycxx . . $ CSoundFile#CutOffToFrequency(e99c713d50db71c7).(UINTcxx . . $ UINT# nCutOff, int flt_modifier) const
19 //-----------------------------------------------------------------------
20 {
21 float Fc;
22
23 if (m_dwSongFlagscxx . . $ CSoundFile#m_dwSongFlags. & SONG_EXFILTERRANGEcxx . . $ `ext/psmplug/sndfile.h:252:9`!)
24 Fc = 110.0f * powcxx . . $ pow(d59a45cd3bfd2eda).(2.0f, 0.25f + ((float)(nCutOff*(flt_modifier+256)))/(21.0f*512.0f));
25 else
26 Fc = 110.0f * powcxx . . $ pow(d59a45cd3bfd2eda).(2.0f, 0.25f + ((float)(nCutOff*(flt_modifier+256)))/(24.0f*512.0f));
27 LONGcxx . . $ LONG# freq = (LONGcxx . . $ LONG#)Fc;
28 if (freq < 120) return 120;
29 if (freq > 10000) return 10000;
30 if (freq*2 > (LONGcxx . . $ LONG#)gdwMixingFreqcxx . . $ CSoundFile#gdwMixingFreq.) freq = gdwMixingFreqcxx . . $ CSoundFile#gdwMixingFreq.>>1;
31 return (DWORDcxx . . $ DWORD#)freq;
32 }
33
34
35 // Simple 2-poles resonant filter
36 void CSoundFilecxx . . $ CSoundFile#::SetupChannelFiltercxx . . $ CSoundFile#SetupChannelFilter(4984ec9b1cb9496).(MODCHANNELcxx . . $ MODCHANNEL# *pChn, BOOLcxx . . $ BOOL# bReset, int flt_modifier) const
37 //----------------------------------------------------------------------------------------
38 {
39 float fc = (float)CutOffToFrequencycxx . . $ CSoundFile#CutOffToFrequency(e99c713d50db71c7).(pChn->nCutOffcxx . . $ _MODCHANNEL#nCutOff., flt_modifier);
40 float fs = (float)gdwMixingFreqcxx . . $ CSoundFile#gdwMixingFreq.;
41 float fg, fb0, fb1;
42
43 fc *= (float)(2.0*3.14159265358/fs);
44 float dmpfac = powcxx . . $ pow(d59a45cd3bfd2eda).(10.0f, -((24.0f / 128.0f)*(float)pChn->nResonancecxx . . $ _MODCHANNEL#nResonance.) / 20.0f);
45 float d = (1.0f-2.0f*dmpfac)* fc;
46 if (d>2.0) d = 2.0;
47 d = (2.0f*dmpfac - d)/fc;
48 float e = powcxx . . $ pow(d59a45cd3bfd2eda).(1.0f/fc,2.0f);
49
50 fg=1/(1+d+e);
51 fb0=(d+e+e)/(1+d+e);
52 fb1=-e/(1+d+e);
53
54 pChn->nFilter_A0cxx . . $ _MODCHANNEL#nFilter_A0. = (int)(fg * FILTER_PRECISIONcxx . . $ `ext/psmplug/snd_flt.cpp:12:9`!);
55 pChn->nFilter_B0cxx . . $ _MODCHANNEL#nFilter_B0. = (int)(fb0 * FILTER_PRECISIONcxx . . $ `ext/psmplug/snd_flt.cpp:12:9`!);
56 pChn->nFilter_B1cxx . . $ _MODCHANNEL#nFilter_B1. = (int)(fb1 * FILTER_PRECISIONcxx . . $ `ext/psmplug/snd_flt.cpp:12:9`!);
57
58 if (bReset)
59 {
60 pChn->nFilter_Y1cxx . . $ _MODCHANNEL#nFilter_Y1. = pChn->nFilter_Y2cxx . . $ _MODCHANNEL#nFilter_Y2. = 0;
61 pChn->nFilter_Y3cxx . . $ _MODCHANNEL#nFilter_Y3. = pChn->nFilter_Y4cxx . . $ _MODCHANNEL#nFilter_Y4. = 0;
62 }
63 pChn->dwFlagscxx . . $ _MODCHANNEL#dwFlags. |= CHN_FILTERcxx . . $ `ext/psmplug/sndfile.h:88:9`!;
64 }
65
66 #endif // NO_FILTER