====== 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 [[http://www.musicpd.org|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//: +-------+ +---------------+ +-------------+ +--------+ |sensors+--------->+HW/SW interface+---------->+conductor SW +<------->+ Websrv | +-------+ /dev +---------------+ stdio, |cGRE | RPC |cYEL {s}| |rfid | |readmifare.pl | OSC,.. +------+------+ oAuth +--------+ |camera | |acr122.c | ^ |arduino| |tagid.pl | | | {d}| |etc. {d}| |TCP/IP +-------+ +---------------+ v +--+--+ +------------+ |cBLU | | | TCP/IP | | |GUI/Feedback+<------------------------------------+ MPD | |cPNK | | | +------------+ +-----+ * [[sf>mpd]] or http://www.musicpd.org - the music player daemon * [[http://trac.mediamatic.nl/picnic/browser/tools/rfidtools| rfidtools]] - Sonmicro and ACR RFID reader software * RDF, RPC .. * [[start|RFID wiki]] introduction ''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: (play|pause|stop) [+-] percent folder/file.mp3 [file/folder.mp3]* name [name]* [/pattern/]* [!/pattern/]* * ''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: play pause stop -5 80 Neil_Young !/full_album/ /black/ ====== Software ====== {{ :wiki:rfid:mpdscreen.png?300|..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 [[http://gareus.org/gitweb/?p=scripts.git|source repository]]. You can check out the latest version with direct links: * [[http://gareus.org/gitweb/?p=scripts.git;a=blob_plain;f=perlsdl.pl;hb=HEAD|download perlsdl.pl]] * [[http://gareus.org/gitweb/?p=scripts.git;a=blob_plain;f=mprfid.pl;hb=HEAD|download mprfid.pl]] \\ \\ **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 \\ extern>http://gareus.org/gitweb/?p=scripts.git;a=blob_plain;f=mprfid.pl;hb=HEAD extern>http://gareus.org/gitweb/?p=scripts.git;a=blob_plain;f=perlsdl.pl;hb=HEAD ====== References ====== * [[sf>mpd]] * http://kitenet.net/~joey/code/mpdtoys/ - MPD toys ; handy scripts * http://trac.mediamatic.nl/picnic/browser/tools/rfidtools