MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / filterChannel

Method filterChannel

extlibs/soloud/src/filter/soloud_fftfilter.cpp:56–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54 }
55
56 void FFTFilterInstance::filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, double aTime, unsigned int aChannel, unsigned int aChannels)
57 {
58 if (aChannel == 0)
59 {
60 updateParams(aTime);
61 }
62
63 if (mInputBuffer == 0)
64 {
65 mInputBuffer = new float[512 * aChannels];
66 mMixBuffer = new float[512 * aChannels];
67 mTemp = new float[256];
68 memset(mInputBuffer, 0x2f, sizeof(float) * 512 * aChannels);
69 memset(mMixBuffer, 0, sizeof(float) * 512 * aChannels);
70 }
71
72 float * b = mTemp;
73
74 int i;
75 unsigned int ofs = 0;
76 unsigned int chofs = 512 * aChannel;
77 unsigned int bofs = mOffset[aChannel];
78
79 while (ofs < aSamples)
80 {
81 for (i = 0; i < 128; i++)
82 {
83 mInputBuffer[chofs + ((bofs + i + 128) & 511)] = aBuffer[ofs + i];
84 mMixBuffer[chofs + ((bofs + i + 128) & 511)] = 0;
85 }
86
87 for (i = 0; i < 256; i++)
88 {
89 b[i] = mInputBuffer[chofs + ((bofs + i) & 511)];
90 }
91 FFT::fft256(b);
92
93 // do magic
94 fftFilterChannel(b, 128, aSamplerate, aTime, aChannel, aChannels);
95
96 FFT::ifft256(b);
97
98 for (i = 0; i < 256; i++)
99 {
100 mMixBuffer[chofs + ((bofs + i) & 511)] += b[i] * (128 - abs(128 - i)) * (1.0f / 128.0f);
101 }
102
103 for (i = 0; i < 128; i++)
104 {
105 aBuffer[ofs + i] += (mMixBuffer[chofs + ((bofs + i) & 511)] - aBuffer[ofs + i]) * mParam[0];
106 }
107 ofs += 128;
108 bofs += 128;
109 }
110 mOffset[aChannel] = bofs;
111 }
112
113 void FFTFilterInstance::fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels)

Callers

nothing calls this directly

Calls 2

fft256Function · 0.85
ifft256Function · 0.85

Tested by

no test coverage detected