Receiving MIDI OSC with Pd

I’ve got my Pi set up as a hotspot, i can see it on my network. How do I receive messages into Pd? No sure where to start with this. I can send messages from a udpsend object in Max MSP on my laptop, although I’m supposed to specify a port as well as the IP address with udpsend, not sure which port to specify. And then, what objects can receive this data in Pd?Or does it come straight to Pd’s MIDI ports?

Hi, its default port is 12101 (https://github.com/velolala/touchosc2midi/blob/master/touchosc2midi/advertise.py#L13)

Once touchosc2midi gets started after triple clicking the button, there should be a virtual MIDI port on the system which you can then connect to other ports using aconnectgui, and use it as any regular MIDI port in Pure Data.

If you’re sending osc from Max MSP, you’d have to follow ‘TouchOSC’ protocol, but I couldn’t find a good reference on that.

Otherwise, you should be able to use osc directly in Pure Data by using appropriate objects to receive it, without going through touchosc2midi. Touchosc2midi is useful for turning your phone or tablet into a wireless MIDI controller, if you’re sending OSC messages yourself instead of using a ready-made client, then you don’t need to depend on touschosc2midi directly.

Triple clicking only works if I disconnect from my wifi router before triple clicking.
After triple click I can see a Pisound hotspot from my laptop and phone, but I can’t see any indication that touchosc2MIDI has started. And I don’t see any new ports in aconnectgui. I only have the two regular MIDI ports visible

I tried installing touchosc2midi and the install failed. I’m kind of stuck knowing where to go for basic stuff - like for instance I don’t know how to check if touch osc2midi is installed. I managed to monitor midi in with the terminal but there was no midi coming over OSC from my laptop or touchOSC on my iPhone.

I also don’t know what are the appropriate objects to receive OSC in Pd. There are instructions on the Touch OSC website but they seem to be for OS X or they use pd-extended which is discontinued, and an object dumpOSC which doesn’t seem to exist for raspbian. Stuck!

After everything is setup properly, you should have a virtual MIDI port available while the WiFi hotspot is enabled:

And you should use it the same way as other MIDI ports, it’s not really necessary to use OSC directly in your patches - that is the point of touchosc2midi - to convert it under the hood to the regular MIDI messages.

image

How did you try installing it? What errors did you get? You can run in a terminal:

which touchosc2midi
touchosc2midi --version

If these commands are producing some sensible output, it’s installed.

OK… the problem was that touchosc2midi did not get installed with pisound - the documentation seems to say it gets installed automatically with pisound, but it wasn’t. After trying to install touchosc2midi with these instructions https://github.com/velolala/touchosc2midi which didn’t work, I eventually used pisound-config to install touchosc2midi and now i have virtual ports and can receive midi data.

2 Likes

Sorry about that, which part are you referring to? I did a quick search and couldn’t locate it, but I’d like to update the documentation to be more explicit on this.

Good to hear you got it working!

This bit says triple clicking launches touchosc2midi monitor, doesn’t mention it needs installing.
https://blokas.io/pisound/docs/the-button/#toggle_wifi_hotspotsh-toggle-wifi-hotspot-mode

I got it working from Touch OSC on my phone. Still struggling with sending MIDI from Max MSP on my laptop!

Are you connected to the Pisound WiFi hotspot on your laptop? Are any of the examples on https://hexler.net/docs/touchosc-setup-other helpful?

One way to see whether there’s any data incoming at all is to:

sudo apt-get install liblo-tools
sudo killall touchosc2midi # This is in order to free up the 12101 port
oscdump 12101 # This will print the incoming data

When changing controls on a TouchOSC client, you should see output like:

/midi m MIDI [0x00 0x43 0x06 0xb0]
/midi m MIDI [0x00 0x42 0x06 0xb0]

I get data incoming in the terminal window no problem with the method you describe

however … all the example patches on https://hexler.net/docs/touchosc-setup-other use objects that won’t open in Pd, such as dumpOSC and OSCroute. I’ve tried searching for them using Pd’s “find externals” but nothing comes up…I can’t find any Pd objects that will receive or send OSC
There are some network externals in libraries such as “mrpeach” and “maxlib” but when i install those libraries the network objects (and some others) won’t load.
edit: it looks like pd vanilla has netreceive and netsend built in to deal with network messages. But I can’t get anything out of them…

You only need to use the OSC objects if you want to send arbitrary OSC messages. Those missing OSC objects likely aid in unpacking the OSC message to handle it in an easier way, but if you do manage to get something from the network into Pure Data, likely there’s other means of interpreting the messages.

However, as I understood, you just want to use the same TouchOSC method as using the app on the mobile to get MIDI data into Pure Data wirelessly:

In that case, you do not have to do anything specific in Pure Data, and just rely on touhosc2midi to do the conversion. Basically, all you’d have to do is to send appropriate data from Max MSP to UDP 172.24.1.1, port 12101, (assuming the laptop is connected to the Pisound WiFi hotspot) then touchosc2midi will convert it to regular MIDI data for you. The data to be sent from Max MSP should be exactly the same lines as you saw when using oscdump utility:

/midi m MIDI [0x00 0x43 0x06 0xb0]
  • 0xb0 means it’s a control change message on the 1st MIDI channel
  • 0x06 is the CC number
  • 0x43 is the value.
  • 0x00 not entirely sure of the purpose of this byte here, all MIDI messages (apart from SYSEX) fit in up to 3 bytes. I couldn’t find any Touch OSC protocol documentation. In case of USB MIDI, it also uses 4 byte transfers, and the 4th byte contains additional info on ‘virtual cable’ (if the USB MIDI device provides multiple input / output ports, as well as a hint on the MIDI message it is (similar to 0xb0 in the first byte))

Hope this helps :slight_smile:

1 Like

A post was split to a new topic: Receiving Touch OSC