A few things to prevent having AlSA Xrun’s and possible reduncing overall latency:
- disabling Bluetooth (edit raspi-config and also disabling related services)
- overclock the RPi (I’m using a 3B, so 1300 MHz instead of 1200 and enabling force_turbo in raspi-config and replacing the ‘ondemand’ scaling_governor by ‘performance’ so the CPU always run at full speed)
- boot only in console mode (raspi-config)
- create a systemd service that starts ‘multimidicast’ and ‘yoshimi’ and then connects them with ‘aconnect’
This last step was tricky… I had to force a 15 seconds delay before starting ‘multimidicast’ because it was complaining that there was no multicast support on the kernel (looks like wi-fi needs a lot of time to settle).
Also had to find a way to load the proper instrument when ‘yoshimi’ starts:
yoshimi -a -b 1024 -i -c --state=/home/pi/ipmidi/harpa-state.state &
“harpa-state.state” is a state file I previously generated inside ‘yoshimi’ console, after setting the proper instrument (an harp, ID 107 from bank 110).
So my Raspberry Pi 3B now automatically starts a MIDI synth and plays whatever MIDI commands it receives through multicast.
I can now play with my “keyboard” (the pair of EV3 with 8 touch sensors) and also with TouchDAW on my Android phone at the same time. No stucked notes and no noises that might indicate Xrun’s. But there is a small background noise that I think is coming from the internal sound card – for just a 10 or 11 bit PWM emulating a sound card it’s very acceptable but I will try a USB sound card I have here to see if it reduces the noise.