How to read data from a midi keyboard?

I can’t figure out how to read note data from a midi keyboard. I have the ofxMidi add-on in my project, and I have looked through all the examples and I none of them happen to read the notes from my midi keyboard. I have a Novation Impulse 49 and I can read data from the keyboard.
Let me know what else I can do to fix this?

void ofApp::newMidiMessage(ofxMidiMessage& msg)
{
	std::cout << "Midi key pressed\n";
}

The above code does not return anything when I press keys. I have tried to use keyPressed() as well.

have u checked listInPorts() and openPort() are the right ones for ur controller? are u adding the listener?

Would be much easier if u post all ur code

@dizzy
I copied this code and tried to run it:


I should add that when I type ? I get my model of midi controller but the keys don’t function.

When it runs, check the console, this line midiIn.listInPorts(); in setup() should print out the list of midi devices.

The novation should be printed somewhere, you will likely need to change the 1 in the next line midiIn.openPort(1); to the index of the novation.

I was not aware that the port numbers had to match. I has 1 but I actually needed port 0 selected. Thanks.

1 Like

No probs. It’s possible to have multiple midi devices connected hence the ports. ofxMidi lets you open the device by name using the string that is printed by listInDevices