brummer10 / guitarix

guitarix virtual versatile amplification for Jack/Linux
254 stars 28 forks source link

midi feedback to controller is inconsistent with a large number of controls during preset change #170

Closed AtlantaScott closed 3 weeks ago

AtlantaScott commented 3 weeks ago

Pardon the long post here but I've got some inconsistent results happening and so I wanted to provide more context in case someone is able to evaluate my situation and identify the issue. Please feel free to tag this issue as you see fit. If this is too complex or tedious to deal with I certainly understand and I'll manage to find a work-around.

I have been having some inconsistent results with midi feedback sent to a USB Behringer X-touch Mini Midi Controller. When changing presets the midi information sent is not consistent. I believe it should sent the exact same set of midi commands to tell the external controller what the status of each mapped button and encoder for the preset being loaded. However, sometimes it skips certain controllers and sends a smaller number of midi events. The result is that some of the buttons and encoder LEDs are not updated.

With both the A and B layers of the X-touch used to their full extent, there are quite a lot of midi controllers available. When the number of mappings is lower than about 30 I rarely have a problem, but when i get in the range of 46 to 60 controller mappings (resulting in an equal number of midi events being sent from guitarix to the controller for each program change) the program seems to randomly skip some controller events and may, for example, send only 28 to 43 events for a preset with 47 events expected. If I go back an forth between two presets the number of events will vary, sometimes seemingly dependent on how rapidly I change presets. Sometimes the correct number of events are sent and all LEDs update. The overall issue seems to be related to the midi information sent to the controller during a preset change and this in turn seems to be related to the complexity of the preset and the number of total midi events I have mapped to the controls.

I read that there was a 60ms delay between a change on the GUI and when the midi changes that occurred during that time period are sent out. I'm wondering if it is possible that there is some timing issue that is causing a feedback loop or in some way influencing how the midi information is collected and sent out for each preset change that is related to this 60ms time period? I have a number of different external plugins in many of the presets and I'm wondering if I'm just causing the program to take a bit longer than it should to parse through all of the plugin information and settings. It feels like I've just pushed something a little too far and something gets lost in the process of evaluating the preset being loaded and preparing the table of midi command updates to be sent out.

I am able to monitor the midi information sent from guitarix to the USB midi controller to update the button and encoder states by watching in the midisnooper application. On a program change all of the midi controller states are dumped at once. My assumption is that guitarix sends the state for every controller in the list, not just the controls that are directly mapped in the preset being loaded. Watching the midisnooper info is how I know that the issue is related to the table of commands being assembled and sent out . The table is being generated somehow incorrectly in my case. I tried going back to a clean install with a 'as installed' version of the head config file and using only plugins that came with guitarix and removing all external plugins, but i got the same result. All was fine up to about 35 or 40 mapped controllers, but once I got over 48 the midi output started dropping some of the commands. Again, sometimes it would work correctly and send all 48 commands, but inevitably it would start dropping 3 to 20 commands on a program change.

The buttons and encoders on the X-touch consistently send information to Guitarix and the GUI is very responsive when individual controls are used. The issue only seems to occur on a program change. I have never noticed any issue with GUI to controller sync when I'm using individual buttons or encoders.

I can provide a list of example controller descriptions from the head config file as well as example presets or lists of plugins I'm using. Let me know what other information could be helpful if anyone has the time or gumption to look into this issue.

OS: Xubuntu 22.04 Minimal Guitarix version 0.46.0 Midi Controller: Behringer X-touch mini Global Midi is being used (not saved with presets), Channel 11 for 'set midi channel'. All buttons on X-touch set with 'toggle state' so LED follows GUi state.

I will typically bring in external plugins and I'm not sure if the use of these somehow causes an additional delay or issue with changing presets and how the midi information is sent out. Examples of external plugins I use: Calf mono and stereo compressor, Calf reverb, GX_saturator, Simple High Pass Filter, plus some GX plugins from the additional Guitarix LV2 plugins installation (GxPlugins.lv2).

Note that I often use more than one command per individual button or encoder. For example to turn on two FX's with one button or with the BPM for flange plus chorus tied to the same encoder so that they are time synchronized. If I were to use all of the midi controller mapping that i want to I'd have something like 80 independent lines in the midi controller section in the config file.

I use three different methods to run the GUI on my headless setup: a regular XFCE X-server session with monitor attached, a SSH shell to the headless box from another machine where I can initiate guitarix -N (no GUI) on headless machine and then control it with guitarix -G (GUI only) on the second machine. I can also use tiger VNC to run a desktop on this second machine via link-local ethernet and guitarix GUI runs fine that way too. While there is some slight variation in the behavior of the midi output for each GUI method, I don't think it's the problem, but I thought I'd mention it in case you have a different insight.

I hope to find a solution to this issue because I've been really enjoying the use of this X-touch Mini USB midi controller as the primary interface to a headless Guitarix install. Using a fanless CPU with modest power I'm able to run at 64 samples/2 periods in server sync mode with a measured loopback total latency of right at 4 ms with all kinds of plugins going plus one NAM model running with very few x-runs. Guitarix and NAM are a fantastic pairing.

brummer10 commented 3 weeks ago

Hi I'm curently away for some weeks. Your issue may be related to a fix Limit for max cc Store I've Set Here: https://github.com/brummer10/guitarix/blob/master/trunk/src/headers/gx_jack.h#L115 You could try to increase that Limit to 50 or Higher.

AtlantaScott commented 3 weeks ago

Thanks for getting back to me. It appears to have worked! I changed that limit to 75 in that source file you pointed to, recompiled and reinstalled and the problem seems to have gone away! That is key to being able to get the most out of a controller like the Behringer X-touch mini. If anyone else comes across this info I'd be happy to share my experiences with getting this controller working nicely with Guitarix. It's a relatively low cost, small footprint midi controller I've found that integrates well with Guitarix. The info in the GUI will map back to the LED's on the encoders and buttons. Now thanks to this fix I can map all buttons and layers plus assign multiple GUI widgets to the same knob/CC. Over two layers you get 16 knobs and 32 buttons plus the master fader. I program the unit on Windows and use it in Xubuntu.
I'll close this out but let you know if the issue is not fully resolved.