Home › Category Archives › Audio

Support for JACK Audio in Adobe Flash

I use JACK quite frequently for playing guitar and recording etc, and while it is quite flexible, one thing I was unable to do was this: Get Flash audio to route through JACK. Most commonly this is when I want to play a Youtube video, and I find I have to stop jackd, which requires shutting down most JACK-aware applications, play the video, restart JACK, blah blah blah. Not really functional.

 

A quick search and I found libflashsupport-jack – and was excited! Look, something to make Flash work with JACK! So I checked out the git repo at git://repo.or.cz/libflashsupport-jack.git but it wouldn’t compile. Looked into it, and the major problem was that it includes a deprecated file in the kernel headers: linux/videodev.h, but alas, as of kernel version 2.6.38 the header file linux/videodev.h is no longer included in the kernel.

 

Long story short: I got the file, put it in with the libflashsupport source, hacked around with the code a bit, and TADA! I can now play Flash when JACK is running!

 

Even more importantly, for you that is, I’ve made a fork of the old repo, and have made the new working version available!

 

I’ll set up a proper homepage for this little project, but for now I’ll just link to the github repo and some instructions Note: if you go to http://github.com/pvint/libflashsupport-jack2 there is also a link to download a zipfile):

git clone git://github.com/pvint/libflashsupport-jack2.git
cd libflashsupport-jack2
sh bootstrap.sh
make
make install

(You must be root to do the make install, of course)
On a 64bit platform, you’ll likely need to create a symlink as well to get Flash to use this:

ln -s /usr/local/lib/flashsupport.so /usr/lib64

 

Now, fire up your JACK and your browser (You may need to restart the browser if it’s running), and try it out, it should just work!

 

If you have any issues, feel free to drop me a not here or by email.

Share Button

Connecting multiple sound devices with JACK and ALSA

The problem: JACK connects to one (generally the default) sound device, but you may have a second (third, fourth, etc) device that you want to record from or playback on.

Example situation (Actually, my situation):
Device #1: The NVidia sound card built in to the PC/Laptop.
Device #2: Guitar amplifier connected via USB
Device #3: USB headset/microphone.

Software I use:
(Note that this is all free software for Linux, versions may exist for other operating systems)

  • QJackCtl – essentially to start/stop JACK
  • Patchage – Used for making the connections between devices
  • alsa_in/alsa_out – Used to add the extra sound devices for JACK. If you installed JACK, you should have these command line programs
  • Ardour – for recording the tracks
  • aplay and arecord – part of the alsa-utils package

First Steps

Before starting anything, connect the devices, and use aplay and arecord to list what our devices are:
To list the playback devices:

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: NVidia [HDA NVidia], device 0: CONEXANT Analog [CONEXANT Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: LX3000 [Microsoft LifeChat LX-3000], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

And the capture devices:

$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: NVidia [HDA NVidia], device 0: CONEXANT Analog [CONEXANT Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: LX3000 [Microsoft LifeChat LX-3000], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: Amplifier [Mustang Amplifier], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Now, to translate this into standard ALSA lingo, the NVidia built-in device is card0, so we will refer to it as HW0, The M$ LX-3000 headset is card 1, thus referred to as HW1, and the Fender Mustang Amp is HW2.

Okay, so now running QJackCtl and clicking “Start” should get JACK running on HW0, the built-in sound device (Assuming it’s still at default settings). If you now start Patchage, you should see something like the following:
patchage_ss1
Now for the fun part; let’s get the input from the amplifier connected. Open up a terminal and run “alsa_in -j Amplifier -d HW:2″ and you should see something like:

$ alsa_in -j Amplifier -d hw:2
selected sample format: 16bit
delay = 4094
delay = 1019

Don’t worry if you get a couple of those “delay” messages when it first starts up.
Now, let’s get the mic on the headset connected:

$ alsa_in -j Mic -d hw:1
WARNING: chennel count does not match (requested 2 got 1)
selected sample format: 16bit
delay = 3255

Note the message about channel count – that’s just because it defaults to 2, if you don’t like seeing the message you can add a “-c 1″ to the command.

Now the last thing, the headset speakers:

$ alsa_out -j Headphones -d hw:1 -r 44100
selected sample format: 16bit

Note that I added a “-r 44100″ – in my situation everything else defaults to 44100, but the headset defaults to 48000 and sounds like crap.

Now, let’s check on what it looks like in Patchage now:

patchage_ss2

Now we’re getting somewhere!

So now, I’ll fire up Ardour and add a couple tracks – 1 stereo track for the guitar and one mono track for the vocals. (I normally also use Hydrogen for a drum track as well, but I’ll skip that in the interest of keeping this shorter) Once that’s done, we’ll make the connections in Patchage by right-clicking on items that are connected automatically that we don’t want and selecting “Disconnect All”, then dragging the mouse from one device to another to “wire them up”.

Once it’s done, you should see something like the below:
patchage_ss3

I know the connections in Patchage might look a bit confusing, but play around with it a bit and you’ll find it’s pretty intuitive.

And now, you’re ready to Rock!

Share Button