Step-by-step to run a midi keyboard input device? 12.04
I have a Korg Nanokey, and I'd like to make it produce sound in ubuntu. I've read that means I should be using Rosegarden, and that Rosegarden uses JACK, but does not install it. (Although checking out Ubuntu Software Center, apparently some components of JACK are installed by default?)
I understand there can be a lot of work setting up JACK without it fighting the default sound server. Can someone give me a step-by-step method for what I need to do to plug in my midi machine and hear music when I press keys as simply as possible (without messing up pulseaudio, ie, so I can still access Skype and ordinary desktop stuff)? I'm fine installing JACK, but I'd like to sandbox it a little if it has the chance of messing up regular desktop.
I've looked through a couple resources, but I'm not sure what's outdated, but the following looked helpful...
- http://ubuntuforums.org/showthread.php?t=1686497
- http://jackaudio.org/pulseaudio_and_jack
If you just want to get your keyboard to play sound, this is very simple, and you won't need JACK nor Rosegarden for that. These tools are great if you want to record MIDI signal, write notes, and route audio between separate applications, but you don't need that to play sound with your keyborard.
My step-by-step would be to:
Plug in your MIDI device to your computer. If that's a USB MIDI keyboard, just plug the USB, if it has only MIDI plug, you may want to use a MIDI to USB device.
Download/Install a synthesizer. There is a large variety of sound synthesing applications for Ubuntu. You may like ZynAddSubFX (really powerful one), FluidSynth or QSynth (support soundfonts), AMSynth, AMS. Make sure to browse Ubuntu Software Center for synthesizer that will grab your interest.
Launch the synthesizer. Of course it has to be running to produce sound.
Tell the system to pass data from your keyboard to the synthesizer. You need to create a link between your keyboard and your synthesizer, so that MIDI signal is passed to it. You can either use
aconnect
tool, or one of it's graphical backends (which are simpler to use), likeaconnectgui
orkaconnect
. While aconnect is installed by default, you can get the other two from Software Center. Once you connect your keyboard, and synthesizer, follow to the final step...Press a key on your keyboard. You will hear some sound! If not, make sure if your system sound is not muted, and that our speakers are connected. Also, some synthesizers require you to choose an instrument before they produce any sound.
Fine tune your synthesizer settings. You will most likely not enjoy the initial sound of the synthesizer. In case of ZynAddSubFX, this will be a plain sine wave, boring! However, you can easily browse a great collection of timbres, and you can customize them fully. All synthesizers provide you lots of customisation, it's worth to spend some time choosing what you like most.
Proceed to play. Good luck and have fun!
I have also once written an article on general workflow for music production with external keyboard on Ubuntu, it should be useful in your case. Here's the link.
I don't know about Rosegarden, but you can run qjackctl from the package manager. Amsynth is an easy little way to make sound midi->jack.
I don't know how to run jack and pulseaudio at the same time - ie running chrome through jack (looking into it right now, actually). My experience in 12.04 is easy so far to make sound.
- Install qjackctl and amsynth from the package manager
- Shut down any web browsers or other pulseaudio things that could be taking the sound hardware
- Start qjackctl (you may have to fiddle with params in settings but I didn't-this time)
- Start Amsynth
- In the ALSA tab of qjackctl (why is it not the midi tab ?!?!) connect your usb midi device (hopefully detected automatically) to Amsynth ...
- Make sure amsynth is connected to the audio out ...
- Play!
MIDI on Linux is highly modular and, as a result, initially overwhelming. It's nice to have a low-complexity solution working before you bother with optimizations, but unfortunately Ubuntu doesn't come with a default working configuration. Here's the simplest way that I have found...
sudo apt install qsynth vmpk ## install components
qsynth & vmpk ## launch
-
Qsynth -> Setup -> Sountfonts -> Open
:FluidR3_GM.sf2
-
Virtual MIDI Piano Keyboard -> Edit -> Connections
->-
Enable MIDI Thru on MIDI Output
: (checked) -
Input MIDI Connection
: (Your Controller) -
Output MIDI Connection
:FLUID Synth
-
At this point, you should be able to play notes from either your external MIDI controller or from the virtual piano GUI (the GUI works even if you don't have an external controller).
From the Keyboard GUI you can select different instruments (see Program
). From the Qsynth GUI you can manipulate the volume (see Gain
) as well as Reverb/Chorus effects. There is also a Panic
button in case the reverb goes off the rails.
This was specifically tested on clean install of Ubuntu Studio 18.04, but similar steps worked for Ubuntu MATE 16.04, with a notable automatic configuration difference being that Qsynth -> Setup -> Audio -> Audio Driver
defaulted to jack
in Ubuntu Studio but to alsa
on Ubuntu MATE.
Glitchy static with ALSA [SOLVED]
On both 16.04 and 18.04, I have experienced weird static when Qsynth initially starts working with alsa. This static seems to affect all audio sources, but it somehow works itself out in a minute or two (at least partially).
I later tried this setup on a less powerful CPU and noticed a similar static that did not seem to resolve over time. [As an aside, I noticed that this static correlated with the ALSA plug-in [qsynth]
line glitching in and out in the Applications tab of Sound Preferences
].
This led me to play around with some Qsynth Settings, and I found something that seems to solve both static/glitch problems (maybe with a trade-off of a minor latency increase):
-
Qsynth
->Setup
->Audio
->Buffer Size
:128
-
Qsynth
->Setup
->Audio
->Buffer Count
:8
Apparently, the CPU can't always keep up with the required burst rate, so a little extra buffering is needed to prevent underruns. Presumably the are other settings that could also affect this.
vmpk
loses its connection to Qsynth
when the settings are changed. The quickest way to experiment with changing settings is to close and restart vmpk
to force a reconnect.
Alternative: "Polyphone" application (not in Ubuntu repositories)
I've got my eye on Polyphone as a (nearly) all-in-one solution (essentially a superset of qsynth+vmpk). Although it isn't in the Ubuntu repositories so far (as of 19.04 Disco), it was easy to build from source on 18.04 (also, there is a pre-built Ubuntu .deb provided).
The package doesn't include a default soundfont (it is a soundfont creator/editor), but you can get one with sudo apt install fluid-soundfont-gm
(at /usr/share/sounds/sf2/
) -- or try downloading from the application's "Online repository" (but this may require an account).
Go to Settings->General->Input/Output
and make sure the Audio/MIDI settings are sensible, then open a soundfont and select an instrument under Presets
and it should be ready to play music from your MIDI controller, or from the built-in virtual keyboard.
Find out about your sound card:
aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: HDMI [HDA Intel HDMI], device 3: HDMI 0 [HDMI 0]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 0: HDMI [HDA Intel HDMI], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: HDMI [HDA Intel HDMI], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 0: ALC3235 Analog [ALC3235 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
We will be using card1, device0, thus hw:1,0
My pipeline scenario that finally worked, using jack-control (qjackctl)
and qsynth
was:
- Install jack-tools, jack-server, qsynth
- Open up qsynth and go to Setup. In
MIDI
tab, I selectMidi Driver: alsa-seq
. InAudio
tab I selectAudio Driver: jack
. -
Fire up jack server with
jackd -R -d alsa -d hw:1,0
Open
qjacktctl
and:
4.1 Go to Connect
-> ALSA
. In the left column find out your keyboard and connect it to qsynth
that lies in the right column. Also make sure that in the first column (AUDIO
), qsynth
is connected to your speakers (right column).
4.2 Back in the main qjackctl
window Go to setup->settings->advanced
and in the right column, choose Output Device
(speakers) and Input Device
(Midi keyboard)
By this step I was able to hear my keyboard. An overall screenshot of the setup follows
PS: In this scenario no other application can use the speakers at the same time.