MidiInput::openDevice(int deviceIndex, MidiInputCallback *callback)

How do I pass the MidiCallback parameter in MidiInput::openDevice(int deviceIndex, MidiInputCallback *callback) ?

void MainComponent::handleIncomingMidiMessage(MidiInput *source, const MidiMessage&message)
{
    // application crashes instantly after a midi message is sent to it
}

void MainComponent::buttonClicked(Button* button)
{
    MidiInput *midiInput;

    midiInput = MidiInput::openDevice(0, this);

    midiInput -> start();
}

The code seems correct, except that usually you put a space either before or after the ampersand when you declare the argument MidiMessage&, but that is just a readability issue.

It would help, if you post the line, where the debugger points to when crashing, together with the stack trace…

I got it to work. In the original code the problem was from setting a label’s text from handleIncomingMidiMessage. I should have posted the code exactly as it was.
Also, the ampersand thing was just a typo when I made the post.

Thanks.