MIDI Command Server

Previously, in order to be able to shut down my Pi from the MODEP UI, I wrote a script to listen for a particular MIDI CC and value, then shut the host system down.

I then thought of a number of different uses for this same MIDI-triggering-commands approach, and re-implemented it in a more generalized fashion as MidiCmdServer:

In the script, you can easily set any number of new command for it to listen for like this:

#midi_cmd(cc_num, cc_val, "command to run", optional_uptime_second_restriction)
midi_cmd(64, 127, "init 0", 120)
# ^ same as the original shutdown server functionality
midi_cmd(127, 30, "echo 'test' > /tmp/test")
midi_cmd(64, 0, "uptime > /tmp/uptime")

Commands are executed via os.system.

This approach allows for also assigning whatever commands you might want on a host system, to any MIDI CC number and value.

To have the server start on boot, I usually add it to crontab (set your path properly):

@reboot /usr/bin/sudo /path/to/midi_cmd_server.py &

In the MODEP UI, simply select the MidiCmdServer as an output (capture) MIDI port and connect your expected MIDI source to it.

Hopefully this proves to be useful to other folks who are messing around with MIDI stuff on their Pis and other hardware!

Happy Hacking

3 Likes

Good stuff! :slight_smile:

Btw, you may easily load other pedalboards via /usr/local/modep/modep-btn-scripts/modep-ctrl.py script on the system, so you may implement a reliable program change handling to change pedalboards.

Hey, now that is a real neat script you pointed me at!

I forked that project and made some adjustments, then made a pull request for those changes to get merged back in, including a few functions to be able to load a pedalboard by name:

modep@modep:~/modep-btn-scripts $ ./modep-ctrl.py load-board HEXA_SYNTHS
Switching /usr/local/modep/.pedalboards/DEFAULT.pedalboard -> /usr/local/modep/.pedalboards/HEXA_SYNTHS.pedalboard
modep@modep:~/modep-btn-scripts $ 

I’ve been experimenting with it for just a bit, and it seems like this will work out quite well in my setup with the MidiCmdServer and the Behringer FCB1010 with Eureka.

Notably, I can set up a single foot switch that sends MIDI CC signals to flip between two saved pedalboards depending on whether it’s on (127) or off (0)!
And that can be achieved with just two lines of code in the MidiCmdServer:

midi_cmd(83, 127, "/usr/local/modep/modep-btn-scripts/modep-ctrl.py load-board HEXA_SYNTHS")
midi_cmd(83, 0, "/usr/local/modep/modep-btn-scripts/modep-ctrl.py load-board DEFAULT")

I suspect that this approach would have issues if one is using a MIDI device that sends the same control-change signals over and over.
That might just boil down to not assigning this thing to watch a wah pedal or something like that, and stick to things like buttons instead.
Also, in my crash-testing, I found that flipping between pedals too quickly can cause issues. It seemed like the pedals from both the boards to load up, and there would be a LOT of extra noise.
YMMV, but it works for me :slight_smile:

Hey! Thank you for the pull request. I’ll soon add a couple of comments there.

The script originally was meant to be used with Pisound’s The Button (https://blokas.io/modep/docs/MODEP-and-Pisound/), that’s the reason why the first bank is used for loading the pedalboards, the index loaded is based on the amount of successive clicks. This allows to easily define the order of the pedalboards you want to load, just by reordering them in the first bank in the web UI.

Working with generic /pedalboards endpoint does not allow to define the order in a similar fashion.

Loading by name is a useful addition. :slight_smile:

Aha, I see! I had not explored the banks functionality properly.

I’ll get that sorted out and have some revisions soon.

1 Like

Hello guys
has this developed to anything more user-friendly at all?
I see no more entries since 2019
let me know if there is anything usable with a midi foot controller like the DigiTech Control8

as I am in the middle of building this if instead of the midi there are different ways to change pedalboard and on/off effects once the pedalboard is selected (maybe using the GPIO) please let me know
I thought of using this controller as I had it laying around and I thought the implementation was easier than construct some external pedals :slight_smile:
Also, coding is not my forte, so I rely on already available script :expressionless:

thank you anyway for all the work you guys have done to release such a great product :heart: