Issues with Cinder-MIDI2 / RtMidi not detecting ports

Hey folks, I was revisiting an old app that used to work well with an external MIDI controller and realized the MIDI part doesn’t work on this new mac laptop I use which is on the Mojave OS.

It seems that RtMidi, which is what the Cinder-MIDI2 block is built on top of, is not detecting any ports because it is stuck in dummy mode although it should be in MacOS mode. Digging through the code, more specifically RtMidi.h, it seems that depends on the CINDER_MAC preprocessor macro being set properly which seems to happen in configure.cmake.

Any idea why something could go wrong here? Could it maybe be due to build order and the midi block not being built before that variable is properly set? Anything that could have regressed because of Mojave? Things were working fine on my old mac which was on the previous OS.

Thanks for your help!
Johan

For what it’s worth I just tested things with python-rtmidi and in that case it does return available ports so it does seem related to something with my Cinder app.

Have you tried to add the -D__MACOSX_CORE__ flag to your build? As far as I know this is what is required by RtMidi on macOS.

-Gabor

1 Like

Thanks @gabor_papp! My understanding skimming through RtMidi’s code is that this would happen automatically when CINDER_MAC is properly set. See: https://github.com/brucelane/Cinder-MIDI2/blob/master/lib/RtMidi.h#L576

But maybe not on Mojave and I need to add that explicitly? What would be a good place to add that flag? This is what my make file currently looks like: https://github.com/couleurs/nightsea-live/blob/master/proj/cmake/CMakeLists.txt

Thanks so much for your help :slight_smile:

Are you using CMake to build your project? I cannot see the CMake build files for Bruce’s Cinder-MIDI2.

1 Like

I am! And you’re right, the CMake build files are not there for the MIDI but I created them locally: https://gist.github.com/couleurs/1003849914ce139adc3a30a9e300d798

This was a while back but I think I just created this file by re-purposing what was done with other blocks. I am by no means a CMake expert. But this is probably the right place to add the flag you mentioned?

yes, i would try adding something like this:

	add_definitions( -D__MACOSX_CORE__ )
1 Like

Hmm when I do so I get a warning saying that macro was already defined (which makes sense given that it seems that the block customizes RtMidi.h to automatically define the macro when CINDER_MAC is set). But I also get a bunch of linker errors saying all the functions for MidiInCore are not defined, although they should get defined when that macro is on. Very confusing :confused:

Hmm I think some of my issues might be related to not properly importing CoreMIDI. When I do so, and hardcode __MACOSX_CORE__ in the custom RtMidi.h from the block, or explicitly add the Mac flag as @gabor_papp suggested, things work as expected. Not quite sure why I need to do that though since CINDER_MAC should take of things, but I will update the thread if I find out. At least I’m unblocked :slight_smile:

1 Like