=> back to xoc3.io

2021-09-02 - play midi on linux

i've been doing more midi related things lately. here is how i play midi on linux.

audio group. ensure your user is a part of the audio group first. to add yourself to that group, run usermod:

usermod -a -G audio $USER

install a soundfont. the only soundfont file format i'm aware of is the .sf2 format. you can try random .sf2 files from online, but i like freepats the most.

=> freepats homepage | freepats arch package

install timidity++. timidity++ is used to emulate midi hardware.

=> arch timidity++ package

update timidity++ config. once timidity is installed, add your .sf2 file path to the timidity config file:

echo soundfont /usr/share/soundfonts/freepats-general-midi.sf2 >> /etc/timidity/timidity.cfg

install alsa-utils. midi hardware support is actually built into the linux kernel, but we need a binary the alsa project maintains that interacts with the built in midi support:

=> arch alsa-utils package

emulate midi hardware. this command tells timidity to act as midi hardware for alsa:

timidity -iA

play midi. use the alsa utility to connect to the emulated hardware and play the midi file.

aplaymidi -l # prints the available midi ports
aplaymidi -p 128:0 midifile.mid # 128:0 is a midi port, use the output from aplaymidi -l to figure this out

if you have a midi output device, you can actually skip most of these steps and just run aplaymidi!

some links that helped me understand this process:

=> arch midi guide | arch timidity guide | ted's midi guide

Proxy Information
Original URL
gemini://xoc3.io/blog/2021-09-02
Status Code
Success (20)
Meta
text/gemini;charset=UTF-8
Capsule Response Time
632.608073 milliseconds
Gemini-to-HTML Time
0.807077 milliseconds

This content has been proxied by September (3851b).