Re: [HOWTO] Implementing pitch-shifting and
crossfading (for filler music/other sources) for
PyKaraoke on Linux with JACK



On Fri, Apr 07, 2006 at 12:29:58PM -0600, William Ferrell wrote:
> This HOWTO attempts to document how the whole thing fits together, how
> to implement it on your own system, and how to use it in production at
> a karaoke (or really any DJ'ed) show.

This is really spiffy. I'm not sure how easily I'm going to be able to
integrate it with the control-top I want to construct (which I've
finally, at least, sketched out, and am trying to learn Glade to mock
up), but...

> The JACK Audio Connection Kit is a real-time virtual mixing board for
> Linux (and possibly other platforms; I haven't yet investigated this)

I understand JACK has been ported successfully to OS/X now, which
probably isn't too surprising.

> that uses a low-latency server and protocol to connect sound
> applications and devices to each other. It can control all sorts of
> real hardware (sound cards, MIDI controllers, etc.) and can accept
> inputs from just about anything (media players, MIDI controllers,
> etc.) for both audio and control.

Specifically, it can talk to my Phase 26 USB box, with 3 stereo outputs
(I'm very much a "real mixing board" kind of guy).

> JACK includes a useful tool, qjackctl, that will be used in this HOWTO
> to configure JACK and to automate patching our different tools
> together.

You do *not* want to try to play with JACK without qj; take my word on
this.

> This HOWTO uses JACK Rack for two things: first, it is used to perform
> the actual pitch-shifting work when needed (audio from PyKaraoke is
> passed to JACK Rack instead of straight ot the sound card). Second, it
> performs crossfading work; I use different audio sources
> (specifically, XMMS and MPlayer) during my shows, and smoothly
> transitioning from them to CD+G music and back is important. JACK Rack
> is, in this configuration, the only piece of software on the chain
> that is connected to the sound card. All audio playback runs through
> JACK Rack whether it is doing anything to the sound or not.

Can JR, or the modules it encases, be controlled by DBus (or any other
message passing facility)?

> It supports MP3, Ogg Vorbis, WAV, FLAC, and all sorts of other audio
> formats. It can play video (via MPlayer, actually), but we want manual
> control over that kind of thing so we'll only be using XMMS for audio.

Mplayer is sort of ungainly for playing audio directly, isn't it?

> MPlayer is a multimedia player for Linux. It supports audio and video
> playback, tons of media formats, lots of output devices and types, and
> has more features than I can adequately count here.

Here's a curious idea: I wonder how hard it would be to recast Kelvin's
rendering code as an Mplayer codec? Did we already talk about this?

> For our purposes, we'll simply be chaining it to JACK as an audio
> source (letting it do its own thing for video, if needed) so we can
> crossfade between it and the filler music XMMS provides.

How *are* you deconflicting video output sources, anyway?

> 1.5 Tom's Audio Processing LADSPA Plugins
>
> http://tap-plugins.sourceforge.net/
>
> This set of plugins, compatible with JACK Rack, includes the one we
> want: pitch shifting. This is what will provide us with digital
> pitch-shifting for CD+G playback. Really, it can affect all sound, but
> we just want it to affect CD+G.

Ah; it's TAP that's doing it.

> 2. Setting Up the Parts
>
> It's beyond the scope of this HOWTO to document the
> installation/configuration procedure for the software used; if you're
> using a modern Linux distribution (like Debian, Ubuntu, or Gentoo),
> its package management system should already have these packages
> available.

Note: SuSE, in particular, tends to have an out of date JACK; I
wouldn't be surprised to find that other distros do as well -- Will?
Could you document the version numbers of all your components?

> 2.1. Configuring ALSA to Talk to JACK
>
> By default, ALSA just talks to your real sound device. We want it to
> default to connecting to JACK instead, though, so it's necessary to
> create a .asoundrc file. It belongs in the home directory of the
> account you're using for production shows. Just edit ~/.asoundrc and
> you should be fine. Its contents should be:
>
> pcm.!default {
> type plug
> slave { pcm "jack" }
> }
>
> pcm.jack {
> type jack
> playback_ports {
> 0 alsa_pcm:playback_1
> 1 alsa_pcm:playback_2
> }
> capture_ports {
> 0 alsa_pcm:capture_1
> 1 alsa_pcm:capture_2
> }
> }
>
> Test that this is working properly by starting JACK (run qjackctl and
> start a JACK server), then watch the "Connections" bay as you run
> "aplay somefile.mp3" -- you should see a new client appear, and it
> will probably automatically connect to the sound card (this is JACK's
> default behavior).

This is *nice* detail, Will.

> 2.2. Setting Up the Sound Processor (JACK Rack)
>
> Start up JACK Rack (the command is "jack-rack"). It will start with an
> empty effects stack, which is what we want.

Do you mention where is the best place to start all this stuff?
.profile for the login account? /etc/rc.*?

> PyKaraoke needs no modifications because it uses SDL, which honors
> .asoundrc. MPlayer needs to be told either to use JACK or SDL as its
> audio output method:
>
> # mplayer -ao sdl ...
> -or-
> # mplayer -ao jack ...

You can configure that in mplayer.conf, right?

> Fire off an MPlayer instance with a song to make sure it appears as a
> client in the qjackctl Connections window.
>
> If you're using MPlayer with SDL, you'll notice that PyKaraoke and
> MPlayer appear pretty much the same within the Connections window.
> That's an important detail later.

Because you're cheating? :-)

> I've posted this HOWTO at
> http://willfe.com/index.php/Pitch-shifting_With_PyKaraoke_and_JACK_HOWTO
> as well. I'll get it formatted properly here in a few minutes.

And, BTW; kudos on the site; blogging with MW isn't easy.

Cheers,
-- jra
--
Jay R. Ashworth jra@xxxxxxxxxxx
Designer Baylink RFC 2100
Ashworth & Associates The Things I Think '87 e24
St Petersburg FL USA http://baylink.pitas.com +1 727 647 1274

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

A: Top-posting.
Q: What is the most annoying thing on Usenet and in e-mail?


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642




Privacy