Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIDI over USB #29

Closed
nwesthoff opened this issue Apr 24, 2018 · 10 comments
Closed

MIDI over USB #29

nwesthoff opened this issue Apr 24, 2018 · 10 comments

Comments

@nwesthoff
Copy link

nwesthoff commented Apr 24, 2018

I would like to send MIDI over USB from a Traktor Pro Remix Deck (in step sequence or one-shot mode) to be able to use the NSynth Super in a live environment while DJ'ing.

Is it possible to send MIDI over USB? Or do I have to use the 5-pin DIN port? If this is currently not possible, could it be added using an openFrameworks package?
I couldn't find anything about it in the docs, and would try myself, but I'm currently waiting for the PCB to arrive.

@KyleWerle
Copy link
Contributor

The NSynth can only send / receive MIDI over USB as a USB Host. It is less easy to send MIDI between two host computers. There are many ways to do what you want, but very few of them are easy to setup and none as easy as connecting the NSynth Super to your computer with a USB cable.

The easiest solution in this case is to use a USB to MIDI DIN Adapter.

@nwesthoff
Copy link
Author

Okay! It would make the whole live setup a little more cumbersome, but fortunately my audio interface already has MIDI DIN in/out, so I'll just get a cable and be done with it. Thanks.

@nanu-c
Copy link

nanu-c commented May 15, 2018

This is easly done by adding the ofxMidi library to the app

@nanu-c
Copy link

nanu-c commented May 15, 2018

I can expand the openframeworksapp to do that and it's only some 20 lines of code

@nanu-c
Copy link

nanu-c commented May 15, 2018

  • get a version of ofxMidi that works with yout version of openframeworks for 0.9.8
    $ cd /home/pi/opt/of/addons && git clone https://github.com/danomatika/ofxMidi/
  • add ofxMidi to ~/opt/of/apps/open-nsynth/open-nsynth/addons.make
  • in /home/pi/opt/of/apps/open-nsynth/open-nsynth/src/ofApp.h add at the beginning after the includes #include "ofxMidi.h" and change line 35 to
    class ofApp : public ofBaseApp, public ofxMidiListener{
  • add at line 73
               // the midi stuff
                void newMidiMessage(ofxMidiMessage& eventArgs);
                ofxMidiIn midiIn;
                ofxMidiMessage midiMessage;
  • In /home/pi/opt/of/apps/open-nsynth/open-nsynth/src/ofApp.cpp change after line 77 add at end of void ofApp::setup() -> adapt this to your needs
	// print input ports to console 
	midiIn.listPorts(); // via instance -> comment this line when done
	//ofxMidiIn::listPorts(); // via static as well
	
	// open port by number (you may need to change this)
	midiIn.openPort(1);
	//midiIn.openPort("IAC Pure Data In");	// by name
	//midiIn.openVirtualPort("ofxMidiIn Input"); // open a virtual port
	
	// don't ignore sysex, timing, & active sense messages,
	// these are ignored by default
	midiIn.ignoreTypes(false, false, false);
	
	// add ofApp as a listener
	midiIn.addListener(this);
	
	// print received messages to the console
midiIn.setVerbose(true);
  • add at the end of ofApp.cpp
void ofApp::newMidiMessage(ofxMidiMessage& msg) {
		midiMessage = msg;
	// ofLog(OF_LOG_NOTICE,"channel: " + ofToString(midiMessage.channel) + " control: "
	// + ofToString(midiMessage.control) +" value: " + ofToString(midiMessage.value)+" pitch: " + ofToString(midiMessage.pitch)
	// +" velocity: " + ofToString(midiMessage.velocity));
		int idx;
		idx = midiMessage.pitch;
		if (msg.velocity == 127){
			synthMutex.lock();
			synth.on(idx);
			synthMutex.unlock();
		}
		else{
			synthMutex.lock();
			synth.off(idx);
			synthMutex.unlock();
		}
}
  • in ~/opt/of/apps/open-nsynth/open-nsynth run $ make -j4
  • stop nysth service sudo service open-nsynth stop
  • run compiled app $ bin/open-nsynth

@hagan66
Copy link

hagan66 commented Aug 29, 2018

Has anyone done this and prepared a ready-to-go image file? I have no recent programming experience but I would very much like my Nsynth to speak USB. :-)

@gitunit
Copy link

gitunit commented Jan 7, 2019

@nanu-c thx for the code. there is a minor typo though. it should be "listInPorts()" instead of "listPorts" at least in the latest version of ofxMidi.

@gitunit
Copy link

gitunit commented Jan 8, 2019

@nanu-c seems not that easy. have you tested it yourself? im unable to list the port created with "loopMIDI" in Windows. i have connected the device via the pcb's USB port with the PC. should i use the USB port on the pi instead?

@nanu-c
Copy link

nanu-c commented Jan 8, 2019

it's different, you have to put a usbmidi device in the raspberry pi. Like a akai or so.
If you wan't to use your pcb as usbmidi it's not possible like that because I think the usb connector on the pcb is only for power.

if you want use the touch/knobs as midi input and send it to a other machine there a 2 common ways to do it.

  1. connect the rpi to your windows network

  2. use either https://github.com/hiroyuki/ofxArtnet for Artnet or

osc depending what is supported py the program you try to use in windows.
https://github.com/openframeworks/openFrameworks/tree/patch-release/addons/ofxOsc https://www.youtube.com/watch?v=TczI-tSOIpY

@gitunit
Copy link

gitunit commented Jan 8, 2019

ok. i get it. thx for clarification. btw. im from vienna, too. saw your homepage. nice projects ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants