- LEGO ipMIDI
- My first MIDI instrument
- Yoshimi Pi
- Tuning the Pi
- A few last notes
After some weeks working fine I decided to integrate this ipMIDI thing with my wife’s new LEGO Grand Piano. Doing this I realized a few things were missing in these posts:
The audio card
I indeed changed from the internal audio to a cheap USB audio card. The background noise has gone, as expected.
The sound card is seen as “hw:CARD=Set,DEV=0” so I needed to add a parameter to the ‘yoshimi ‘command (you can find the available audio devices with the ALSA command “aplay -L”… sometimes the same card will show more than one because the chipset may support several audio modes)
The startup script
the script first starts ‘multimidicast’, then it starts ‘yoshimi’ and sets the MIDI connections between the two:
!/usr/bin/env bash sudo sh -c "echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" sleep 15 /home/pi/ipmidi/multimidicast-1.4/multimidicast & sleep 3 yoshimi -a -b 1024 -i --state=/home/pi/ipmidi/harpa-state.state & yoshimi -a -i -c --state=/home/pi/ipmidi/harpa-state.state --alsa-audio=hw:CARD=Set,DEV=0 & sleep 5 aconnect 128:0 129:0 aconnect 128:1 129:0 aconnect 128:2 129:0 aconnect 128:3 129:0
(before all that it all changes the kernel governor from the default ‘ondemand’ to ‘scaling’)
In order to run this script automatically when the Raspberry Pi turns out I created a systemd service (used this guide):
[Unit] Description=Yoshimi After=network.target [Service] Type=oneshot RemainAfterExit=true ExecStart=/home/pi/ipmidi/startup.sh WorkingDirectory=/home/pi/ipmidi StandardOutput=inherit StandardError=inherit Restart=no User=pi [Install] WantedBy=multi-user.target
exactly, nothing else is needed. When trying to use a python script on the RPi to control the Grand Piano I realized that I had disabled bluetooth to reduce latency. But instead of reverting it I installed everything again on a larger microSD card because the one I was using had not enough space for updates. Doing that I made no performance tuning at all and the the performance is still quite good using my Android phone in hotspot mode.