I had seen a post on this forum a while back asking this similar question, and I cannot find it through the forum search. If someone could link that thread for me I would be mighty obliged.
Here is my question regardless. I am still attempting to implement a simple low pass filter. I have gotten over the previous hurtles with null pointers. When I open a track in Audacity and apply my VST, all that occurs is the track plays with some static and pops in the background.
Here is my process audio block:
void FishTankAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
const int totalNumInputChannels = getTotalNumInputChannels();
const int totalNumOutputChannels = getTotalNumOutputChannels();
// If it ever becomes the point that there are more ouputs then inputs,
// Then regenerate this file, and see what they did for that sitch :)
// This is the place where you'd normally do the guts of your plugin's
// audio processing...
// Set up variables
//AudioSampleBuffer mainInputOutput = busArrangement.getBusBuffer(buffer, true, 0);
float sr = m_sampleRate;
for (int chan = 0; chan < buffer.getNumChannels(); chan++)
for (int samp = 0; samp < buffer.getNumChannels(); samp++)
// Test values
float testReadPointer = buffer.getReadPointer(chan)[samp];
float testValue = calculate(buffer.getReadPointer(chan)[samp]);
// Actual code.
buffer.getWritePointer(chan)[samp] = calculate(buffer.getReadPointer(chan)[samp]);
And here is my calculate function, which does the low pass
This is a common mistake…
Your calculate is a stateful method. But you are using the same state for all channels.
You need a separate set of m_a, m_b and m_c for every channel (or better create a filter class you can instanciate for each channel)
You need separate filter states for each channel, so you should restructure your code so that you can freely instantiate as many independent filter objects as you need. (That is, implement your filter as a class that you then instantiate in your plugin audioprocessor object as many times as you have audio channels to process.)
No, I understood what you meant. I was going to make a vector of a new class, as opposed to an Array of a struct. But I think I will just use an Array instead. I appreciate the clarification though! I’m new to JUCE, not C++.
You are in a processor’s context, right?
For instance you can check the num of outbut channels using int AudioProcessor::getMainBusNumOutputChannels()…
If you are in an audioSource, you can use the AudioSourceChannelInfo struct, but only in the getNextAudioBlock(), where you shouldn’t make allocations…
For some reasons a pure AudioSource has no channel numbers property, I don’t know why…