Closed Stooovie closed 1 year ago
This should work, and does with my keyboards - midi.autoconnect: 1
is all you need. When you say disconnect/reconnect, are you physically unplugging the USB cable, or just disconnecting by turning a switch on the LX88+ on/off? If the latter, then the USB chip in the LX88+ might still be powered by the Pi's USB port, so when you turn the keyboard on it doesn't properly re-announce itself to the Pi.
Trying right now and both have the same effect - MIDI coming in according to aseqdump but no audio coming out. I really do need to manually do
sudo systemctl restart squishbox.service
to get audio working after turning on or plugging in the keyboard.
This might be a fluidsynth problem with keyboards that present as multiple devices - one for keybed and one for controls; another user had a similar problem using a Keystation MK3 in #71. If you run fluidsynth from the command line with -o midi.autoconnect=1
do you get the same behavior?
I get this but still, no audio after turning the keyboard off and back again, despite this saying it's connected succesfully.
pi@rpi:/usr/local/bin $ fluidsynth -o midi.autoconnect=1
FluidSynth runtime version 2.3.2
Copyright (C) 2000-2023 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of Creative Technology Ltd.
fluidsynth: Connection of Midi Through Port-0 succeeded
fluidsynth: Connection of Impact LX88+ MIDI1 succeeded
fluidsynth: Connection of Impact LX88+ MIDI2 succeeded
fluidsynth: warning: Failed to set thread to high priority
Type 'help' for help topics.
> fluidsynth: warning: Failed to set thread to high priority
fluidsynth: Connection of Impact LX88+ MIDI1 succeeded
fluidsynth: Connection of Impact LX88+ MIDI2 succeeded
There is no audio until I call either ./headlesspi.py
or sudo systemctl restart squishbox.service
So I'll probably need some script that detects a USB device plugged in and runs either of these commands.
For posterity, if someone's in the same situation. I made a nektar_connect.sh
script with just
#!/bin/bash
sudo systemctl restart squishbox.service
and a new file in /etc/udev/rules.d
called 99-nektar_connect.rules
with this content:
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="2467", ATTRS{idProduct}=="2018", RUN+="/home/pi/nektar_connect.sh"
I found the idVendor and idProduct numbers with lsusb.
Now, whenever I turn on the keyboard, it restarts the squishbox service, and everything works as expected.
(BTW ChatGPT wrote it for me. I know it usually invents BS but this time, it worked).
Glad you found a workaround, and thanks for sharing it here.
If you get a chance to check, I'd still be curious to know if the LX88+ has a problem connection to plain old fluidsynth
(without running the squishbox service), but your command
pi@rpi:/usr/local/bin $ fluidsynth -o midi.autoconnect=1
doesn't load a soundfont, so you wouldn't hear any audio no matter what. Unless you load one using fluidsynth shell commands e.g.
load sf2/GeneralUser.sf2
. You might also need to select a preset usingselect 0 1 0 0
.
My goal is to have the Pi4 with Fluidsynth/Fluidpatcher permanently turned on and only having to turn on the MIDI keyboard (Nektar LX88+) to start playing.
Currently, if I disconnect/reconnect (or turn off/on) the keyboard, Fluidsynth doesn't start playing unless I manually restart the squishbox service.
midi.autoconnect is already set to "1" in squishboxconf.yaml.
What else can I do? Thanks!
BTW thanks for all your help so far!