danomatika / ofxMidi

(maintained) Midi addon for openFrameworks
Other
262 stars 72 forks source link

Receive Sysex #42

Closed fred-dev closed 7 years ago

fred-dev commented 7 years ago

There seems to be a problem receiving Sysex (on OSX -cant test any other platforms now). I know I have to enable it as it is ignored, but after I do I cannot get the message contents.

cout<<ofToString(midiMessage.status);
if (midiMessage.status==MIDI_SYSEX) {
    ofLogVerbose()<<"Sysex Message"<<endl;
    ofLogVerbose()<<"Message Size " + ofToString(midiMessage.bytes.size())<<endl;
}

This code never makes to printing Sysex Message, I can verify I am sending a sysex message with other applications. If I check the size of the message as soon as it comes it is reported as 0

danomatika commented 7 years ago

Have you tested with the MidiInputExample project? I'm on OS X and just checked. Sysex seems to be working, at least the data being sent from the Pure Data test patch res/miditest.pd. The example prints the sysex bytes it sees:

[verbose] ofxMidiIn: IAC Driver Pure Data Out: Sysex 0 [ F0 47 00 42 48 00 00 01 4B 00 01 00 04 00 F7 ] 2002.82
danomatika commented 7 years ago

Also, you can enable verbose printing in your own app so ofxMidi will print all the messages and bytes it receives. This way you can tell if it's a problem with ofxMidi or your receiving logic.

Enable verbose printing in your app's setup function:

ofSetLogLevel(OF_LOG_VERBOSE); // turn everything on or...
ofSetLogLevel("ofxMidiIn", OF_LOG_VERBOSE, ); // just enable verbose for the ofxMidiIn object
fred-dev commented 7 years ago

Ok, I had a chance to do some tests, I am working with midi machine control commands. Instead of processing I used the addon itself to format the commands.

Here is the code I use to generate the commands

void ofApp::buildSysExMMCMessage(char ID) { sysexMMCMsg.clear(); sysexMMCMsg.push_back(MIDI_SYSEX); sysexMMCMsg.push_back(0x7F); sysexMMCMsg.push_back(0x7F); sysexMMCMsg.push_back(0x06); sysexMMCMsg.push_back(ID); sysexMMCMsg.push_back(MIDI_SYSEX_END);

}

and to send

void ofApp::keyPressed(int key){ if (key=='1') { buildSysExMMCMessage(1); midiOut.sendMidiBytes(sysexMMCMsg); } if (key=='2') { buildSysExMMCMessage(2); midiOut.sendMidiBytes(sysexMMCMsg); } if (key=='3') { buildSysExMMCMessage(3); midiOut.sendMidiBytes(sysexMMCMsg); }

}

In midi monitor I get this

19:28:51.646 To Bus 1 SysEx F0 7F 7F 06 03 F7

But using this code with ofxMidi receiving the messages from the IAC port

void ofApp::newMidiMessage(ofxMidiMessage& msg) {

cout<<ofToString(midiMessage.status);
if (midiMessage.status==MIDI_SYSEX) {
    ofLogVerbose()<<"Sysex Message"<<endl;
    ofLogVerbose()<<"Message Size " + ofToString(midiMessage.bytes.size())<<endl;
    ofxOscMessage m;

}

I am still only printing 0

I do see that the messages we are dealing with are not the same size. Maybe I was mistaken that midi universal real time sysex was a subset of sysex? However when I use the add to send with the same

void ofApp::buildSysExMMCMessage(char ID)

Method, to my midi machine control enabled applications (protools, cubase etc), it works fine and controls them, this is using the sysex and sysexend predefines from the ofxMidi addon.

Let me know what you think the solution might be, or if you need any more info or code.

Thanks for replying so fast

Cheers

Fred

On 27 Sep 2016, at 18:30, Dan Wilcox notifications@github.com wrote:

Also, you can enable verbose printing in your own app & ofxMidi will print all the messages & bytes it receives. This way you can tell if it's a problem with ofxMidi our your receiving logic.

Enable verbose printing in your app's setup function:

ofSetLogLevel(OF_LOG_VERBOSE); // turn everything on or... ofSetLogLevel("ofxMidiIn", OF_LOG_VERBOSE, ); // just enable verbose for the ofxMidiIn object — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/danomatika/ofxMidi/issues/42#issuecomment-249919858, or mute the thread https://github.com/notifications/unsubscribe-auth/ABg9lTzhnJh0KB8rVhwqvTf4GWOeJY_Uks5quUSvgaJpZM4KF-Gf.

fred-dev commented 7 years ago

Yes, it was my own stupidity, please mark as solved, sorry for the hassle.