RFID interface to the Music Player Daemon

Swipe a tag to change the music. It's easier than you think ;)

Introduction

BLOG post in progress. It fit's here very well as introduction.

Motivation

I'm using the music player daemon as an easy to use home-stereo. MPD is a very mature and stable software that /plays/ music, has sufficient features and offers control-clients for many platforms.

What I'm unhappy about is that all user-interfaces for music suck. well some suck less and others are just technically pragmatic. - No use in complaining; I've been working on solutions over the past years and certainly contributed to the mess.

With industrialization and machinery that could not comprehend semantics, the western culture also started to loose a feeling for context. Music transformed from Symphonies to Albums and is these days sold per Track; quite often cited out of context. - Well it can't get much worse, beyond web-2.0 there's hope to get some sense back. - The semantic web won't change the world, but people using it will.

So how does this translate to music? Let's first separate inter-active (playing an instrument, composing music or compositing sound) and active (listening to music, perceiving sound). Here I'm only concerned with the latter and state that it should be as unobtrusive as possible. The user (aka audiophile) should not be concerned with anything but the listening experience; He/she only chooses the environment: fi an opera-hall, a windy boulevard or a sound-studio. Respectively the conductor, wind or operator take care of the rest.

It's freedom of the user to choose between being active or passive to the the music. But currently there's not even a choice: cover-art adds little extra these days; and you-tube is the new pop. Nevertheless there's web-radios and endeavours by enthusiastic people who may end up educating more people than they dream of.

Remote-control the remote-control

I don't need to explain /play/, /next/, /pause/ interfaces so that's a good ;) - playlists representing albums or music collections are also on this list. We can safely add tangible user interfaces, and I'll add MPD to start prototyping…

The idea is to remote control a music player with sensors such as RFID, motion or brightness detectors, not forgetting classical buttons; linked with power of the semantic web.

MPD already offers many user-interfaces from commandline to GUI, joystick and LIRC. While it's not the most flexible and fancy player available (eg. lack of media collection management, connection-encryption, push based API,..) it's good enough for the purpose.

Cutting it down to day-projects:

mprfid is a perl script that allows to flexibly assign RFID tags (read from stdin) to actions controlling a MPD (using Audio::MPD).

Framework

work in progress

Tag-IDs can either be hardcoded or linked using a wiki-page that specifies the command to execute for the given tag. The command set are in XML DokuWiki-extension tag syntax, defined as follows:

<mpd control>(play|pause|stop)</mpd>
<mpd volume>[+-] percent</mpd>
<mpd play [OPTIONS]*>folder/file.mp3 [file/folder.mp3]*</mpd>
<mpd song [OPTIONS]*>name [name]* [/pattern/]* [!/pattern/]*</mpd>
  • control directly controls MPD playback.
  • volume allows to change the volume in steps from 0 to 100. prefixing + or - to the integer performs adjustments relative to the current value.
  • play will clear the playlist, enqueue all space, tab or new-line separated files (relative to MPDs root-folder) to the playlist and start playing.
  • song searches space, tab or new-line separated file or path names in the MPD database; afterwards it optionally filters the search-results with regular-expression patterns.

OPTIONS

  • noplay - don't start playing automatically
  • rand or random - shuffle the playlist after adding files

example commands:

<mpd control>play</mpd>
<mpd ctrl>pause</mpd> 
<mpd control>stop</mpd>
<mpd volume>-5</mpd>
<mpd volume>80</mpd>
<mpd song rand>Neil_Young !/full_album/ /black/ </mpd> 

Software

..just swiped the //Neil Young// Tag.

Besides MPD, you'll need perl, libaudio-mpd-perl (Audio::MPD) for the conductor and libsdl-perl (SDL) for the display screen.

  • mprfid is a perl reads from stdin and sends commands to MPD.
  • perlsdl - excuse the lame name - is a dumb BIG-FONT MPD monitor-window.

Both scripts use the MPD_HOST environment variable or alternatively use the first argument as such.

The software is available from the source repository. You can check out the latest version with direct links:



usage:

# example using ACR/tikitag readers
acr122 | mprfid.pl
# or 
export MPD_HOST="user@host"; acr122 | while [ 1 ]; do mprfid.pl ; done
#
# for sonmirco/mifare readers
tagid.pl | mprfid.pl "password@mpd-host"

# launch the GUI:
./perlsdl.pl "password@mpd-host"
# or
export MPD_HOST="password@mpd-hostname" 
perlsdl.pl


Failed to retrieve: http://gareus.org/gitweb/?p=scripts.git;a=blob_plain;f=mprfid.pl;hb=HEAD
Failed to retrieve: http://gareus.org/gitweb/?p=scripts.git;a=blob_plain;f=perlsdl.pl;hb=HEAD

References

 
wiki/rfid/mprfid.txt · Last modified: 23.12.2011 20:26 (external edit)
   |