Blinken xmms

blinken_xmms
Das blinken_xmms ist ein Spectrum-Analyser-Plugin für den Multimedia Player Xmms. Es sendet UDP-Pakete an 127.0.0.1:2323 im BLP - Blinkenlights Protokoll mit 8x18 Pixeln. Die Ausgabe kann z.B. mit lldrv auf ein BlinkenLEDsPro umgeleitet werden.

Quellcode
Den Quellcode für das XMMS-Plugin habe ich mit Hilfe von Workshop: Vis-Plugins in XMMS und XMMS Plugin tutorial at nobugs.org erstellen können. Desweiteren waren Informationen zum BLP - Blinkenlights Protokoll sehr nützlich. Der "Rechen-Kern" für die Visualisierung entspricht dem des spectrum Plugins.

blinken_xmms.c ! Beim Speichern --> Dateiname: blinken_xmms.c !

 /* XMMS - Cross-platform multimedia player * Copyright (C) 1998-2000  Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License forore details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // --> INSTALL: //gcc -Wall --shared `xmms-config --cflags` -o blinken_xmms.so blinken_xmms.c //install blinken_plugin.so `xmms-config --visualization-plugin-dir` 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0,  0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0,  0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0} unsigned char msg[156]=MSG; int sock; static gint16 bar_heights[NUM_BANDS]; static gdouble scale; void our_init; void our_cleanup; void our_playback_start; void our_playback_stop; void our_render_freq( gint16 data[1][256]); VisPlugin g_our_plugin = { 	NULL,   /* handle */ NULL,   /* filename */ 0,	   /* session id */ "Blinken-Plugin", /* description */ 1,	   /* PCM Channels */ 1,	   /* Freq. Channels */ /* Callbacks ... */ 	our_init,		/* init */ our_cleanup,	/* cleanup */ NULL,		/* about-dialog */ NULL,		/* configure-dialog */ NULL,		/* disable-plugin */ our_playback_start, /* playback-start */ our_playback_stop, /* playback-top */ NULL, /* render-pcm */ our_render_freq	/* render-freq */ }; VisPlugin *get_vplugin_info(void) { return( & g_our_plugin); } void our_init { 	if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { 		printf("couldn't create socket"); our_cleanup; // programm mit fehlercode 1 beenden exit(1); } 	// Struktur anlegen, mit Nullen initialisieren und füllen struct sockaddr_in dest_addr; memset(&dest_addr, 0, sizeof(dest_addr));             // alles mit Nullen füllen dest_addr.sin_family     = AF_INET;                   // muss hier nochmal stehen dest_addr.sin_port       = htons(2323);               // auf dem Port läuft meistens HTTP dest_addr.sin_addr.s_addr = inet_addr("127.0.0.1");   // IP Adresse von www.example.net if (connect(sock, (struct sockaddr*) &dest_addr, sizeof(dest_addr)) == -1) { 		printf("couldn't connect to 127.0.0.1:2323"); our_cleanup; exit(2); // mit fehlercode aussteigen } 	send(sock, msg, 156, 0); scale = HEIGHT / log(256); } void our_cleanup { 	close(sock); // wir schließen den descriptor wieder } void our_playback_start { 	//printf( OUR_PREFIX" playback_start\n"); } void our_playback_stop { 	unsigned char msg[156]=MSG; send(sock, msg, 156, 0); } void our_render_freq( gint16 data[1][256]) { 	int result,zeile,spalte; int i,j,c; gint y; 	gint xscale[NUM_BANDS] = {0, 1, 2, 3, 5, 7, 10, 14, 20, 28, 40, 54, 74, 85, 101, 137, 140, 150}; for(i = 0; i < NUM_BANDS; i++) { 		for(c = xscale[i], y = 0; c < xscale[i + 1]; c++) { 			if(data[0][c] > y) 				y = data[0][c]; } 		y >>= 7; if(y != 0) { 			y = (gint)(log(y) * scale); if(y > HEIGHT) y = HEIGHT; } 		if(y > bar_heights[i]) bar_heights[i] = y; 		else if(bar_heights[i] > 4) bar_heights[i] -= 4; else bar_heights[i] = 0; } 	spalte = 0; zeile = 0; for(i=12;i<=155;i++) { 		j = i-12; zeile = j/18; spalte = j%18; if((-bar_heights[spalte]+8)<=zeile) { 			msg[i]=0x01; } 		else { 			msg[i]=0x00; } 	} 	result = send(sock, msg, 156, 0); return; }
 * 1) include 
 * 2) include 
 * 1) include 
 * 2) include 
 * 3) include 
 * 4) include 
 * 5) include 
 * 6) include  // für exit
 * 7) include  // für close
 * 8) include  // fürs memset
 * 9) include  // fürs inet_addr
 * 1) define NUM_BANDS 18
 * 2) define WIDTH 18
 * 3) define HEIGHT 8
 * 1) define MSG {0xDE,0xAD,0xBE,0xEF,0,0,0,0,0x00,0x012,0x00,0x08,\
 * 1) define OUR_PREFIX "blinken-plugin:"



Installation
gcc -Wall --shared `xmms-config --cflags` -o blinken_xmms.so blinken_xmms.c

install blinken_plugin.so `xmms-config --visualization-plugin-dir`

Evtl. ist das dev. Paket von xmms erforderlich.

Nun kann man mit einem Rechtsklick auf das XMMS-Fenster im Menü: Visualisierung-->Visualisierungs-Plugins

Blinken-Plugin

auswählen. Um den UDP-Stream umzuleiten kann z.B

./BlinkenOutput -l 2323 -d /dev/lldrv

benutzt werden.

Links
download source