# Newbie question: using DSP with transportSource

**URL:** <https://forum.juce.com/t/newbie-question-using-dsp-with-transportsource/31700>\
**Category:** Audio Plugins\
**Created:** [February 10, 2019, 12:30pm UTC](https://forum.juce.com/t/newbie-question-using-dsp-with-transportsource/31700 "2019-02-10T12:30:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bposin](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@bposin](https://forum.juce.com/u/bposin)\
**Post date:** [February 10, 2019, 12:30pm UTC](https://forum.juce.com/t/newbie-question-using-dsp-with-transportsource/31700/1 "2019-02-10T12:30:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mcmartin](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mcmartin/32/7432_2.png) [@mcmartin](https://forum.juce.com/u/mcmartin)\
**Post date:** [February 10, 2019, 2:29pm UTC](https://forum.juce.com/t/newbie-question-using-dsp-with-transportsource/31700/2 "2019-02-10T14:29:49Z")

</div>

Why is `i` going from `totalNumInputChannels` to `totalNumOutputChannels`? If `totalNumInputChannels` is 3 (for instance with a mic input and 2 line inputs) and `totalNumOutputChannels` is 2 (for instance with stereo speakers), your loop is doing nothing.

If you are making a simple audio player, then I guess you don’t really care about inputs, so `i` should go from `0` to `totalNumOutputChannels` (excluded).

---

<div class="post-metadata">

**Author:** ![bposin](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@bposin](https://forum.juce.com/u/bposin)\
**Post date:** [February 10, 2019, 2:37pm UTC](https://forum.juce.com/t/newbie-question-using-dsp-with-transportsource/31700/3 "2019-02-10T14:37:36Z")

</div>

I just left that line as it was written already when you start building the app template from projucer, I defined somewhere that the number of inputs is 0 (since, as you said it’s an audio player), so it’s actually going from 0 to 2. Either way, that’s just to clear the buffers, so it shouldn’t really cause any problems. I tried just placing 0 as you said and there’s no difference related to my problem.

Thank you anyway, I’ll keep this in mind when doing something with more inputs
