Difference between revisions of "USB MIDI keyboards"

From ArchWiki
Jump to: navigation, search
m (Note about default behavior and how to use alsa instead)
m (Qsynth using JACK: fix code block breaking list, use italic for UI text)
 
Line 84: Line 84:
 
==== Qsynth using JACK ====
 
==== Qsynth using JACK ====
  
# We need to install {{pkg|qsynth}}, [[jack]], {{pkg|qjackctl}}
+
# We need to install {{pkg|qsynth}}, [[JACK]], {{pkg|qjackctl}}
# Launch qjackctl and check the settings:
+
# Launch qjackctl and check the settings: {{bc|<nowiki>
  Server Path: jackd
+
Server Path: jackd
  Driver: alsa
+
Driver: alsa
  Realtime=enable; Priority:0
+
Realtime=enable; Priority:0
  Frames/Period:512
+
Frames/Period:512
  Soft Mode=enable; Periods/Buffer:2
+
Soft Mode=enable; Periods/Buffer:2
  Rest of parameters=disable(by default)
+
Rest of parameters=disable(by default)
  Dither: None
+
Dither: None
  Audio: Duplex
+
Audio: Duplex
# Start jackd using qjackctl (the '''Play''' button)
+
</nowiki>}}
 +
# Start jackd using qjackctl (the ''Play'' button)
 
# Connect your USB keyboard
 
# Connect your USB keyboard
# Start QSynth and go to '''Setup''', where you need to load soundfont in SF2 format. You can get free SoundFonts from http://soundfonts.narod.ru/ (in Russian). When QSynth asks you to restart the engine after loading the SoundFont, do so.
+
# Start QSynth and go to ''Setup'', where you need to load soundfont in SF2 format. You can get free SoundFonts from http://soundfonts.narod.ru/ (in Russian). When QSynth asks you to restart the engine after loading the SoundFont, do so.
# Go to qjackctl, click '''Connect''' and choose the ALSA tab. On the left side you will see connected MIDI keyboard, on the left side - QSynth. Choose MIDI keyboard and QSynth, and click '''Connect'''.
+
# Go to qjackctl, click ''Connect'' and choose the ALSA tab. On the left side you will see connected MIDI keyboard, on the left side - QSynth. Choose MIDI keyboard and QSynth, and click ''Connect''.

Latest revision as of 04:53, 11 August 2018

This how-to assumes that you are using ALSA and that your sound card is set up so you can listen to music. Known to work using this how-to is the Evolution MK-631 USB midi keyboard with SB Live! Value card. Execute these instructions as an unprivileged user unless otherwise noted.

Preliminary Testing

ALSA

Install the alsa-utils package.

Type aseqdump. It should output something like:

Waiting for data at port 128:0. Press Ctrl+C to end.
Source_ Event_________________ Ch _Data__

Not much will show up there, so press Ctrl+C to quit the program.

Plugging the keyboard

Now plug the keyboard in and turn it on. The keyboard should power up. Output of lsusb should contain:

Bus 002 Device 002: ID 0a4d:00a0 Evolution Electronics, Ltd

Output of lsmod | grep usb should contain the following modules:

usb_midi               25348  0
snd_usb_audio          70592  0
snd_usb_lib            16640  1 snd_usb_audio

Now type aconnect -i to list all MIDI input ports. The output should contain:

client 72: 'MK-361 USB MIDI keyboard' [type=kernel]
    0 'MK-361 USB MIDI keyboard MIDI 1'

The client number is probably going to be different though. Take note of it.

Verifying Events

Type aseqdump -p ## where you should replace ## with the client number of your keyboard. You should see:

 72:0   Active Sensing

popping out all the time. Pressing a key should produce:

 72:0   Note on                 0  65  94
 72:0   Note on                 0  65   0

Various other events (turning control knobs, changing channels, etc.) should register in the list. This is a handy way of ensuring that your keyboard is running properly.

To send MIDI events back to the keyboard or another MIDI output device, you can use run aplaymidi -p ## midifile.mid and specify a MIDI file.

Playing

To hear a sound when you push a button on your keyboard, you need a synthesizer that converts the MIDI signal into audio.

Some soundcards have a built-in hardware synthesizer, but these are not common in modern sound cards, especially not in onboard sound cards. An easier option is a software synthesizer, which is just a program which you can load with you own instrument samples.

Hardware synthesizer

Type aconnect -o to list all MIDI output ports. It depends a lot on your sound card. On SB Live! Value, you get the following output:

client 64: 'EMU10K1 MPU-401 (UART)' [type=kernel]
    0 'EMU10K1 MPU-401 (UART)'
client 65: 'Emu10k1 WaveTable' [type=kernel]
    0 'Emu10k1 Port 0  '
    1 'Emu10k1 Port 1  '
    2 'Emu10k1 Port 2  '
    3 'Emu10k1 Port 3  '

Here client 65 is the actual MIDI synthesizer. Assuming the soundcard is set up properly, you should be able to route the output of the keyboard to the MIDI synthesizer. Assuming out is the output client number (65 in our example) and in is the input client number (72 in our example), type aconnect in out. Now you can play your keyboard via the MIDI output of your sound card.

Software synthesizer

Qsynth

  1. Install qsynth.
  2. Start QSynth and go to Setup, where you need to load soundfont in SF2 format. You can get free SoundFonts from fluidplug-gitAUR, or from http://soundfonts.narod.ru/ (in Russian). When QSynth asks you to restart the engine after loading the SoundFont, do so.
  3. Type aconnect -o to list all MIDI output ports. Find the one that contains FLUID Synth and note the client number.
  4. Type aconnect -i to list all MIDI input ports. Note the Keyboard client number.
  5. Assuming out is the output client number and in is the input client number (72 in our example), type aconnect in out. Now you can play your keyboard and QSynth should produce sounds.
Note: You need to run aconnect in out each time you restart Qsynth or change the instrument/SoundFont.
Note: Qsynth default audio driver is set to jack. To use alsa run : qsynth -a alsa

Qsynth using JACK

  1. We need to install qsynth, JACK, qjackctl
  2. Launch qjackctl and check the settings:
    Server Path: jackd
    Driver: alsa
    Realtime=enable; Priority:0
    Frames/Period:512
    Soft Mode=enable; Periods/Buffer:2
    Rest of parameters=disable(by default)
    Dither: None
    Audio: Duplex
    
  3. Start jackd using qjackctl (the Play button)
  4. Connect your USB keyboard
  5. Start QSynth and go to Setup, where you need to load soundfont in SF2 format. You can get free SoundFonts from http://soundfonts.narod.ru/ (in Russian). When QSynth asks you to restart the engine after loading the SoundFont, do so.
  6. Go to qjackctl, click Connect and choose the ALSA tab. On the left side you will see connected MIDI keyboard, on the left side - QSynth. Choose MIDI keyboard and QSynth, and click Connect.