I guess my gui minimization question… Well… Moving on with what I hope is a more interesting question…
I am implementing a basic peaking filter with gain, Q, and frequency controls (variables in uppercase). as follows.
[code]void PeakEqAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
const int numChannels = buffer.getNumChannels();
const int numSamples = buffer.getNumSamples();
const int numOutputChannels = getNumOutputChannels();
const float pi = 3.14159265358979323846264338f;
for (int channel = 0; channel < numChannels; ++channel)
{
float* channelData = buffer.getSampleData (channel);
for (int i = 0; i < numSamples; ++i)
{
//Input
const float xn = channelData[i];
// Delay samples
float xn_1 = m_f_xz_1;
float xn_2 = m_f_xz_2;
float yn_1 = m_f_yz_1;
float yn_2 = m_f_yz_2;
//Calculate intermediate values
/* edited out long and boring difference equation stuff here for posting online */
// Replace new delay values
m_f_xz_2 = xn_1;
m_f_xz_1 = xn;
m_f_yz_2 = yn_1;
m_f_yz_1 = yn;
//Output, rewrite to buffer.
channelData[i] = yn;
} //End of sample buffer loop
}// End of channel increment loop
for (int i = numChannels; i < numOutputChannels; ++i) //clear out output buffers
{
buffer.clear (i, 0, buffer.getNumSamples());
}
// End of Process Block
}[/code]
Here’s the issue - when I have the channel “for” loop in the code so it will process multiple channels I get a lot of dropouts (say the plug is on a stereo output master), that tend towards channel 1 (so right in the case of a stereo output). However, If I force it to only process one channel for example:
It works perfectly, just on one channel though (so EQ math is correct).
I have messed a lot with it changing things around to try to zero down what the issue might be. One interesting thing I stumbled onto if I replace the EQ code with a simple channelData[i] = xn * VOLUME
. The output is perfect no glitches with 2 channels.
I think I understand processBlock member of AudioProcessor. I’m giving it 2 channels in, and there are 2 channels out so it expects those 2 channels to be re filled with the output.
Also, I wouldn’t think the EQ equation vs a simple volume should make any difference. Or maybe the extra processing time does. I’ve tried it in a couple different hosts with the same result.
Any ideas appreciated. I’m sure I’m missing something obvious. I’m learning…
Jim