Hi. I have a rather basic question, since I’ve only recently started with JUCE. I’ve been following the tutorials on how to make an audio player and trying to expand on that. So I did the player, and also added a gain slider following another tutorial, which worked well. Then I decided to add a basic EQ with 5 bands using the dsp module. I think I set it up correctly (the filters and the chain), but no sound comes out (also no obvious errors, so I’m not sure how to debug it) and I think that I might have misunderstood how to implement it in the processBlock function.
void AudioPlayerBpAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) { auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear(i, 0, buffer.getNumSamples()); transportSource.getNextAudioBlock(AudioSourceChannelInfo(buffer)); auto phase = *phaseParameter < 0.5f ? 1.0f : -1.0f; auto currentGain = *gainParameter * phase; if (currentGain == previousGain) { buffer.applyGain(currentGain); dsp::AudioBlock<float> block(buffer); dsp::ProcessContextReplacing<float> context(block); filter.process(context); } else { buffer.applyGainRamp(0, buffer.getNumSamples(), previousGain, currentGain); previousGain = currentGain; dsp::AudioBlock<float> block(buffer); dsp::ProcessContextReplacing<float> context(block); filter.process(context); } }
Also, this here’s the prepare code
void AudioPlayerBpAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) { transportSource.prepareToPlay(samplesPerBlock, sampleRate); auto phase = *phaseParameter < 0.5f ? 1.0f : -1.0f; previousGain = *gainParameter * phase; dsp::ProcessSpec spec; spec.sampleRate = sampleRate; spec.maximumBlockSize = uint32(samplesPerBlock); spec.numChannels = uint32(getTotalNumOutputChannels()); filter.prepare(spec); }
Based on what I read about the dsp module and the examples I saw, I thought this should work, but I guess not. Is this the wrong way to approach this?