(→Links) |
imported>Took mNo edit summary |
||
(9 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
---- |
|||
<b>This page is obsolete. The new Version is here:</b> [[Blinken_XMMS]] |
|||
---- |
|||
== blinken_xmms == |
== blinken_xmms == |
||
Das blinken_xmms ist ein Spectrum-Analyser-Plugin für den Multimedia Player [[Xmms]]. Es sendet [[UDP]]-Pakete an |
Das blinken_xmms ist ein Spectrum-Analyser-Plugin für den Multimedia Player [[Xmms]]. Es sendet [[UDP]]-Pakete an eine konfigurierbare IP Adresse 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. |
||
{| class="wikitable" |
|||
|- |
|||
! Blinkt zu D&B Musik |
|||
! Konfigurations GUI |
|||
|- |
|||
| [[Image:BlinkenPlugin.gif]] |
|||
| [[Image:Blinken_XMMS_GUI.png]] |
|||
|- |
|||
|Erstellt mit [http://blinkenlights.de/blinkentools.de.html blm2gif] |
|||
|- |
|||
| (Graustufen werden leider nicht konvertiert), |
|||
| |
|||
|} |
|||
== Quellcode == |
|||
[[Image:BlinkenPlugin.gif]] |
|||
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 und Konfig-GUI! |
|||
Blinkt zu D&B Musik; erstellt mit [http://blinkenlights.de/blinkentools.de.html blm2gif] |
|||
[[:Image:Blinken_XMMS.c.txt | Blinken_XMMS.c]] ! Beim Speichern --> Dateiname: Blinken_XMMS.c ! |
|||
(Graustufen werden leider nicht konvertiert) |
|||
[[:Image:blinken_xmms.h.txt | blinken_xmms.h]] ! Beim Speichern --> Dateiname: blinken_xmms.h ! |
|||
== 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/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. |
|||
[[:Image:configure.c.txt | configure.h]] ! Beim Speichern --> Dateiname: configure.c ! |
|||
Jetzt mit Graustufen! |
|||
[[:Image:Blinken_xmms.c.txt | blinken_xmms.c]] ! Beim Speichern --> Dateiname: blinken_xmms.c ! |
|||
=== Blinken_XMMS.c === |
|||
<highlightSyntax language="c"> |
<highlightSyntax language="c"> |
||
/* Blinken_XMMS : for XMMS - Cross-platform multimedia player |
|||
* |
|||
* 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 XMMS. |
|||
*/ |
|||
/* Compile: |
|||
* gcc -Wall --shared `xmms-config --cflags` -o Blinken_XMMS.so Blinken_XMMS.c |
|||
* Install: |
|||
* install Blinken_XMMS.so `xmms-config --visualization-plugin-dir` |
|||
*/ |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <unistd.h> |
|||
#include <string.h> |
|||
#include <math.h> |
|||
#include <sys/time.h> |
|||
#include <sys/types.h> |
|||
#include <sys/socket.h> |
|||
#include <netinet/in.h> |
|||
#include <arpa/inet.h> |
|||
#include <xmms/plugin.h> |
|||
#include <xmms/configfile.h> |
|||
#include "./configure.c" |
|||
#define NUM_BANDS 18 |
|||
#define WIDTH 18 |
|||
#define HEIGHT 8 |
|||
#define NUM_BANDS 18 |
|||
#define MSG {0xFE,0xED,0xBE,0xEF,0x00,0x00,0x00,0x00,0x00,0x012,0x00,0x08,\ |
|||
#define WIDTH 18 |
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
|||
#define HEIGHT 8 |
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
|||
#define FRAMEDURATION 40000 |
|||
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} |
|||
#define MSG {0xFE,0xED,0xBE,0xEF,0x00,0x00,0x00,0x00,0x00,0x012,0x00,0x08,\ |
|||
static int sock; |
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
|||
static unsigned char msg[156]=MSG; |
|||
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 int sock; |
|||
static unsigned char msg[156]=MSG; |
|||
static unsigned char scalmsg[10] = {0x11, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0xAA, 0xCC, 0x00}; |
|||
BlinkenXmmsConfig blinken_cfg; |
|||
void our_init(); |
|||
void our_cleanup(); |
|||
void our_playback_start(); |
|||
void our_playback_stop(); |
|||
void our_render_freq(gint16 data[1][256]); |
|||
static gdouble scale; |
|||
static gint16 bar_heights[NUM_BANDS]; |
|||
void blinken_init(); |
|||
VisPlugin g_our_plugin = |
|||
void blinken_playback_start(); |
|||
{ |
|||
void blinken_playback_stop(); |
|||
NULL, /* handle */ |
|||
void blinken_render_freq(gint16 data[1][256]); |
|||
NULL, /* filename */ |
|||
0, /* session id */ |
|||
"blinken_xmms", /* description */ |
|||
0, /* 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 */ |
|||
}; |
|||
static long int timer; |
|||
struct timeval tp; |
|||
VisPlugin g_blinken_plugin = |
|||
{ |
|||
NULL, /* handle */ |
|||
return( & g_our_plugin); |
|||
NULL, /* filename */ |
|||
} |
|||
0, /* session id */ |
|||
"Blinken_XMMS", /* description */ |
|||
0, /* PCM Channels */ |
|||
1, /* Freq. Channels */ |
|||
/* Callbacks ... */ |
|||
blinken_init, /* init */ |
|||
blinken_cleanup, /* cleanup */ |
|||
NULL, /* about-dialog */ |
|||
blinken_configure, /* configure-dialog */ |
|||
NULL, /* disable-plugin */ |
|||
blinken_playback_start, /* playback-start */ |
|||
blinken_playback_stop, /* playback-top */ |
|||
NULL, /* render-pcm */ |
|||
blinken_render_freq /* render-freq */ |
|||
}; |
|||
VisPlugin *get_vplugin_info(void) |
|||
void our_init() |
|||
{ |
|||
return( & g_blinken_plugin); |
|||
if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) |
|||
} |
|||
{ |
|||
printf("couldn't create socket"); |
|||
our_cleanup(); // programm mit fehlercode 1 beenden |
|||
exit(1); |
|||
} |
|||
/* Read current settings from the xmms config file */ |
|||
// Struktur anlegen, mit Nullen initialisieren und füllen |
|||
void blinken_read_config(void) |
|||
struct sockaddr_in dest_addr; |
|||
{ |
|||
memset(&dest_addr, 0, sizeof(dest_addr)); // alles mit Nullen fuellen |
|||
ConfigFile *cfg; |
|||
dest_addr.sin_family = AF_INET; // muss hier nochmal stehen |
|||
gchar *filename; |
|||
dest_addr.sin_port = htons(2323); // auf dem Port sollte UDP laufen |
|||
dest_addr.sin_addr.s_addr = inet_addr("127.0.0.1"); // IP Adresse von 'localhost' |
|||
filename = g_strconcat(g_get_home_dir(), "/.xmms/config", NULL); |
|||
cfg = xmms_cfg_open_file(filename); |
|||
if (cfg) |
|||
{ |
|||
xmms_cfg_read_string(cfg, "Blinken_XMMS", "blinkenip", &blinken_cfg.ip); |
|||
xmms_cfg_read_int(cfg, "Blinken_XMMS", "blinkenport", &blinken_cfg.port); |
|||
xmms_cfg_free(cfg); |
|||
} |
|||
g_free(filename); |
|||
if (blinken_cfg.ip==NULL) { |
|||
blinken_cfg.ip = g_strdup("127.0.0.1"); |
|||
blinken_cfg.port = 2323; |
|||
} |
|||
} |
|||
/* Save current settings to the xmms config file */ |
|||
if (connect(sock, (struct sockaddr*) &dest_addr, sizeof(dest_addr)) == -1) |
|||
void blinken_save_config(void) |
|||
{ |
|||
{ |
|||
printf("couldn't connect to 127.0.0.1:2323"); |
|||
ConfigFile *cfgfile; |
|||
our_cleanup(); |
|||
gchar *filename; |
|||
exit(2); // mit fehlercode aussteigen |
|||
} |
|||
filename = g_strconcat(g_get_home_dir(), "/.xmms/config", NULL); |
|||
send(sock, msg, 156, 0); // senden |
|||
cfgfile = xmms_cfg_open_file(filename); |
|||
scale = (HEIGHT + 1)/ log(256); |
|||
if (!cfgfile) |
|||
} |
|||
cfgfile = xmms_cfg_new(); |
|||
xmms_cfg_write_string(cfgfile, "Blinken_XMMS", "blinkenip", blinken_cfg.ip); |
|||
xmms_cfg_write_int(cfgfile, "Blinken_XMMS", "blinkenport", blinken_cfg.port); |
|||
xmms_cfg_write_file(cfgfile, filename); |
|||
xmms_cfg_free(cfgfile); |
|||
g_free(filename); |
|||
} |
|||
void blinken_udp_init(void) |
|||
{ |
|||
if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) |
|||
{ |
|||
printf("couldn't create socket"); |
|||
blinken_cleanup(); |
|||
exit(1); |
|||
} |
|||
struct sockaddr_in dest_addr; |
|||
memset(&dest_addr, 0, sizeof(dest_addr)); |
|||
dest_addr.sin_family = AF_INET; |
|||
dest_addr.sin_port = htons(blinken_cfg.port); |
|||
dest_addr.sin_addr.s_addr = inet_addr(blinken_cfg.ip); |
|||
if (connect(sock, (struct sockaddr*) &dest_addr, sizeof(dest_addr)) == -1) |
|||
void our_cleanup() |
|||
{ |
|||
{ |
|||
printf("couldn't connect to %s:%d\n",blinken_cfg.ip,blinken_cfg.port); |
|||
close(sock); // wir schliessen den descriptor wieder |
|||
blinken_configure(); |
|||
} |
|||
blinken_cleanup(); |
|||
exit(2); |
|||
} |
|||
//printf("connected to %s:%d\n",blinken_cfg.ip,blinken_cfg.port); |
|||
send(sock, msg, 156, 0); |
|||
} |
|||
void blinken_init() |
|||
{ |
|||
/*printf( "playback_start\n");*/ |
|||
if (blinken_cfg.ip==NULL) |
|||
} |
|||
blinken_read_config(); |
|||
blinken_udp_init(); |
|||
scale = (HEIGHT + 1)/ log(256); |
|||
} |
|||
void blinken_cleanup() |
|||
{ |
|||
close(sock); |
|||
} |
|||
void our_playback_stop() |
|||
{ |
|||
unsigned char msg[156]=MSG; |
|||
send(sock, msg, 156, 0); |
|||
} |
|||
void blinken_playback_start() |
|||
{ |
|||
gettimeofday(&tp,NULL); |
|||
timer=tp.tv_usec; |
|||
//printf( "playback_start\n"); |
|||
} |
|||
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}; |
|||
void blinken_playback_stop() |
|||
for(i = 0; i < NUM_BANDS; i++) |
|||
{ |
|||
unsigned char msg[156]=MSG; |
|||
for(c = xscale[i], y = 0; c < xscale[i + 1]; c++) |
|||
send(sock, msg, 156, 0); |
|||
{ |
|||
} |
|||
if(data[0][c] > y) |
|||
{ |
|||
y = data[0][c]; |
|||
} |
|||
} |
|||
void blinken_render_freq( gint16 data[1][256]) |
|||
y >>= 7; |
|||
{ |
|||
if(y != 0) |
|||
gettimeofday(&tp,NULL); |
|||
{ |
|||
if ((tp.tv_usec-timer)<FRAMEDURATION && (tp.tv_usec-timer)>0) |
|||
y = (gint)(log(y) * scale); |
|||
return; |
|||
if(y > HEIGHT+1) |
|||
//printf( "playback_run %ld\n",tp.tv_usec-timer); |
|||
{ |
|||
timer=tp.tv_usec; |
|||
y = HEIGHT+1; |
|||
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; |
|||
} |
|||
} |
|||
} |
|||
zeile = 0; |
|||
for(i=12;i<=155;i++) |
|||
{ |
|||
j = i-12; |
|||
zeile = j/18; |
|||
spalte = j%18; |
|||
bar_heights[i] = -y+9; |
|||
{ |
|||
msg[i]=0xFF; |
|||
} |
|||
else if((bar_heights[spalte])<zeile+1) |
|||
{ |
|||
msg[i]=scalmsg[bar_heights[spalte]]; |
|||
} |
|||
else |
|||
{ |
|||
msg[i]=0x00; |
|||
} |
|||
} |
} |
||
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> |
</highlightSyntax> |
||
== Installation == |
|||
[[gcc]] -Wall --shared `xmms-config --cflags` -o blinken_xmms.so blinken_xmms.c |
|||
=== blinken_xmms.h === |
|||
install blinken_plugin.so `xmms-config --visualization-plugin-dir` |
|||
<highlightSyntax language="c"> |
|||
Evtl. ist das dev. Paket von xmms erforderlich. |
|||
extern void blinken_udp_init(); |
|||
Nun kann man mit einem Rechtsklick auf das XMMS-Fenster im Menü: Visualisierung-->Visualisierungs-Plugins |
|||
extern void blinken_cleanup(); |
|||
extern void blinken_configure(void); |
|||
blinken-xmms |
|||
extern void blinken_read_config(void); |
|||
extern void blinken_save_config(void); |
|||
typedef struct |
|||
auswählen. Um den UDP-Stream umzuleiten kann z.B |
|||
{ |
|||
gchar *ip; |
|||
gint port; |
|||
} BlinkenXmmsConfig; |
|||
extern BlinkenXmmsConfig blinken_cfg; |
|||
./BlinkenOutput -l 2323 -d /dev/[[lldrv]] |
|||
</highlightSyntax> |
|||
benutzt werden. |
|||
== Test == |
|||
=== configure.h === |
|||
<highlightSyntax remoteFile="http://www.s23.org/w/images/f/f9/Blinken_xmms.c.txt" language="c"></highlightSyntax> |
|||
<highlightSyntax language="c"> |
|||
<tasks> |
|||
[3] Fix "highlightSyntax remoteFile" (mutante) |
|||
</tasks> |
|||
#include <gtk/gtk.h> |
|||
=== The relevant code snippet === |
|||
#include "blinken_xmms.h" |
|||
static GtkWidget *configure_win = NULL; |
|||
static GtkWidget *vbox, *options_frame, *options_vbox; |
|||
static GtkWidget *bbox, *ok, *cancel; |
|||
static GtkWidget *dev_ip, *dev_port; |
|||
static void configure_ok(GtkWidget *w, gpointer data) |
|||
{ |
|||
blinken_cfg.ip = g_strdup(gtk_entry_get_text(GTK_ENTRY(dev_ip))); |
|||
blinken_cfg.port = atoi(gtk_entry_get_text(GTK_ENTRY(dev_port))); |
|||
printf("ip: %s\nport: %d\n",blinken_cfg.ip,blinken_cfg.port); |
|||
blinken_cleanup(); |
|||
blinken_udp_init(); |
|||
blinken_save_config(); |
|||
gtk_widget_destroy(configure_win); |
|||
} |
|||
void blinken_configure (void) |
|||
{ |
|||
GtkWidget *frame, *table, *label, *label_port; |
|||
if(configure_win) |
|||
return; |
|||
blinken_read_config(); |
|||
configure_win = gtk_window_new(GTK_WINDOW_DIALOG); |
|||
gtk_container_set_border_width(GTK_CONTAINER(configure_win), 10); |
|||
gtk_window_set_title(GTK_WINDOW(configure_win), ("Blinken XMMS configuration")); |
|||
gtk_window_set_policy(GTK_WINDOW(configure_win), FALSE, FALSE, FALSE); |
|||
gtk_window_set_position(GTK_WINDOW(configure_win), GTK_WIN_POS_MOUSE); |
|||
gtk_signal_connect(GTK_OBJECT(configure_win), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), |
|||
&configure_win); |
|||
vbox = gtk_vbox_new(FALSE, 5); |
|||
options_frame = gtk_frame_new(("Options:")); |
|||
gtk_container_set_border_width(GTK_CONTAINER(options_frame), 5); |
|||
options_vbox = gtk_vbox_new(FALSE, 5); |
|||
gtk_container_set_border_width(GTK_CONTAINER(options_vbox), 5); |
|||
frame = gtk_frame_new(("Connection")); |
|||
gtk_box_pack_start(GTK_BOX(options_vbox), frame, FALSE, FALSE, 0); |
|||
table = gtk_table_new(2, 1, FALSE); |
|||
gtk_container_set_border_width(GTK_CONTAINER(table), 5); |
|||
gtk_container_add(GTK_CONTAINER(frame), table); |
|||
gtk_table_set_row_spacings(GTK_TABLE(table), 5); |
|||
gtk_table_set_col_spacings(GTK_TABLE(table), 5); |
|||
label = gtk_label_new(("IP Adr.:")); |
|||
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); |
|||
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); |
|||
gtk_widget_show(label); |
|||
dev_ip = gtk_entry_new(); |
|||
gtk_entry_set_text(GTK_ENTRY(dev_ip), blinken_cfg.ip); |
|||
gtk_table_attach_defaults(GTK_TABLE(table), dev_ip, 1, 2, 0, 1); |
|||
gtk_widget_show(dev_ip); |
|||
label_port = gtk_label_new(("Port:")); |
|||
gtk_misc_set_alignment(GTK_MISC(label_port), 1.0, 0.5); |
|||
gtk_table_attach_defaults(GTK_TABLE(table), label_port, 0, 1, 1, 2); |
|||
gtk_widget_show(label_port); |
|||
dev_port = gtk_entry_new(); |
|||
gtk_entry_set_text(GTK_ENTRY(dev_port), g_strdup_printf("%d", blinken_cfg.port)); |
|||
gtk_table_attach_defaults(GTK_TABLE(table), dev_port, 1, 2, 1, 2); |
|||
gtk_widget_show(dev_port); |
|||
gtk_widget_show(table); |
|||
gtk_widget_show(frame); |
|||
gtk_container_add(GTK_CONTAINER(options_frame), options_vbox); |
|||
gtk_widget_show(options_vbox); |
|||
gtk_box_pack_start(GTK_BOX(vbox), options_frame, TRUE, TRUE, 0); |
|||
gtk_widget_show(options_frame); |
|||
bbox = gtk_hbutton_box_new(); |
|||
gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); |
|||
gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); |
|||
gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); |
|||
ok = gtk_button_new_with_label(("OK")); |
|||
gtk_signal_connect(GTK_OBJECT(ok), "clicked", GTK_SIGNAL_FUNC(configure_ok), NULL); |
|||
GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT); |
|||
gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 0); |
|||
gtk_widget_show(ok); |
|||
cancel = gtk_button_new_with_label(("Cancel")); |
|||
gtk_signal_connect_object(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), |
|||
GTK_OBJECT(configure_win)); |
|||
GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); |
|||
gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); |
|||
gtk_widget_show(cancel); |
|||
gtk_widget_show(bbox); |
|||
gtk_container_add(GTK_CONTAINER(configure_win), vbox); |
|||
gtk_widget_show(vbox); |
|||
gtk_widget_show(configure_win); |
|||
gtk_widget_grab_default(ok); |
|||
} |
|||
Here is the relevant code snippet from syntaxHighlightExtension.php. Do you see a problem? |
|||
<highlightSyntax language="php3"> |
|||
/** |
|||
* If its a remote file, open it up and parse the returned contents. |
|||
*/ |
|||
} else if($argv["remoteFile"]){ |
|||
$openFileName = $argv["remoteFile"]; |
|||
$fp = fopen($openFileName, "r"); |
|||
if(!$fp){ |
|||
$output = "Error: Syntax Highlighter could not open the file ".$openFileName."<br />"; |
|||
} else { |
|||
$fileContents = fread($fp, 8096); |
|||
fclose($fp); |
|||
$output .= "<div style=\"font-weight: bold;\"><h1>Code from <a href=\"".$argv["remoteFile"]."\">".$argv["remoteFile"]."</a></h1><pre>\n"; |
|||
$output .= $highlighter->highlight_text($fileContents); |
|||
$output .= "</pre></div>"; |
|||
} |
|||
return $output; |
|||
/** |
|||
* Else we just want to highlight the code within the syntaxHighlight tags. |
|||
*/ |
|||
} else { |
|||
</highlightSyntax> |
</highlightSyntax> |
||
== Installation == |
|||
[[gcc]] -Wall --shared `xmms-config --cflags` -o Blinken_XMMS.so Blinken_XMMS.c |
|||
install Blinken_XMMS.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. Mit einem Klick auf den Konfigurationsknopf ist es möglich die Ziel- IP Adresse und Port einzutragen. Um den UDP-Stream umzuleiten kann z.B |
|||
./BlinkenOutput -l 2323 -d /dev/[[lldrv]] |
|||
benutzt werden. |
|||
== Links == |
== Links == |
||
[ |
[[Blinken_XMMS|download source]] |
||
<tasks> |
|||
[3] ['bitte lokalen Pfad angeben, evtl. Lösung für (siehe oben)'/w/images/f/f9/Blinken_xmms.c.txt download source] (mutante) |
|||
</tasks> |
|||
[[Category:Blinkenlights]] |
[[Category:Blinkenlights]] |
||
Latest revision as of 00:48, 29 February 2008
This page is obsolete. The new Version is here: Blinken_XMMS
blinken_xmms[edit]
Das blinken_xmms ist ein Spectrum-Analyser-Plugin für den Multimedia Player Xmms. Es sendet UDP-Pakete an eine konfigurierbare IP Adresse im EBLP - extended Blinkenlights protocol mit 8x18 Pixeln. Die Ausgabe kann z.B. mit lldrv auf ein BlinkenLEDsPro umgeleitet werden.
Blinkt zu D&B Musik | Konfigurations GUI |
---|---|
Erstellt mit blm2gif | |
(Graustufen werden leider nicht konvertiert), |
Quellcode[edit]
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 und Konfig-GUI!
Blinken_XMMS.c ! Beim Speichern --> Dateiname: Blinken_XMMS.c !
blinken_xmms.h ! Beim Speichern --> Dateiname: blinken_xmms.h !
configure.h ! Beim Speichern --> Dateiname: configure.c !
Blinken_XMMS.c[edit]
<highlightSyntax language="c">
/* Blinken_XMMS : for XMMS - Cross-platform multimedia player
- 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 XMMS.
- /
/* Compile:
- gcc -Wall --shared `xmms-config --cflags` -o Blinken_XMMS.so Blinken_XMMS.c
- Install:
- install Blinken_XMMS.so `xmms-config --visualization-plugin-dir`
- /
- include <stdio.h>
- include <stdlib.h>
- include <unistd.h>
- include <string.h>
- include <math.h>
- include <sys/time.h>
- include <sys/types.h>
- include <sys/socket.h>
- include <netinet/in.h>
- include <arpa/inet.h>
- include <xmms/plugin.h>
- include <xmms/configfile.h>
- include "./configure.c"
- define NUM_BANDS 18
- define WIDTH 18
- define HEIGHT 8
- define FRAMEDURATION 40000
- 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 int sock; static unsigned char msg[156]=MSG; static unsigned char scalmsg[10] = {0x11, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0xAA, 0xCC, 0x00};
BlinkenXmmsConfig blinken_cfg;
static gdouble scale; static gint16 bar_heights[NUM_BANDS];
void blinken_init(); void blinken_playback_start(); void blinken_playback_stop(); void blinken_render_freq(gint16 data[1][256]);
static long int timer; struct timeval tp;
VisPlugin g_blinken_plugin = {
NULL, /* handle */ NULL, /* filename */ 0, /* session id */ "Blinken_XMMS", /* description */ 0, /* PCM Channels */ 1, /* Freq. Channels */ /* Callbacks ... */ blinken_init, /* init */ blinken_cleanup, /* cleanup */ NULL, /* about-dialog */
blinken_configure, /* configure-dialog */
NULL, /* disable-plugin */ blinken_playback_start, /* playback-start */ blinken_playback_stop, /* playback-top */ NULL, /* render-pcm */ blinken_render_freq /* render-freq */
};
VisPlugin *get_vplugin_info(void)
{
return( & g_blinken_plugin);
}
/* Read current settings from the xmms config file */ void blinken_read_config(void) { ConfigFile *cfg; gchar *filename;
filename = g_strconcat(g_get_home_dir(), "/.xmms/config", NULL); cfg = xmms_cfg_open_file(filename);
if (cfg) { xmms_cfg_read_string(cfg, "Blinken_XMMS", "blinkenip", &blinken_cfg.ip); xmms_cfg_read_int(cfg, "Blinken_XMMS", "blinkenport", &blinken_cfg.port);
xmms_cfg_free(cfg); } g_free(filename);
if (blinken_cfg.ip==NULL) { blinken_cfg.ip = g_strdup("127.0.0.1"); blinken_cfg.port = 2323; } }
/* Save current settings to the xmms config file */ void blinken_save_config(void) { ConfigFile *cfgfile; gchar *filename;
filename = g_strconcat(g_get_home_dir(), "/.xmms/config", NULL); cfgfile = xmms_cfg_open_file(filename); if (!cfgfile) cfgfile = xmms_cfg_new(); xmms_cfg_write_string(cfgfile, "Blinken_XMMS", "blinkenip", blinken_cfg.ip); xmms_cfg_write_int(cfgfile, "Blinken_XMMS", "blinkenport", blinken_cfg.port);
xmms_cfg_write_file(cfgfile, filename); xmms_cfg_free(cfgfile); g_free(filename); }
void blinken_udp_init(void) {
if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { printf("couldn't create socket"); blinken_cleanup(); exit(1); }
struct sockaddr_in dest_addr; memset(&dest_addr, 0, sizeof(dest_addr)); dest_addr.sin_family = AF_INET;
dest_addr.sin_port = htons(blinken_cfg.port); dest_addr.sin_addr.s_addr = inet_addr(blinken_cfg.ip);
if (connect(sock, (struct sockaddr*) &dest_addr, sizeof(dest_addr)) == -1) {
printf("couldn't connect to %s:%d\n",blinken_cfg.ip,blinken_cfg.port); blinken_configure();
blinken_cleanup(); exit(2); }
//printf("connected to %s:%d\n",blinken_cfg.ip,blinken_cfg.port);
send(sock, msg, 156, 0);
}
void blinken_init() {
if (blinken_cfg.ip==NULL) blinken_read_config(); blinken_udp_init(); scale = (HEIGHT + 1)/ log(256); }
void blinken_cleanup() {
close(sock);
}
void blinken_playback_start()
{
gettimeofday(&tp,NULL);
timer=tp.tv_usec;
//printf( "playback_start\n");
}
void blinken_playback_stop()
{
unsigned char msg[156]=MSG; send(sock, msg, 156, 0);
}
void blinken_render_freq( gint16 data[1][256])
{
gettimeofday(&tp,NULL);
if ((tp.tv_usec-timer)<FRAMEDURATION && (tp.tv_usec-timer)>0)
return;
//printf( "playback_run %ld\n",tp.tv_usec-timer);
timer=tp.tv_usec;
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>
blinken_xmms.h[edit]
<highlightSyntax language="c">
extern void blinken_udp_init(); extern void blinken_cleanup();
extern void blinken_configure(void); extern void blinken_read_config(void); extern void blinken_save_config(void);
typedef struct { gchar *ip; gint port; } BlinkenXmmsConfig;
extern BlinkenXmmsConfig blinken_cfg;
</highlightSyntax>
configure.h[edit]
<highlightSyntax language="c">
- include <gtk/gtk.h>
- include "blinken_xmms.h"
static GtkWidget *configure_win = NULL; static GtkWidget *vbox, *options_frame, *options_vbox; static GtkWidget *bbox, *ok, *cancel;
static GtkWidget *dev_ip, *dev_port;
static void configure_ok(GtkWidget *w, gpointer data) { blinken_cfg.ip = g_strdup(gtk_entry_get_text(GTK_ENTRY(dev_ip))); blinken_cfg.port = atoi(gtk_entry_get_text(GTK_ENTRY(dev_port))); printf("ip: %s\nport: %d\n",blinken_cfg.ip,blinken_cfg.port); blinken_cleanup(); blinken_udp_init(); blinken_save_config(); gtk_widget_destroy(configure_win); }
void blinken_configure (void) { GtkWidget *frame, *table, *label, *label_port; if(configure_win) return;
blinken_read_config();
configure_win = gtk_window_new(GTK_WINDOW_DIALOG); gtk_container_set_border_width(GTK_CONTAINER(configure_win), 10); gtk_window_set_title(GTK_WINDOW(configure_win), ("Blinken XMMS configuration")); gtk_window_set_policy(GTK_WINDOW(configure_win), FALSE, FALSE, FALSE); gtk_window_set_position(GTK_WINDOW(configure_win), GTK_WIN_POS_MOUSE); gtk_signal_connect(GTK_OBJECT(configure_win), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &configure_win);
vbox = gtk_vbox_new(FALSE, 5);
options_frame = gtk_frame_new(("Options:")); gtk_container_set_border_width(GTK_CONTAINER(options_frame), 5);
options_vbox = gtk_vbox_new(FALSE, 5); gtk_container_set_border_width(GTK_CONTAINER(options_vbox), 5);
frame = gtk_frame_new(("Connection")); gtk_box_pack_start(GTK_BOX(options_vbox), frame, FALSE, FALSE, 0);
table = gtk_table_new(2, 1, FALSE); gtk_container_set_border_width(GTK_CONTAINER(table), 5); gtk_container_add(GTK_CONTAINER(frame), table); gtk_table_set_row_spacings(GTK_TABLE(table), 5); gtk_table_set_col_spacings(GTK_TABLE(table), 5);
label = gtk_label_new(("IP Adr.:")); gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); gtk_widget_show(label);
dev_ip = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(dev_ip), blinken_cfg.ip); gtk_table_attach_defaults(GTK_TABLE(table), dev_ip, 1, 2, 0, 1); gtk_widget_show(dev_ip);
label_port = gtk_label_new(("Port:")); gtk_misc_set_alignment(GTK_MISC(label_port), 1.0, 0.5); gtk_table_attach_defaults(GTK_TABLE(table), label_port, 0, 1, 1, 2); gtk_widget_show(label_port);
dev_port = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(dev_port), g_strdup_printf("%d", blinken_cfg.port)); gtk_table_attach_defaults(GTK_TABLE(table), dev_port, 1, 2, 1, 2); gtk_widget_show(dev_port);
gtk_widget_show(table); gtk_widget_show(frame);
gtk_container_add(GTK_CONTAINER(options_frame), options_vbox); gtk_widget_show(options_vbox);
gtk_box_pack_start(GTK_BOX(vbox), options_frame, TRUE, TRUE, 0);
gtk_widget_show(options_frame);
bbox = gtk_hbutton_box_new(); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
ok = gtk_button_new_with_label(("OK")); gtk_signal_connect(GTK_OBJECT(ok), "clicked", GTK_SIGNAL_FUNC(configure_ok), NULL); GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT); gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 0); gtk_widget_show(ok);
cancel = gtk_button_new_with_label(("Cancel"));
gtk_signal_connect_object(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy),
GTK_OBJECT(configure_win));
GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0);
gtk_widget_show(cancel);
gtk_widget_show(bbox);
gtk_container_add(GTK_CONTAINER(configure_win), vbox); gtk_widget_show(vbox); gtk_widget_show(configure_win); gtk_widget_grab_default(ok); }
</highlightSyntax>
Installation[edit]
gcc -Wall --shared `xmms-config --cflags` -o Blinken_XMMS.so Blinken_XMMS.c
install Blinken_XMMS.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. Mit einem Klick auf den Konfigurationsknopf ist es möglich die Ziel- IP Adresse und Port einzutragen. Um den UDP-Stream umzuleiten kann z.B
./BlinkenOutput -l 2323 -d /dev/lldrv
benutzt werden.
Links[edit]
Blinken_xmms has been viewed <counter>page=Blinken_xmms&namespace=0</counter> times.