ofxMidi updates


#1

Atruro posted an ofxMidiIn addon in this-thread based on rtMidi and pcoo events.

I’ve joined him the development, adding midi out & multiple message types over different channels. My latest file is here…

https://github.com/chrisoshea/ofxMidi

(still a few bugs and fixes to do)

I’ve used input and output successfully on windows for this-installation running all day with 6 midi channels and large volumes of data.

I’ve just seen this-thread from CongoZombie & kylemcdonald using Core Midi.

Whats the difference in using Core Midi over rtMidi? Are there platform specific problems with rtMidi?

Whats the status of this addon?

For the sake of simplicity for new users, maybe we should make one global ofxMidi addon that works with everything.

Thoughts?


#2

On a project about two months ago, I couldn’t get ofxMidi to work on either a mac or an XP machine. Switched to rtMidi and worked a treat (although I didn’t implement the callback function). I did have a few threading issues when using it in conjunction with the video player but got around it evenutally (something conflicting with poco if I recall).

It would be really nice to have a proper ofxMidi or at least a midi->osc convertor.


#3

Global ofxMidi addon that is multi-platform and handles i/o: yes, this would be great.

The ofxMidi I contributed to was meant as a step in this direction, but it stopped at Windows and OSX output. (Arturo developed midi input independently of it).

RtMidi uses CoreAudio on OSX http://www.music.mcgill.ca/~gary/rtmidi/index.html#compiling

I’m against RtMidi right now, just because I couldn’t get it working when I needed it. But it seems like it’s the best solution, as it’s multi-platform. We’d just need to wrap it and figure out any tricks for getting compiled.

It might just be a case where we need to create an example project for different IDEs rather than trying to walk people through the same setup steps each time.


#4

it would be great if anyone on mac could try the file i posted at the top and see if it compiles.


#5

Works happily for me on OSX. I’d try on Linux but that laptop is already stuck in a box, I’ll check it tomorrow when I unpack.


#6

I’ve successfully used PortMidi before for Midi in if that’s of any interest:
http://portmedia.sourceforge.net/
Could be an alternative…


#7

Not to hijack the thread, but I’m curious what kinds of problems people have run into with rtAudio. I should check out portaudio I think, looks quite interesting.


#8

it would be great if anyone on mac could try the file i posted at the top and see if it compiles.

It works perfectly on my mac/Tiger (input and output)

Great job done !
Bernard


#9

I’ve tried to use ofxMidi on Windows with CodeBlocks, but I keep getting these errors:

_
obj\release\addons\ofxMidi\src\ofxMidiIn.o:ofxMidiIn.cpp:(.text+0x5e)||undefined reference to RtMidiIn::openPort(unsigned int)'| obj\release\addons\ofxMidi\src\ofxMidiIn.o:ofxMidiIn.cpp:(.text+0x307b)||undefined reference toRtMidiIn::RtMidiIn()’|
obj\release\addons\ofxMidi\src\ofxMidiIn.o:ofxMidiIn.cpp:(.text+0x392b)||undefined reference to RtMidiIn::RtMidiIn()'| obj\release\addons\ofxMidi\src\ofxMidiOut.o:ofxMidiOut.cpp:(.text+0x7b9)||undefined reference toRtMidiOut::RtMidiOut()’|
obj\release\addons\ofxMidi\src\ofxMidiOut.o:ofxMidiOut.cpp:(.text+0x9c9)||undefined reference to RtMidiOut::RtMidiOut()'| obj\release\addons\ofxMidi\src\ofxMidiOut.o:ofxMidiOut.cpp:(.text+0x43)||undefined reference toRtMidiOut::openPort(unsigned int)’|
_

Though I’ve added all ofxMidi files to my project and added the search directories too.


#10

hi, also having a lil touble compiling on mac.
using the latest 0.02 download from the addons page although there was no example, so took the example source from 0.01

getting the following error:

error: cannot allocate an object of abstract type ‘testApp’
note: because the following virtual functions are pure within ‘testApp’:
note: virtual void ofxMidiListener::newMidiMessage(ofxMidiEventArgs&)

the example was for 005 so probably some small change is making it freak out in 006.

anyone have it working in 006 on mac?

L.


#11

So, I just tried my hand at compiling this latest 0.02 version of ofxMidi on Mac OS 10.5.8. Here’s how I got it to work:

First, before anything, make sure you’ve added both the ofxMidi addon’s source to your project and that you’ve added CoreMIDI.Framework to your project as well (http://forum.openframeworks.cc/t/ofxmidi-questions/2520/4).

Next, I made a class to act as my listener. I just got an M-Audio X-Session Pro controller and wanted to hook it up to my project. You’ll want to make a class of your own. We’ll pretend it’s called MyMidiListener. You’ll stick the .h and .cpp files in your project’s src folder.

First the header file (called MyMidiListener.h):

  
  
#pragma once  
#include "ofxMidi.h"  
  
class MyMidiListener : public ofxMidiListener {  
	  
	public:  
		MyMidiListener();  
		~MyMidiListener();  
		void newMidiMessage(ofxMidiEventArgs& eventArgs);  
};  
  

And now the actual cpp file (called MyMidiListener.cpp):

  
  
#include "MyMidiListener.h"  
  
// Constructor  
MyMidiListener::MyMidiListener(){  
}  
  
// Destructor  
MyMidiListener::~MyMidiListener(){  
}  
  
// Method that receives MIDI event messages.  
void MyMidiListener::newMidiMessage(ofxMidiEventArgs& eventArgs){  
	cout << "byteOne = " << eventArgs.byteOne << endl;  
	cout << "byteTwo[" << eventArgs. byteTwo << endl;  
  
	// Do the stuff you need to do with   
	// the ofxMidiEventArgs instance.  
}  
  

Now in your testapp.h header file, you’ll need to declare a couple member variables. One for the ofxMidiIn instance, and one for the MyMidiListener instance. Make sure you have the #include directives at the top of your header file for both “ofxMidi.h” and “MyMidiListener.h”.

  
  
ofxMidiIn midiIn;  
MyMidiListener midiListener;  
  

Now in your testapp.cpp file, in the setup() method, add these lines:

  
  
// This outputs the various ports  
// and their respective IDs.  
midiIn.listPorts();  
  
// Now open a port to whatever   
// port ID your MIDI controller is on.  
midiIn.openPort(0);   
  
// Add your MyMidiListener instance  
// as a listener.  
midiIn.addListener(&midiListener);  
  

Now, when your computer receives MIDI events, your listener’s newMidiMessage method will get called. You can (and should) add some additional methods to your MyMidiListener class so that your main testapp application can actually get data from it.


#12

good job, that worked!
thx, L.


ofxMidi questions
#13

[quote author=“mikecreighton”]So, I just tried my hand at compiling this latest 0.02 version of ofxMidi on Mac OS 10.5.8. Here’s how I got it to work:

Now, when your computer receives MIDI events, your listener’s newMidiMessage method will get called. You can (and should) add some additional methods to your MyMidiListener class so that your main testapp application can actually get data from it.[/quote]

Thanks for these instructions. It seems to work (im getting a list of available devices printed in the console), but Im kinda clueless what I have to do now (sorry, kinda new to this thingy :slight_smile:


#14

Yay, its working! After another few attempts suddenly I got incoming midi data printed to the console (haven’t got a clue why that didn’t happen in the first place), and after some more days of breaking my head I figured out how to add the necessary methods for using the incoming data in my program (so now I know how to do that in general too ;)).


#15

For another nice tutorial on getting ofxMidi to work, check out this post http://www.jocabola.com/archives/lab/oflab-at-the-va-part-i/ from the Decode OF Lab.

It comes with an example-project that works “out of the box” as long as you put ofxMidi in your addons folder. I’ve attached the version of ofxMidi linked to in the post, as I think addons.openframeworks.cc is being phased out and I’m not sure it’s posted anywhere else.

ofxMidi.zip


#16

Thx kylemcdonald,

many troubles of my ofxMidi-quest were solved by this version of ofxMidi and the right example…

Here I go…


#17

I’m having some trouble with using ofxMidiOut to change a control in Ableton Live using Xcode.

I’m using a Korg Nano midi controller.

I’m assigning a control in Ableton from the midi controller and it says it’s on channel 16, Control 64.

Here’s the important part of my code:

  
void testApp::setup(){  
	midiOut.listPorts();  
	midiOut.openPort(0);  
}  
  
void testApp::update(){  
	midiOut.sendControlChange(16, 64, 4);  
}  

If I look in the output of GDB it says:
ofxMidiOut: 1 ports available
0: nanoKONTROL CTRL

So I know that it can at least see the midi controller and it’s not throwing any errors.

However, no matter how long I run the sketch, the control does not change in Ableton.

I’ve also tested some VSTs with the same result.

Any ideas what I could be doing wrong?


#18

jfenwick, i’m not sure what direction you want your midi messages to be going.

are you trying to use your korg as an interface between OF and abelton? that doesn’t work. you’ll need a midi loopback app/driver, which is os-dependent.


#19

kylemcdonald, that was definitely it. Thanks!

As soon as I looked up midi loopback for OS X I found out that Audio MIDI Setup has the IAC Driver, which I believe stands for Inter Application Driver. No idea what the C is for in that acronym :stuck_out_tongue:

I think the real trick is to go into Ableton > Preferences > Midi Sync and make sure that Remote is set to ON.

That’s my guessed based on my limited understanding.


#20

instead of

  
midiout.openPort(0);  

use

  
midiout.openVirtualPort("NameOfYourApplication");  

(use any name you wish insead of “NameOfYourApplication”)

and than you can select thiis name as input port in the other application.