[PD-cvs] SF.net SVN: pure-data: [10127] trunk/externals/iem/dmx512/src/dmxout.c
zmoelnig at users.sourceforge.net
zmoelnig at users.sourceforge.net
Tue Jul 1 11:56:22 CEST 2008
Revision: 10127
http://pure-data.svn.sourceforge.net/pure-data/?rev=10127&view=rev
Author: zmoelnig
Date: 2008-07-01 02:56:21 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
number of values is now a preprocessor define
(so we can easily change it: dmx4linux seems to be way faster with small (<128) valuearrays)
Modified Paths:
--------------
trunk/externals/iem/dmx512/src/dmxout.c
Modified: trunk/externals/iem/dmx512/src/dmxout.c
===================================================================
--- trunk/externals/iem/dmx512/src/dmxout.c 2008-07-01 09:15:48 UTC (rev 10126)
+++ trunk/externals/iem/dmx512/src/dmxout.c 2008-07-01 09:56:21 UTC (rev 10127)
@@ -23,6 +23,8 @@
static t_class *dmxout_class;
static t_class *dmxout_class2;
+#define NUM_DMXVALUES 512
+
typedef struct _dmxout
{
t_object x_obj;
@@ -33,14 +35,14 @@
t_float x_port;
int x_portrange;
- dmx_t x_values[512];
+ dmx_t x_values[NUM_DMXVALUES];
} t_dmxout;
static void dmxout_clearbuf(t_dmxout*x)
{
int i=0;
- for(i=0; i<512; i++) x->x_values[i]=0;
+ for(i=0; i<NUM_DMXVALUES; i++) x->x_values[i]=0;
}
static void dmxout_close(t_dmxout*x)
@@ -83,7 +85,7 @@
}
}
-static void dmxout_doout(t_dmxout*x, dmx_t values[512])
+static void dmxout_doout(t_dmxout*x, dmx_t values[NUM_DMXVALUES])
{
int i;
if(x->x_device<=0) {
@@ -91,14 +93,14 @@
return;
}
#if 0
- for(i=0; i<512; i++) {
+ for(i=0; i<NUM_DMXVALUES; i++) {
post("dmx[%d]=%03d", i, values[i]);
}
endpost();
#endif
lseek (x->x_device, 0, SEEK_SET); /* set to the current channel */
- write (x->x_device, values, 512); /* write the channel */
+ write (x->x_device, values, NUM_DMXVALUES); /* write the channel */
}
static void dmxout_doout1(t_dmxout*x, short port, unsigned char value)
@@ -117,8 +119,8 @@
pd_error(x, "value %f out of bounds [0..255]", f);
return;
}
- if(x->x_port<0. || x->x_port>512.) {
- pd_error(x, "port %f out of bounds [0..512]", x->x_port);
+ if(x->x_port<0. || x->x_port>NUM_DMXVALUES) {
+ pd_error(x, "port %f out of bounds [0..%d]", x->x_port, NUM_DMXVALUES);
return;
}
@@ -132,9 +134,9 @@
int errors=0;
int port=x->x_port;
- if((port+count)>=512) {
- if(count>512)count=512;
- port=512-count;
+ if((port+count)>=NUM_DMXVALUES) {
+ if(count>NUM_DMXVALUES)count=NUM_DMXVALUES;
+ port=NUM_DMXVALUES-count;
}
dmxout_clearbuf(x);
@@ -162,8 +164,8 @@
short portrange=(short)f_portrange;
- if(baseport<0 || baseport>=512) {
- pd_error(x, "port %f out of bounds [0..512]", f_baseport);
+ if(baseport<0 || baseport>=NUM_DMXVALUES) {
+ pd_error(x, "port %f out of bounds [0..%d]", f_baseport, NUM_DMXVALUES);
baseport =0;
}
x->x_port = baseport;
@@ -175,9 +177,9 @@
portrange=x->x_portrange;
}
- if (baseport+portrange>512) {
- pd_error(x, "upper port exceeds 512! clamping");
- portrange=512-baseport;
+ if (baseport+portrange>NUM_DMXVALUES) {
+ pd_error(x, "upper port exceeds %d! clamping", NUM_DMXVALUES);
+ portrange=NUM_DMXVALUES-baseport;
}
x->x_portrange=portrange;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Pd-cvs
mailing list