MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / Process

Method Process

Source/FreqDomainBoilerplate.cpp:65–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65void FreqDomainBoilerplate::Process(double time)
66{
67 PROFILER(FreqDomainBoilerplate);
68
69 IAudioReceiver* target = GetTarget();
70
71 if (target == nullptr || !mEnabled)
72 return;
73
74 ComputeSliders(0);
75 SyncBuffers();
76
77 float inputPreampSq = mInputPreamp * mInputPreamp;
78 float volSq = mVolume * mVolume;
79
80 int bufferSize = GetBuffer()->BufferSize();
81
82 mRollingInputBuffer.WriteChunk(GetBuffer()->GetChannel(0), bufferSize, 0);
83
84 //copy rolling input buffer into working buffer and window it
85 mRollingInputBuffer.ReadChunk(mFFTData.mTimeDomain, fftWindowSize, 0, 0);
86 Mult(mFFTData.mTimeDomain, mWindower, fftWindowSize);
87 Mult(mFFTData.mTimeDomain, inputPreampSq, fftWindowSize);
88
89 mFFT.Forward(mFFTData.mTimeDomain,
90 mFFTData.mRealValues,
91 mFFTData.mImaginaryValues);
92
93 for (int i = 0; i < fftFreqDomainSize; ++i)
94 {
95 float real = mFFTData.mRealValues[i];
96 float imag = mFFTData.mImaginaryValues[i];
97
98 //cartesian to polar
99 float amp = 2. * sqrtf(real * real + imag * imag);
100 float phase = atan2(imag, real);
101
102 phase = FloatWrap(phase + mPhaseOffset, FTWO_PI);
103
104 //polar to cartesian
105 real = amp * cos(phase);
106 imag = amp * sin(phase);
107
108 mFFTData.mRealValues[i] = real;
109 mFFTData.mImaginaryValues[i] = imag;
110 }
111
112 mFFT.Inverse(mFFTData.mRealValues,
113 mFFTData.mImaginaryValues,
114 mFFTData.mTimeDomain);
115
116 for (int i = 0; i < bufferSize; ++i)
117 mRollingOutputBuffer.Write(0, 0);
118
119 //copy rolling input buffer into working buffer and window it
120 for (int i = 0; i < fftWindowSize; ++i)
121 mRollingOutputBuffer.Accum(fftWindowSize - i - 1, mFFTData.mTimeDomain[i] * mWindower[i] * .0001f, 0);
122

Callers

nothing calls this directly

Calls 14

MultFunction · 0.85
FloatWrapFunction · 0.85
AddFunction · 0.85
BufferSizeMethod · 0.80
WriteChunkMethod · 0.80
GetChannelMethod · 0.80
ReadChunkMethod · 0.80
ForwardMethod · 0.80
InverseMethod · 0.80
AccumMethod · 0.80
GetBufferMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected