How to use midi with juce


i’m a newbie in juce and c++ …
i try to use midi and it doesn’t work …

MidiOutput* midiOutput;
MidiMessage* midiMessage;
midiMessage->noteOn(1,50,(UINT8) 127);

i know how to use midi with windows api but when i include <windows.h> i get a lot of compilation errors …

i also know it’s very basic questions but i search examples in the forum and i found nothing and there is no midi in the demo

many thanks for your answer !!!


your main problem is with your midiMessage.

notice how you’re trying to use a pointer (MidiMessage*) before you’ve set it to anything. You don’t need to have a pointer … you could say

midiOutput->sendMessageNow (MidiMessage::noteOn(1,50,127));

The noteOn function is a static member of the MidiMessage class, which means you can call it from outside any particular instance. It will generate for you an object, which you can use as above, or have a line like…

MidiMessage m (MidiMessage::noteOn(1,50,127));

… to create one in scope to be used for multiple tasks. You’d then of course use

midiOutput->sendMessageNow (m);


thanks haydxn !!! it works
i’m beginning … c++ and pointers are not easy … :wink: