In my DJ setup, I use the JACK sound server to link my mixing program to a bunch of fun effects. It is possible to get JACK to perform at extremely low latencies (~6ms and less) but it’s hard to get all the options just right. For the benefit of others who don’t want to go through the same trial and error I did, here is the command line I’m using to launch jack:
–timeout 4500: client timeout in ms. This is very important, because Mixxx might hang for longer than the default 500ms when it’s loading tracks. If that happens, JACK kicks out Mixxx and playback stops
-d alsa: Use ALSA backend
(Note, after this argument, the rest of the arguments are ALSA-specific
-p $size -n $periods: These two options are what determines the size of the sound buffer. The first number is the frame size, in bytes (I think). The second is the number of frames. Multiply the two together to get the total size. With a special realtime kernel, I can set this to 64 and 4 (total: 256, or about 6ms). With a standard kernel, it has to be 128 and 3 (total: 384, 9ms). The idea is you want to get the total multiplied number as small as possible without inducing the dreaded XRUN, which happens when your computer can’t feed audio to the sound card fast enough.
-i 4 -o 4: 4 inputs, 4 outputs
-r 44100: CD-rate audio
Yeah, I know, if I just bought a mac and Traktor or Serato I wouldn’t have to deal with this shit, but I’m cheap and can’t resist a challenge.
The Native Instruments Audio4DJ is a professional-quality USB soundcard for DJing that is also supported under linux. Like mode devices that are “supported” under linux, however, it can be tricky to set up correctly. In my case, I need the device to work with the JACK sound server, and I needed to do a little extra work.
The first trick is setting up ALSA so that JACK works happily with the card. The problem is that the drivers don’t supply any regular mixer controls for the Audio4DJ, which makes jackd unhappy. So when creating a .asoundrc, it’s necessary to substitute the internal soundcard as the mixer elements for that device. Putting this text in ~/.asoundrc does the trick:
pcm.AUDIO4DJ {
type multi;
# bind hardware devices
slaves.a.pcm "hw:1,0,0";
slaves.a.channels 2;
slaves.b.pcm "hw:1,0,1";
slaves.b.channels 2;
# bind channels to virtual device;
bindings.0.slave a;
bindings.0.channel 0;
bindings.1.slave a;
bindings.1.channel 1;
bindings.2.slave b;
bindings.2.channel 0;
bindings.3.slave b;
bindings.3.channel 1;
}
# JACK will be unhappy if there is no mixer to talk to, so we set
# this to card 0. This could be any device but 0 is easy.
#note that audio4dj is actually card 1 -- we are faking mixer elements so JACK is happy:
ctl.AUDIO4DJ {
type hw;
card 0;
}
The second question is how to change the input mode of the Audio4DJ from phono to line and back. Normally this type of setting would be found in the alsamixer program, but for some reason it’s hidden away. This script makes it easy:
#!/bin/bash
if [ "$1"x == "x" ] ; then
echo "$0 [phono|line|timecode]"
exit 1
fi
dev=`aplay -l | grep Audio4DJ | grep "device 0" | cut -d\ -f 2 | cut -d: -f 1`
if [ "$dev"x == "x" ] ; then
echo "Audio 4 DJ not connected"
exit 1
fi
result=0
if [ "$1" == "phono" ] ; then
amixer -c $dev cset numid=1 2 > /dev/null
result=$?
elif [ "$1" == "line" ] ; then
amixer -c $dev cset numid=1 1 > /dev/null
result=$?
elif [ "$1" == "timecode" ] ; then
amixer -c $dev cset numid=1 0 > /dev/null
result=$?
else
echo "$0 [phono|line|timecode]"
exit 1
fi
if [ $result -ne 0 ] ; then
echo "Error setting Audio 4 DJ input"
exit $result
fi
More beats. I always listen to my mixes the day after I make them, because how am I going to know what I’m doing wrong unless I check my work? Often, while actively mixing, something will sound ok, but listening to it later it’ll sound forced or messy. Lives, unexamined and otherwise, relative worth w.r.t. living, etc etc.
Most people do a spooooky halloween special mix, but this isn’t that, really. huh. Maybe I’ll do one today.
Stefny – Flight
Navy b. – S P
Rodrigo Rivera – Despegue programado N2
nemecek – vindaloo jones
Insanek – My last brain (Original Mix)
Ricardo Serapio – Onche
alec troniq – i`m the foolaloof [agaric rmx]
Steve Bug – Swallowed Too Much Bass feat. Paris The Black Fu – Joris Voorn Remix
This one came out pretty well, although there were two stupid mistakes that I covered up with a little post-editing and there a couple transitions that sound sloppy. I’m now hosting files on SoundCloud, which has a really nice interface for listening to tracks and commenting on them.
Tracklist:
unfound43_04_-_minimorph_-_real_place
ldo_benitez_rota_de_nuevo_btb_mix
Tino Boa – Dreisamkeit live
Uniquex_down-draftLabel
Justin Martin, Claude VonStroke – Beat That Bird – Original Mix
Here’s another DJ mix I made recently. I think this one came out quite well, with a minimum of mistakes and much better beat-matching than usual. “Yes Ma’am” is one of my favorite tracks right now. Comments welcome.
Tracklist (about an hour):
david bernabe – alflolol
licuadora system – playing with sticks
monokao – destruccion masiva
DJ Chus, Carlos Manaca, Pablo Ceballos – The Strong Rhythm – D-Unity Remix
NDKj – Main Course – Minicoolboyz Remix
Marc Houle – Dirty Dirty – Original Mix
DJ Baldino – Jumping – Original Mix
Ricky Ambilotti – Construkt – Original Mix
Thega – Hay Dios Mio (Sergio Soroa Remix)
Mark Knight, Funkagenda – Flauta Magica – Original Mix
Do you not like glitchy, thumpy, electronic music? Sorry, can’t help it. The first CD I ever bought that I really, actually wanted for myself was Rave ‘Til Dawn, because I eagerly wanted to own the track “Fuck You.”
One thing I’d always wanted to try was DJing, because hey, doesn’t everyone? It’s like being a musician but without all that hard work, skill, and practice. I’d never really pursued the interest, though, because being a DJ, even as a hobbiest, had always been an extremely expensive proposition. Good turntables cost 600$ each, a mixer is another $100 or more, and there’s all the vinyl I’d need to buy. I know myself well enough that I didn’t want to risk dropping close to a grand on a hobby that, in all probability, I’d lose interest in after a month.
In recent years, laptop DJing has gotten more popular, but I still didn’t want to spend 500$ on the software and more on the mp3 music. I could have acquired these by bittorrent or whatever, but I don’t like stealing software and also hate rebooting into windows. Ideally I wanted an open source program that would run on linux, but most of the options I found sucked. My dream of being a superstar DJ appeared forever out of reach.
Then one lazy day of clicking around the internet I discovered Mixxx, an open-source DJing application. Amazingly, it doesn’t suck. After some experimentation, it became clear Mixxx not only didn’t suck, but was actually pretty good. Around the same time, I’d also discovered the wide world of netlabel music. There are artists all over the world who are more than happy to share their tracks for free on the internet. Because I’m not stealing the music, it’s easy to preview tracks and download the ones I like. I quickly built up a catalog of a few hundred decent tracks. I was very close to actually being able to mix music! Visions of neon-haired techno girls danced in my head.
So I have software, I have music, and I haven’t spent any money yet! The Mixxx developers recommend the Hercules DJ MP3 as a good cheap controller, so I snagged one off ebay for 70$. I also have a small older version of this M-Audio MIDI keyboard which I got used for 60$ or so ((I got this when I was playing around with freewheeling, until I realized I don’t play the keyboard)). Lastly, I have an M-Audio Sonica Theater for simultaneous main mix output and headphone preview output ((I also got this from ebay, used. There’s a lot of decent hardware out there that doesn’t really go bad)).
With all of that, my setup was complete:
Total cost: ~$150
I got some practice spinning tunes, and quickly discovered all sorts of annoying problems with Mixxx and my setup. The default mixxx theme, for instance, is ugly and doesn’t use screen-space well. I downloaded a cool-looking theme called “Trancer”, but then I wasn’t happy with that so I did what any linux user would do — hacked it and made my own version:
I also wanted to have more control over filters and effects, so I set up a JACK pipeline so I could use my MIDI keyboard to select and tweak effects outside of Mixxx itself. I use the jack-rack program to handle the effects, although I had to hack that too. So when I’m mixing, this is what my desktop looks like:
And while I was playing some music, I discovered some aspects of the Mixxx music library that I didn’t like. Like, I needed some way of knowing which tracks I’d already played so I wouldn’t accidentally play them again. Also, the search bar also didn’t allow for multiple search terms. So I hacked away at the mixxx source code. Now the search box works right and I know if I’ve played a track as well as how many times I’ve ever played it.
The most important patch is the one for mixxx itself. The library is really hobbled without it.
After all this hacking, I finally have a setup that works well. I’m sure a European jet-set lifestyle is not far behind, but although I’ve been mixing for like, close to two months now, I’m still not a superstar DJ. But I did record one session that I consider post-worthy. I call it, “Mixxx session 090710.” Future mix postings will have a full tracklist, but due to a mistake, this one doesn’t. Enjoy!
The dream:
I want a streaming radio station for my company that itunes can tune in to, where anyone at work can upload tracks and add them to the playlist.
Explanation:
MusicPD is an awesome music server that I’ve talked aboutbefore, and it would be perfect for setting up my little radio station. Users would be able to add files to the playlist from any browser, and mpd now supports shoutcast, which should make turning it into a streaming station easy.
However, right now mpd only supports shoutcast streaming in OGG Vorbis format, and iTunes can’t play OGG. Since everyone in the office is on iTunes, I need some way of getting mpd to spit out mp3 to icecast.
Enter JACK! Jack is a “pro-audio” subsystem for connecting applications, kind of like shell pipes for audio. It can be kind of daunting to work with, but in this case it’s best to just think of it as glue connecting one program with another.
For instance, mpd has a JACK output plugin, and there’s another program, Darkice, that has a JACK input and sends audio to icecast. I can link mpd and darkice with jack, and that should solve my mp3 problem.
So, to review: mpd (links via JACK to) darkice (which encodes mp3s for) icecast (which streams to) itunes
The Wrinkle:
Make it work on a mac server. At work we don’t have a recent machine running linux that’s up all the time and that isn’t mission-critical, so I have to make due with one of the mac workstations. Luckily macports will do a lot of the heavy lifting.
A Note:
This took a lot of building, installing, and configuration that I don’t have space to cover here. I’m trying to record everything I did that was abnormal or not obvious. If you’re comfortable installing software on unix and you know how to configure a program based on the examples and READMEs, there should be enough information here to reproduce my work.
Getting the software:
Install macports on the mac
Install the following ports: apache2 faac faad2 flac id3lib mad lame libid3tag libvorbis speex
Install this port: php5 +apache2 +macosx +pear
Install the following by source: curl, jack (do not use “jackosx”, build it from source), icecast, darkice, mpd
Apply my patch to mpd/src/audioOutputs/audioOutput_jack.c to make it work on mac osx.
Details:
JACK:
Built with these options: ./configure --prefix=/opt/local --with-default-tmpdir=/tmp
I just start JACK with jackd -d dummy -r 44100
If I don’t specify a default tmpdir, jack crashes complaining it can’t stat /dev/shm. I don’t need to use a real audio device in jack because I’m not outputting the audio to the speakers.
Icecast:
built with ./configure --prefix=/opt/local
No special configuration needed other than what’s specific to my site.
Darkice:
Built with ./configure --prefix=/opt/local/ --with-lame-prefix=/opt/local/ --with-vorbis-prefix=/opt/local/ --with-faac-prefix=/opt/local/ --with-jack-prefix=/opt/local/
I probably didn’t need all those options, but heck, it works.
I set up the configuration file so that the audio device is jack (no quotes).
MusicPD:
built with ./configure --prefix=/opt/local --with-faad=/opt/local --with-libFLAC=/opt/local --with-mad=/opt/local --with-libvorbis=/opt/local/ --with-id3tag=/opt/local
I set up the configuration file to use jack as a device. I need to tell mpd to connect to darkice when it starts up, but darkice picks its port names based on its pid, so it’s always different. What I did is create mpd.conf.in, with this as the device config:
audio_output {
type "jack"
name "MPDJack"
ports "darkice-REPLACEME:left,darkice-REPLACEME:right"
}
Then I run a script to actually start mpd: #!/bin/bash
pid=`jack_lsp | grep darkice | cut -d '-' -f 2 | cut -d ':' -f 1 | uniq`
cat mpd.conf.in | eval sed -e 's/REPLACEME/$pid/g;' > mpd.conf
mpd ./mpd.conf
Putting it all together:
Once all of those pieces are in place, I can start the radio station by starting the various programs in this order:
Jack first,
then icecast,
then darkice, (-v 10 for debugging)
and finally mpd. (--verbose --stdout --no-daemon for debugging)
That’s it. I can control the mpd server and it plays music. If I run jack_lsp -c -p I can see mpd is connected to darkice. I can tune in to the icecast stream from itunes and hear it. With simple mac file sharing, users can connect to the server and drop music in the database. Then mpd can either rescan every hour or so with cron, or when the user clicks “update db” in pitchfork.
Setting up pitchfork is left as an exercise for the reader.
Char and I went to see Ben Folds at the opening of the Boston Pops season. It was fun, except for the part where some guy in the second balcony started punching some other guy in the face.
so i’m sitting here in the center on second balcony and to the left of me on the same level in the middle of the sound someone screams and everyone looks over there and it looked like someone was about to fall over the edge or something. then i kept watching and the guy goes up a couple rows and looks like hes talking to this other guy and then all of a sudden punches him. and then proceeds to keep punching him. the people around there try to restrain him and stuff, but it was really intense. and people were kind of screaming, so it even stopped the music for a couple minutes as they got it under control. but seriously who fights at a freaking boston pops concert. anyway.
That’s pretty much the way I remember it, although I missed the part where someone was about to fall off the balcony. I heard a woman’s voice cry out, and I couldn’t figure out where it came from. I thought maybe someone had too much to drink. And then I saw a commotion way over on the left side, and sure enough some guy just starts punching someone else in the face.
In the movies, when things like that happen, there is always the horrified “oh!” of gentle-men and -women in the audience. Funny enough, it actually happens in real life too! People were still mumbling to each other after the orchestra started up again.
Other than that, the concert was excellent. The hall sounded beautiful, and Ben Folds rocked the house. It was quite a meeting of two very different audiences — the regular Pops crowd, and a lot of Ben Folds fans. (Note: the altercation appeared to be between regular-pops-crowd-types, not rowdy young ben-folds-types.)