Tag Archives: mp3

Faster MP3 options for Raspberry Pi

One thing the Raspberry Pi is not good at is encoding MP3s at any great speed. At best (using lame) you might get slightly better than 2× real time playback. If you’re using your Raspberry Pi to transcode to another format, that might be slow enough (with other system overhead) to make the output stutter.

While it would be nice to have the GPU as a general media encoder, we’re not there yet. If you must encode mp3s quickly on a Raspberry Pi, there are a couple of options:

Please note that both of these are based on the old ’8hz’ mp3 encoder, which was a fairly literal interpretation of the original Fraunhofer code. They only start producing okay sounding files at high bitrates.

If you need to decode mp3s quickly, MAD is pretty good: http://www.underbit.com/products/mad. It’s in the repos as ‘madplay’.

Raspbian ftw!

Raspbian is good. If you haven’t upgraded your Raspberry Pi to run it — or any other hard float distro — then you should. It makes the little board seem positively zippy.

The processor on the Pi is an odd beast. It’s an ARMv6, somewhere between the ARMv5 that the original Debian distro supported, and the ARMv7, which has to have hardware floating point support. The Pi’s processor has floating point in hardware, but it wasn’t supported in the first distribution. Raspbian fixes this, and also has a nice hardware setup wizard (which I wish I’d known about before I spent a while preconfiguring the SD card on another Linux box, grr).

My highly unscientific benchmark of how fast a computer is is encoding an audio file with ‘lame -V2′. If it comes out faster than real time, it’s fast enough. My first trial in late June came out at a dismal 27% real time — so that would mean that a 4 minute song would take 14′ 49″ to encode. Very poor. Trying it again with Raspbian today gave me 209% real time — so that same song would be done in 1′ 55″. Much better.

While I was fossicking about with the Pi, I switched its power adapter over to a battery-backed outlet on my UPS. With summer storms, our power has been a bit glitchy, and the tiny USB power supply wasn’t able to ride through any of them. This, I hope, will allow me to have an uptime better than the time between storms …

I also made this last week:

It’s a GPIO breakout, a sort of home made Adafruit Pi Cobbler. It’s on a tiny 13×4 fragment of stripboard. The soldering was fiddly, as stripboard is only single sided, so there was much fine tipped soldering iron action (and swearing). I now have the parts to built Mike Cook’s Breakout board with zener diodes providing protection, but this will do for simple applications if I’m careful.

mockingbird

Very little urban hum this morning (holiday), and the air conditioners really hadn’t started yet, so please be amused by the sounds of the garden (featuring mostly mockingbird): about quarter to nine. It does a passable seagull and also a red-tailed hawk. The vehicle reversing sound, though, is real.

(at least I don’t have a mockingbird problem.)

“Go scratch a rock on some congealed oil and tell me what it sounds like”

I’m either getting old or conventional, ‘cos I bought something I said I would never have enough time or space for: a turntable. I won’t forsake my beloved MP3s, but there are somethings you just can’t get electronically. One of them being the 1981 Stampfel & Weber album “Going Nowhere Fast”, which I snagged from Etsy from a west coast seller.

I bought an elderly Technics from Ring Audio, and set it up with a USB phono preamp from Phonopreamps.com. It sounds good, I guess. It certainly sounds different from MP3s, but better …? Dunno. My two cynical theories hypotheses of vinyl snobbery are:

  1. The more you have invested in your system, the more confirmation bias tells you it sounds better.
  2. Vinyl is the record industry’s last-gasp attempt attempt at relevancy, because you can’t home-cut your own discs. As there’s always analogue loss in ripping from vinyl, it’s self-policed rights management by the sound quality snobs. Imagine that: DRM conditioned into the listeners themselves!

I have not got a lot of records:

Albums

  1. Going Nowhere Fast — Stampfel & Weber
  2. The Holy Modal Rounders
  3. The Holy Modal Rounders 2 (are you sensing a pattern here?)
  4. Acedia — Black Walls

Single-ish Things

  1. The Television Tells Us / Freeing Song by Reindeer — The Music Tapes (Julian sent me this in 1998, and I think this is the first time I’ve played it. For a few days, it was the only record I had, and it was merciful that Catherine was away, as she only has a normal human tolerance for this sort of thing)
  2. Ghetto Kitty Island Split 7″ – featuring Chicken on a Raft, Of Montreal, Bart Davenport and The Minders.

Speaking of which, I understand that the latter EP is not exactly widely known, is totes OOP, and completists might dig Of Montreal‘s ”Epistle to a Pathological Creep (demo)”, so here it is ripped for your listening pleasure:

Ghetto Kitty Island Split 7" (2004)I recorded it with arecord, and edited it with Audacity.  The arecord command line (more for my reference than your interest) was:

arecord -D 'hw:CARD=CODEC,DEV=0' -V stereo -c 2 -f dat -d 900 ghettokittyisland.wav

which records 900 seconds of audio at DAT quality to the file ghettokittyisland.wav, while showing a simple text meter on the screen.

Generational loss in MP3 re-encoding

Okay, name this tune:

madplay / lame – 1000 iterations

(You’ll have to scroll about half way in before anything starts)

Didn’t get it? Try this:

madplay 24-bit / lame – 1000 iterations

(Again, you’ll have to scroll about half way in before anything starts)

Missed that one? Okay then, how about:

lame / lame – 1000 iterations

(no need to scroll here.)

Unless you’ve been living under a rock, it’s a clip from Adele‘s Someone Like You. Sure, you can’t make out the words too well in the last one, but at least they don’t sound like some dire paen to Cthulhu, like the first two do.

All of the above samples are the same source file re-encoded 1000 times. I’d heard that there was some loss to encoding MP3s, but thought that if you kept about the same bitrate, there wouldn’t be too much loss. I wanted to test out my theory, so I took:

  • LAME — a quality mp3 encoder (that can also decode to WAV)
  • madplay — a decent mp3 decoder that uses fixed point for speed
  • a shell script (see below) that encodes an MP3 1000 times, feeding the output of the last run as the input of the next.
  • a sample clip; in this case, ganked from Amazon.com: 21: Adele: Music using Audio Hijack Pro.

The original sample looks pretty clean; it’s not the highest quality, but it’s clear:

The first thing that strikes about the multiply-reencoded file is that it’s much longer:

This is because LAME adds padding to the beginning and end of each song. All this padding adds up over 1000 runs.

I’d used madplay extensively before, so I knew it worked reliably. First, I tried it using an intermediate sample size of 16 bits (same as the source) and no dithering. Just after 100 runs, Ms Adkins’ plaintive voice becomes hard to understand:
madplay / lame – 100 iterations

I’d turned dithering off in the first test, as I thought it would overcome the signal. As the signal was pretty much gone, I didn’t think I had much to lose, so I tried it at madplay’s full capability of 24 bit internal processing. Again, 100 runs was where things started to go really sideways:
madplay 24-bit / lame – 100 iterations

LAME can also decode MP3s, and remarkably, the lyrics remained discernable after 1000 interations (so go and see the third sample up top). Sure, it sounds scratchy, but the piano sounds like a piano and not like some underwater harp. LAME is clearly able to recognize its own input, and decode it accordingly. madplay, on the other hand, just treats an MP3 as a generic MP3, hence the over-compression and extra silences.

So really, if you’re going to re-encode music, it matters more what you use to decode your MP3s. If you can use the same tool for both, all the better.

Continue reading

Richard Harvey – A New Way of Seeing

A New Way of Seeing was created by Richard Harvey for ICL for the launch of a new series of computers in 1979. Since it was only released to ICL dealers and their clients, it’s not widely known. This is a shame, as it’s a delicious slice of electro-prog.

So here it is: A New Way of Seeing – Richard Harvey (mp3).

Quality’s not great, ‘cos the audio’s ganked from this YouTube video. Seeing as ICL is long gone, this is probably the best we’ll have to live with.

Banjo at home

Got some better pictures of the banjo yesterday. And sounds, too!

Please excuse the ropeyness of the following playing; I’d never played fretless until I built this:

mississippi john dalek

I really, really don’t know what my iPod was thinking when it rendered a perfectly good mono MP3 of Mississippi John Hurt like this:

Mississippi John Hurt – Frankie (accidental robot mix)

Mississippi John Hurt - Frankie (accidental robot mix)

Old Man Luedecke instore

Old Man Luedecke just gets better and better. Here’s a half-hour instore he did at Criminal Records last week.

Old Man Luedecke - Criminal Records (Toronto) instore, 2010-04-08

something went wrong

At the automatic podcast today, something went very wrong with the announcements. Hear what I mean.

I was playing with flite‘s new voices, and I think the command line went up the chute.

fast fixed-point MP3 encoder for ARM

CompRec, though extremely poor quality (no psychoacoustic modelling! Old-school twinkly-burbly MP3s here we come!) is a fast MP3 encoder you can build on the SheevaPlug. It’s perfect for my limited needs.
(thanks to wb6ymh for finding this.)

time to get MAD

The prime reason I bought the Sheevaplug is to run the automatic podcast. Every day, the script has to decode a bunch of mp3s to WAV format.On a normal computer, this takes a few seconds per file. On the Sheevaplug – with no floating-point instructions, things get painful:

$ time lame --mp3input 03-in_the_aeroplane_over_the_sea.mp3 03-in_the_aeroplane_over_the_sea.wav
ID3v2 found. Be aware that the ID3 tag is currently lost when transcoding.
LAME 3.98 32bits (http://www.mp3dev.org/)
Using polyphase lowpass filter, transition band: 16538 Hz - 17071 Hz
Encoding 03-in_the_aeroplane_over_the_sea.mp3
to 03-in_the_aeroplane_over_the_sea.wav
Encoding as 44.1 kHz j-stereo MPEG-1 Layer III (11x) 128 kbps qval=3
Frame          |  CPU time/estim | REAL time/estim | play/CPU |    ETA
7750/7750  (100%)|    8:45/    8:45|    8:46/    8:46|   0.3851x|    0:00
-------------------------------------------------------------------------------
kbps        LR    MS  %     long  %
128.0        2.1  97.9       100.0
Writing LAME Tag...done
ReplayGain: -8.9dB

real    8m46.408s
user    8m45.940s
sys    0m0.090s

That’s right – nearly 9 minutes to decode a song! My very first Pentium 75 could probably do better than that.

I’d heard that MAD was really fast on integer-only CPUs, so I tried it:

$ time madplay -o 03-in_the_aeroplane_over_the_sea.wav 03-in_the_aeroplane_over_the_sea.mp3
MPEG Audio Decoder 0.15.2 (beta) - Copyright (C) 2000-2004 Robert Leslie et al.
Title: In the Aeroplane Over the Sea
Artist: Neutral Milk Hotel
Album: In the Aeroplane Over the Sea
Track: 3
Year: 1998
Genre: Alternative
Comment:
7748 frames decoded (0:03:22.3), +1.2 dB peak amplitude, 1423 clipped samples

real    0m7.134s
user    0m6.500s
sys    0m0.580s

Seven seconds sure beats nearly nine minutes. Now, if only I could find an integer MP3 encoder …

good, not quite great

I accidentally dropped and broke my car mp3 player, so had to come up with another music solution. I caved and bought an iTrip for my iPod Nano. It sounds pretty good.

What’s good about it is that it allows you to charge your iPod from a standard USB Mini-B. What’s not so good is that it doesn’t have full USB pass-through, so you can’t sync your iPod, and have to stick with that stupid dock cable.

(and don’t get me started on the really annoying connector on my work cell phone …)

how does he do that?

Someone asked how the automatic podcast works. It’s a bit complex, and they probably will be sorry they asked.

I have all my music saved as MP3s on a server running Firefly Media Server. It stores all its information about tracks in a SQLite database, so I can very easily grab a random selection of tracks.

Since I know the name of the track and the artist from the Firefly database, I have a selection of script lines that I can feed to flite, a very simple speech synthesizer. Each of these spoken lines is stored as as wav file, and then each candidate MP3 is converted to wav, and the whole mess is joined together using SoX. SoX also created the nifty (well, I think so) intro and outro sweeps.

The huge wav file of the whole show is converted to MP3 using LAME and uploaded to my webhost with scp. All of this process is done by one Perl script – it also creates the web page, the RSS feed, and even logs the tracks on Last.fm.

Couldn’t be simpler.

20000th track

My music archive just hit 20K. The lucky track is MomusI was a Maoist Intellectual.

Momus is giving away his albums that he did for Creation as an advent calendar. So far, he’s released The Poison Boyfriend and Tender Pervert; more to follow.

the little computer that should

My home server went phut last week. There was a brief power outage, and everything else came back on — except the server. It was a three year old Mini-ITX box, and I’m casting about for ways to replace it.

To serve my immediate music serving and podcasting needs, I have pressed The Only Computer That Runs Windows into service, running Ubuntu using Wubi. Unfortunately, I do still occasionally need to run Garmin Mapsource, which only runs on Windows, and also The Only Computer That Runs Windows is also rather too nice a laptop to be sat doing server duty.

I have some options:

  • Get a new motherboard for the mini-itx box. Via still has some crazy ideas about pricing (over $200 for a fanless C7?) but maybe I’ll go for Intel’s snappily-named D945GCLF, which looks okay for what I need and is only $80.
  • I could resurrect the old Athlon box I got in 2002, but it’s big, loud, and its components are probably near end of life. Also, why disturb a mature spider habitat?

What I was really looking for was one of those tiny fanless internet appliance boxes that were so 2007 (like the Koolu and the Zonbu, both of which have moved on to other things), but such units, without the tied storage service contract, are upwards of $500.

My needs are simple:

  • run Firefly to feed the Soundbridges;
  • generate the automatic podcast every day, which realistically means a linux box with Perl, sqlite and the like;
  • have something to ssh into when boredom strikes the need arises. Perhaps unwise having an open machine sitting directly on the internet, but only the ssh port will be open.

I really also need to get rid of all the computer junk in the basement. It now includes two fritzed mini-ITX systems and the world’s slowest PostScript laser printer. Such fun.