imported>Veyron |
imported>Veyron No edit summary |
||
Line 1: | Line 1: | ||
== 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 [http://wiki.blinkenarea.org/bin/view/Blinkenarea/ |
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 [http://wiki.blinkenarea.org/bin/view/Blinkenarea/ExtendedBlinkenlightsProtocol EBLP - extended Blinkenlights protocol] mit 8x18 Pixeln. Die Ausgabe kann z.B. mit [[lldrv]] auf ein [[BlinkenLEDsPro]] umgeleitet werden. |
||
== Quellcode == |
== Quellcode == |
||
Den Quellcode für das XMMS-Plugin habe ich mit Hilfe von [http://dev.webreeze.de/portal/modules.php5?name=OnlineArticle&pid=5 Workshop: Vis-Plugins in XMMS] und [http://www.nobugs.org/developer/xmms/xmms-nobugs.html XMMS Plugin tutorial at nobugs.org] erstellen können. Desweiteren waren Informationen zum [http://wiki.blinkenarea.org/bin/view/Blinkenarea/ |
Den Quellcode für das XMMS-Plugin habe ich mit Hilfe von [http://dev.webreeze.de/portal/modules.php5?name=OnlineArticle&pid=5 Workshop: Vis-Plugins in XMMS] und [http://www.nobugs.org/developer/xmms/xmms-nobugs.html XMMS Plugin tutorial at nobugs.org] erstellen können. Desweiteren waren Informationen zum [http://wiki.blinkenarea.org/bin/view/Blinkenarea/ExtendedBlinkenlightsProtocol EBLP - extended Blinkenlights protocol] sehr nützlich. Der "Rechen-Kern" für die Visualisierung entspricht dem des [http://cvs.xmms.org/cvsweb.cgi/xmms/Visualization/sanalyzer/ spectrum] Plugins. |
||
Jetzt mit Graustufen! |
Jetzt mit Graustufen! |
||
Line 225: | Line 225: | ||
Nun kann man mit einem Rechtsklick auf das XMMS-Fenster im Menü: Visualisierung-->Visualisierungs-Plugins |
Nun kann man mit einem Rechtsklick auf das XMMS-Fenster im Menü: Visualisierung-->Visualisierungs-Plugins |
||
blinken-xmms |
|||
Blinken-Plugin |
|||
auswählen. Um den UDP-Stream umzuleiten kann z.B |
auswählen. Um den UDP-Stream umzuleiten kann z.B |
||
./BlinkenOutput -l 2323 -d /dev/lldrv |
./BlinkenOutput -l 2323 -d /dev/[[lldrv]] |
||
benutzt werden. |
benutzt werden. |
Revision as of 13:11, 25 January 2007
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 EBLP - extended Blinkenlights protocol 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 EBLP - extended Blinkenlights protocol sehr nützlich. Der "Rechen-Kern" für die Visualisierung entspricht dem des spectrum Plugins.
Jetzt mit Graustufen!
blinken_xmms.c ! Beim Speichern --> Dateiname: blinken_xmms.c !
<HighlightSyntax>
/* 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. */
/* Compile: * gcc -Wall --shared `xmms-config --cflags` -o blinken_xmms.so blinken_xmms.c * Install: * install blinken_plugin.so `xmms-config --visualization-plugin-dir` */
#include <stdio.h> #include <xmms/plugin.h>
#include <stdio.h> #include <math.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <arpa/inet.h>
#define NUM_BANDS 18 #define WIDTH 18 #define HEIGHT 8
#define MSG {0xFE,0xED,0xBE,0xEF,0x00,0x00,0x00,0x00,0x00,0x012,0x00,0x08,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
static unsigned char msg[156]=MSG; static int sock; static unsigned char scalmsg[10] = {0x11, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0xAA, 0xCC, 0x00};
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_xmms", /* 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); }
#define OUR_PREFIX "blinken-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); // senden scale = (HEIGHT + 1)/ 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+1) { y = HEIGHT+1; }
}
bar_heights[i] = -y+9;
}
spalte = 0; zeile = 0; for(i=12;i<=155;i++) { j = i-12; zeile = j/18; spalte = j%18;
if((bar_heights[spalte])==zeile+1) { msg[i]=0xFF; } else if((bar_heights[spalte])<zeile+1) { msg[i]=scalmsg[bar_heights[spalte]]; } else { msg[i]=0x00; }
}
result = send(sock, msg, 156, 0); return; }
</HighlightSyntax>
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-xmms
auswählen. Um den UDP-Stream umzuleiten kann z.B
./BlinkenOutput -l 2323 -d /dev/lldrv
benutzt werden.