Hello, I’m new at programming in C++ and juce is making me really uncomfortable, I’m still learning.
Im trying to program a Mid-Side EQ with 5 bands and since I know that I can’t use the same filter for all the blocks I used an Owned array for everything.
Excuse me in advance, the code maybe is not the most elegant but I’m trying to make everything more clear because I really can’t figure out where is the problem.
I have this in the private part of the filter module (the buffer is already split up in M/S:
juce::OwnedArray<juce::dsp::LinkwitzRileyFilter<float>> filtersMid, filtersSide;
juce::OwnedArray<juce::AudioBuffer<float>> buffersMid, buffersSide;
juce::OwnedArray<juce::dsp::AudioBlock<float>> blocksMid, blocksSide;
juce::OwnedArray<juce::dsp::ProcessContextReplacing<float>> contextsMid, contextsSide;
I will try to not post all the code (since is just a repetition of the following lines in loops). These are some of the lines I used.
Constructor:
filtersMid.add(new juce::dsp::LinkwitzRileyFilter<float>);
filtersMid.getUnchecked(0)->setType(juce::dsp::LinkwitzRileyFilterType::lowpass);
prepareToPlay:
juce::dsp::ProcessSpec spec;
spec.maximumBlockSize = samplesPerBlock;
spec.numChannels = 1;
spec.sampleRate = sampleRate;
filtersMid.getUnchecked(0)->reset();
filtersMid.getUnchecked(0)->prepare(spec);
filtersMid.getUnchecked(0)->setCutoffFrequency(100);
buffersMid.add(new juce::AudioBuffer<float>);
buffersMid.getUnchecked(0)->setSize(1, samplesPerBlock);
blocksMid.add(new juce::dsp::AudioBlock<float>(*buffersMid.getUnchecked(0)));
contextsMid.add(new juce::dsp::ProcessContextReplacing<float>(*blocksMid.getUnchecked(0)));
And these are some of the lines I used in processBlock:
buffersMid.getUnchecked(0)->copyFrom(0,0,buffer.getReadPointer(0),numSamples);
filtersMid.getUnchecked(0)->process(*contextsMid.getUnchecked(0));
The last line is giving me Access Violation Exception, meaning something is wrong with pointers, but I really don’t know how to solve it. Only vst crashes, while standalone starts, but not working as intended.
Thanks in advance for the help!