Reputation: 183
I am trying to read the MIDI Input from a MIDI Keyboard on Ubuntu 18.04 64-bit.
I decided to use JACK Audio Connection Kit (JACK) Client for Python. After the installation I want to run a simple program to print all received MIDI events.
But after running
client = jack.Client('MIDI-Monitor')
I received
ALSA: Cannot open PCM device alsa_pcm for playback.
Falling back to capture-only mode
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
At first I checked if the MIDI Keyboard is working. I used Kmidimon, and I saw events when I pressed the keys. So the MIDI Keyboard works.
Then I searched the web and tried the following:
Use that command and let it run in background jackd -R -d alsa -d hw:0,3
(and all possible combinations, 0 means card number, 3 means device number, see also the response for command aplay -l
)
But the python program did not response me the events, when I pressed the buttons on the MIDI Keyboard.
Here is a part of response for command aplay -l
card 0: HDMI [HDA Intel HDMI], device 3: HDMI 0 [HDMI 0]
card 0: HDMI [HDA Intel HDMI], device 7: HDMI 1 [HDMI 1]
card 0: HDMI [HDA Intel HDMI], device 8: HDMI 2 [HDMI 2]
card 0: HDMI [HDA Intel HDMI], device 9: HDMI 3 [HDMI 3]
card 1: PCH [HDA Intel PCH], device 0: ALC892 Analog [ALC892 Analog]
card 1: PCH [HDA Intel PCH], device 1: ALC892 Digital [ALC892 Digital]
Could you please help me point out where the problem is?
Upvotes: 2
Views: 1444
Reputation: 183
The main point is, we need to give the right command to start the jack server with the right driver, device id, and maybe MIDI ports.
Use the following command to run jack server in background:
sudo jackd -d alsa -d hw:2,0 -X seq
"-d alsa" means the ALSA driver will be used.
"-d hw:2,0 -X seq" is backend option for "-d alsa"
"-d hw:2,0" means the ALSA pcm device to use, and all possible combinations, 2 means card number, 0 means device number, the information can be found in the response for command aplay -l
(which is on the bottom of this answer)
"-X seq" means to specify a set of JACK MIDI ports that correspond to each ALSA "sequencer" client (which includes each hardware MIDI port on the machine)
The possible working response from the command would look like this:
jackdmp 1.9.12
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
Copyright 2016-2017 Filipe Coelho.
... (some lines omitted)
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
audio_reservation_init
Acquire audio card Audio2
creating alsa driver ... hw:2,0|hw:2,0|1024|2|48000|0|0|nomon|swmeter|-|32bit
configuring for 48000Hz, period = 1024 frames (21.3 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 2 periods for playback
port created: Midi-Through:midi/playback_1
port created: Midi-Through:midi/capture_1
port created: CME-M-Key:midi/playback_1
port created: CME-M-Key:midi/capture_1
port created: KMidimon:midi/playback_1
port created: KMidimon:midi/capture_1
Here are part of the output from command aplay -l
, which shows information about card 2
card 2: PCH [HDA Intel PCH], device 0: ALC892 Analog [ALC892 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
Sources:
Man Page for jackd: https://www.mankier.com/1/jackd
Similar Solution on the web: https://askubuntu.com/questions/320946/jackd-does-not-work-aplay-l-shows-two-instances-of-the-same-card-ubuntu-13-04
Upvotes: 2