you can try the [mediasettings] lib from iem which allow you to choose midi driver from patch
or you can also directly send message to pd to setup midi port
use :
[receive pd]
|
[print pd]
while changing midi settings to monitor what messages you should sent to select OSS MIDI
remember [loadbang] could happen *before* midi and audio settings when pd is launched with -nogui option
so if you use a loadbang to change midi settings, you should also have a [delay] just before choosing midi settings to let pd load the driver
moreover, concerning Raspbian, Pd and MIDI, I made a little patch that plugs all ALSA MIDI input device to all output devices (avoiding feedback loop)
It's alsa but it's works on Raspbian (but not tested with NanoKontrol)
the patch also maps each keyboard key to a MIDI message
+
a