# Processing buffers separately

**URL:** <https://forum.juce.com/t/processing-buffers-separately/31202>\
**Category:** Audio Plugins\
**Created:** [January 9, 2019, 7:34pm UTC](https://forum.juce.com/t/processing-buffers-separately/31202 "2019-01-09T19:34:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sktsalad](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@Sktsalad](https://forum.juce.com/u/Sktsalad)\
**Post date:** [January 9, 2019, 7:34pm UTC](https://forum.juce.com/t/processing-buffers-separately/31202/1 "2019-01-09T19:34:28Z")

</div>

Yes, I read a lot of similar topics, specially about drum machines, but still can’t go on from here. Just want to build a very basic sample player with 8 separated drum samples.  
Got almost everything working, the multi-out-synth plugin inspired me, even the separate velocity for each “sample sound” I was able to achieve… but then it comes the panning. Can’t make it work for each synth:

```
   void processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiBuffer) override
{
    auto busCount = getBusCount (false);
    buffer.clear();
    MidiBuffer processedMidi;
    int time;
    MidiMessage m;
    
    for (MidiBuffer::Iterator i (midiBuffer); i.getNextEvent (m, time);)
    {
        if (m.isNoteOn())
        {
            int x = m.getNoteNumber();
            if (x == 36){
                uint8 newVel = m.getVelocity() * noteOnVel ;
                m = MidiMessage::noteOn(m.getChannel(), m.getNoteNumber(), newVel);
            }
            else if (x == 38){
                uint8 newVel = m.getVelocity() * noteOnVel2 ;
                m = MidiMessage::noteOn(m.getChannel(), m.getNoteNumber(), newVel);
            }
           // else if...
        }
        else if (m.isNoteOff()) { }
        else if (m.isAftertouch()) { }
        else if (m.isPitchWheel()) { }
        processedMidi.addEvent (m, time);
    }
    midiBuffer.swapWith (processedMidi);
    
    for (auto busNr = 0; busNr < busCount; ++busNr)
    {
        auto midiChannelBuffer = filterMidiMessagesForChannel (midiBuffer, busNr + 1);
        auto audioBusBuffer = getBusBuffer (buffer, false, busNr);
        synth [busNr]->renderNextBlock (audioBusBuffer, midiChannelBuffer, 0, audioBusBuffer.getNumSamples());
        buffer.applyGain (0, 0, buffer.getNumSamples(), gainL);
        buffer.applyGain (1, 0, buffer.getNumSamples(), gainR);
        synth2 [busNr]->renderNextBlock (audioBusBuffer, midiChannelBuffer, 0, audioBusBuffer.getNumSamples());
        buffer.applyGain (0, 0, buffer.getNumSamples(), gainL);
        buffer.applyGain (1, 0, buffer.getNumSamples(), gainR);
        synth3 [busNr]->renderNextBlock (audioBusBuffer, midiChannelBuffer, 0, audioBusBuffer.getNumSamples());
       //synth4...
        
    }
}

```

For sure it won’t work.  
I’m new in C++, couldn’t understand how to apply the renderNextBlock as was constantly answered from other similar topics.  
Thanks for any direction!
