Closing in on a Solution
bubbles
[info]natowelch
So here's what I think my DJing toolchain is going to look like:

jackd -R -dalsa -dhw:0,3 -r44100 -p1024 -n2 -P &
ecasound -i jack &
cle mplayer -ao jack:port=ecasound -af scaletempo -quiet -slave sometrack.mp3
cle mplayer -ao jack:port=ecasound -af scaletempo -quiet -slave someothertrack.mp3
[...]

JACKd provides the low-latency sound server and signal routing between mplayer and ECAsound. ECAsound will be standing between mplayer and the soundcard; I intend to use it to control the signal routing and mixing between the stereo channels of each mplayer "deck" (of which there can be unlimited numbers, apparently!) and the four output channels - stereo mains, and, of course, stereo headphone monitors. On my cheapo Sound Blaster Live! value, I've got a front and rear stereo surround, so I just split the "front" jack to the speakers, and use the "rear" jack for the headphones. Pie! ECAsound can apply LADSPA effects, if desired (EQs, compressor/limiters, phasers/flangers... etc.) and volume levels, of course, all of which can be controlled in real-time through any MIDI controller.

The reason I'm stuck on Mplayer is because of the scaletempo audio filter, which handles the pitch-moderation necessary to keep a track at the same pitch while changing the playback speed, avoiding the "chipmunk effect". Having it handled at the source, by a native mplayer plugin, instead of having to hack something together later in the output chain should make things much, much easier. Then I can use mplayer's slave mode with a script to control the seeking for cue points and "nudging", and the playback speed for tempo synchronization and beatmatching.

I am pretty happy about this, because I have just put this together and verified that the latency through this chain is TINY, as far as I can tell. I was tapping keys to launch cue points in time with the currently playing track with somewhat better success than I was with Mixxx last night. And I haven't even tried to install OSSv4 or even a real-time kernel. After spending a few hours frustrated by trying to connect bits with UNIX fifos, this is looking good.

I love ecasound. It helped me out a lot when I was trying to peel annoying ads off of Magnatune tracks (which they no longer tack on, thankfully), and it is one of the best-documented audio tools I've seen. Nice for an application with no GUI whatsoever - which actually makes it eminently usable to a hacker, because you can script everything. A GUI is a Graphical USER Interface, but a Command Line Interface is, in essence, an Application Programming Interface at the same time as a user interface. That API accessibility is what GUIs have lost for a long time, and are starting to reclaim with things like Applescript (which is certainly old, but confined to the Mac OS ghetto) and DBus.

DJ Software Update
bubbles
[info]natowelch
I hit a brick wall today when I discovered I couldn't mix mplayer's output across two outputs (one for fronts, one for monitoring).

So instead, I went back to review some old DJ software. Mixxx is starting to look much better. It was not hanging and crashing as much as the last time I tried it, and it's under active development. Apparently they are grabbing the attention of hardware controller vendors, who are releasing open source drivers. The beta version even has a scripting environment that looks fun.

BPMDJ also released a new version recently. I guess I'm not real excited about how the interface is put together, but the tempo analysis is top-notch, and using the "beatgraph" visualization to set cue points is a nice tool I've not seen elsewhere.

So after an email exchange with the author, I was able to decipher the binary format used by its index files, and wrote a php script (meh. it was fast, and I knew it) to parse the beat period, calculate the tempo, and use eyeD3 to insert it into the mp3 file's id3 tags. Mixxx, once it loads the file, will then pick the bpm out of that tag, and synchronize track playback based on that.

The beta version of Mixxx also saves cue points in it's library. I wonder if I could translate that to the id3 Event Timing Codes tag? That way all that data is stored in the file.

I suppose I'm about to find out whether the existing tools are useful enough that I won't be reinventing any wheels after all.

Also interesting in the Linux audio front is a recent review of Linux sound drivers, which speaks very highly of OSSv4. There's a widespread impression that OSSv3 was left behind for ALSA back in the day when the the original developer decided to close the source (a more than adequate reason). But since that time, 4front has re-released OSS version 4 under the GPL, giving it an opportunity for a second look. And it's very, very good-looking indeed, with latencies well below ALSA in most cases, backward-compatibility with all ancient applications that never switched to ALSA (indeed, often the problem is that apps don't support OSS), and non-blocking behavior now the default.

I will need to check this out soon.

Boredom Begets Industry
bubbles
[info]natowelch
I'm learning Python, so I can write music software.

No, it's not C++. It's Python.

I think what I might do is use BPMDJ to analyze tracks, and then write my own mixer app with the data it generates.

My imagined DJ interface consists of two diamonds. The upper diamond controls stereo output, and the lower diamond controls output to headphone monitors. The levels for each source deck (left and right) are plotted as a coordinate within each diamond, such that the bottom corner is both decks at zero, the top is both decks at full, the left corner is the left deck at full and the right deck at zero, etc.

Tell me if anybody's seen this before; I've not DJed enough to actually know what's out there.

Crap. I wonder if this could work on a touchscreen smartphone. The iPhone only has one stereo output, but the OpenMoko NeoFreeRunner could play USB host to an additional USB sound card. Ha! Who'd a thunk?

DJ Me Too
bubbles
[info]natowelch
I pulled an all-nighter last night to get familiar with some nice DJing tools for GNU/Linux.

A few months ago, I went digging through the net looking at and trying various tools. Most of them seemed to suck in a few ways. Many were unstable, or in perpetual alpha or beta, abandoned, etc. You know how it goes - the fields of FOSS code are littered with the failures that proprietary developers never allow to come to light.

Mixxx holds much promise, works fairly well, and participated in Google's Summer of Code this year, so it's actively being developed. The only drawback was the beat-matching algorithm it used was just plain terrible, even for single-tempo dance music. That's pretty much a deal breaker.

But much diligence has brought me to know and love BpmDJ. There are many strikes against it, but, somehow, this appears to be the only application that actually works well. The interface is less than intuitive, the documentation is out of date and incomplete, but a night of reading, experimenting, and hacking a few things here and there paid of quite well.

It's beat-matching algorithm isn't perfect, either, but the Beat Graph visualization tool is a brilliant and welcome. It allows you to see instantly and intuitively whether or not the application's tempo analysis for a track is correct. And if not, it allows you to tweak it into alignment in nearly-real time. Once you've established the tempo, playback keys that seek forward or back along a playing track are aligned with the structure of the music (bars/notes) rather than the audio. Save a few cue points, and you can send playback anywhere in the song while staying in time.

Bizarrely, BpmDj discontinued it's software mixer component due to disinterest on the part the developer. There's a contributed alsa configuration file that may allow people to create to independently-mixed virtual stereo channels and fake it, but in the end, you really do need a separate monitor channel to do this right anyway. I might see if I can mediate any conflicts between my SoundBlaster Live and my motherboard's onboard sound and see if I can use the extra port as a headphone monitor. Originally, I was having stability problems doing software mixing with it (with alsa dmix), which led me to disable it entirely in favor of the SBLive, which has hardware mixing. Perhaps if a more narrow range of software uses it, it will be able to work more smoothly.

It took some diligence and practice, but I'm already seeing results and having fun. Best of all, I am quite pleased to be able to do it with free-as-in-you software. Now I need to go through my collection, doing tempo analyses, making corrections where necessary, and recording index and cue points to make things snappy on the fly.

Yeah, I know. Just what the world needs: another damn DJ. Don't worry, I'm in no hurry to inflict myself on any dance floors just yet.

Home