TouchOSC + Modep - Toggles and presets

Hi all. I’ve recently come across Patchbox and Modep having been playing with PureData for a while both with TouchOSC and I think it’s a great piece of sofware but I have a couple of questions I’ve not been able to find the answers too.

Basically, I have a PI 3B+ running headless (modep in a browser for pedalboard setup), a Behringer UCA-222 USB card, an AKAI MPKmini mk2 controller and TouchOSC running from a mobile phone for other controls not on the MPKmini.

I have a single pedalboard setup in modep that has an AMSynth, a FluidGM Drums and a FluidGM Pianos - amongst other bits-n-poieces. Now I what to be able to toggle the synth, drums and piano ideally from the phone through TouchOSC so I can switch between them. I don’t really want to switch pedalboards as I’m using a looper on the board as well and want to combine/overlay all instruments one at a time.

When I use a Toggle button in TouchOSC the button triggers the CC midi msg for the specific instrument but it doesn’t stay ON. As soon as I release the button it goes OFF and so does the instrument. I’ve tried various things in the OSC editor e.g the Toggle button using a value, touch, local feedback on/off but nothing seems to allow it to stick on. Any ideas? When not connected to the patchbox the buttons do stay on until toggled - but obviously nothing happens. I can use the MPK controller for sending the CC msgs but I would prefer to use the phone.

Secondly, I’m not using PiSound but I’d like to be able to use the Amsynth and step through/or choose specific presets - like the next/prev button scripts for PiSound. Program Change messages from the MPK don’t seem to go through to the synth and in modep I can’t ‘MIDI Learn’ against the presets to be able to assign them to something. Is there a way this can be done?

I know it’s a long shot but I wondered if I could somehow get a conventional OSC message out of TouchOSC (e.g. /preset/BriansBank01_050_Peavey) that contained a preset name in Amsynth and then somehow on patchbox ( the tricky bit) intercept that message in a script (shell or python) then fire a URL request (as the modep web interface does to 'http://patchbox.local/effect/preset/load//graph/amsynth_1?uri=http%3A%2F%2Fcode.google.com%2Fp%2Famsynth%2Famsynth%23BriansBank01_050_Peavey5&_=1593003250166) to actually change the preset, then I could define all the presets I want in TouchOSC and switch between them.

Any help would be appreciated and sorry for the long post.

Greg

Program Change for synth’s presets may be a limitation of the MOD software itself.

About toggling through Touch OSC - you should create a layout and use Toggle controls, it should send one CC value in the ‘on’ state, and another in the ‘off’ state, this is how you should be able to control the on/off state in the pedals. Another idea would be to instead use mixer or gain pedals to turn down the volume of currently unused devices.

About switching presets via script - the plugins themselves are standard LV2 plugins. You may be able to access their parameters directly through some LV2 libraries, including getting the list of presets. One example library is liblilv, we’ve used it with Python to generate the list of all plugins in MODEP :slight_smile: But AFAIR it is not available in apt-get, so you have to build and install from source.

Thanks for the reply @Giedrius. I’ve moved on a little with this now using a slightly different approach. I’ve resorted to using the MPK CC controls to toggle the instruments which isn’t a big deal. I’ve also managed to select presets in AMSynth using touch buttons through TouchOSC.

The way I’ve done this is to have a python script run at startup which is based on the ‘MIDI Command Server’ from here -> MIDI Command Server.

I’ve got it listening messages on an unused CC channel and then takes the control value to perform a lookup into an array of preset mappings and uses the message value (0 or 127) to provide the on/off value. This info is then used to construct a URL GET request that I send to the patchbox server - as the MODEP interface does to change the preset.

# TouchOSC CH16 - on/off for AMSynth Instrument preset GET requests
if msg.channel == 15 and msg.value == 127 and lastPreset != msg.control:
PARAMS = {'uri':'http://code.google.com/p/amsynth/amsynth#' + presets[msg.control]} 
URL = 'http://patchbox.local/effect/preset/load/graph/amsynth_1'
r = session.get(url = URL, params = PARAMS)

This seems to work quite nicely.

I also tried to use a similar mechansim for the instrument toggling but this uses an AJAX POST to patchbox.local/effect/parameter/set/
… but that doesn’t seem to work :frowning:

FluidDrums kit selection uses the same POST mechanism too and that doesn’t work either although I get ‘true’ response from it but the kit doesn’t change. Even going throught the browser Dev tools, replaying the XmlHTTPRequest doesn’t work - so I think I’m missing something for these posts.

I’m going to take a look at the liblilv library you mentioned to see if that will help.

Thanks

1 Like

@Giedrius I’ve managed to get lilv working to some extent through python on the Pi - this is using the standard image download. I don’t really know much about lilv but all that is returned from the WORLD.get_all_plugins() are the following: ‘Simple Amplifier’, ‘Example Fifths’, ‘Example Metronome’, ‘Example MIDI Gate’ and ‘Example Parameters’ when clearly there are loads showing in MODEP. Documentation seems quite thin on the ground about lilv and I’m not really sure where to go from here.

Anyway, I’ve found an alternative workaround that does the job for me.

I figured out why the AJAX POST requests were failing to change any plugin parameters. It turns out that in the …‘dist-packages/mod/webserver.py’ that handles the requests, it checks for an internal session initialisation which doesn’t exist returns True rather than actually doing the setting.

The solution was to use websockets instead of POST requests. Now I’m able to change parameters as the MODEP web interface does.

Thanks

1 Like

It’s based on the LV2_PATH environment variable. You may set it as such and then run your script:

export LV2_PATH=/usr/modep/lv2
python3 my_script.py

or simply

LV2_PATH=/usr/modep/lv2 ./my_script.py
1 Like

That does indeed work - might need to investigate that a bit more now.

Thanks

1 Like

I have the same problem. Is it possible to share your websockets solution.
Response TRUE after POST request i think from here https://github.com/BlokasLabs/mod-ui/blob/3ce5950eb13bb7a8278a598f3dea456c814bcaee/mod/webserver.py#L966 HMI (MOD`s hardware or websockets) not initialized.
Also have tried to communicate with MOD-HOST via sockets (https://github.com/moddevices/mod-host) without success .