A little progress: Audio on low speed CPUs

I made a little progress today, with the problem of console music players at very low processor speeds. The house favorite, moc, has a tendency to stutter on machines slower than about 200Mhz (that might vary from machine to machine and distro to distro) with standard-quality sound files.

By all means it should be possible to play mp3 or ogg files on machines far slower than 150Mhz, but for whatever reason, the machine slows to a sputtering crawl, CPU use sits solidly at 100 percent, sound quality drops to a hideous level and the entire experience is an unqualified failure.

Today, during a brief break, I rebuilt moc 2.5.0-alpha4 to remove absolutely everything I don’t use — unwanted codecs, unneeded support flags, you name it — and leaving only things I knew I would need for either my own 100-percent ogg collection, or streaming music channels.

I think it made a difference. There is still a measure of stuttering on startup, and when a new file is started (which I assume is lag caused by some kind of caching process).

But that stutter only lasts a half a second or a little more on 44Khz VBR ogg files, which is a vast improvement over the continual chirping I was getting with the default configuration of moc 2.4.4 for Crux.

It’s still not perfect — CPU use is still in the 85-100 percent range, any interaction with the machine causes a skip or two, and outside interference (like the normal power off for the screen) also causes a hiccup.

But it seems to recover much more quickly, I don’t have to drop out of the interface to listen to a song, and it’s relatively usable. And listenable, if that’s a word. 🙂

For the record, this is the Pkgfile I used to do this; if you’re also a Cruxian you could give this a try. Arch users could also adjust this to their liking. Note that this pulls libsndfile and adds flac — those are personal preferences.

# Description: Console audio player.
# URL: http://moc.daper.net/
# Maintainer: 
# Packager: 
# Depends on: curl flac libvorbis libid3tag libmad
 

name=moc
version=2.5.0-alpha4
release=1
source=(ftp://ftp.daper.net/pub/soft/$name/unstable/$name-$version.tar.bz2)

build() {
	cd $name-$version

	./configure \
	--prefix=/usr \
	--mandir=/usr/man \
	--with-alsa \
	--with-curl \
	--with-flac \
	--with-mp3 \
	--with-ncurses \
	--with-vorbis \
	--without-aac \
	--without-ffmpeg \
	--without-jack \
	--without-modplug \
	--without-musepack \
	--without-ncursesw \
	--without-oss \
	--without-rcc \
	--without-samplerate \
	--without-sidplay2 \
	--without-sndfile \
	--without-speex	\
	--without-timidity \
	--without-wavpack \
	--disable-nls \
	--disable-debug

	make
	make DESTDIR=$PKG install
	install -D -m 0644 -t $PKG/usr/share/moc/ config.example keymap.example 
	rm -rf $PKG/usr/share/doc
}

Let me know if you have better luck, or if you can trim back the player itself any further. In the mean time, I’ll be trying to force the BIOS power management to stop interrupting my music when the system is on battery. 🙂

12 thoughts on “A little progress: Audio on low speed CPUs

  1. mulenmar

    I’ve had no chance to try this myself, but I’ve read that ALSA itself can cause the stuttering problem. Perhaps you should try OSS4?

    Reply
  2. Patrick

    You can also try compiling the relevant applications and libraries with -Os and -ffast-math. That should help a bit.

    Reply
    1. K.Mandla Post author

      I’ve tried those flags in the past with different applications, and you’re right, I should try them again.

      Sometimes ffast-math left me with broken applications or libraries though. I usually use -Os on machines with little memory.

      Reply
  3. Gavin

    Have you tried the FLAC music format?

    I have all my CD rips in FLAC and high quality MP3. My server (Pentium 133MHz running Debian stable with a Soundblaster AWE64 ISA card) is able to play back my FLAC files using about 30-40% CPU usage. Playing an MP3 generally has the CPU at 100% usage. I use MOC as my music player.

    I realise FLAC files are a lot larger but if its stutter free playback old older hardware you want then you may have to change format. Of course being lossless FLAC files are also higher quality than MP3s 🙂

    I have a large hard drive (1TB) in my Pentium machine so disk space isn’t a problem (for now) but perhaps this isn’t an option for you.

    Something to consider though.

    Reply
    1. K.Mandla Post author

      Not … really. I’ve tried different frontends that employ different decoders, but results have usually been the same. I am thinking about recasting some of the music I listen to most as lower quality, or switching codecs. At this point, it’s either that or swap ALSA for OSS. Anything could work. …

      Reply
  4. Luca

    Ogg Vorbis got quite a bit of slack when it first became popular due to the higher CPU usage compared to MP3s. The default libvorbis decoder uses floating point math quite intensively, which on older machines can be slow. There is an alternative called libvorbisidec which uses integer only math, it appears to be quite popular with embedded systems:

    http://www.nslu2-linux.org/wiki/HowTo/BuildMpd

    Reply
    1. K.Mandla Post author

      I’ve tried using nice in the past, but it didn’t seem to make too much difference. My meager understanding of nice, coupled with my meager understanding of the problem, suggests that playing tunes is overwhelming even the nice-ing option. But I am not opposed to trying again. …

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s