# Send Midi CC directly or via ProcessBlock?

**URL:** <https://forum.juce.com/t/send-midi-cc-directly-or-via-processblock/36370>\
**Category:** Audio Plugins\
**Created:** [November 27, 2019, 10:57am UTC](https://forum.juce.com/t/send-midi-cc-directly-or-via-processblock/36370 "2019-11-27T10:57:00Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![mixer1985](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@mixer1985](https://forum.juce.com/u/mixer1985)\
**Post date:** [November 27, 2019, 11:45am UTC](https://forum.juce.com/t/send-midi-cc-directly-or-via-processblock/36370/4 "2019-11-27T11:45:19Z")

</div>

```void
{
    buffer.clear();
    midiMessages.clear();
    MidiBuffer generatedMidi;
    int time;
    MidiMessage m;
    int8 ccTempVal;
    int8 myVal = (int8)CC00Val;

    if (myVal != ccTempVal)
    {
        m = MidiMessage::controllerEvent(2, 1, myVal);
        generatedMidi.addEvent(m, midiMessages.getLastEventTime());
    }
    else generatedMidi.clear();

    ccTempVal = myVal;
    midiMessages.swapWith (generatedMidi);
    
    
}

```

This is what I saw in another post and they recommended this:

> [@Simple example of a VST plugin sending a MIDI CC](https://forum.juce.com/t/simple-example-of-a-vst-plugin-sending-a-midi-cc/17070/9):
>
> Well, if you define your ccTempVal inside the processBlock and furthermore don’t initialize it, it is pure luck, if the comparism returns true or false 😉  
> Make it a member variable of your AudioProcessor, and initialize it in the constructor

So I can keep the code but move the ccTempVal out.  
Is it maybe wise then, since I need to check 30-40 variables that I make an array and then put the checking loop and the sending in the processBlock?

---

_[View the full topic](https://forum.juce.com/t/send-midi-cc-directly-or-via-processblock/36370)._
