36

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...

0

5 Answers 5

40

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:

  1. 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.

  2. 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.

  3. Launch the synthesizer. Of course it has to be running to produce sound.

  4. 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), like aconnectgui or kaconnect. 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...

  5. 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.

  6. 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.

  7. 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.

5
  • How do I set the links for aconnectgui? I accidentally connected a bunch of things together, I want to reset the links. Mar 26, 2015 at 2:55
  • @TatakaiWasumi Select the scissors tool and then left-click on a connection. It will 'cut' (i.e., delete) the connection. Sep 3, 2015 at 1:26
  • If you choose to qjackctrl, you can use the connections tab to route the synthesizer to output to the speakers (if it doesn't by default) and the USB MIDI input into the synth input. I had to do this when ZynAddSubFX failed to connect to the speaker output, and aconnectgui could not make this connection. Sep 3, 2015 at 1:28
  • I had to also add qjackctl in the pipeline to make qsynth produce actual sound. qjackctl can also perform step4 so aconnect is not needed in that case. Additional step in that case is to configure input/output devices in qjackctl by going setup->settings->advanced
    – chefarov
    Jun 10, 2017 at 17:07
  • 1
    Your link to the s.fox post on your blog now links to a malware site, FYI.
    – Caleb Jay
    Oct 21, 2020 at 21:37
8

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.

25
  • After you have a basic setup working, you might be interested in some of the many options described here: Ted's Linux MIDI Guide Jun 17, 2018 at 18:49
  • Note to self: Some controllers need to be powered on before you can use them. Jul 7, 2018 at 19:18
  • Now if I could just figure out how to transpose the controller... Jul 9, 2018 at 2:39
  • 1
    @Bani, I've not yet been able to use MIDI over Bluetooth on Ubuntu. I tried again tonight with my Xkey Air but it fails to pair (Ubuntu 18.04). This might be the path forward, but I'm not up for trying at the moment. Another option that I encountered tonight is a $50 dongle called "WIDI Bud" that, I think, will automatically convert Bluetooth to MIDI. Post back if you figure it out -- I'd like to be able to do this too! Nov 25, 2019 at 1:34
  • 1
    awesome, that worked too! Now I can use it both ways: FP-30 as input or I can play at the virtual keyboard for the sound to come out at the FP-30
    – Bani
    Nov 26, 2019 at 2:44
5

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!
1
  • 1
    It's qjackctl not qjackctrl Mar 26, 2015 at 2:38
3

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:

  1. Install jack-tools, jack-server, qsynth
  2. Open up qsynth and go to Setup. In MIDI tab, I select Midi Driver: alsa-seq. In Audio tab I select Audio Driver: jack.
  3. Fire up jack server with

    jackd -R -d alsa -d hw:1,0

  4. 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

enter image description here

PS: In this scenario no other application can use the speakers at the same time.

2

To extend the accepted answers point 4 "Tell the system to pass data from your keyboard to the synthesizer" I'll just quote the Arch wiki which helped me immensely by giving simple to the point instruction:

Find the ID of your Midi Keyboard using aconnect --input, example:

client 28: 'MPK mini' [type=kernel,card=3]

Find the ID of your Synthesizer or whatever using aconnect --output, example:

client 128: 'amsynth' [type=user,pid=51421]

Route your input to your output using aconnect 28 128

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .