Tactile Music Box – part 1

The Concept

I was thinking about the problem of digital collections not being tactile enough, and came up with a project idea to make a digital collection physical.

nfc-readerSo the thought here (click for bigger version) is that 1″ square tiles, probably plastic, could have an album art sticker on one side and an RFID/NFC chip sticker on the other side. You’d have a 1:1 ratio of albums to tiles, so if you have a huge collection it might be problematic… or you could just do favorites to keep it more lightweight.

The project idea is a Raspberry Pi 1 or 2 with Kodi (formally XBMC) and an NFC reader. The NFC tags on the tiles would be programmed with the album ID, on scanning one, it would communicate with Kodi to bring up and play that album. I’d want to rig up some play/pause/next/prev controls, maybe buttons, maybe just an IR receiver and a remote.

The nice thing about using a Raspberry Pi is that with a decently-sized microSD card, the music could be stored on the Pi itself. So NFC reader, Kodi, and MP3s are all handled by the same device. The whole thing could be placed in one box, all you would need to do is connect it to HDMI or a headphone jack.

Playing music on the Raspberry Pi

After some looking around, I settled on MOC instead of Kodi, which is very lightweight and allows playing music on command line. I couldn’t quite get it to play a directory, so ended up converting a directory to a playlist and passing that to MOC.

My bash scripting is pretty rusty, but I cobbled something together that functions.

It’s called playah.sh, and passing it a path to a directory of music starts MOC and plays files in that directory.

if [ -z "$1" ]; then 
echo usage: $0 path/to/directory/with/music

# start the mocp service, if needed
if ! pidof -o %PPID mocp > /dev/null; then
mocp -S
# clear the playlist
mocp -c

# generate a playlist file from a dir search
find $MP3DIR/*.mp3 -maxdepth 1 > playlist.m3u

# add the playlist to mocp
mocp -a playlist.m3u

# start playing the files
mocp --play

# then control the playlist with these commands
# mocp --next
# mocp --previous
# mocp --stop

Next Steps

I am waiting for the NFC reader I ordered (coming from China), once that arrives, it’s time to get physical!