Upto: Table of Contents of full book "Programming and Using Linux Sound"

Jack

Jack is designed for professional audio. In this chapter we apply the techniques from earlier chapters to building a Karaoke system.

Using jack rack for effects

Karaoke takes inputs from MIDI sources and from microphones. These are mixed together. Generally there is an overall volume control but there is usually a volume control for the microphones as well. While the MIDI source should be passed straight through, it is common to apply a reverb effect to the microphones.

These are all effects that can be supplied by LADSPA modules (see the LADSPA chapter). The Jack application jack-rack makes these plugins accessible to Jack applications so that LADSPA effects can be applied to Jack pipelines.

It is fairly straighforward to add a module to a session. Click on the "+" button and choose from the enormous menu of effects. For example, choosing the Karaoke plugin from the Utilities menu looks like

Some of the modules that might be relevant are

Multiple modules may be applied in a single jack-rack application, and multiple applications can be run. For example, to apply a volume control to a microphone and then apply reverb before sending to the speakers can be done by adding the TAP reverberator and then one of the amplifiers. This looks like

Jack Rack with reverb and amplifier plugins
Jack rack with reverb and amplifier plugins

I'm running this on a USB Sound Blaster TruStudioPro. This is only 16-bits and I can't seem to find a suitable Jack hardware configuration. So I'm running Jack by hand using a plug device, which Jack complains about but works anyway:

	 
jackd -dalsa -dplughw:2 -r 48000
	 
       

Although gladish can see it under its Jack configuration menu, I haven't managed to get gladish to accept the SoundBlaster as a setting - so far I can only manage to get Jack running under as a plug device and gladish keeps swapping it back to a hardware device.

qjackctl does an okay job of saving and restoring sessions, starting jack-rack with its correct plugins and their settings, and linking it to the correct capture and playback ports.

Playing MIDI

The major synthesizer engines TiMidity and FluidSynth will output to ALSA devices. To bring them into the Jack world, Jack needs to be started with the -Xseq option or for a2jmidid to be run.

We can try to manage the connections using the Jack session manager (e.g. qjackctl). But this hits a snag using the MIDI synthesizers such as TiMidity or FluidSynth since they assume a PulseAudio output rather than Jack output. Restoring a session fails to restore the synthesizer with Jack output.

We can try to manage the connections using LADSPA. Unfortunately I have so far been unable to manage the Jack server settings using gladish. So it starts Jack using the default ALSA settings and doesn't use the -Xseq setting to map the ALSA ports to Jack. We need to start a2jmidid and then it can succesfully manage a session of e.g timidity, jack_keyboard and a2jmidid.

Even then, the connection diagram looks a mess:

LADISH playing MIDI
LADISH playing MIDI

TiMidity plus Jack Rack

In the chapter on Karaoke TiMidity we used TiMidity with a Jack backend and an Xaw interface to give a basic Karaoke system. We can now improve on that by using Jack Rack effects:

The resulting system looks like

TiMidity with Jack Rack
TiMidity with Jack Rack

Customising TiMidity build

The version of TiMidity from the Ubuntu distro crashes if I try to dynamically load another interface. As the code is stripped, it is not possible to find out why. So to add a new interface we need to build TiMidity from source.

The commands I now use are

	
./configure --enable-audio=alsa,jack \
            --enable-interface=xaw,gtk \
            --enable-server \
            --enable-dynamic
make clean
make
	
      

An interface with key, say 'k', can then be run with Jack output by

	
timidity -d. -ik -Oj --trace  --trace-text-meta 54154.mid
	
      

Playing MP3+G with Jack Rack pitch shifting

The player vlc will play MP3+G files. Often the MP3+G is a zipped files containing both an MP3 file and CDG file with the same root. This must be unzipped, and then can be played by giving vlc the MP3 filename:

vlc file.mp3
      

This will pick up the CDG file and display the lyrics.

vlc can be used with Jack by the --aout jack option

vlc --aout jack file.mp3
      

One of the common requests for vlc is to have a "pitch control" mechanism. While it should be possible to add LADPSA pitch controls to vlc, no-one has got around to it yet. But we can still add LADSPA effects through jack-rack.

The steps are

The result of this with vlc playing MP3 audio through the pitch filter and also showing the CDG video should look like

Playing MP3+G file

Conclusion

This chapter has discussed a number of ways of building Jack pipelines to add effects to MIDI and MP3+G files.


Copyright © Jan Newmarch, jan@newmarch.name
Creative Commons License
"Programming and Using Linux Sound - in depth" by Jan Newmarch is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License .
Based on a work at https://jan.newmarch.name/LinuxSound/ .

If you like this book, please contribute using PayPal

Or Flattr me:
Flattr this book