Bembel-B Blog


Auvisio Alarm Station PX-4000: What a failure!

What is an alarm clock good for, if it doesn’t keep the correct time?! Zarro! 0:00!
Auvisio Alarm Station PX-4000
So I decided to get a not too expensive MP3-enabled Radio Alarm Clock and ordered Auvisio Alarm Station PX-4000 from the German mailorder Pearl for 49 EUR. Looks like I bought the last one, because now it’s not available anymore. :] Well, whatever, I’ll continue with my ramblings.
The awaited package arrived on Friday and already on Saturday I knew this piece of plastic and metal is pure rubbish. First I was surprised about the quite rather nice sound quality (even though a bit harsh on the highs), but a few hours later I found the clock to be out of sync some minutes. It’s running about 8 minutes too fast per 24 hours! What a joke!
Another big downside is the inability to set the volume for your MP3 alarm. It will just play at full volume, letting you wake up with an heart attack and waking up the entire house and probably neighbors of half the street too. :) Additionally, the FM radio receiving is pretty bad. Even the strongest channels have a loud hiss and other static.
The manual mentions upgradeable firmware with the software on the CD-ROM. But my package didn’t come with a CD-ROM. In the end I doubt that a firmware upgrade will fix the badly calibrated quartz of the clock.

Conclusion: Don’t buy this thing, as nice as it may appear to be from the specs! Unusable clock, unusable alarm, unusable radio. Not very good for being a radio alarm clock. :P
I didn’t find much on the Internet about this device, only one short review and a magazine review I’d have to pay for. So I’ll return it and try one of Pearls other MP3-enabled radio alarm clocks.


Fixed-point Ogg Vorbis and Musepack Decoder Packages for Debian Etch ARM

I’m using Firefly Media Server on a Linksys NSLU2 running Debian Etch to stream my whole music collection to my Pinnacle SoundBridge HomeMusic. Many files in my collection are in Ogg Vorbis format and a few in Musepack too, which unfortunately aren’t natively supported by the SoundBridge. Luckily Firefly can transcode audio files on the fly e.g. using the ssc plug-in and any console application via shell scripts. But the problem with the Debian packages is that they don’t take into account the missing floating point unit (FPU) of the NSLU2 hardware, and that makes oggdec/ogg123 and mpc123 take ages – way below real-time – to transcode. Fixed point versions of the transcoders aren’t available in the Debian Etch package repositories even the sourcecode already exists, so I had to build them myself.
Linksys NSLU2
I first searched the Debian packages for fixed point versions.
I found the libvorbisidec package, which is the fixed point version of libvorbis also going by the name Tremor. The vorbis-tools is only available as normal floating-point version linked to libvorbisdec. For Musepack there are (floating-point) packages libmpcdec3 for the library and mpc123 for the application.
In the Firefly forums I found patches for vorbis-tools (providing the ogg123 and oggdec transcoders), so that I could build Tremor versions of the transcoder apps.
In the Musepack sources there’s already a define variable to build with fixed point math only. So I would just have to enable that and rebuild the library and transcoder.

To make a long story short, here are the Debian Etch ARM binary packages for fixed-point Ogg Vorbis and Musepack:

I will gladly provide the sources. Feel free to ask for them! You can download the Deb sources for libmpcdec and vorbis-tools further below.


These are the integer Lenny ARM binaries. Libvorbisidec is available through the official repos.:

Update 2

Here are the Deb sources (.dsc, .diff.gz and .orig.tar.gz) to build your own binary Deb packages.

Performance now is very good on my 266 MHz NSLU2. From what I’ve seen in top, mpc123 and ogg123 stay below 50% CPU usage and decoding is done faster than real-time.

Only to show off how unbelievably cool I am ;), and in case somebody would like to reproduce these builds on another distribution, I’ll roughly describe the steps I’ve taken.

Build libvorbisidec

Pretty straight forward. As far as I remember I only had to rebuild the source package:

mkdir -p ~/debuild/libvorbisdec
cd ~/debuild/libvorbisdec
dget -x
cd libvorbisidec-1.0.2
debuild -rfakeroot -uc -us
cd ..
sudo dpkg -i libvorbisidec1_1.0.2+svn14261-1_arm.deb libvorbisidec-dev_1.0.2+svn14261-1_arm.deb

Patch and build vorbis-tools

This one was trickier. The patches found on the forum aren’t complete. The older one is blindly changing the endianess of the resulting audio data, thereby producing only noise on the little endian Debian I use. The newer one misses linking mpcdec to libvorbisidec.

mkdir -p ~/debuild/vorbis-tools
cd ~/debuild/vorbis-tools
dget -x
cp -pr vorbis-tools_1.1.1 vorbis-tools_1.1.1.wrk
cd vorbis-tools_1.1.1.wrk
[apply and manually fix the tremor patch]
[create tremor patch file against vorbis-tools_1.1.1/]
[copy patch file to vorbis-tools_1.1.1/debian/patches]
[add patch file at bottom of vorbis-tools_1.1.1/debian/patches/series]
[add libvorbisidec-dev dependency to vorbis-tools_1.1.1/debian/control and document Tremor versions in description]
[increase version and add changes in changelog via dch -i]
cd vorbis-tools_1.1.1
debuild -rfakeroot -uc -us
cd ..
dpkg -i vorbis-tools_1.1.1-7_arm.deb

Patch and build libmpcdec

Here I add a patch to enable the fixed-point define. Beware, the following steps are just written down from memory in a hurry. So expect flaws. :)

mkdir -p ~/debuild/libmpcdec
cd ~/debuild/libmpcdec
dget -x
cp -pr libmpcdec-1.2.2 libmpcdec-1.2.2.wrk
vim libmpcdec-1.2.2.wrk/include/mpcdec/math.h
[uncomment #define MPC_FIXED_POINT]
mkdir libmpcdec-1.2.2.wrk/debian/patches
diff -Naur libmpcdec-1.2.2 libmpcdec-1.2.2.wrk > libmpcdec-1.2.2.wrk/debian/patches/enable_fixed_point.diff
cd libmpcdec-1.2.2.wrk
dch -i
[increases version in changelog. add some notes.]
debuild -rfakeroot -uc -us
cd ..
dpkg -i libmpcdec3_1.2.2-2_arm.deb libmpcdec-dev_1.2.2-2_arm.deb

Build mpc123

This one has only to be rebuilt with the fixed-point libmpcdec version above installed.

mkdir -p ~/debuild/mpc123
cd ~/debuild/mpc123
dget -x
cd mpc123-0.2.2
debuild -rfakeroot -uc -us
cd ..
dpkg -i mpc123_0.2.2-1_arm.deb

I haven’t found a fast enough way to transcode Monkey’s Audio (aka. APE) files yet, but that’s mainly because I don’t have any (which haven’t been transcoded to mp3 by myself already). For your information: Building the Monkey’s Audio Codec (MAC) for Linux did work.
I think when looking for more low resource or fixed-point codecs, a good place to look for is the Rockbox Wiki. That’s what I used too.

To make this Firefly Transcoding post more complete, here’s my current version of the ssc script:

# script to facilitate server-side transcoding of ogg files
# Usage:   
# You may need to fix these paths:


ape_file() {

ffmpeg_file() {
    $FFMPEG -i "$FILE" -acodec pcm_s16le -f wav - | $WAVSTREAMER -o $OFFSET $FORGELEN

mpc_file() {
    $MPC --quiet --wav - "$FILE" | $WAVSTREAMER -o $OFFSET $FORGELEN

ogg_file() {
    $OGG123 -q -d wav -f - "$FILE" | $WAVSTREAMER -o $OFFSET $FORGELEN

flac_file() {
    $FLAC --silent --decode --stdout "$FILE" | $WAVSTREAMER -o $OFFSET $FORGELEN


# this is nonsense!
if [ "$3" != "" ]; then
  FORGELEN="-l ${3%.*}"

case "$1" in
# here you could cat a generic "error" wav...
# cat /path/to/error.wav

Oh, FYI I’m using mt-daapd 0.2.4+r1376-1 from the Debian repo. I got the wavstreamer binary and the ssc script example by extracting them from a newer Debian package. The Firefly Wiki provides more information on transcoding implementation.


[2008-04-11: Add Lenny Debs.]
[2008-06-06: Add Deb sources for libmpcdec and vorbis-tools.]
[2009-04-26: Fix links.]


Scrobbling Everywhere All the Time

I must confess I’ve become quite a fanboy. :) So what would be more important than keeping track of as much music playing as possible. Scrobbling the plays of my PC audioplayer Amarok and Foobar2000 ain’t that spectacular, but feeding statistics of my mobile MP3 Player SanDisk Sansa e200 and my stand-alone player Pinnacle SoundBridge HomeMusic (licensed by Roku) I consider being more of that Social Music Revolution

Scrobbling Sansa e200 with Rockbox

Precondition is using the great alternative Firmware Rockbox. It already has the Audioscrobbler logging built in. To submit the logs I use the PC application QTScrobbler under Linux (and occasionally Windows). That’s very easy and convenient. Just be sure to set your Sansa’s clock somewhat correct.

Scrobbling SoundBridge with Firefly Mediaserver

To gain access to my whole music collection without having a PC running, I’m using the fine Linksys NSLU2 NAS running the Firefly Mediaserver (aka. mt-daapd) with a cheapo 160 GB USB HDD (Storage) and a 2 GB USB Flash Drive (OS) attached. I’ve had a working setup using the alternative NSLU2 firmware Unslung, but soon switched to Debian ARM, for its greater versatility and more straight forward configuration.

I’ll write more detailed posts on the NSLU2 soon, especially regarding Firefly and fixed-point Transcoding and Radio. But for now a quick overview on the setup, which should be possible on other platforms and for any streaming client too.

I obtained the Firefly Mediaserver prebuilt from the Firefly website. Installation is quite easy and well documented.

Submission to is done by the Python application Lastfmsubmitd. As the name suggests it’s a daemon permanently waiting for data to be submitted. That data is gathered from text files placed e.g. in /var/spool/lastfm. Under Unslung I had to manually install it from source (python install), and for Debian it’s in the apt repo (but I built a deb package of the recent version found in Debian unstable).

Creating the data files is done periodically by a shell script based on what I found in the Firefly Forum. It’s run every 5 minutes by cron and queries the “last played field” of Firefly’s collection database and outputs results to Lastfmsubmitd’s spool directory.
That’s my current shell script (converting GMT+1 timestamps to UTC by substracting 3600 seconds):


# fetch newly played songs from fireflydb and write
# into lastfmsubmitd readable format

# config

# get last run time
if [ -e "$LASTFILE" ]

# get last database file date
if [ -e "$DBLSFILE" ]

# exit when database file unchanged
if [ "$DBLSRUN" == "$DBLSNOW" ]

# log file date

# query database
OUTFILE=$(mktemp "$TMPDIR"/mt-daapd-XXXXXXXX)
"$SQLITE" "$DATABASE" 'SELECT artist,album,title,track,song_length,time_played FROM songs where time_played > '"$LASTRUN"' ORDER BY time_played ASC;' | gawk -F '|' '{ printf "---\nartist: \"%s\"\nalbum: \"%s\"\ntitle: \"%s\"\ntrack: %s\nlength: %d\ntime: !timestamp %s\n",$1,$2,$3,$4,$5/1000,strftime("%Y-%m-%d %T",$6-3600) }' > "$OUTFILE"

# place non-zero result into spool, else drop file
if [ -s "$OUTFILE" ]
  chmod 664 "$OUTFILE"
  rm "$OUTFILE"

# log query date
echo "LASTRUN="`date +%s` > "$LASTFILE"

Downside of this solution is, Firefly will only consider a track as played, if it has been completely and continuously been played. So skipping or pausing a track will cause it to not be submitted.
Also there’s no separation between Podcasts and the rest of my music collection. What I haven’t tried yet, is the behaviour when playing web radio via Firefly playlists, as I do all radio streaming directly through the SoundBridge user interface.
To iron out the downsides using the same approach, the first one would need changes to the Firefly code I guess, the others could probably be fixed modifying the shell script.


The SATAnic Power of State-of-the-Art OSes and Installing Them

I recently did a clean install of Windows XP and Fedora Core 5 on my SATA HDD and it was quite an odyssey to get it working. I’ll briefly describe the odds I was confronted with. The real problem was to get Windows NTLDR/boot.ini bootstrap and the GRUB bootloader installed and configured correctly. One source of trouble seems to be that I had my old (even though unpartitioned) IDE HDD still plugged in and it could not be disabled in the BIOS. I am using an Asus A7N8X-E Deluxe mainboard.

Installing Windows XP

Of course one needed to have the Sil SATA driver on a floppy disk and press F6 when the Windows XP Install CD got booted. I knew this already. But downloading that 20+ MB driver package from the Asus website took over 30 minutes with about 13KB/s.. Very frustrating!
The strange thing with the Windows install was that it wouldn’t let me install on the SATA HDD without having enough free space on the IDE HDD. I had to create some partition on the IDE HDD and then the first step of installation continued.
Funny enough, the Windows bootloader got installed on that IDE HDD. So I had my Windows installed on drive C: (SATA) and the bootloader on drive D: (IDE) with a boot.ini configured to load Windoze from the second (SATA) HDD.
To fix that, I had to change the boot.ini to use the first HDD. I edited the file using a Linux Live-CD and copied it to a floppy disk (as there is no text editor included in the Windows Recovery Console AFAIK). Then I booted the Windows Recovery Console and copied all files from the IDE drive and the fixed boot.ini from the floppy disk to the SATA drive. This of course only was sufficient, as I wanted to use GRUB as my bootloader. Quite interesstingly, the drive letters using the Recovery Console where different, i.e. C: was IDE and D: was SATA.. Stupid drive letters anachronism I say!

Installing Fedora Core 5

The installation process was quite straight forward. Only thing that was annoying: There was only the option to install GRUB into the boot sector of the IDE drive or into the beginning of the first Linux partition (SATA). So I had to reinstall GRUB giving the desired destination after the OS was installed.
But this wasn’t enough. The problem is that I booted from CD and therefore the CD-ROM drive was seen as first boot drive and the HDD was considered the second drive. So I had to edit /boot/grub/ and define the HDD to be the first boot drive and do a reinstall of GRUB (grub-install /dev/sda).


Some part of problems I think were caused because I had that IDE HDD still installed. On the other hand the installer programs should be smart enough to automagically get around these problems. Sadly I didn’t find the solution as directly as it may sound. Searching the web I didn’t find anything describing my case, so this is why I wrote this..
My description of problems and how I solved them is surely very compressed for such a complex and confusing topic. So feel free to ask for clarification etc. by commenting.


[2006-04-23: Add tags.]


How to clone a defective hard drive, migrate a Linux installation, and locate defective files

As my (just 15 months old Samsung IDE) hdd continuously had more and more bad sectors, I had to replace it with a new (Seagate SATA) one. Here’s what I did to save as much data as possible, keeping my old filesystems (NTFS, FAT32, ext3, swap).

old opened hard disk drive


Boot from the Linux Live-CD Knoppix 4.0.2 enabling DMA at the boot prompt with knoppix dma.

cat /proc/swaps shows me Knoppix is using the swap partition on my defective hdd.

All following commands in this entire HOWTO have to be issued as user root! Use su - to switch to root.

So I unmount the swap partition with swapoff /dev/hda6.

Now the cloning process using dd_rescue is started, filling unreadable sectors with zeroes.

dd_rescue -A /dev/hda /dev/sda

About two hours later copying of all 160GB is finished.
As I didn’t set a logfile for dd_rescue to report bad sectors and Knoppix’ dmesg has only a small buffer space (and the syslog file isn’t used at all), I sadly ain’t able to name all the bad sectors positions at this time. So you would better use that logfile option!
So for now I only know the number of bad blocks (1328!), the total amount of unreadable data (~700kB), and, from what I could read scrolling down the terminal screen, the approximate locations of the bad blocks given in MB counted from the beginning of the hdd.

Let the cloned Linux installation use the new hdd

As I wasn’t able to mount the cloned partitions immediately afterwards, I did a reboot of Knoppix and it worked then. Good thing!

mount -o remount,rw /dev/sda2
mount -o remount,rw /dev/sda3

I now have to fix the partitions locations definitions for my cloned Linux installation to use the new hard drive.

I add the line (hd1) /dev/sda to my boot partition at /mnt/sda2/grub/

Also change the grub bootloader configuration at /mnt/sda2/grub/grub.conf from hd0 to hd1 and the kernel parameter root like this:

title Fedora Core (2.6.12-1.1372_FC3)
        root (hd1,1)
        kernel /vmlinuz-2.6.12-1.1372_FC3 ro root=/dev/sda3 rhgb quiet
        initrd /initrd-2.6.12-1.1372_FC3.img

Then there’s to fix the fstab at /mnt/sda3/etc/fstab. I change the device from /dev/hda to /dev/sda and also switch from using labels (/boot and /) for my Linux partitions to using the distinct device node names (/dev/sda2 and /dev/sda3).

Also mtab at /mnt/sda3/etc/mtab has to be fixed the same way.

And as I am using automount, these configuration files (/mnt/sda3/etc/auto.*) have to be fixed too.

Only thing left is the swap partition. I fixed that simply by rebooting from the new hdd (as defined in the BIOS settings) and typing this in the terminal:

swapon /dev/sda6
swapoff /dev/hda6

UPDATE: The above configuration still uses the bootloader in the old HDD’s MBR. The old HDD is still seen as the first boot device by the BIOS (therefore I use hd1 and not hd0). I figured that out when I wiped my old HHD’s partitions.
To exclusively boot from the new (cloned) HDD, you have to reinstall GRUB on this HDD. The process I would have had to use is a little tricky, and can be found in my posting about installing OSes on a SATA HDD.
In brief, one boots from the Fedora Rescue CD and chroots to the Fedora partition on the new HDD. Then fix the /boot/grub/ to see the HDD as first boot device and reinstall grub on this HDD. You would also have to fix /boot/grub/grub.conf to use hd0 instead of hd1 and configure your BIOS to boot from this HDD.
If you still have your old HDD intact (i.e. the system is booting from HDD), you most probably can skip the step of booting from the Rescue CD and simply boot from the HDD.

Let the cloned Windows XP installation use the new hdd

Heheh.. No way, dude! At least it would take hours and days from my knowledge. You would have to edit \boot.ini and also the System Registry’s drive and partition definitions. And then all paths and drive letters still point to the old hdd (as far it’s still plugged in).
So, once again, Microsith’s ultimate answer is: Reformat and reinstall! Outch!

Find bad sectors and affected files

The SMART system will only name the first bad sector it finds. On Linux there’s a tool called badblocks. I only tried its non-desctructive read-write test and it’s slow but reliable. But if you kept the dd_rescue log (unlike me), you find the block numbers there.

To locate a file by block number on a Linux filesystem (ext2, ext3, minix, reiserfs etc.), one can use debugfs as described in a HOWTO at smartmontools.

Locating files by sector or block number on a NTFS partition is possible under Linux with the use of ntfscluster found in the ntfsprogs utility suite by the Linux-NTFS Project.

How to do this on FAT or NTFS systems is still unknown to me. After googling for quite a long time I still did not come up with a solution. I guess one should be able to accomplish this with a disk editor. Still the question, which one would that be?!

Copyright notice

The photograph showing an old opened hard disk drive used in this entry is in the Public Domain and thus free of any Copyright restrictions. The content is provided by Michael Connors and Morguefile and has the ref id# 13218.


[2006-04-23: Add tags.]
[2006-07-21: Reinstall GRUB to be able to boot exclusively from the clone. Locate files by sector or cluster number on NTFS partitions. More tags.]

Blog at