Queremos configurar un equipo para que reproduzca musica y se pueda controlar fácilmente desde diversos puntos.
Se trata de un equipo con 1 tarjeta de sonido Sound Blaster Live! (con 4 canales), la cual funciona en Linux con a través del módulo emu10k1 El Sistema Operativo de la máquina es Ubuntu Gutsy
La música esta organizada en el servidor utilizando el árbol de directorios:
Se trata de un servidor de reproducción, al cual se configuran diversos origenes para la música y gestiona la musica a través de los directorios, etiquetas ID3Tag, listas de reproducción y streams de audio sin consumir apenas recursos de la máquina, a diferecia de otros reproductores con interfaces de red para control remoto.
Tan simple como:
usuario@maquina:~ $ sudo apt-get install mpd libmpeg3-1 libogg0
Editamos el fichero de configuración: teniendo en cuenta:
music_directory
playlist_directory
audio_output { [...] }
mixer_type "software"
Quedando el fichero de configuración para nuestra situación así:
music_directory "/home/multimedia/musica"
playlist_directory "/home/multimedia/musica/playlist"
db_file "/var/lib/mpd/tag_cache"
log_file "/var/log/mpd/mpd.log"
error_file "/var/log/mpd/errors.log"
pid_file "/var/run/mpd/pid"
state_file "/var/lib/mpd/state"
user "mpd"
bind_to_address "0.0.0.0"
log_level "default"
audio_output {
type "alsa"
name "Sound BLaster"
device "hw:0,0" # optional
format "44100:16:2" # optional
}
mixer_type "software"
En el servidor multimedia se han configurado diversos clientes por software:
Cliente en modo comando para controlar al servidor de musica de una manera fácil.
usuario@maquina:~ $ sudo apt-get install mpc
usuario@maquina:~ $ mpc help Usage: mpc <command> [command args]... mpc version: 0.12.1 mpc Displays status mpc add <file> Add a song to the current playlist mpc crop Remove all but the currently playing song mpc del <position> Remove a song from the current playlist mpc play [<position>] Start playing at <position> (default: 1) mpc next Play the next song in the current playlist mpc prev Play the previous song in the current playlist mpc pause Pauses the currently playing song mpc toggle Toggles Play/Pause, plays if stopped mpc stop Stop the currently playing playlists mpc seek [+-][HH:MM:SS]|<0-100>% Seeks to the specified position mpc clear Clear the current playlist mpc outputs Show the current outputs mpc enable <output #> Enable a output mpc disable <output #> Disable a output mpc shuffle Shuffle the current playlist mpc move <from> <to> Move song in playlist mpc playlist Print the current playlist mpc listall [<file>] List all songs in the music dir mpc ls [<directory>] List the contents of <directory> mpc lsplaylists Lists currently available playlists mpc load <file> Load <file> as a playlist mpc save <file> Saves a playlist as <file> mpc rm <file> Removes a playlist mpc volume [+-]<num> Sets volume to <num> or adjusts by [+-]<num> mpc repeat <on|off> Toggle repeat mode, or specify state mpc random <on|off> Toggle random mode, or specify state mpc search <type> <query> Search for a song mpc crossfade [<seconds>] Set and display crossfade settings mpc update [<path>] Scans music directory for updates mpc stats Displays statistics about MPD mpc version Reports version of MPD For more information about these and other options look at man 1 mpc
Sonata es un cliente gráfico escrito en phyton que controla remotamente mpd.
usuario@maquina:~ $ sudo apt-get install sonata
Lanzar sonata y por defecto se conectará contra localhost, si no es tan facil como abrirlo y poner en la configuación el host/ip donde esta corriendo el servidor MPD
Se trata de un script escrito en Locolandia para poder integrarlo fácilmente con el gestor de botones de metacity.
Pues bien creas el script siguiente:
#!/bin/bash # # MPC Loading music styles or groups simple. # Pablo Catalina <xkill@locolandia.net> # # use: # mpc-selector style reggae # mpc-selector group "Bob Marley" # files must be order following that tree # $ROOT_DIR/ # -> $STYLE_DIR # -> reggae/.. # -> flamenco/.. # -> clasic/.. # -> ... # -> $GROUP_DIR # -> Bob Marley/... # -> Camaron/... # -> ... # # Pablo Catalina <xkill@locolandia.ath.cx> # #ROOT_DIR with end slash like root/ if there is no root dir leave blank ROOT_DIR="" STYLE_DIR="estilos/" GROUP_DIR="grupos/" if [ -z "$2" ] then echo "Use mpc-selector <style|group> \"somegroup or something else\"" exit 1 fi mpc clear if [ "$1" = "style" ] then mpc add "$ROOT_DIR$STYLE_DIR$2" else mpc add "$ROOT_DIR$GROUP_DIR$2" fi mpc random on mpc play
Lo copias a un directorio del $PATH y le das permisos de ejecución:
usuario@maquina:~ $ sudo mv mpd-selector /usr/local/bin/ usuario@maquina:~ $ sudo chmod 755 /usr/local/bin/mpd-selector
Pues le puedes decir para cargar un estilo:
usuario@maquina:~ $ mpd-selector style reggae
O un grupo determinado:
usuario@maquina:~ $ mpd-selector group "Tiken Jah fakoly"