Using more than 4 MIDI-USB controllers [partially SOLVED]

Hi,
I’v got a very strange issue. In my set I have 5 usb midi keyboards connected to Zynthian (Rbp4). I have play on this settings on my live YT music last year. And everything was ok. Few days back I’v made an fresh Zynthian update. And now when I try to start it (with 5 midi keys connected) I have an start error. Everything is ok when only 4 of them are connected. But after start when I’m connecting 5th usb midi, it don’t work.
And there is no mater which one is connected, with usb hub (active or passive) or straight.
Simply: 4 usb midi working, 5 - don’t.
I have very decent power supply (3.1A).
Adam

Hi @ejdzi

What is your soundcard configuration Jackd Options?

dtoverlay=hifiberry-dacplus

Jackd Options:
-P 70 -t 2000 -s -d alsa -d hw:sndrpihifiberry -S -r 44100 -p 256 -n 2 -X raw
Exactly the same as before, when everything was ok.
EDIT
And when I choose “dummy device” soundcard Zynthian is starting well with 5 usb controllers attached but only 4 of it are working. I will try with another power supply (original for RPi4) later today.
Edit2
I’m sorry but I can’t figure it.
New power supply - only 4 usb midi. :frowning:
New Zynthian image - only 4… :frowning:
The last working with whole set image was Build Date: 2020-04-11 last updated around september.
Please help, I do not know what could cause this situation

Have you tried do disable native jackd midi drivers with the -X none option? Your devices should still show up thanks to a2jmidid. That works for me after some trouble with the raw and seq drivers.

Thanx, but please how and where can I do this disabling, because I can’t find it by myself, sorry.

Do you have terminal access either via ssh (user: root, password: raspberry) or webconf SYSTEM->Terminal? Please post the output from these commands:

amidi -l

jack_lsp -t midi

when 4 are connected and Zynthian starts

root@zynthian:~# amidi -l
Dir Device    Name
IO  hw:0,0    f_midi
IO  hw:3,0,0  cme MIDI 1
IO  hw:3,0,1  cme MIDI 2
IO  hw:4,0,0  Arduino Micro MIDI 1
IO  hw:5,0,0  iRig Keys MIDI 1
IO  hw:6,0,0  Xkey37 MIDI 1
root@zynthian:~# jack_lsp -t midi
system:midi_capture_1
        8 bit raw midi
system:midi_playback_1
        8 bit raw midi
system:midi_capture_2
        8 bit raw midi
system:midi_capture_3
        8 bit raw midi
system:midi_playback_2
        8 bit raw midi
system:midi_playback_3
        8 bit raw midi
system:midi_capture_4
        8 bit raw midi
system:midi_playback_4
        8 bit raw midi
system:midi_capture_5
        8 bit raw midi
system:midi_playback_5
        8 bit raw midi
system:midi_capture_6
        8 bit raw midi
system:midi_playback_6
        8 bit raw midi
ttymidi:MIDI_in
        8 bit raw midi
ttymidi:MIDI_out
        8 bit raw midi
ZynMidiRouter:midi_out
        8 bit raw midi

when 5 are connected and there is start error:

root@zynthian:~# amidi -l
Dir Device    Name
IO  hw:0,0    f_midi
IO  hw:3,0,0  nanoPAD2 MIDI 1
IO  hw:4,0,0  cme MIDI 1
IO  hw:4,0,1  cme MIDI 2
IO  hw:5,0,0  Arduino Micro MIDI 1
IO  hw:6,0,0  iRig Keys MIDI 1
IO  hw:7,0,0  Xkey37 MIDI 1
root@zynthian:~# jack_lsp -t midi
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Error: cannot connect to JACK, server is not running.

Okay - so we see that ALSA is recognising all the interfaces. I see you have:

  • nanoPAD2
  • CME apparently with 2 MIDI ports
  • Arduino Micro
  • iRig Keys
  • Xkey37

JACK server is not running so we need to figure that out. Will you post the output of journalctl -ru jack2|head -n 30?

root@zynthian:~# journalctl -ru jack2|head -n 30
-- Logs begin at Wed 2021-03-24 14:58:36 GMT, end at Thu 2021-03-25 16:09:18 GMT. --
Mar 25 16:09:09 zynthian systemd[1]: jack2.service: Scheduled restart job, restart counter is at 7.
Mar 25 16:09:09 zynthian systemd[1]: jack2.service: Service RestartSec=1s expired, scheduling restart.
Mar 25 16:09:08 zynthian systemd[1]: jack2.service: Failed with result 'exit-code'.
Mar 25 16:09:08 zynthian systemd[1]: jack2.service: Main process exited, code=exited, status=255/EXCEPTION
Mar 25 16:09:08 zynthian jackd[1898]: Failed to open server
Mar 25 16:09:07 zynthian jackd[1898]: ALSA lib pcm_hw.c:1822:(_snd_pcm_hw_open) Invalid value for card
Mar 25 16:09:07 zynthian jackd[1898]: ALSA lib pcm_hw.c:1822:(_snd_pcm_hw_open) Invalid value for card
Mar 25 16:09:07 zynthian jackd[1898]: creating alsa driver ... hw:sndrpihifiberry|hw:sndrpihifiberry|256|2|44100|0|0|nomon|swmeter|-|16bit
Mar 25 16:09:07 zynthian jackd[1898]: self-connect-mode is "Don't restrict self connect requests"
Mar 25 16:09:07 zynthian jackd[1898]: JACK server starting in realtime mode with priority 70
Mar 25 16:09:07 zynthian jackd[1898]: under certain conditions; see the file COPYING for details
Mar 25 16:09:07 zynthian jackd[1898]: This is free software, and you are welcome to redistribute it
Mar 25 16:09:07 zynthian jackd[1898]: jackdmp comes with ABSOLUTELY NO WARRANTY
Mar 25 16:09:07 zynthian jackd[1898]: Copyright 2016-2019 Filipe Coelho.
Mar 25 16:09:07 zynthian jackd[1898]: Copyright 2004-2016 Grame.
Mar 25 16:09:07 zynthian jackd[1898]: Copyright 2001-2005 Paul Davis and others.
Mar 25 16:09:07 zynthian jackd[1898]: jackdmp 1.9.14
Mar 25 16:09:07 zynthian systemd[1]: Started JACK2 Audio Server.
Mar 25 16:09:07 zynthian systemd[1]: Stopped JACK2 Audio Server.
Mar 25 16:08:46 zynthian systemd[1]: jack2.service: Scheduled restart job, restart counter is at 6.
Mar 25 16:08:46 zynthian systemd[1]: jack2.service: Service RestartSec=1s expired, scheduling restart.
Mar 25 16:08:44 zynthian systemd[1]: jack2.service: Failed with result 'exit-code'.
Mar 25 16:08:44 zynthian systemd[1]: jack2.service: Main process exited, code=exited, status=255/EXCEPTION
Mar 25 16:08:44 zynthian jackd[1705]: Failed to open server
Mar 25 16:08:44 zynthian jackd[1705]: ALSA lib pcm_hw.c:1822:(_snd_pcm_hw_open) Invalid value for card
Mar 25 16:08:44 zynthian jackd[1705]: ALSA lib pcm_hw.c:1822:(_snd_pcm_hw_open) Invalid value for card
Mar 25 16:08:44 zynthian jackd[1705]: creating alsa driver ... hw:sndrpihifiberry|hw:sndrpihifiberry|256|2|44100|0|0|nomon|swmeter|-|16bit
Mar 25 16:08:44 zynthian jackd[1705]: self-connect-mode is "Don't restrict self connect requests"
Mar 25 16:08:44 zynthian jackd[1705]: JACK server starting in realtime mode with priority 70

Looks like something odd with the soundcard. Will you please post a screen capture of http://zynthian.local/hw-audio.

Also the HARDWARE, SYSTEM and SOFTWARE sections from webconf dasboard: http://zynthian.local.

Also the output of lsusb.

You must be using a USB hub - Zynthian only has 4 USB sockets. This could be relevant. You could try ticking the Limit USB speed to 12Mb/s: option in webconf HARDWARE->Audio, advanced settings to see if it makes a difference.

I’m using hub of course but I used it for the last 3 years and it was ok always.
I’v tried USB speed to 12Mb/s but with no effect.

But please, I do not want to bother you too much, if this is not an obvious issue. maybe it is something wrong with my particular set. :blush:



root@zynthian:~# lsusb
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 007: ID 2341:8037 Arduino SA
Bus 001 Device 005: ID 1963:0005
Bus 001 Device 008: ID 258f:0b02
Bus 001 Device 006: ID 0227:0227
Bus 001 Device 004: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 003: ID 0944:0116 KORG, Inc.
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Tricky! I’m not sure what’s going on. Is it possible you have changed the connections? Try plugging the hub into different USB sockets and try moving the keyboards to different sockets.

So, I have tried all combinations: different usb sockets, different keboards, 1 to 4 through hub, 1 to 4 straight to Rpi and in the end is always: four working, fifth don’t.
When I start Zynthian without any keyboards and then connect one by one (no matter if straight or through hub) ALSA is recognising all the interfaces if it is less than 5. 5th not appear in midi ports window.
When I start Zynthian with all 5 keyboards connected ALSA is recognising all 5 interfaces but Zynthian UI does not start (Error screen with IP). Maybe I should try another usb hub?

Go into the audio options on the web UI. Make sure advanced view is enabled. You will see a line “Jackd Options” that usually ends with “-X raw”. You can replace “raw” with “seq” to use the ALSA sequencer MIDI interface, or “none” to not use any MIDI driver at all. This will not disable Jacks MIDI routing (both ALSA and Jack) what is essential for Zynthian. Because Zynthian is running the a2jmidid ALSA/Jackd MIDI daemon, the MIDI devices that ALSA loads correctly should still show up in Jack MIDI and thus Zynthians MIDI configuration.

I don’t think that is true. Zynthian runs a2jmidid without handling hardware ports. It is used only for alsa software ports.

That is odd. On my Zynthian a2jmidid had the “-e” option enabled by default and the hardware shows up. That’s why after too much problems with the “raw” driver I was able to disable the MIDI driver for Jack and still use my hardware. Maybe an update did not get through properly.
It might make sense to add a line “a2jmidid Options” to the advanced audio configuration. Not just to enable/disable hardware, but it sometimes makes sense to disable the unique IDs with the -u option.

I can confirm this is an issue. I managed to find enough USB MIDI devices to trigger this on my Zynthian 4.1 with RPi4. Please add a ticket to the issue tracker.

@catherder you seem to be correct that a2jmidid does handle the hardware if it is disabled in jackd. The man page suggested it wouldn’t as configured.

Disabling jackd handling of MIDI (by removing -x raw does allow Zynthian to boot with 5 USB devices attached but ALSA still only sees 4 of them so that is only a partial fix.

I can confirm, that’s right. Just ran an update and the “-e” is gone. The only hardware port that is still mapped under a2j is my Android Tablet, but that’s probably one of the many Android quirks.

Oddly the a2jmidid service has the --export-hw parameter commented out but is still implementing the feature. The USB MIDI devices are exposed by a2jmidid when the service is running. Removing this commented part of the service disables hardware export so something odd going on with the service and behaviour is not as designed. All very interesting but does not address the matter in hand!

@ejdzi will you check the output of dmesg after plugging in the 5th device? Do you see an error -28 and/or report of “Not enough bandwidth for new device state”? I am seeing this when I plug in the last (non-working) device.