Handlemidimessage in plugin

Hi!

I created a graph, and a plugin that implement handlemidimessage because I want to filter dinamically messages that come from device I don’t want.

The plugin midi in contained in the graph…
So now to make di callback called?

Trying in another application from scratch with this code handleIncomingMidiMessage is never called… what I’m missing?

class MainComponent  : public juce::Component, public MidiInputCallback
{
public:
    //==============================================================================
     MainComponent()
    {
        setSize (600, 400);
        for (auto availableDevice : MidiInput::getAvailableDevices ())
        {
        auto midi = MidiInput::openDevice(availableDevice.identifier, this);
        midi->start();
        }
     }
    ~MainComponent() override {}    
    void paint (juce::Graphics&) override {}
    void resized() override {}

private:
    void handleIncomingMidiMessage (MidiInput* source, const MidiMessage& message) override { DBG("somenthing");} //never printed....

    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
};

I believe, the return value from MidiInput::openDevice is a unique_ptr, so after you leave the for loop scope, the MidiInput is deleted…

1 Like

You’re right… I’m a very idiot… :see_no_evil: Now all works, really thank you! :pray:

1 Like

You’re far from an idiot! Been there, done that! :rofl:

1 Like