How I got to listening to music in my car using a USB pendrive as source (it’s not as simple as I’d have thought.)

Listening to music from an USB source (ie. a pendrive) should be a trivial thing, but, ridiculously, it isn’t. It’s not that difficult either, but it took me a bit of fiddling to get it right, so thought I’d record it for the benefit of future me.

First off, at the time of writing this, I have a 2016 Volvo V60, but as I was doing the fiddling I saw many others have very similar problems with Toyotas and basically any other brands. And this makes sense of course: the mediacenter in my car is probably some Bosch or Pioneer whitelabel box, that also controls the radio, and many other things. Adding USB audio support to car audio systems has clearly been an afterthought, something to check on the specs sheet that a very small and not very loud percentage of customers would actually want to use.

Second, it’s obviously (theoretically) easy to just listen to music from my phone via Bluetooth like the rest of the gen pop, except since the latest iOS upgrade my iPhone forgets how to Bluetooth just about every day, and I don’t want to sit around and wait for it to graciously decide to connect… it’s easier to just have a pendrive plugged in with my favorite “drive no evil” playlist or some other music that starts playing as soon as the car starts, you know, going.

There are 2 main things I want to record here:

  1. The format of the music, and the
  2. USB media itself.

So:

What kind of MP3 will my car audio eat?

What I discovered is it doesn’t like my 320kbps 48kHz MP3s. What that means of course is it doesn’t play them:

Car computer says no.

With the Scientific Method (ie. fiddling with it) I was able to figure out what is the first format it likes:

  • 320 kbps / 48 kHz – haha no
  • 320 kbps / 44.1 kHz – haha no
  • 256 kbps / 48 kHz – yeah baby!
  • basically everything below 256 kbps / 48 kHz – absolutely
Car computer says yes.

Eventually I settled lower to be sure: 192kbps 44.1kHz works perfectly, and given it’s a car, it’s not that bad… you have wheel noise, traffic noise etc. anyway so the lower bitrate audio doesn’t hurt your ear. (Naturally, .ogg and .flac are out of the question.)

After the decision, I created a separate folder structure on my laptop and copied my favourite car music in it, and ran this little script to resample all music within:

#!/bin/sh

find . -type f -iname "*.mp3" | while read file; do
 mv "$file" "${file}.bak" && \
 lame --mp3input -q 0 -b 192 --resample 44.1 "${file}.bak" "$file"
done

Of course I also remove all backup files once I see (via some random sampling) that all went well:

#!/bin/sh

find . -type f -iname "*.bak" | while read file; do
 rm "$file"
done

Now I have my car targeted music folder, time to write to the USB pendrive.

How to copy my car music to the pendrive?

Here’s the trick: if I just copy, my dumb car audio will play the files in seemingly random order. Not alphabetic (per filename), not based on id3 title or track # tags… The reason is my stupid car audio system plays files in physical order. Didn’t know this was a thing? Well I didn’t. Luckily there is a handy little tool called fatsort to sort the vfat fs on the pendrive.

But because it’s also a dumb utility, first it’s time to remove special characters from all the mp3s. I had to do this in one folder.

rename 's/[^a-zA-Z0-9_]//g' *.mp3

After this, with an unmounted-but-plugged-in pendrive:

apt install fatsort
fatsort /dev/[id of the usb pendrive partition]

Aaand done!

The upgrade of this would be something like a Raspberry Pi in the car with e.g. Kodi on it, so I can have better controls over playlists and random play, and sort based on Genre (which is clearly something the engineers of these media boxes never considered), enabling me to also upload frequently played audiobooks.

But that’s for another day, and another post.

Leave a Reply

Your email address will not be published. Required fields are marked *