MIDI keyboards
MIDI keyboards should work out of the box.
Tools
Useful tools used in this guide.
apt install usbutils alsa-utilspacman -Syu usbutils alsa-utilsnix shell nixpkgs#{usbutils,alsa-utils}Check connection
Check USB connection using lsusb from usbutils
$ lsusb
Bus 001 Device 012: ID 0499:1718 Yamaha Corp. Digital PianoCheck if it gets recognized as a MIDI device using aconnect from alsa-utils
$ aconnect -i
client 0: 'System' [type=kernel]
0 'Timer '
1 'Announce '
client 14: 'Midi Through' [type=kernel]
0 'Midi Through Port-0'
client 24: 'Digital Piano' [type=kernel,card=2]
0 'Digital Piano MIDI 1'
1 'Digital Piano MIDI 2'Check MIDI events using aseqdump, also from alsa-utils.
$ aseqdump -p 24 # this is the client number from the previous command
24:0 Active Sensing
24:0 Active Sensing
24:0 Active Sensing
24:0 Note on 0, note 96, velocity 74
24:0 Active Sensing
24:0 Note off 0, note 96, velocity 64
24:0 Active Sensing
24:0 Active SensingTIP
You can also use qpwgraph to visually see the MIDI and audio nodes.
Audio
Some MIDI keyboards also send audio to the computer, you should be able to see it as a regular audio device.
You can also listen to your computer's audio in your keyboard's speakers, you just need to select your keyboard as audio output. Most Desktop Environments have an option to change the audio output device, but you can also use pavucontrol.
INFO
Audio input/output devices from my Yamaha p-125 appears simply as "Digital Piano", so look for something like that.
Playing and recording MIDI
To play a .mid file on your MIDI device, you can use aplaymidi from alsa-utils
$ aplaymidi -l
Port Client name Port name
14:0 Midi Through Midi Through Port-0
24:0 Digital Piano Digital Piano MIDI 1
24:1 Digital Piano Digital Piano MIDI 2aplaymidi -p 24:0 path/to/song.midTo record MIDI you can use a Digital Audio Workstation.
But for simple use cases you can try arecordmidi from alsa-utils.
arecordmidi -p 24:0 path/to/output.mid # then press CTRL-C to stopMIDI Visualizers
The most convenient solution would be to use a web application that uses the web MIDI API. However, we can't access the API in an OBS browser source as of now...
So for now we're stuck at either using another API to receive MIDI events or a native application.
Web
- proof-of-concept with
obs-websocket: https://github.com/h-banii/midi-visualizer-js
Native
WARNING
Under construction...