Fun with Commandline Sound Editing
It should have been a simple task: given two MP3 files, concatenate them so that the first song blends smoothly into the next (crossfading). It seems basic enough that any decent audio mixer would have an easy way to do it, but not ecasound.
Ecasound is a very powerful commandline audio mixer for Linux, and despite it kicking my ass today I’m pretty impressed with it. But it could not do a simple crossfade out of the box. After an hour pouring over the documentation, examples, man page, and googling around I figured out how you’re supposed to do it:
1. Fade the last N seconds of the first song into the first M of the second:
ecasound -a:1 -i song2.mp3 -ea:100 -kl:1,0,100,[N] \
-a:2 -i song1.mp3 -ea:100 -kl:1,100,0,[M] -y:[len - M] \
-a:all -o snip3.mp3
2. Make a copy of the first song:
cp song1.mp3 crossfaded.mp3
3. Append the second song onto the first, cropping off the last M seconds of it so that the crossfaded part comes in at the right place:
ecasound -i song2.mp3 -o crossfaded.mp3 -y:[len - M]
Which seems a bit convoluted to an n00b like me since you have to know the length of the first song and, well, easy things should be easy, right? But whatever. Problem was, the last step to do the append (which I took directly from the examples page) simply did not work. It just overwrote crossfaded.mp3 with song2.mp3.
So I went out looking for another way to do a crossfade on Linux and re-found sox, a utility I used a few years back to generate MP3 thumbnails. Recent versions contain a script by Kester Clegg and Chris Bagwel that does crossfades in one step. Finally! For some reason Ubuntu Linux’s apt repository doesn’t include these with their sox package, so I needed to get the source from off their site and modify it so it could find the sox binaries. Here’s the (very slightly) modified crossfader utility. Go sox!
Add New Comment
Viewing 1 Comment
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks
(Trackback URL)