Trying to create a Midi Controller VST

I'm basically trying to create a VST that will control a bunch of other plugin's parameters using midi signals.

I have this code in my processBlock

    juce::MidiBuffer output;
    juce::MidiMessage msg;
    if(UserParams[MidiFlag] == 1.0)
    {
        output.clear();
        if(UserParams[Button1] == 1.0)
        {
            msg.noteOn(1,50,1.0f);
        }
        else
        {
            msg.noteOff(1,50,0);
        }
        UserParams[MidiFlag] = 0.0;
        output.addEvent (msg, 1);
        midiMessages.swapWith(output);
    }
 

When I press the 1 toggle button I've created so far, it looks like I'm receiving the Midi message, but it does't register when I'm trying to assign it to a parameter.

I'm using loopBe to loop the midi signals back to my DAW and it works when I hook up the juce demo plugin. I can assign parameters of different plugin's to any of the keyboard keys using that.

I figure I'm just sending the midi command differently than the demo plugin is and that's where my problem is, but I'm still having trouble figuring it out.

Any ideas?

You're totally misusing the MidiMessage::noteOn/Off methods - they're static methods that return an object.

Ahh ok. I feel dumb. Just changed 

msg.noteOn(1,50,1.0f);

to

msg = MidiMessage::noteOn(1,50,1.0f);

and it works perfect.

Thanks!