Norns - can I disable MIDI so it can be used by another program?

i’ve written a custom midi → osc program so that i can use one button from my nanokontrol to send multiple osc messages (e.g. one button can toggle reverb on/off and set reverb levels to my prefs) and so i don’t have to map dozens of keys. this program works great if the nanokontrol is running off another computer, but i’d like to just run it from the norns itself so i don’t have to have another computer.

the trouble i’m having is that norns is smart about midi devices and intends to consume any device that is plugged into it. because of this, i can’t connect to a usb device using any program other than the norns ui. if i try to stop norns (~/norns/, then plug in my device, then connect to it via another program, and then start norns again, norns (rightly) doesn’t like this and won’t start.

is there a way i can tell the norns to ignore a particular midi device so that my custom program can utilize it? perhaps there is a line in the norns codebase i can comment out and then rebuild it as a midi-less version? or is there a less severe way? i suppose this wouldn’t be a problem if i had a grid…but i’m not there yet :wink:

to completely disable MIDI in the C layer:

you should be able to comment out this search pattern from the list of USB device paths which are monitored:

alternatively (in case it is somehow scanned anyway?) you could skip this bit where it actually makes the connection with an ALSA call:

(or of course you could add a bit of code that checks the path for your particular device.)

@tehn et al, this is yet another use case that could be handled by the addition of customizable USB discovery logic.

1 Like

and my annoying non-answer would be: you could just send the OSC from the norns lua interpreter. if you want to shim a system-level MIDI handler that is independent of scripts it could go in here:

or i guess it could programatically add a handler when it detects that particular device, here:

1 Like

but the actual answer to the question is: no, there is presently no mechanism for ignoring a device. AFAIK, implementing this would require changes to the C layer where it asks ALSA for the device handle.

1 Like

thank you @zebra. your answers are always thorough and helpful!

i think i’ll goto the C layer. i like the idea of sending from the lua interpreter, but i’d like to have the OSC messages sent from my program so it still leaves the option to run it from another computer.

my question is more fundamental: is there something your program does that could not be easily created inside of the norns ecosystem? i imagine a lua script to forward midi to OSC would be eminently simple, much more so than your go program (though i haven’t read the code).

what was your rationale for going this way?

1 Like

i wasn’t really thinking inside the norns ecosystem - but i believe the norns system would accomodate this instead of mangling the C layer. i can write a generic importable library that does midi -> osc. and then just add a line to the scripts i want to control!

i think my rationale was just that i know go better than lua :slight_smile: but lua is pretty straightforward to figure out. on that note - are there simple examples of making an importable lua library for a norns script? edit: nvm! this tutorial showed me what i need to know!


let me know if i can help, would be happy to sort out any issues (we’re deep into a reevaluation of the docs more broadly)