1
0
Fork 0
forked from len0rd/rockbox

Accept FS #10244 by Wincent Balin: more pdbox work done for GSoC; also some keyword and line-ending fixes by me

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21626 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Peter D'Hoye 2009-07-03 22:16:11 +00:00
parent eabeb928dd
commit 0d4560cb03
113 changed files with 10637 additions and 4420 deletions

View file

@ -42,6 +42,10 @@ The OSC webpage is http://cnmat.cnmat.berkeley.edu/OpenSoundControl
*/ */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#else /* ROCKBOX */
#ifdef WIN32 #ifdef WIN32
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -52,6 +56,7 @@ The OSC webpage is http://cnmat.cnmat.berkeley.edu/OpenSoundControl
#ifdef UNIX #ifdef UNIX
#include <stdio.h> #include <stdio.h>
#endif #endif
#endif /* ROCKBOX */
/* structure definition of your object */ /* structure definition of your object */
@ -114,6 +119,9 @@ static void StrCopyUntilSlash(char *target, const char *source);
// free // free
static void OSCroute_free(t_OSCroute *x) static void OSCroute_free(t_OSCroute *x)
{ {
#ifdef ROCKBOX
(void) x;
#endif
// freebytes(x->x_vec, x->x_nelement * sizeof(*x->x_vec)); // freebytes(x->x_vec, x->x_nelement * sizeof(*x->x_vec));
} }
@ -154,7 +162,9 @@ void OSCroute_setup(void) {
void *OSCroute_new(t_symbol *s, int argc, t_atom *argv) void *OSCroute_new(t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
t_OSCroute *x = (t_OSCroute *)pd_new(OSCroute_class); // get memory for a new object & initialize t_OSCroute *x = (t_OSCroute *)pd_new(OSCroute_class); // get memory for a new object & initialize
int i; //{{raf}} n not used int i; //{{raf}} n not used
@ -236,6 +246,9 @@ void *OSCroute_new(t_symbol *s, int argc, t_atom *argv)
void OSCroute_version (t_OSCroute *x) { void OSCroute_version (t_OSCroute *x) {
#ifdef ROCKBOX
(void) x;
#endif
// EnterCallback(); // EnterCallback();
post("OSCroute Version " OSC_ROUTE_VERSION post("OSCroute Version " OSC_ROUTE_VERSION
", by Matt Wright. pd jdl, win32: raf.\nOSCroute Compiled " __TIME__ " " __DATE__); ", by Matt Wright. pd jdl, win32: raf.\nOSCroute Compiled " __TIME__ " " __DATE__);
@ -248,15 +261,27 @@ void OSCroute_version (t_OSCroute *x) {
void OSCroute_assist (t_OSCroute *x, void *box, long msg, long arg, void OSCroute_assist (t_OSCroute *x, void *box, long msg, long arg,
char *dstString) { char *dstString) {
#ifdef ROCKBOX
(void) box;
#endif
// EnterCallback(); // EnterCallback();
if (msg==ASSIST_INLET) { if (msg==ASSIST_INLET) {
#ifdef ROCKBOX
strcpy(dstString, "Incoming OSC messages");
#else
sprintf(dstString, "Incoming OSC messages"); sprintf(dstString, "Incoming OSC messages");
#endif
} else if (msg==ASSIST_OUTLET) { } else if (msg==ASSIST_OUTLET) {
if (arg < 0 || arg >= x->x_num) { if (arg < 0 || arg >= x->x_num) {
post("* OSCroute_assist: No outlet corresponds to arg %ld!", arg); post("* OSCroute_assist: No outlet corresponds to arg %ld!", arg);
} else { } else {
#ifdef ROCKBOX
strcpy(dstString, "subaddress + args for prefix ");
strcat(dstString, x->x_prefixes[arg]);
#else
sprintf(dstString, "subaddress + args for prefix %s", x->x_prefixes[arg]); sprintf(dstString, "subaddress + args for prefix %s", x->x_prefixes[arg]);
#endif
} }
} else { } else {
post("* OSCroute_assist: unrecognized message %ld", msg); post("* OSCroute_assist: unrecognized message %ld", msg);
@ -266,6 +291,9 @@ void OSCroute_assist (t_OSCroute *x, void *box, long msg, long arg,
} }
void OSCroute_list(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv) { void OSCroute_list(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv) {
#ifdef ROCKBOX
(void) s;
#endif
// EnterCallback(); // EnterCallback();
if (argc > 0 && argv[0].a_type == A_SYMBOL) { if (argc > 0 && argv[0].a_type == A_SYMBOL) {
/* Ignore the fact that this is a "list" */ /* Ignore the fact that this is a "list" */

View file

@ -1,87 +1,95 @@
/* (C) Guenter Geiger <geiger@epy.co.at> */ /* (C) Guenter Geiger <geiger@epy.co.at> */
/* /*
These filter coefficients computations are taken from These filter coefficients computations are taken from
http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
written by Robert Bristow-Johnson written by Robert Bristow-Johnson
*/ */
#include "m_pd.h" #ifdef ROCKBOX
#ifdef NT #include "plugin.h"
#pragma warning( disable : 4244 ) #include "pdbox.h"
#pragma warning( disable : 4305 ) #include "m_pd.h"
#endif #include "math.h"
#include <math.h> #include "filters.h"
#include "filters.h" #else /* ROCKBOX */
#include "m_pd.h"
/* ------------------- bandpass ----------------------------*/ #ifdef NT
#pragma warning( disable : 4244 )
static t_class *bandpass_class; #pragma warning( disable : 4305 )
#endif
void bandpass_bang(t_rbjfilter *x) #include <math.h>
{ #include "filters.h"
t_atom at[5]; #endif /* ROCKBOX */
t_float omega = e_omega(x->x_freq,x->x_rate);
t_float alpha = e_alpha(x->x_bw* 0.01,omega); /* ------------------- bandpass ----------------------------*/
t_float b1 = 0.;
t_float b0 = alpha; static t_class *bandpass_class;
t_float b2 = -alpha;
t_float a0 = 1 + alpha; void bandpass_bang(t_rbjfilter *x)
t_float a1 = -2.*cos(omega); {
t_float a2 = 1 - alpha; t_atom at[5];
t_float omega = e_omega(x->x_freq,x->x_rate);
/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */ t_float alpha = e_alpha(x->x_bw* 0.01,omega);
t_float b1 = 0.;
if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) { t_float b0 = alpha;
post("bandpass: filter unstable -> resetting"); t_float b2 = -alpha;
a0=1.;a1=0.;a2=0.; t_float a0 = 1 + alpha;
b0=1.;b1=0.;b2=0.; t_float a1 = -2.*cos(omega);
} t_float a2 = 1 - alpha;
SETFLOAT(at,-a1/a0); /* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */
SETFLOAT(at+1,-a2/a0);
SETFLOAT(at+2,b0/a0); if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) {
SETFLOAT(at+3,b1/a0); post("bandpass: filter unstable -> resetting");
SETFLOAT(at+4,b2/a0); a0=1.;a1=0.;a2=0.;
b0=1.;b1=0.;b2=0.;
outlet_list(x->x_obj.ob_outlet,&s_list,5,at); }
}
SETFLOAT(at,-a1/a0);
SETFLOAT(at+1,-a2/a0);
void bandpass_float(t_rbjfilter *x,t_floatarg f) SETFLOAT(at+2,b0/a0);
{ SETFLOAT(at+3,b1/a0);
x->x_freq = f; SETFLOAT(at+4,b2/a0);
bandpass_bang(x);
} outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
}
static void *bandpass_new(t_floatarg f,t_floatarg bw)
{ void bandpass_float(t_rbjfilter *x,t_floatarg f)
t_rbjfilter *x = (t_rbjfilter *)pd_new(bandpass_class); {
x->x_freq = f;
x->x_rate = 44100.0; bandpass_bang(x);
outlet_new(&x->x_obj,&s_float); }
/* floatinlet_new(&x->x_obj, &x->x_gain); */
floatinlet_new(&x->x_obj, &x->x_bw);
if (f > 0.) x->x_freq = f; static void *bandpass_new(t_floatarg f,t_floatarg bw)
if (bw > 0.) x->x_bw = bw; {
return (x); t_rbjfilter *x = (t_rbjfilter *)pd_new(bandpass_class);
}
x->x_rate = 44100.0;
outlet_new(&x->x_obj,&s_float);
void bandpass_setup(void) /* floatinlet_new(&x->x_obj, &x->x_gain); */
{ floatinlet_new(&x->x_obj, &x->x_bw);
bandpass_class = class_new(gensym("bandpass"), (t_newmethod)bandpass_new, 0, if (f > 0.) x->x_freq = f;
sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0); if (bw > 0.) x->x_bw = bw;
class_addbang(bandpass_class,bandpass_bang); return (x);
class_addfloat(bandpass_class,bandpass_float); }
}
void bandpass_setup(void)
{
bandpass_class = class_new(gensym("bandpass"), (t_newmethod)bandpass_new, 0,
sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0);
class_addbang(bandpass_class,bandpass_bang);
class_addfloat(bandpass_class,bandpass_float);
}

File diff suppressed because it is too large Load diff

View file

@ -1,86 +1,93 @@
/* (C) Guenter Geiger <geiger@epy.co.at> */ /* (C) Guenter Geiger <geiger@epy.co.at> */
/* /*
These filter coefficients computations are taken from These filter coefficients computations are taken from
http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
written by Robert Bristow-Johnson written by Robert Bristow-Johnson
*/ */
#include "m_pd.h" #ifdef ROCKBOX
#ifdef NT #include "plugin.h"
#pragma warning( disable : 4244 ) #include "pdbox.h"
#pragma warning( disable : 4305 ) #include "m_pd.h"
#endif #include "math.h"
#include <math.h> #include "filters.h"
#include "filters.h" #else /* ROCKBOX */
#include "m_pd.h"
#ifdef NT
#pragma warning( disable : 4244 )
/* ------------------- equ ----------------------------*/ #pragma warning( disable : 4305 )
static t_class *equ_class; #endif
#include <math.h>
void equ_bang(t_rbjfilter *x) #include "filters.h"
{ #endif /* ROCKBOX */
t_atom at[5];
t_float omega = e_omega(x->x_freq,x->x_rate);
t_float alpha = e_alpha(x->x_bw*0.01,omega); /* ------------------- equ ----------------------------*/
t_float b0 = 1 + alpha*e_A(x->x_gain); static t_class *equ_class;
t_float b1 = -2.*cos(omega);
t_float b2 = 1 - alpha*e_A(x->x_gain); void equ_bang(t_rbjfilter *x)
t_float a0 = 1 + alpha/e_A(x->x_gain); {
t_float a1 = -2.*cos(omega); t_atom at[5];
t_float a2 = 1 - alpha/e_A(x->x_gain); t_float omega = e_omega(x->x_freq,x->x_rate);
t_float alpha = e_alpha(x->x_bw*0.01,omega);
/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw);*/ t_float b0 = 1 + alpha*e_A(x->x_gain);
t_float b1 = -2.*cos(omega);
if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) { t_float b2 = 1 - alpha*e_A(x->x_gain);
post("equ: filter unstable -> resetting"); t_float a0 = 1 + alpha/e_A(x->x_gain);
a0=1.;a1=0.;a2=0.; t_float a1 = -2.*cos(omega);
b0=1.;b1=0.;b2=0.; t_float a2 = 1 - alpha/e_A(x->x_gain);
}
/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw);*/
SETFLOAT(at,-a1/a0);
SETFLOAT(at+1,-a2/a0); if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) {
SETFLOAT(at+2,b0/a0); post("equ: filter unstable -> resetting");
SETFLOAT(at+3,b1/a0); a0=1.;a1=0.;a2=0.;
SETFLOAT(at+4,b2/a0); b0=1.;b1=0.;b2=0.;
}
outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
} SETFLOAT(at,-a1/a0);
SETFLOAT(at+1,-a2/a0);
SETFLOAT(at+2,b0/a0);
void equ_float(t_rbjfilter *x,t_floatarg f) SETFLOAT(at+3,b1/a0);
{ SETFLOAT(at+4,b2/a0);
x->x_freq = f;
equ_bang(x); outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
} }
static void *equ_new(t_floatarg f,t_floatarg g,t_floatarg bw) void equ_float(t_rbjfilter *x,t_floatarg f)
{ {
t_rbjfilter *x = (t_rbjfilter *)pd_new(equ_class); x->x_freq = f;
equ_bang(x);
x->x_rate = 44100.0; }
outlet_new(&x->x_obj,&s_float);
floatinlet_new(&x->x_obj, &x->x_gain);
floatinlet_new(&x->x_obj, &x->x_bw); static void *equ_new(t_floatarg f,t_floatarg g,t_floatarg bw)
if (f > 0.) x->x_freq = f; {
if (bw > 0.) x->x_bw = bw; t_rbjfilter *x = (t_rbjfilter *)pd_new(equ_class);
if (g != 0.) x->x_gain = g;
return (x); x->x_rate = 44100.0;
} outlet_new(&x->x_obj,&s_float);
floatinlet_new(&x->x_obj, &x->x_gain);
floatinlet_new(&x->x_obj, &x->x_bw);
void equalizer_setup(void) if (f > 0.) x->x_freq = f;
{ if (bw > 0.) x->x_bw = bw;
equ_class = class_new(gensym("equalizer"), (t_newmethod)equ_new, 0, if (g != 0.) x->x_gain = g;
sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0); return (x);
class_addbang(equ_class,equ_bang); }
class_addfloat(equ_class,equ_float);
}
void equalizer_setup(void)
{
equ_class = class_new(gensym("equalizer"), (t_newmethod)equ_new, 0,
sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0);
class_addbang(equ_class,equ_bang);
class_addfloat(equ_class,equ_float);
}

View file

@ -1,75 +1,82 @@
/* /*
These filter coefficients computations are taken from These filter coefficients computations are taken from
http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
written by Robert Bristow-Johnson written by Robert Bristow-Johnson
*/ */
#ifndef __GGEE_FILTERS_H__ #ifndef __GGEE_FILTERS_H__
#define __GGEE_FILTERS_H__ #define __GGEE_FILTERS_H__
#ifdef ROCKBOX
#include "math.h"
#ifndef M_PI #else
#define M_PI 3.141593f #include <math.h>
#endif #endif
#ifndef M_PI
#include <math.h> #define M_PI 3.141593f
#define LN2 0.69314718 #endif
#define e_A(g) (pow(10,(g/40.)))
#define e_omega(f,r) (2.0*M_PI*f/r) #define LN2 0.69314718
#define e_alpha(bw,omega) (sin(omega)*sinh(LN2/2. * bw * omega/sin(omega))) #define e_A(g) (pow(10,(g/40.)))
#define e_beta(a,S) (sqrt((a*a + 1)/(S) - (a-1)*(a-1))) #define e_omega(f,r) (2.0*M_PI*f/r)
#define e_alpha(bw,omega) (sin(omega)*sinh(LN2/2. * bw * omega/sin(omega)))
#define e_beta(a,S) (sqrt((a*a + 1)/(S) - (a-1)*(a-1)))
typedef struct _rbjfilter
{
t_object x_obj; typedef struct _rbjfilter
t_float x_rate; {
t_float x_freq; t_object x_obj;
t_float x_gain; t_float x_rate;
t_float x_bw; t_float x_freq;
} t_rbjfilter; t_float x_gain;
t_float x_bw;
} t_rbjfilter;
static int check_stability(t_float fb1,
t_float fb2,
t_float ff1, static int check_stability(t_float fb1,
t_float ff2, t_float fb2,
t_float ff3) t_float ff1,
{ t_float ff2,
float discriminant = fb1 * fb1 + 4 * fb2; t_float ff3)
{
if (discriminant < 0) /* imaginary roots -- resonant filter */ #ifdef ROCKBOX
{ (void) ff1;
/* they're conjugates so we just check that the product (void) ff2;
is less than one */ (void) ff3;
if (fb2 >= -1.0f) goto stable; #endif
} float discriminant = fb1 * fb1 + 4 * fb2;
else /* real roots */
{ if (discriminant < 0) /* imaginary roots -- resonant filter */
/* check that the parabola 1 - fb1 x - fb2 x^2 has a {
vertex between -1 and 1, and that it's nonnegative /* they're conjugates so we just check that the product
at both ends, which implies both roots are in [1-,1]. */ is less than one */
if (fb1 <= 2.0f && fb1 >= -2.0f && if (fb2 >= -1.0f) goto stable;
1.0f - fb1 -fb2 >= 0 && 1.0f + fb1 - fb2 >= 0) }
goto stable; else /* real roots */
} {
return 0; /* check that the parabola 1 - fb1 x - fb2 x^2 has a
stable: vertex between -1 and 1, and that it's nonnegative
return 1; at both ends, which implies both roots are in [1-,1]. */
} if (fb1 <= 2.0f && fb1 >= -2.0f &&
1.0f - fb1 -fb2 >= 0 && 1.0f + fb1 - fb2 >= 0)
goto stable;
}
return 0;
stable:
return 1;
#endif }
#endif

View file

@ -1,379 +1,452 @@
/* (C) Guenter Geiger <geiger@xdv.org> */ /* (C) Guenter Geiger <geiger@xdv.org> */
#include "m_pd.h" #include "m_pd.h"
#include "g_canvas.h" #include "g_canvas.h"
/* ------------------------ gcanvas ----------------------------- */ /* ------------------------ gcanvas ----------------------------- */
#define BACKGROUNDCOLOR "grey" #define BACKGROUNDCOLOR "grey"
#define DEFAULTSIZE 80 #define DEFAULTSIZE 80
static t_class *gcanvas_class; static t_class *gcanvas_class;
typedef struct _gcanvas typedef struct _gcanvas
{ {
t_object x_obj; t_object x_obj;
t_glist * x_glist; t_glist * x_glist;
t_outlet* out2; t_outlet* out2;
t_outlet* out3; t_outlet* out3;
int x_width; int x_width;
int x_height; int x_height;
int x; int x;
int y; int y;
int x_xgrid; int x_xgrid;
int x_ygrid; int x_ygrid;
} t_gcanvas; } t_gcanvas;
static void rectangle(void* cv,void* o,char c,int x, int y,int w,int h,char* color) { static void rectangle(void* cv,void* o,char c,int x, int y,int w,int h,char* color) {
sys_vgui(".x%x.c create rectangle \ #ifdef ROCKBOX
%d %d %d %d -tags %x%c -fill %s\n",cv,x,y,x+w,y+h,o,c,color); (void) cv;
} (void) o;
(void) c;
static void move_object(void* cv,void* o,char c,int x, int y,int w,int h) { (void) x;
sys_vgui(".x%x.c coords %x%c %d %d %d %d\n", (void) y;
cv,o,c,x,y,x+w,y+h); (void) w;
(void) h;
} (void) color;
#else /* ROCKBOX */
static void color_object(void* cv,void* o,char c,char* color) { sys_vgui(".x%x.c create rectangle \
sys_vgui(".x%x.c itemconfigure %x%c -fill %s\n", cv, %d %d %d %d -tags %x%c -fill %s\n",cv,x,y,x+w,y+h,o,c,color);
o, c,color); #endif /* ROCKBOX */
} }
static void delete_object(void* cv,void* o,char c) { static void move_object(void* cv,void* o,char c,int x, int y,int w,int h) {
sys_vgui(".x%x.c delete %x%c\n", #ifdef ROCKBOX
cv, o,c); (void) cv;
} (void) o;
(void) c;
static void line(void* cv,void* o,char c,int x,int y,int w,int h,char* color) { (void) x;
sys_vgui(".x%x.c create line \ (void) y;
%d %d %d %d -tags %x%c -fill %s\n",cv,x,y,x+w,y+h,o,c,color); (void) w;
} (void) h;
#else /* ROCKBOX */
sys_vgui(".x%x.c coords %x%c %d %d %d %d\n",
/* widget helper functions */ cv,o,c,x,y,x+w,y+h);
#endif /* ROCKBOX */
void gcanvas_drawme(t_gcanvas *x, t_glist *glist, int firsttime) }
{
int i; static void color_object(void* cv,void* o,char c,char* color) {
if (firsttime) { #ifdef ROCKBOX
rectangle(glist_getcanvas(glist),x,'a', (void) cv;
x->x_obj.te_xpix, x->x_obj.te_ypix, (void) o;
x->x_width, x->x_height,BACKGROUNDCOLOR); (void) c;
for (i=1;i<x->x_xgrid;i++) (void) color;
line(glist_getcanvas(glist),x,'b'+ i, #else /* ROCKBOX */
x->x_obj.te_xpix + x->x_width*i/x->x_xgrid, sys_vgui(".x%x.c itemconfigure %x%c -fill %s\n", cv,
x->x_obj.te_ypix, o, c,color);
0, x->x_height,"red"); #endif /* ROCKBOX */
for (i=1;i<x->x_ygrid;i++) }
line(glist_getcanvas(glist),x,'B'+ i,
x->x_obj.te_xpix, static void delete_object(void* cv,void* o,char c) {
x->x_obj.te_ypix + x->x_height*i/x->x_ygrid, #ifdef ROCKBOX
x->x_width, 0,"blue"); (void) cv;
} (void) o;
else { (void) c;
move_object( #else /* ROCKBOX */
glist_getcanvas(glist),x,'a', sys_vgui(".x%x.c delete %x%c\n",
x->x_obj.te_xpix, x->x_obj.te_ypix, cv, o,c);
x->x_width, x->x_height); #endif /* ROCKBOX */
for (i=1;i<x->x_xgrid;i++) }
move_object(glist_getcanvas(glist),x,'b'+ i,
x->x_obj.te_xpix + x->x_width*i/x->x_xgrid, static void line(void* cv,void* o,char c,int x,int y,int w,int h,char* color) {
x->x_obj.te_ypix, #ifdef ROCKBOX
0, x->x_height); (void) cv;
for (i=1;i<x->x_ygrid;i++) (void) o;
move_object(glist_getcanvas(glist),x,'B'+ i, (void) c;
x->x_obj.te_xpix, (void) x;
x->x_obj.te_ypix + x->x_height*i/x->x_ygrid, (void) y;
x->x_width, 0); (void) w;
} (void) h;
(void) color;
{ #else /* ROCKBOX */
/* outlets */ sys_vgui(".x%x.c create line \
int n = 3; %d %d %d %d -tags %x%c -fill %s\n",cv,x,y,x+w,y+h,o,c,color);
int nplus, i; #endif /* ROCKBOX */
nplus = (n == 1 ? 1 : n-1); }
for (i = 0; i < n; i++)
{
int onset = x->x_obj.te_xpix + (x->x_width - IOWIDTH) * i / nplus; /* widget helper functions */
if (firsttime)
sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xo%d\n", void gcanvas_drawme(t_gcanvas *x, t_glist *glist, int firsttime)
glist_getcanvas(glist), {
onset, x->x_obj.te_ypix + x->x_height - 1, int i;
onset + IOWIDTH, x->x_obj.te_ypix + x->x_height, if (firsttime) {
x, i); rectangle(glist_getcanvas(glist),x,'a',
else x->x_obj.te_xpix, x->x_obj.te_ypix,
sys_vgui(".x%x.c coords %xo%d %d %d %d %d\n", x->x_width, x->x_height,BACKGROUNDCOLOR);
glist_getcanvas(glist), x, i, for (i=1;i<x->x_xgrid;i++)
onset, x->x_obj.te_ypix + x->x_height - 1, line(glist_getcanvas(glist),x,'b'+ i,
onset + IOWIDTH, x->x_obj.te_ypix + x->x_height); x->x_obj.te_xpix + x->x_width*i/x->x_xgrid,
} x->x_obj.te_ypix,
/* inlets */ 0, x->x_height,"red");
n = 0; for (i=1;i<x->x_ygrid;i++)
nplus = (n == 1 ? 1 : n-1); line(glist_getcanvas(glist),x,'B'+ i,
for (i = 0; i < n; i++) x->x_obj.te_xpix,
{ x->x_obj.te_ypix + x->x_height*i/x->x_ygrid,
int onset = x->x_obj.te_xpix + (x->x_width - IOWIDTH) * i / nplus; x->x_width, 0,"blue");
if (firsttime) }
sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xi%d\n", else {
glist_getcanvas(glist), move_object(
onset, x->x_obj.te_ypix, glist_getcanvas(glist),x,'a',
onset + IOWIDTH, x->x_obj.te_ypix + 1, x->x_obj.te_xpix, x->x_obj.te_ypix,
x, i); x->x_width, x->x_height);
else for (i=1;i<x->x_xgrid;i++)
sys_vgui(".x%x.c coords %xi%d %d %d %d %d\n", move_object(glist_getcanvas(glist),x,'b'+ i,
glist_getcanvas(glist), x, i, x->x_obj.te_xpix + x->x_width*i/x->x_xgrid,
onset, x->x_obj.te_ypix, x->x_obj.te_ypix,
onset + IOWIDTH, x->x_obj.te_ypix + 1); 0, x->x_height);
for (i=1;i<x->x_ygrid;i++)
} move_object(glist_getcanvas(glist),x,'B'+ i,
} x->x_obj.te_xpix,
x->x_obj.te_ypix + x->x_height*i/x->x_ygrid,
} x->x_width, 0);
}
{
/* outlets */
void gcanvas_erase(t_gcanvas* x,t_glist* glist) int n = 3;
{ int nplus, i;
int n,i; nplus = (n == 1 ? 1 : n-1);
delete_object(glist_getcanvas(glist),x,'a'); for (i = 0; i < n; i++)
for (i=1;i<x->x_xgrid;i++) {
delete_object(glist_getcanvas(glist),x,'b'+ i); #ifndef ROCKBOX
for (i=1;i<x->x_ygrid;i++) int onset = x->x_obj.te_xpix + (x->x_width - IOWIDTH) * i / nplus;
delete_object(glist_getcanvas(glist),x,'B'+ i); if (firsttime)
sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xo%d\n",
n = 2; glist_getcanvas(glist),
while (n--) { onset, x->x_obj.te_ypix + x->x_height - 1,
sys_vgui(".x%x.c delete %xo%d\n",glist_getcanvas(glist),x,n); onset + IOWIDTH, x->x_obj.te_ypix + x->x_height,
} x, i);
} else
sys_vgui(".x%x.c coords %xo%d %d %d %d %d\n",
glist_getcanvas(glist), x, i,
onset, x->x_obj.te_ypix + x->x_height - 1,
/* ------------------------ gcanvas widgetbehaviour----------------------------- */ onset + IOWIDTH, x->x_obj.te_ypix + x->x_height);
#endif /* ROCKBOX */
}
static void gcanvas_getrect(t_gobj *z, t_glist *owner, /* inlets */
int *xp1, int *yp1, int *xp2, int *yp2) n = 0;
{ nplus = (n == 1 ? 1 : n-1);
int width, height; for (i = 0; i < n; i++)
t_gcanvas* s = (t_gcanvas*)z; {
#ifndef ROCKBOX
int onset = x->x_obj.te_xpix + (x->x_width - IOWIDTH) * i / nplus;
width = s->x_width; if (firsttime)
height = s->x_height; sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xi%d\n",
*xp1 = s->x_obj.te_xpix; glist_getcanvas(glist),
*yp1 = s->x_obj.te_ypix; onset, x->x_obj.te_ypix,
*xp2 = s->x_obj.te_xpix + width; onset + IOWIDTH, x->x_obj.te_ypix + 1,
*yp2 = s->x_obj.te_ypix + height; x, i);
} else
sys_vgui(".x%x.c coords %xi%d %d %d %d %d\n",
static void gcanvas_displace(t_gobj *z, t_glist *glist, glist_getcanvas(glist), x, i,
int dx, int dy) onset, x->x_obj.te_ypix,
{ onset + IOWIDTH, x->x_obj.te_ypix + 1);
t_gcanvas *x = (t_gcanvas *)z; #endif /* ROCKBOX */
x->x_obj.te_xpix += dx; }
x->x_obj.te_ypix += dy; }
gcanvas_drawme(x, glist, 0);
canvas_fixlinesfor(glist_getcanvas(glist),(t_text*) x); }
}
static void gcanvas_select(t_gobj *z, t_glist *glist, int state)
{
t_gcanvas *x = (t_gcanvas *)z; void gcanvas_erase(t_gcanvas* x,t_glist* glist)
color_object(glist,x,'a',state ? "blue" : BACKGROUNDCOLOR); {
} int n,i;
delete_object(glist_getcanvas(glist),x,'a');
for (i=1;i<x->x_xgrid;i++)
static void gcanvas_activate(t_gobj *z, t_glist *glist, int state) delete_object(glist_getcanvas(glist),x,'b'+ i);
{ for (i=1;i<x->x_ygrid;i++)
/* t_text *x = (t_text *)z; delete_object(glist_getcanvas(glist),x,'B'+ i);
t_rtext *y = glist_findrtext(glist, x);
if (z->g_pd != gatom_class) rtext_activate(y, state);*/ n = 2;
} while (n--) {
#ifndef ROCKBOX
static void gcanvas_delete(t_gobj *z, t_glist *glist) sys_vgui(".x%x.c delete %xo%d\n",glist_getcanvas(glist),x,n);
{ #endif
t_text *x = (t_text *)z; }
canvas_deletelinesfor(glist_getcanvas(glist), x); }
}
static void gcanvas_vis(t_gobj *z, t_glist *glist, int vis) /* ------------------------ gcanvas widgetbehaviour----------------------------- */
{
t_gcanvas* s = (t_gcanvas*)z;
if (vis) static void gcanvas_getrect(t_gobj *z, t_glist *owner,
gcanvas_drawme(s, glist, 1); int *xp1, int *yp1, int *xp2, int *yp2)
else {
gcanvas_erase(s,glist); #ifdef ROCKBOX
} (void) owner;
#endif
/* can we use the normal text save function ?? */ int width, height;
t_gcanvas* s = (t_gcanvas*)z;
static void gcanvas_save(t_gobj *z, t_binbuf *b)
{
t_gcanvas *x = (t_gcanvas *)z; width = s->x_width;
binbuf_addv(b, "ssiisiiii", gensym("#X"),gensym("obj"), height = s->x_height;
(t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, *xp1 = s->x_obj.te_xpix;
gensym("gcanvas"),x->x_width,x->x_height, *yp1 = s->x_obj.te_ypix;
x->x_xgrid, *xp2 = s->x_obj.te_xpix + width;
x->x_ygrid); *yp2 = s->x_obj.te_ypix + height;
binbuf_addv(b, ";"); }
}
static void gcanvas_displace(t_gobj *z, t_glist *glist,
int dx, int dy)
t_widgetbehavior gcanvas_widgetbehavior; {
t_gcanvas *x = (t_gcanvas *)z;
static void gcanvas_motion(t_gcanvas *x, t_floatarg dx, t_floatarg dy) x->x_obj.te_xpix += dx;
{ x->x_obj.te_ypix += dy;
x->x += dx; gcanvas_drawme(x, glist, 0);
x->y += dy; canvas_fixlinesfor(glist_getcanvas(glist),(t_text*) x);
outlet_float(x->out2,x->y); }
outlet_float(x->x_obj.ob_outlet,x->x);
} static void gcanvas_select(t_gobj *z, t_glist *glist, int state)
{
void gcanvas_key(t_gcanvas *x, t_floatarg f) t_gcanvas *x = (t_gcanvas *)z;
{ color_object(glist,x,'a',state ? "blue" : BACKGROUNDCOLOR);
post("key"); }
}
static void gcanvas_activate(t_gobj *z, t_glist *glist, int state)
static void gcanvas_click(t_gcanvas *x, {
t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, #ifdef ROCKBOX
t_floatarg doit,int up) (void) z;
{ (void) glist;
glist_grab(x->x_glist, &x->x_obj.te_g, (t_glistmotionfn) gcanvas_motion, (void) state;
(t_glistkeyfn) NULL, xpos, ypos); #endif
/* t_text *x = (t_text *)z;
x->x = xpos - x->x_obj.te_xpix; t_rtext *y = glist_findrtext(glist, x);
x->y = ypos - x->x_obj.te_ypix; if (z->g_pd != gatom_class) rtext_activate(y, state);*/
outlet_float(x->out2,x->y); }
outlet_float(x->x_obj.ob_outlet,x->x);
outlet_float(x->out3,0); static void gcanvas_delete(t_gobj *z, t_glist *glist)
} {
t_text *x = (t_text *)z;
static int gcanvas_newclick(t_gobj *z, struct _glist *glist, canvas_deletelinesfor(glist_getcanvas(glist), x);
int xpix, int ypix, int shift, int alt, int dbl, int doit) }
{
if (doit)
gcanvas_click((t_gcanvas *)z, (t_floatarg)xpix, (t_floatarg)ypix, static void gcanvas_vis(t_gobj *z, t_glist *glist, int vis)
(t_floatarg)shift, 0, (t_floatarg)alt,dbl); {
t_gcanvas* s = (t_gcanvas*)z;
if (dbl) outlet_float(((t_gcanvas*)z)->out3,1); if (vis)
return (1); gcanvas_drawme(s, glist, 1);
} else
gcanvas_erase(s,glist);
void gcanvas_size(t_gcanvas* x,t_floatarg w,t_floatarg h) { }
x->x_width = w;
x->x_height = h; /* can we use the normal text save function ?? */
gcanvas_drawme(x, x->x_glist, 0);
} static void gcanvas_save(t_gobj *z, t_binbuf *b)
{
static void gcanvas_setwidget(void) t_gcanvas *x = (t_gcanvas *)z;
{ binbuf_addv(b, "ssiisiiii", gensym("#X"),gensym("obj"),
gcanvas_widgetbehavior.w_getrectfn = gcanvas_getrect; (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix,
gcanvas_widgetbehavior.w_displacefn = gcanvas_displace; gensym("gcanvas"),x->x_width,x->x_height,
gcanvas_widgetbehavior.w_selectfn = gcanvas_select; x->x_xgrid,
gcanvas_widgetbehavior.w_activatefn = gcanvas_activate; x->x_ygrid);
gcanvas_widgetbehavior.w_deletefn = gcanvas_delete; binbuf_addv(b, ";");
gcanvas_widgetbehavior.w_visfn = gcanvas_vis; }
gcanvas_widgetbehavior.w_clickfn = gcanvas_newclick;
class_setsavefn(gcanvas_class,gcanvas_save);
} t_widgetbehavior gcanvas_widgetbehavior;
static void gcanvas_motion(t_gcanvas *x, t_floatarg dx, t_floatarg dy)
static void *gcanvas_new(t_symbol* s,t_int ac,t_atom* at) {
{ x->x += dx;
t_gcanvas *x = (t_gcanvas *)pd_new(gcanvas_class); x->y += dy;
outlet_float(x->out2,x->y);
x->x_glist = (t_glist*) canvas_getcurrent(); outlet_float(x->x_obj.ob_outlet,x->x);
}
/* Fetch the width */ void gcanvas_key(t_gcanvas *x, t_floatarg f)
{
x->x_width = DEFAULTSIZE; #ifdef ROCKBOX
if (ac-- > 0) { (void) x;
if (at->a_type != A_FLOAT) (void) f;
error("gcanvas: wrong argument type"); #endif
else post("key");
x->x_width = atom_getfloat(at++); }
if (x->x_width < 0 || x->x_width > 2000) {
error("gcanvas: unallowed width %f",x->x_width); static void gcanvas_click(t_gcanvas *x,
x->x_width = DEFAULTSIZE; t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl,
} t_floatarg doit,int up)
} {
#ifdef ROCKBOX
/* Fetch the height */ (void) shift;
(void) ctrl;
x->x_height = DEFAULTSIZE; (void) doit;
if (ac-- > 0) { (void) up;
if (at->a_type != A_FLOAT) #endif
error("gcanvas: wrong argument type"); glist_grab(x->x_glist, &x->x_obj.te_g, (t_glistmotionfn) gcanvas_motion,
else (t_glistkeyfn) NULL, xpos, ypos);
x->x_height = atom_getfloat(at++);
x->x = xpos - x->x_obj.te_xpix;
if (x->x_height < 0 || x->x_height > 2000) { x->y = ypos - x->x_obj.te_ypix;
error("gcanvas: unallowed height %f",x->x_height); outlet_float(x->out2,x->y);
x->x_width = DEFAULTSIZE; outlet_float(x->x_obj.ob_outlet,x->x);
} outlet_float(x->out3,0);
} }
/* Fetch the xgrid */ static int gcanvas_newclick(t_gobj *z, struct _glist *glist,
int xpix, int ypix, int shift, int alt, int dbl, int doit)
x->x_xgrid = 0; {
if (ac-- > 0) { #ifdef ROCKBOX
if (at->a_type != A_FLOAT) (void) glist;
error("gcanvas: wrong argument type"); #endif
else if (doit)
x->x_xgrid = atom_getfloat(at++); gcanvas_click((t_gcanvas *)z, (t_floatarg)xpix, (t_floatarg)ypix,
(t_floatarg)shift, 0, (t_floatarg)alt,dbl);
if (x->x_xgrid < 0 || x->x_xgrid > x->x_width/2) {
error("gcanvas: unallowed xgrid %f",x->x_xgrid); if (dbl) outlet_float(((t_gcanvas*)z)->out3,1);
x->x_xgrid = 0; return (1);
} }
}
void gcanvas_size(t_gcanvas* x,t_floatarg w,t_floatarg h) {
/* Fetch the ygrid */ x->x_width = w;
x->x_height = h;
x->x_ygrid = 0; gcanvas_drawme(x, x->x_glist, 0);
if (ac-- > 0) { }
if (at->a_type != A_FLOAT)
error("gcanvas: wrong argument type"); static void gcanvas_setwidget(void)
else {
x->x_ygrid = atom_getfloat(at++); gcanvas_widgetbehavior.w_getrectfn = gcanvas_getrect;
gcanvas_widgetbehavior.w_displacefn = gcanvas_displace;
if (x->x_ygrid < 0 || x->x_ygrid > x->x_height/2) { gcanvas_widgetbehavior.w_selectfn = gcanvas_select;
error("gcanvas: unallowed xgrid %f",x->x_ygrid); gcanvas_widgetbehavior.w_activatefn = gcanvas_activate;
x->x_ygrid = 0; gcanvas_widgetbehavior.w_deletefn = gcanvas_delete;
} gcanvas_widgetbehavior.w_visfn = gcanvas_vis;
} gcanvas_widgetbehavior.w_clickfn = gcanvas_newclick;
class_setsavefn(gcanvas_class,gcanvas_save);
outlet_new(&x->x_obj, &s_float); }
x->out2 = outlet_new(&x->x_obj, &s_float);
x->out3 = outlet_new(&x->x_obj, &s_float);
return (x); static void *gcanvas_new(t_symbol* s,t_int ac,t_atom* at)
} {
#ifdef ROCKBOX
(void) s;
#endif
void gcanvas_setup(void) t_gcanvas *x = (t_gcanvas *)pd_new(gcanvas_class);
{
gcanvas_class = class_new(gensym("gcanvas"), (t_newmethod)gcanvas_new, 0, x->x_glist = (t_glist*) canvas_getcurrent();
sizeof(t_gcanvas),0, A_GIMME,0);
class_addmethod(gcanvas_class, (t_method)gcanvas_click, gensym("click"), /* Fetch the width */
A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
class_addmethod(gcanvas_class, (t_method)gcanvas_size, gensym("size"), x->x_width = DEFAULTSIZE;
A_FLOAT, A_FLOAT, 0); if (ac-- > 0) {
if (at->a_type != A_FLOAT)
gcanvas_setwidget(); error("gcanvas: wrong argument type");
class_setwidget(gcanvas_class,&gcanvas_widgetbehavior); else
} x->x_width = atom_getfloat(at++);
if (x->x_width < 0 || x->x_width > 2000) {
error("gcanvas: unallowed width %f",x->x_width);
x->x_width = DEFAULTSIZE;
}
}
/* Fetch the height */
x->x_height = DEFAULTSIZE;
if (ac-- > 0) {
if (at->a_type != A_FLOAT)
error("gcanvas: wrong argument type");
else
x->x_height = atom_getfloat(at++);
if (x->x_height < 0 || x->x_height > 2000) {
error("gcanvas: unallowed height %f",x->x_height);
x->x_width = DEFAULTSIZE;
}
}
/* Fetch the xgrid */
x->x_xgrid = 0;
if (ac-- > 0) {
if (at->a_type != A_FLOAT)
error("gcanvas: wrong argument type");
else
x->x_xgrid = atom_getfloat(at++);
if (x->x_xgrid < 0 || x->x_xgrid > x->x_width/2) {
error("gcanvas: unallowed xgrid %f",x->x_xgrid);
x->x_xgrid = 0;
}
}
/* Fetch the ygrid */
x->x_ygrid = 0;
if (ac-- > 0) {
if (at->a_type != A_FLOAT)
error("gcanvas: wrong argument type");
else
x->x_ygrid = atom_getfloat(at++);
if (x->x_ygrid < 0 || x->x_ygrid > x->x_height/2) {
error("gcanvas: unallowed xgrid %f",x->x_ygrid);
x->x_ygrid = 0;
}
}
outlet_new(&x->x_obj, &s_float);
x->out2 = outlet_new(&x->x_obj, &s_float);
x->out3 = outlet_new(&x->x_obj, &s_float);
return (x);
}
void gcanvas_setup(void)
{
gcanvas_class = class_new(gensym("gcanvas"), (t_newmethod)gcanvas_new, 0,
sizeof(t_gcanvas),0, A_GIMME,0);
class_addmethod(gcanvas_class, (t_method)gcanvas_click, gensym("click"),
A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
class_addmethod(gcanvas_class, (t_method)gcanvas_size, gensym("size"),
A_FLOAT, A_FLOAT, 0);
gcanvas_setwidget();
class_setwidget(gcanvas_class,&gcanvas_widgetbehavior);
}

View file

@ -1,85 +1,94 @@
/* (C) Guenter Geiger <geiger@epy.co.at> */ /* (C) Guenter Geiger <geiger@epy.co.at> */
/* /*
These filter coefficients computations are taken from These filter coefficients computations are taken from
http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
written by Robert Bristow-Johnson written by Robert Bristow-Johnson
*/ */
#include "m_pd.h"
#ifdef NT #ifdef ROCKBOX
#pragma warning( disable : 4244 ) #include "plugin.h"
#pragma warning( disable : 4305 ) #include "pdbox.h"
#endif #include "m_pd.h"
#include <math.h> #include "math.h"
#include "filters.h" #include "filters.h"
#else /* ROCKBOX */
#include "m_pd.h"
/* ------------------- highpass ----------------------------*/ #ifdef NT
#pragma warning( disable : 4244 )
static t_class *highpass_class; #pragma warning( disable : 4305 )
#endif
void highpass_bang(t_rbjfilter *x) #include <math.h>
{ #include "filters.h"
t_atom at[5]; #endif /* ROCKBOX */
t_float omega = e_omega(x->x_freq,x->x_rate);
t_float alpha = e_alpha(x->x_bw* 0.01,omega);
t_float b1 = -(1 + cos(omega)); /* ------------------- highpass ----------------------------*/
t_float b0 = -b1/2.;
t_float b2 = b0; static t_class *highpass_class;
t_float a0 = 1 + alpha;
t_float a1 = -2.*cos(omega); void highpass_bang(t_rbjfilter *x)
t_float a2 = 1 - alpha; {
t_atom at[5];
/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */ t_float omega = e_omega(x->x_freq,x->x_rate);
t_float alpha = e_alpha(x->x_bw* 0.01,omega);
if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) { t_float b1 = -(1 + cos(omega));
post("highpass: filter unstable -> resetting"); t_float b0 = -b1/2.;
a0=1.;a1=0.;a2=0.; t_float b2 = b0;
b0=1.;b1=0.;b2=0.; t_float a0 = 1 + alpha;
} t_float a1 = -2.*cos(omega);
t_float a2 = 1 - alpha;
SETFLOAT(at,-a1/a0);
SETFLOAT(at+1,-a2/a0); /* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */
SETFLOAT(at+2,b0/a0);
SETFLOAT(at+3,b1/a0); if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) {
SETFLOAT(at+4,b2/a0); post("highpass: filter unstable -> resetting");
a0=1.;a1=0.;a2=0.;
outlet_list(x->x_obj.ob_outlet,&s_list,5,at); b0=1.;b1=0.;b2=0.;
} }
SETFLOAT(at,-a1/a0);
void highpass_float(t_rbjfilter *x,t_floatarg f) SETFLOAT(at+1,-a2/a0);
{ SETFLOAT(at+2,b0/a0);
x->x_freq = f; SETFLOAT(at+3,b1/a0);
highpass_bang(x); SETFLOAT(at+4,b2/a0);
}
outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
}
static void *highpass_new(t_floatarg f,t_floatarg bw)
{
t_rbjfilter *x = (t_rbjfilter *)pd_new(highpass_class); void highpass_float(t_rbjfilter *x,t_floatarg f)
{
x->x_rate = 44100.0; x->x_freq = f;
outlet_new(&x->x_obj,&s_float); highpass_bang(x);
/* floatinlet_new(&x->x_obj, &x->x_gain); */ }
floatinlet_new(&x->x_obj, &x->x_bw);
if (f > 0.) x->x_freq = f;
if (bw > 0.) x->x_bw = bw; static void *highpass_new(t_floatarg f,t_floatarg bw)
return (x); {
} t_rbjfilter *x = (t_rbjfilter *)pd_new(highpass_class);
x->x_rate = 44100.0;
void highpass_setup(void) outlet_new(&x->x_obj,&s_float);
{ /* floatinlet_new(&x->x_obj, &x->x_gain); */
highpass_class = class_new(gensym("highpass"), (t_newmethod)highpass_new, 0, floatinlet_new(&x->x_obj, &x->x_bw);
sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0); if (f > 0.) x->x_freq = f;
class_addbang(highpass_class,highpass_bang); if (bw > 0.) x->x_bw = bw;
class_addfloat(highpass_class,highpass_float); return (x);
} }
void highpass_setup(void)
{
highpass_class = class_new(gensym("highpass"), (t_newmethod)highpass_new, 0,
sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0);
class_addbang(highpass_class,highpass_bang);
class_addfloat(highpass_class,highpass_float);
}

View file

@ -1,90 +1,98 @@
/* (C) Guenter Geiger <geiger@epy.co.at> */ /* (C) Guenter Geiger <geiger@epy.co.at> */
/* /*
These filter coefficients computations are taken from These filter coefficients computations are taken from
http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
written by Robert Bristow-Johnson written by Robert Bristow-Johnson
*/ */
#include "m_pd.h" #ifdef ROCKBOX
#ifdef NT #include "plugin.h"
#pragma warning( disable : 4244 ) #include "pdbox.h"
#pragma warning( disable : 4305 ) #include "m_pd.h"
#endif #include "math.h"
#include <math.h> #include "filters.h"
#include "filters.h" #else /* ROCKBOX */
#include "m_pd.h"
#ifdef NT
/* ------------------- highshelf ----------------------------*/ #pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
static t_class *highshelf_class; #endif
#include <math.h>
void highshelf_bang(t_rbjfilter *x) #include "filters.h"
{ #endif /* ROCKBOX */
t_atom at[5];
t_float omega = e_omega(x->x_freq,x->x_rate);
t_float A = e_A(x->x_gain); /* ------------------- highshelf ----------------------------*/
t_float cs = cos(omega);
t_float sn = sin(omega); static t_class *highshelf_class;
t_float beta = e_beta(A,x->x_bw* 0.01);
void highshelf_bang(t_rbjfilter *x)
t_float b0 = A*((A+1) + (A-1)*cs + beta*sn); {
t_float b1 =-2.*A*((A-1) + (A+1)*cs); t_atom at[5];
t_float b2 = A*((A+1) + (A-1)*cs - beta*sn); t_float omega = e_omega(x->x_freq,x->x_rate);
t_float a0 = ((A+1) - (A-1)*cs + beta*sn); t_float A = e_A(x->x_gain);
t_float a1 = 2.*((A-1) - (A+1)*cs); t_float cs = cos(omega);
t_float a2 = ((A+1) - (A-1)*cs - beta*sn); t_float sn = sin(omega);
t_float beta = e_beta(A,x->x_bw* 0.01);
/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw);*/
t_float b0 = A*((A+1) + (A-1)*cs + beta*sn);
if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) { t_float b1 =-2.*A*((A-1) + (A+1)*cs);
post("highshelf: filter unstable -> resetting"); t_float b2 = A*((A+1) + (A-1)*cs - beta*sn);
a0=1.;a1=0.;a2=0.; t_float a0 = ((A+1) - (A-1)*cs + beta*sn);
b0=1.;b1=0.;b2=0.; t_float a1 = 2.*((A-1) - (A+1)*cs);
} t_float a2 = ((A+1) - (A-1)*cs - beta*sn);
SETFLOAT(at,-a1/a0); /* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw);*/
SETFLOAT(at+1,-a2/a0);
SETFLOAT(at+2,b0/a0); if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) {
SETFLOAT(at+3,b1/a0); post("highshelf: filter unstable -> resetting");
SETFLOAT(at+4,b2/a0); a0=1.;a1=0.;a2=0.;
b0=1.;b1=0.;b2=0.;
outlet_list(x->x_obj.ob_outlet,&s_list,5,at); }
}
SETFLOAT(at,-a1/a0);
SETFLOAT(at+1,-a2/a0);
void highshelf_float(t_rbjfilter *x,t_floatarg f) SETFLOAT(at+2,b0/a0);
{ SETFLOAT(at+3,b1/a0);
x->x_freq = f; SETFLOAT(at+4,b2/a0);
highshelf_bang(x);
} outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
}
static void *highshelf_new(t_floatarg f,t_floatarg g,t_floatarg bw)
{ void highshelf_float(t_rbjfilter *x,t_floatarg f)
t_rbjfilter *x = (t_rbjfilter *)pd_new(highshelf_class); {
x->x_freq = f;
x->x_rate = 44100.0; highshelf_bang(x);
outlet_new(&x->x_obj,&s_float); }
floatinlet_new(&x->x_obj, &x->x_gain);
floatinlet_new(&x->x_obj, &x->x_bw);
if (f > 0.) x->x_freq = f; static void *highshelf_new(t_floatarg f,t_floatarg g,t_floatarg bw)
if (bw > 0.) x->x_bw = bw; {
if (g != 0.) x->x_gain = g; t_rbjfilter *x = (t_rbjfilter *)pd_new(highshelf_class);
return (x);
} x->x_rate = 44100.0;
outlet_new(&x->x_obj,&s_float);
floatinlet_new(&x->x_obj, &x->x_gain);
void highshelf_setup(void) floatinlet_new(&x->x_obj, &x->x_bw);
{ if (f > 0.) x->x_freq = f;
highshelf_class = class_new(gensym("highshelf"), (t_newmethod)highshelf_new, 0, if (bw > 0.) x->x_bw = bw;
sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0); if (g != 0.) x->x_gain = g;
class_addbang(highshelf_class,highshelf_bang); return (x);
class_addfloat(highshelf_class,highshelf_float); }
}
void highshelf_setup(void)
{
highshelf_class = class_new(gensym("highshelf"), (t_newmethod)highshelf_new, 0,
sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0);
class_addbang(highshelf_class,highshelf_bang);
class_addfloat(highshelf_class,highshelf_float);
}

View file

@ -1,226 +1,242 @@
/* (C) Guenter Geiger <geiger@epy.co.at> */ /* (C) Guenter Geiger <geiger@epy.co.at> */
#include <m_pd.h> #ifdef ROCKBOX
#include <math.h> #include "plugin.h"
#include "pdbox.h"
#ifdef NT #include "m_pd.h"
#pragma warning( disable : 4244 ) #include "math.h"
#pragma warning( disable : 4305 ) #else /* ROCKBOX */
#endif #include <m_pd.h>
#include <math.h>
/* ------------------------ hlshelf ----------------------------- */
#ifdef NT
#pragma warning( disable : 4244 )
#ifndef M_PI #pragma warning( disable : 4305 )
#define M_PI 3.141593f #endif
#endif #endif /* ROCKBOX */
#define SRATE 44100.0 /* ------------------------ hlshelf ----------------------------- */
#define MAX_GAIN 120.0f
static t_class *hlshelf_class; #ifndef M_PI
#define M_PI 3.141593f
#endif
typedef struct _hlshelf
{ #define SRATE 44100.0
t_object x_obj; #define MAX_GAIN 120.0f
float s_rate;
float s_gain0; static t_class *hlshelf_class;
float s_gain1;
float s_gain2;
float s_ltransfq; typedef struct _hlshelf
float s_htransfq; {
float s_lradians; t_object x_obj;
float s_hradians; float s_rate;
} t_hlshelf; float s_gain0;
float s_gain1;
float s_gain2;
int hlshelf_check_stability(t_float fb1, float s_ltransfq;
t_float fb2, float s_htransfq;
t_float ff1, float s_lradians;
t_float ff2, float s_hradians;
t_float ff3) } t_hlshelf;
{
float discriminant = fb1 * fb1 + 4 * fb2;
int hlshelf_check_stability(t_float fb1,
if (discriminant < 0) /* imaginary roots -- resonant filter */ t_float fb2,
{ t_float ff1,
/* they're conjugates so we just check that the product t_float ff2,
is less than one */ t_float ff3)
if (fb2 >= -1.0f) goto stable; {
} #ifdef ROCKBOX
else /* real roots */ (void) ff1;
{ (void) ff2;
/* check that the parabola 1 - fb1 x - fb2 x^2 has a (void) ff3;
vertex between -1 and 1, and that it's nonnegative #endif
at both ends, which implies both roots are in [1-,1]. */ float discriminant = fb1 * fb1 + 4 * fb2;
if (fb1 <= 2.0f && fb1 >= -2.0f &&
1.0f - fb1 -fb2 >= 0 && 1.0f + fb1 - fb2 >= 0) if (discriminant < 0) /* imaginary roots -- resonant filter */
goto stable; {
} /* they're conjugates so we just check that the product
return 0; is less than one */
stable: if (fb2 >= -1.0f) goto stable;
return 1; }
} else /* real roots */
{
/* check that the parabola 1 - fb1 x - fb2 x^2 has a
void hlshelf_check(t_hlshelf *x) vertex between -1 and 1, and that it's nonnegative
{ at both ends, which implies both roots are in [1-,1]. */
if (fb1 <= 2.0f && fb1 >= -2.0f &&
if(x->s_gain0 - x->s_gain1 > MAX_GAIN) { 1.0f - fb1 -fb2 >= 0 && 1.0f + fb1 - fb2 >= 0)
x->s_gain0 = x->s_gain1 + MAX_GAIN; goto stable;
post("setting gain0 to %f",x->s_gain0); }
} return 0;
stable:
return 1;
if(x->s_gain1 > MAX_GAIN) { }
x->s_gain1 = MAX_GAIN;
post("setting gain1 to %f",x->s_gain1);
} void hlshelf_check(t_hlshelf *x)
{
if(x->s_gain2 - x->s_gain1 > MAX_GAIN) {
x->s_gain2 = x->s_gain1 + MAX_GAIN; if(x->s_gain0 - x->s_gain1 > MAX_GAIN) {
post("setting gain2 to %f",x->s_gain2); x->s_gain0 = x->s_gain1 + MAX_GAIN;
} post("setting gain0 to %f",x->s_gain0);
}
/* constrain: 0 <= x->s_ltransfq < x->s_htransfq. */
x->s_ltransfq = (x->s_ltransfq < x->s_htransfq) ? x->s_ltransfq : x->s_htransfq - 0.5f;
if(x->s_gain1 > MAX_GAIN) {
if (x->s_ltransfq < 0) x->s_ltransfq = 0.0f; x->s_gain1 = MAX_GAIN;
post("setting gain1 to %f",x->s_gain1);
x->s_lradians = M_PI * x->s_ltransfq / x->s_rate; }
x->s_hradians= M_PI * (0.5f - (x->s_htransfq / x->s_rate));
if(x->s_gain2 - x->s_gain1 > MAX_GAIN) {
} x->s_gain2 = x->s_gain1 + MAX_GAIN;
post("setting gain2 to %f",x->s_gain2);
}
void hlshelf_bang(t_hlshelf *x)
{ /* constrain: 0 <= x->s_ltransfq < x->s_htransfq. */
t_atom at[6]; x->s_ltransfq = (x->s_ltransfq < x->s_htransfq) ? x->s_ltransfq : x->s_htransfq - 0.5f;
float c0, c1, c2, d0, d1, d2; /* output coefs */
float a1, a2, b1, b2, g1, g2; /* temp coefs */ if (x->s_ltransfq < 0) x->s_ltransfq = 0.0f;
double xf;
x->s_lradians = M_PI * x->s_ltransfq / x->s_rate;
hlshelf_check(x); x->s_hradians= M_PI * (0.5f - (x->s_htransfq / x->s_rate));
/* low shelf */ }
xf = 0.5 * 0.115129255 * (double)(x->s_gain0 - x->s_gain1); /* ln(10) / 20 = 0.115129255 */
if(xf < -200.) /* exp(x) -> 0 */
{ void hlshelf_bang(t_hlshelf *x)
a1 = 1.0f; {
b1 = -1.0f; t_atom at[6];
g1 = 0.0f; float c0, c1, c2, d0, d1, d2; /* output coefs */
} float a1, a2, b1, b2, g1, g2; /* temp coefs */
else double xf;
{
double t = tan(x->s_lradians); hlshelf_check(x);
double e = exp(xf);
double r = t / e; /* low shelf */
double kr = t * e; xf = 0.5 * 0.115129255 * (double)(x->s_gain0 - x->s_gain1); /* ln(10) / 20 = 0.115129255 */
if(xf < -200.) /* exp(x) -> 0 */
a1 = (r - 1) / (r + 1); {
b1 = (kr - 1) / (kr + 1); a1 = 1.0f;
g1 = (kr + 1) / (r + 1); b1 = -1.0f;
} g1 = 0.0f;
}
/* high shelf */ else
xf = 0.5 * 0.115129255 * (double)(x->s_gain2 - x->s_gain1); /* ln(10) / 20 = 0.115129255 */ {
if(xf < -200.) /* exp(x) -> 0 */ double t = tan(x->s_lradians);
{ double e = exp(xf);
a2 = -1.0f; double r = t / e;
b2 = 1.0f; double kr = t * e;
g2 = 0.0f;
} a1 = (r - 1) / (r + 1);
else b1 = (kr - 1) / (kr + 1);
{ g1 = (kr + 1) / (r + 1);
double t = tan(x->s_hradians); }
double e = exp(xf);
double r = t / e; /* high shelf */
double kr = t * e; xf = 0.5 * 0.115129255 * (double)(x->s_gain2 - x->s_gain1); /* ln(10) / 20 = 0.115129255 */
if(xf < -200.) /* exp(x) -> 0 */
a2 = (1 - r) / (1 + r); {
b2 = (1 - kr) / (1 + kr); a2 = -1.0f;
g2 = (1 + kr) / (1 + r); b2 = 1.0f;
} g2 = 0.0f;
}
/* form product */ else
c0 = g1 * g2 * (float)(exp((double)(x->s_gain1) * 0.05f * 2.302585093f)); ; {
c1 = a1 + a2; double t = tan(x->s_hradians);
c2 = a1 * a2; double e = exp(xf);
d0 = 1.0f; double r = t / e;
d1 = b1 + b2; double kr = t * e;
d2 = b1 * b2;
a2 = (1 - r) / (1 + r);
if (!hlshelf_check_stability(-c1/d0,-c2/d0,d0/d0,d1/d0,d2/d0)) { b2 = (1 - kr) / (1 + kr);
post("hlshelf: filter unstable -> resetting"); g2 = (1 + kr) / (1 + r);
c0=1.;c1=0.;c2=0.; }
d0=1.;d1=0.;d2=0.;
} /* form product */
c0 = g1 * g2 * (float)(exp((double)(x->s_gain1) * 0.05f * 2.302585093f)); ;
SETFLOAT(at,-c1/d0); c1 = a1 + a2;
SETFLOAT(at+1,-c2/d0); c2 = a1 * a2;
SETFLOAT(at+2,d0/d0); d0 = 1.0f;
SETFLOAT(at+3,d1/d0); d1 = b1 + b2;
SETFLOAT(at+4,d2/d0); d2 = b1 * b2;
outlet_list(x->x_obj.ob_outlet,&s_list,5,at); if (!hlshelf_check_stability(-c1/d0,-c2/d0,d0/d0,d1/d0,d2/d0)) {
} post("hlshelf: filter unstable -> resetting");
c0=1.;c1=0.;c2=0.;
void hlshelf_float(t_hlshelf *x,t_floatarg f) d0=1.;d1=0.;d2=0.;
{ }
x->s_gain0 = f;
hlshelf_bang(x); SETFLOAT(at,-c1/d0);
} SETFLOAT(at+1,-c2/d0);
SETFLOAT(at+2,d0/d0);
SETFLOAT(at+3,d1/d0);
static void *hlshelf_new(t_symbol* s,t_int argc, t_atom* at) SETFLOAT(at+4,d2/d0);
{
t_hlshelf *x = (t_hlshelf *)pd_new(hlshelf_class); outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
t_float k0 = atom_getfloat(at); }
t_float k1 = atom_getfloat(at+1);
t_float k2 = atom_getfloat(at+2); void hlshelf_float(t_hlshelf *x,t_floatarg f)
t_float f1 = atom_getfloat(at+3); {
t_float f2 = atom_getfloat(at+4); x->s_gain0 = f;
hlshelf_bang(x);
}
f1 = atom_getfloat(at);
f2 = atom_getfloat(at);
static void *hlshelf_new(t_symbol* s,t_int argc, t_atom* at)
if ((f1 == 0.0f && f2 == 0.0f) || f1 > f2){ /* all gains = 0db */ {
f1 = 150.0f; #ifdef ROCKBOX
f2 = 5000.0f; (void) s;
} (void) argc;
#endif
if (f1 < 0) f1 = 0.0f; t_hlshelf *x = (t_hlshelf *)pd_new(hlshelf_class);
if (f2 > SRATE) f2 = .5f*SRATE; t_float k0 = atom_getfloat(at);
t_float k1 = atom_getfloat(at+1);
x->s_rate = SRATE; /* srate default */ t_float k2 = atom_getfloat(at+2);
x->s_gain0 = k0; t_float f1 = atom_getfloat(at+3);
x->s_gain1 = k1; t_float f2 = atom_getfloat(at+4);
x->s_gain2 = k2;
x->s_ltransfq = 0.0f; f1 = atom_getfloat(at);
x->s_htransfq = SRATE/2; f2 = atom_getfloat(at);
x->s_lradians = M_PI * x->s_ltransfq / x->s_rate; if ((f1 == 0.0f && f2 == 0.0f) || f1 > f2){ /* all gains = 0db */
x->s_hradians= M_PI * (0.5f - (x->s_htransfq / x->s_rate)); f1 = 150.0f;
f2 = 5000.0f;
floatinlet_new(&x->x_obj, &x->s_gain1); }
floatinlet_new(&x->x_obj, &x->s_gain2);
floatinlet_new(&x->x_obj, &x->s_ltransfq); if (f1 < 0) f1 = 0.0f;
floatinlet_new(&x->x_obj, &x->s_htransfq); if (f2 > SRATE) f2 = .5f*SRATE;
outlet_new(&x->x_obj, &s_list);
x->s_rate = SRATE; /* srate default */
return (x); x->s_gain0 = k0;
} x->s_gain1 = k1;
x->s_gain2 = k2;
void hlshelf_setup(void)
{ x->s_ltransfq = 0.0f;
hlshelf_class = class_new(gensym("hlshelf"), (t_newmethod)hlshelf_new, 0, x->s_htransfq = SRATE/2;
sizeof(t_hlshelf), 0, A_GIMME, 0);
class_addbang(hlshelf_class,hlshelf_bang); x->s_lradians = M_PI * x->s_ltransfq / x->s_rate;
class_addfloat(hlshelf_class,hlshelf_float); x->s_hradians= M_PI * (0.5f - (x->s_htransfq / x->s_rate));
}
floatinlet_new(&x->x_obj, &x->s_gain1);
floatinlet_new(&x->x_obj, &x->s_gain2);
floatinlet_new(&x->x_obj, &x->s_ltransfq);
floatinlet_new(&x->x_obj, &x->s_htransfq);
outlet_new(&x->x_obj, &s_list);
return (x);
}
void hlshelf_setup(void)
{
hlshelf_class = class_new(gensym("hlshelf"), (t_newmethod)hlshelf_new, 0,
sizeof(t_hlshelf), 0, A_GIMME, 0);
class_addbang(hlshelf_class,hlshelf_bang);
class_addfloat(hlshelf_class,hlshelf_float);
}

View file

@ -23,6 +23,11 @@ typedef struct _image
void image_drawme(t_image *x, t_glist *glist, int firsttime) void image_drawme(t_image *x, t_glist *glist, int firsttime)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
(void) firsttime;
#else /* ROCKBOX */
if (firsttime) { if (firsttime) {
char fname[MAXPDSTRING]; char fname[MAXPDSTRING];
canvas_makefilename(glist_getcanvas(x->x_glist), x->x_fname->s_name, canvas_makefilename(glist_getcanvas(x->x_glist), x->x_fname->s_name,
@ -42,16 +47,20 @@ void image_drawme(t_image *x, t_glist *glist, int firsttime)
glist_getcanvas(glist), x, glist_getcanvas(glist), x,
text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)); text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist));
} }
#endif /* ROCKBOX */
} }
void image_erase(t_image* x,t_glist* glist) void image_erase(t_image* x,t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
int n; int n;
sys_vgui(".x%x.c delete %xS\n", sys_vgui(".x%x.c delete %xS\n",
glist_getcanvas(glist), x); glist_getcanvas(glist), x);
#endif /* ROCKBOX */
} }
@ -80,17 +89,23 @@ static void image_displace(t_gobj *z, t_glist *glist,
t_image *x = (t_image *)z; t_image *x = (t_image *)z;
x->x_obj.te_xpix += dx; x->x_obj.te_xpix += dx;
x->x_obj.te_ypix += dy; x->x_obj.te_ypix += dy;
#ifndef ROCKBOX
sys_vgui(".x%x.c coords %xSEL %d %d %d %d\n", sys_vgui(".x%x.c coords %xSEL %d %d %d %d\n",
glist_getcanvas(glist), x, glist_getcanvas(glist), x,
text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),
text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height); text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height);
#endif
image_drawme(x, glist, 0); image_drawme(x, glist, 0);
canvas_fixlinesfor(glist_getcanvas(glist),(t_text*) x); canvas_fixlinesfor(glist_getcanvas(glist),(t_text*) x);
} }
static void image_select(t_gobj *z, t_glist *glist, int state) static void image_select(t_gobj *z, t_glist *glist, int state)
{ {
#ifdef ROCKBOX
(void) z;
(void) glist;
(void) state;
#else /* ROCKBOX */
t_image *x = (t_image *)z; t_image *x = (t_image *)z;
if (state) { if (state) {
sys_vgui(".x%x.c create rectangle \ sys_vgui(".x%x.c create rectangle \
@ -104,14 +119,17 @@ static void image_select(t_gobj *z, t_glist *glist, int state)
sys_vgui(".x%x.c delete %xSEL\n", sys_vgui(".x%x.c delete %xSEL\n",
glist_getcanvas(glist), x); glist_getcanvas(glist), x);
} }
#endif /* ROCKBOX */
} }
static void image_activate(t_gobj *z, t_glist *glist, int state) static void image_activate(t_gobj *z, t_glist *glist, int state)
{ {
#ifdef ROCKBOX
(void) z;
(void) glist;
(void) state;
#endif
/* t_text *x = (t_text *)z; /* t_text *x = (t_text *)z;
t_rtext *y = glist_findrtext(glist, x); t_rtext *y = glist_findrtext(glist, x);
if (z->g_pd != gatom_class) rtext_activate(y, state);*/ if (z->g_pd != gatom_class) rtext_activate(y, state);*/
@ -154,6 +172,10 @@ void image_size(t_image* x,t_floatarg w,t_floatarg h) {
void image_color(t_image* x,t_symbol* col) void image_color(t_image* x,t_symbol* col)
{ {
#ifdef ROCKBOX
(void) x;
(void) col;
#endif
/* outlet_bang(x->x_obj.ob_outlet); only bang if there was a bang .. /* outlet_bang(x->x_obj.ob_outlet); only bang if there was a bang ..
so color black does the same as bang, but doesn't forward the bang so color black does the same as bang, but doesn't forward the bang
*/ */
@ -167,11 +189,11 @@ static void image_setwidget(void)
image_widgetbehavior.w_activatefn = image_activate; image_widgetbehavior.w_activatefn = image_activate;
image_widgetbehavior.w_deletefn = image_delete; image_widgetbehavior.w_deletefn = image_delete;
image_widgetbehavior.w_visfn = image_vis; image_widgetbehavior.w_visfn = image_vis;
#if (PD_VERSION_MINOR > 31) #if defined(PD_VERSION_MINOR) && (PD_VERSION_MINOR > 31)
image_widgetbehavior.w_clickfn = NULL; image_widgetbehavior.w_clickfn = NULL;
image_widgetbehavior.w_propertiesfn = NULL; image_widgetbehavior.w_propertiesfn = NULL;
#endif #endif
#if PD_MINOR_VERSION < 37 #if defined(PD_VERSION_MINOR) && PD_MINOR_VERSION < 37
image_widgetbehavior.w_savefn = image_save; image_widgetbehavior.w_savefn = image_save;
#endif #endif
} }

View file

@ -1,87 +1,94 @@
/* (C) Guenter Geiger <geiger@epy.co.at> */ /* (C) Guenter Geiger <geiger@epy.co.at> */
/* /*
These filter coefficients computations are taken from These filter coefficients computations are taken from
http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
written by Robert Bristow-Johnson written by Robert Bristow-Johnson
*/ */
#include "m_pd.h" #ifdef ROCKBOX
#ifdef NT #include "plugin.h"
#pragma warning( disable : 4244 ) #include "pdbox.h"
#pragma warning( disable : 4305 ) #include "m_pd.h"
#endif #include "math.h"
#include <math.h> #include "filters.h"
#include "filters.h" #else /* ROCKBOX */
#include "m_pd.h"
#ifdef NT
#pragma warning( disable : 4244 )
/* ------------------- lowpass ----------------------------*/ #pragma warning( disable : 4305 )
#endif
static t_class *lowpass_class; #include <math.h>
#include "filters.h"
void lowpass_bang(t_rbjfilter *x) #endif /* ROCKBOX */
{
t_atom at[5];
t_float omega = e_omega(x->x_freq,x->x_rate); /* ------------------- lowpass ----------------------------*/
t_float alpha = e_alpha(x->x_bw*0.01,omega);
t_float b1 = 1 - cos(omega); static t_class *lowpass_class;
t_float b0 = b1/2.;
t_float b2 = b0; void lowpass_bang(t_rbjfilter *x)
t_float a0 = 1 + alpha; {
t_float a1 = -2.*cos(omega); t_atom at[5];
t_float a2 = 1 - alpha; t_float omega = e_omega(x->x_freq,x->x_rate);
t_float alpha = e_alpha(x->x_bw*0.01,omega);
/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */ t_float b1 = 1 - cos(omega);
t_float b0 = b1/2.;
if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) { t_float b2 = b0;
post("lowpass: filter unstable -> resetting"); t_float a0 = 1 + alpha;
a0=1.;a1=0.;a2=0.; t_float a1 = -2.*cos(omega);
b0=1.;b1=0.;b2=0.; t_float a2 = 1 - alpha;
}
/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */
SETFLOAT(at,-a1/a0);
SETFLOAT(at+1,-a2/a0); if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) {
SETFLOAT(at+2,b0/a0); post("lowpass: filter unstable -> resetting");
SETFLOAT(at+3,b1/a0); a0=1.;a1=0.;a2=0.;
SETFLOAT(at+4,b2/a0); b0=1.;b1=0.;b2=0.;
}
outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
} SETFLOAT(at,-a1/a0);
SETFLOAT(at+1,-a2/a0);
SETFLOAT(at+2,b0/a0);
void lowpass_float(t_rbjfilter *x,t_floatarg f) SETFLOAT(at+3,b1/a0);
{ SETFLOAT(at+4,b2/a0);
x->x_freq = f;
lowpass_bang(x); outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
} }
static void *lowpass_new(t_floatarg f,t_floatarg bw) void lowpass_float(t_rbjfilter *x,t_floatarg f)
{ {
t_rbjfilter *x = (t_rbjfilter *)pd_new(lowpass_class); x->x_freq = f;
lowpass_bang(x);
x->x_rate = 44100.0; }
outlet_new(&x->x_obj,&s_float);
/* floatinlet_new(&x->x_obj, &x->x_gain); */
floatinlet_new(&x->x_obj, &x->x_bw); static void *lowpass_new(t_floatarg f,t_floatarg bw)
{
if (f > 0.) x->x_freq = f; t_rbjfilter *x = (t_rbjfilter *)pd_new(lowpass_class);
if (bw > 0.) x->x_bw = bw;
return (x); x->x_rate = 44100.0;
} outlet_new(&x->x_obj,&s_float);
/* floatinlet_new(&x->x_obj, &x->x_gain); */
floatinlet_new(&x->x_obj, &x->x_bw);
void lowpass_setup(void)
{ if (f > 0.) x->x_freq = f;
lowpass_class = class_new(gensym("lowpass"), (t_newmethod)lowpass_new, 0, if (bw > 0.) x->x_bw = bw;
sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0); return (x);
class_addbang(lowpass_class,lowpass_bang); }
class_addfloat(lowpass_class,lowpass_float);
}
void lowpass_setup(void)
{
lowpass_class = class_new(gensym("lowpass"), (t_newmethod)lowpass_new, 0,
sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0);
class_addbang(lowpass_class,lowpass_bang);
class_addfloat(lowpass_class,lowpass_float);
}

View file

@ -1,91 +1,98 @@
/* (C) Guenter Geiger <geiger@epy.co.at> */ /* (C) Guenter Geiger <geiger@epy.co.at> */
/* /*
These filter coefficients computations are taken from These filter coefficients computations are taken from
http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
written by Robert Bristow-Johnson written by Robert Bristow-Johnson
*/ */
#include "m_pd.h" #ifdef ROCKBOX
#ifdef NT #include "plugin.h"
#pragma warning( disable : 4244 ) #include "pdbox.h"
#pragma warning( disable : 4305 ) #include "m_pd.h"
#endif #include "math.h"
#include <math.h> #include "filters.h"
#include "filters.h" #else /* ROCKBOX */
#include "m_pd.h"
#ifdef NT
#pragma warning( disable : 4244 )
/* ------------------- lowshelf ----------------------------*/ #pragma warning( disable : 4305 )
#endif
static t_class *lowshelf_class; #include <math.h>
#include "filters.h"
void lowshelf_bang(t_rbjfilter *x) #endif /* ROCKBOX */
{
t_atom at[5];
t_float omega = e_omega(x->x_freq,x->x_rate); /* ------------------- lowshelf ----------------------------*/
t_float A = e_A(x->x_gain);
t_float cs = cos(omega); static t_class *lowshelf_class;
t_float sn = sin(omega);
t_float beta = e_beta(A,x->x_bw*0.01); void lowshelf_bang(t_rbjfilter *x)
{
t_float b0 = A*((A+1) - (A-1)*cs + beta*sn); t_atom at[5];
t_float b1 = 2.*A*((A-1) - (A+1)*cs); t_float omega = e_omega(x->x_freq,x->x_rate);
t_float b2 = A*((A+1) - (A-1)*cs - beta*sn); t_float A = e_A(x->x_gain);
t_float a0 = ((A+1) + (A-1)*cs + beta*sn); t_float cs = cos(omega);
t_float a1 = -2.*((A-1) + (A+1)*cs); t_float sn = sin(omega);
t_float a2 = ((A+1) + (A-1)*cs - beta*sn); t_float beta = e_beta(A,x->x_bw*0.01);
/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */ t_float b0 = A*((A+1) - (A-1)*cs + beta*sn);
t_float b1 = 2.*A*((A-1) - (A+1)*cs);
if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) { t_float b2 = A*((A+1) - (A-1)*cs - beta*sn);
post("lowshelf: filter unstable -> resetting"); t_float a0 = ((A+1) + (A-1)*cs + beta*sn);
a0=1.;a1=0.;a2=0.; t_float a1 = -2.*((A-1) + (A+1)*cs);
b0=1.;b1=0.;b2=0.; t_float a2 = ((A+1) + (A-1)*cs - beta*sn);
}
/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */
SETFLOAT(at,-a1/a0);
SETFLOAT(at+1,-a2/a0); if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) {
SETFLOAT(at+2,b0/a0); post("lowshelf: filter unstable -> resetting");
SETFLOAT(at+3,b1/a0); a0=1.;a1=0.;a2=0.;
SETFLOAT(at+4,b2/a0); b0=1.;b1=0.;b2=0.;
}
outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
} SETFLOAT(at,-a1/a0);
SETFLOAT(at+1,-a2/a0);
SETFLOAT(at+2,b0/a0);
void lowshelf_float(t_rbjfilter *x,t_floatarg f) SETFLOAT(at+3,b1/a0);
{ SETFLOAT(at+4,b2/a0);
x->x_freq = f;
lowshelf_bang(x); outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
} }
static void *lowshelf_new(t_floatarg f,t_floatarg g,t_floatarg bw) void lowshelf_float(t_rbjfilter *x,t_floatarg f)
{ {
t_rbjfilter *x = (t_rbjfilter *)pd_new(lowshelf_class); x->x_freq = f;
lowshelf_bang(x);
x->x_rate = 44100.0; }
outlet_new(&x->x_obj,&s_float);
floatinlet_new(&x->x_obj, &x->x_gain);
floatinlet_new(&x->x_obj, &x->x_bw); static void *lowshelf_new(t_floatarg f,t_floatarg g,t_floatarg bw)
if (f > 0.) x->x_freq = f; {
if (bw > 0.) x->x_bw = bw; t_rbjfilter *x = (t_rbjfilter *)pd_new(lowshelf_class);
if (g != 0.) x->x_gain = g;
return (x); x->x_rate = 44100.0;
} outlet_new(&x->x_obj,&s_float);
floatinlet_new(&x->x_obj, &x->x_gain);
floatinlet_new(&x->x_obj, &x->x_bw);
void lowshelf_setup(void) if (f > 0.) x->x_freq = f;
{ if (bw > 0.) x->x_bw = bw;
lowshelf_class = class_new(gensym("lowshelf"), (t_newmethod)lowshelf_new, 0, if (g != 0.) x->x_gain = g;
sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0); return (x);
class_addbang(lowshelf_class,lowshelf_bang); }
class_addfloat(lowshelf_class,lowshelf_float);
}
void lowshelf_setup(void)
{
lowshelf_class = class_new(gensym("lowshelf"), (t_newmethod)lowshelf_new, 0,
sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0);
class_addbang(lowshelf_class,lowshelf_bang);
class_addfloat(lowshelf_class,lowshelf_float);
}

View file

@ -1,184 +1,194 @@
/* (C) Guenter Geiger <geiger@epy.co.at> */ /* (C) Guenter Geiger <geiger@epy.co.at> */
#include "math.h" #include "math.h"
#include <m_pd.h> #ifdef ROCKBOX
#include "m_pd.h"
/* ----------------------------- moog ----------------------------- */ #else
static t_class *moog_class; #include <m_pd.h>
#endif
typedef struct _moog /* ----------------------------- moog ----------------------------- */
{ static t_class *moog_class;
t_object x_obj;
t_pd in2;
t_sample x_1,x_2,x_3,x_4; typedef struct _moog
t_sample y_1,y_2,y_3,y_4; {
} t_moog; t_object x_obj;
t_pd in2;
static void moog_reset(t_moog *x) t_sample x_1,x_2,x_3,x_4;
{ t_sample y_1,y_2,y_3,y_4;
x->x_1 = x->x_2 = x->x_3 = x->x_4 = 0; } t_moog;
x->y_1 = x->y_2 = x->y_3 = x->y_4 = 0;
static void moog_reset(t_moog *x)
} {
x->x_1 = x->x_2 = x->x_3 = x->x_4 = 0;
x->y_1 = x->y_2 = x->y_3 = x->y_4 = 0;
static void *moog_new(t_symbol *s, int argc, t_atom *argv) }
{
if (argc > 1) post("moog~: extra arguments ignored");
{
t_moog *x = (t_moog *)pd_new(moog_class); static void *moog_new(t_symbol *s, int argc, t_atom *argv)
outlet_new(&x->x_obj, &s_signal); {
inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); #ifdef ROCKBOX
inlet_new(&x->x_obj, &x->in2, &s_signal, &s_signal); (void) s;
moog_reset(x); (void) argv;
return (x); #endif
} if (argc > 1) post("moog~: extra arguments ignored");
{
t_moog *x = (t_moog *)pd_new(moog_class);
} outlet_new(&x->x_obj, &s_signal);
inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
inlet_new(&x->x_obj, &x->in2, &s_signal, &s_signal);
moog_reset(x);
static t_sample calc_k(t_sample f,t_sample k) { return (x);
if (k>itofix(4)) k = itofix(4); }
if (k < 0) k = 0;
if (f <= itofix(3800)) return k;
k = k - mult(0.5,(f-idiv(itofix(3800),itofix(4300)))); }
return k;
}
t_int *moog_perform(t_int *w) static t_sample calc_k(t_sample f,t_sample k) {
{ if (k>itofix(4)) k = itofix(4);
t_moog* x = (t_moog*) (w[1]); if (k < 0) k = 0;
t_sample *in1 = (t_sample *)(w[2]); if (f <= itofix(3800)) return k;
t_sample *p = (t_sample *)(w[3]); k = k - mult(0.5,(f-idiv(itofix(3800),itofix(4300))));
t_sample *k = (t_sample *)(w[4]); return k;
}
t_sample *out = (t_sample *)(w[5]);
int n = (int)(w[6]); t_int *moog_perform(t_int *w)
t_sample in; {
t_sample pt,pt1; t_moog* x = (t_moog*) (w[1]);
t_sample *in1 = (t_sample *)(w[2]);
t_sample x1 = x->x_1; t_sample *p = (t_sample *)(w[3]);
t_sample x2 = x->x_2; t_sample *k = (t_sample *)(w[4]);
t_sample x3 = x->x_3;
t_sample x4 = x->x_4; t_sample *out = (t_sample *)(w[5]);
t_sample ys1 = x->y_1; int n = (int)(w[6]);
t_sample ys2 = x->y_2; t_sample in;
t_sample ys3 = x->y_3; t_sample pt,pt1;
t_sample ys4 = x->y_4;
t_sample x1 = x->x_1;
t_sample x2 = x->x_2;
while (n--) { t_sample x3 = x->x_3;
if (*p > itofix(8140)) *p = itofix(8140); t_sample x4 = x->x_4;
*k = calc_k(*p,*k); t_sample ys1 = x->y_1;
pt =*p; t_sample ys2 = x->y_2;
pt1=mult((pt+1),ftofix(0.76923077)); t_sample ys3 = x->y_3;
in = *in1++ - mult(*k,ys4); t_sample ys4 = x->y_4;
ys1 = mult(pt1,in) + mult(0.3,x1) - mult(pt,ys1);
x1 = in;
ys2 = mult(pt1,ys1) + mult(0.3,x2) - mult(pt,ys2); while (n--) {
x2 = ys1; if (*p > itofix(8140)) *p = itofix(8140);
ys3 = mult(pt1,ys2) + mult(0.3,x3) - mult(pt,ys3); *k = calc_k(*p,*k);
x3 = ys2; pt =*p;
ys4 = mult(pt1,ys3) + mult(0.3,x4) - mult(pt,ys4); pt1=mult((pt+1),ftofix(0.76923077));
x4 = ys3; in = *in1++ - mult(*k,ys4);
*out++ = ys4; ys1 = mult(pt1,in) + mult(0.3,x1) - mult(pt,ys1);
} x1 = in;
ys2 = mult(pt1,ys1) + mult(0.3,x2) - mult(pt,ys2);
x2 = ys1;
x->y_1 = ys1; ys3 = mult(pt1,ys2) + mult(0.3,x3) - mult(pt,ys3);
x->y_2 = ys2; x3 = ys2;
x->y_3 = ys3; ys4 = mult(pt1,ys3) + mult(0.3,x4) - mult(pt,ys4);
x->y_4 = ys4; x4 = ys3;
x->x_1 = x1; *out++ = ys4;
x->x_2 = x2; }
x->x_3 = x3;
x->x_4 = x4;
x->y_1 = ys1;
return (w+7); x->y_2 = ys2;
} x->y_3 = ys3;
x->y_4 = ys4;
x->x_1 = x1;
#define CLIP(x) x = ((x) > 1.0 ? (1.0) : (x)) x->x_2 = x2;
x->x_3 = x3;
t_int *moog_perf8(t_int *w) x->x_4 = x4;
{
t_moog* x = (t_moog*) (w[1]); return (w+7);
t_sample *in1 = (t_sample *)(w[2]); }
t_sample *p = (t_sample *)(w[3]);
t_sample *k = (t_sample *)(w[4]);
t_sample *out = (t_sample *)(w[5]); #define CLIP(x) x = ((x) > 1.0 ? (1.0) : (x))
int n = (int)(w[6]);
t_int *moog_perf8(t_int *w)
t_sample x1 = x->x_1; {
t_sample x2 = x->x_2; t_moog* x = (t_moog*) (w[1]);
t_sample x3 = x->x_3; t_sample *in1 = (t_sample *)(w[2]);
t_sample x4 = x->x_4; t_sample *p = (t_sample *)(w[3]);
t_sample ys1 = x->y_1; t_sample *k = (t_sample *)(w[4]);
t_sample ys2 = x->y_2; t_sample *out = (t_sample *)(w[5]);
t_sample ys3 = x->y_3; int n = (int)(w[6]);
t_sample ys4 = x->y_4;
t_sample x1 = x->x_1;
t_sample temp,temp2; t_sample x2 = x->x_2;
t_sample pt,pt1; t_sample x3 = x->x_3;
t_sample in; t_sample x4 = x->x_4;
t_sample ys1 = x->y_1;
while (n--) { t_sample ys2 = x->y_2;
if (*p > itofix(8140)) *p = itofix(8140); t_sample ys3 = x->y_3;
*k = calc_k(*p,*k); t_sample ys4 = x->y_4;
pt =mult(*p, ftofix(0.01*0.0140845)) - ftofix(0.9999999f); #ifndef ROCKBOX
pt1=mult((pt+itofix(1)),ftofix(0.76923077)); t_sample temp,temp2;
in = *in1++ - mult(*k,ys4); #endif
ys1 = mult(pt1,(in + mult(ftofix(0.3),x1))) - mult(pt,ys1); t_sample pt,pt1;
x1 = in; t_sample in;
ys2 = mult(pt1,(ys1 + mult(0.3,x2))) - mult(pt,ys2);
x2 = ys1; while (n--) {
ys3 = mult(pt1,(ys2 + mult(0.3,x3))) - mult(pt,ys3); if (*p > itofix(8140)) *p = itofix(8140);
x3 = ys2; *k = calc_k(*p,*k);
ys4 = mult(pt1,(ys3 + mult(0.3,x4))) - mult(pt,ys4);
x4 = ys3; pt =mult(*p, ftofix(0.01*0.0140845)) - ftofix(0.9999999f);
*out++ = ys4; pt1=mult((pt+itofix(1)),ftofix(0.76923077));
in = *in1++ - mult(*k,ys4);
p++;k++; ys1 = mult(pt1,(in + mult(ftofix(0.3),x1))) - mult(pt,ys1);
} x1 = in;
ys2 = mult(pt1,(ys1 + mult(0.3,x2))) - mult(pt,ys2);
x->y_1 = ys1; x2 = ys1;
x->y_2 = ys2; ys3 = mult(pt1,(ys2 + mult(0.3,x3))) - mult(pt,ys3);
x->y_3 = ys3; x3 = ys2;
x->y_4 = ys4; ys4 = mult(pt1,(ys3 + mult(0.3,x4))) - mult(pt,ys4);
x->x_1 = x1; x4 = ys3;
x->x_2 = x2; *out++ = ys4;
x->x_3 = x3;
x->x_4 = x4; p++;k++;
}
return (w+7);
} x->y_1 = ys1;
x->y_2 = ys2;
void dsp_add_moog(t_moog *x, t_sample *in1, t_sample *in2, t_sample *in3, t_sample *out, int n) x->y_3 = ys3;
{ x->y_4 = ys4;
if (n&7) x->x_1 = x1;
dsp_add(moog_perform, 6,(t_int)x, in1,in2,in3, out, n); x->x_2 = x2;
else x->x_3 = x3;
dsp_add(moog_perf8, 6,(t_int) x, in1, in2, in3, out, n); x->x_4 = x4;
}
return (w+7);
static void moog_dsp(t_moog *x, t_signal **sp) }
{
dsp_add_moog(x,sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec,sp[0]->s_n); void dsp_add_moog(t_moog *x, t_sample *in1, t_sample *in2, t_sample *in3, t_sample *out, int n)
} {
if (n&7)
dsp_add(moog_perform, 6,(t_int)x, in1,in2,in3, out, n);
void moog_tilde_setup(void) else
{ dsp_add(moog_perf8, 6,(t_int) x, in1, in2, in3, out, n);
moog_class = class_new(gensym("moog~"), (t_newmethod)moog_new, 0, }
sizeof(t_moog), 0, A_GIMME, 0);
class_addmethod(moog_class, nullfn, gensym("signal"), 0); static void moog_dsp(t_moog *x, t_signal **sp)
class_addmethod(moog_class, (t_method)moog_reset, gensym("reset"), 0); {
class_addmethod(moog_class, (t_method)moog_dsp, gensym("dsp"), A_NULL); dsp_add_moog(x,sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec,sp[0]->s_n);
} }
void moog_tilde_setup(void)
{
moog_class = class_new(gensym("moog~"), (t_newmethod)moog_new, 0,
sizeof(t_moog), 0, A_GIMME, 0);
class_addmethod(moog_class, nullfn, gensym("signal"), 0);
class_addmethod(moog_class, (t_method)moog_reset, gensym("reset"), 0);
class_addmethod(moog_class, (t_method)moog_dsp, gensym("dsp"), A_NULL);
}

View file

@ -1,85 +1,93 @@
/* (C) Guenter Geiger <geiger@epy.co.at> */ /* (C) Guenter Geiger <geiger@epy.co.at> */
/* /*
These filter coefficients computations are taken from These filter coefficients computations are taken from
http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
written by Robert Bristow-Johnson written by Robert Bristow-Johnson
*/ */
#include "m_pd.h" #ifdef ROCKBOX
#ifdef NT #include "plugin.h"
#pragma warning( disable : 4244 ) #include "pdbox.h"
#pragma warning( disable : 4305 ) #include "m_pd.h"
#endif #include "math.h"
#include <math.h> #include "filters.h"
#include "filters.h" #else /* ROCKBOX */
#include "m_pd.h"
#ifdef NT
#pragma warning( disable : 4244 )
/* ------------------- notch ----------------------------*/ #pragma warning( disable : 4305 )
#endif
static t_class *notch_class; #include <math.h>
#include "filters.h"
void notch_bang(t_rbjfilter *x) #endif /* ROCKBOX */
{
t_atom at[5];
t_float omega = e_omega(x->x_freq,x->x_rate);
t_float alpha = e_alpha(x->x_bw* 0.01,omega); /* ------------------- notch ----------------------------*/
t_float b1 = -2.*cos(omega);
t_float b0 = 1; static t_class *notch_class;
t_float b2 = b0;
t_float a0 = 1 + alpha; void notch_bang(t_rbjfilter *x)
t_float a1 = -2.*cos(omega); {
t_float a2 = 1 - alpha; t_atom at[5];
t_float omega = e_omega(x->x_freq,x->x_rate);
/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */ t_float alpha = e_alpha(x->x_bw* 0.01,omega);
t_float b1 = -2.*cos(omega);
if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) { t_float b0 = 1;
post("notch: filter unstable -> resetting"); t_float b2 = b0;
a0=1.;a1=0.;a2=0.; t_float a0 = 1 + alpha;
b0=1.;b1=0.;b2=0.; t_float a1 = -2.*cos(omega);
} t_float a2 = 1 - alpha;
SETFLOAT(at,-a1/a0); /* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */
SETFLOAT(at+1,-a2/a0);
SETFLOAT(at+2,b0/a0); if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) {
SETFLOAT(at+3,b1/a0); post("notch: filter unstable -> resetting");
SETFLOAT(at+4,b2/a0); a0=1.;a1=0.;a2=0.;
b0=1.;b1=0.;b2=0.;
outlet_list(x->x_obj.ob_outlet,&s_list,5,at); }
}
SETFLOAT(at,-a1/a0);
SETFLOAT(at+1,-a2/a0);
void notch_float(t_rbjfilter *x,t_floatarg f) SETFLOAT(at+2,b0/a0);
{ SETFLOAT(at+3,b1/a0);
x->x_freq = f; SETFLOAT(at+4,b2/a0);
notch_bang(x);
} outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
}
static void *notch_new(t_floatarg f,t_floatarg bw)
{ void notch_float(t_rbjfilter *x,t_floatarg f)
t_rbjfilter *x = (t_rbjfilter *)pd_new(notch_class); {
x->x_freq = f;
x->x_rate = 44100.0; notch_bang(x);
outlet_new(&x->x_obj,&s_float); }
/* floatinlet_new(&x->x_obj, &x->x_gain); */
floatinlet_new(&x->x_obj, &x->x_bw);
if (f > 0.) x->x_freq = f; static void *notch_new(t_floatarg f,t_floatarg bw)
if (bw > 0.) x->x_bw = bw; {
return (x); t_rbjfilter *x = (t_rbjfilter *)pd_new(notch_class);
}
x->x_rate = 44100.0;
outlet_new(&x->x_obj,&s_float);
void notch_setup(void) /* floatinlet_new(&x->x_obj, &x->x_gain); */
{ floatinlet_new(&x->x_obj, &x->x_bw);
notch_class = class_new(gensym("notch"), (t_newmethod)notch_new, 0, if (f > 0.) x->x_freq = f;
sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0); if (bw > 0.) x->x_bw = bw;
class_addbang(notch_class,notch_bang); return (x);
class_addfloat(notch_class,notch_float); }
}
void notch_setup(void)
{
notch_class = class_new(gensym("notch"), (t_newmethod)notch_new, 0,
sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0);
class_addbang(notch_class,notch_bang);
class_addfloat(notch_class,notch_float);
}

File diff suppressed because it is too large Load diff

View file

@ -1,312 +1,312 @@
/* (C) Guenter Geiger <geiger@epy.co.at> */ /* (C) Guenter Geiger <geiger@epy.co.at> */
#include "m_pd.h" #include "m_pd.h"
#ifdef NT #ifdef NT
#pragma warning( disable : 4244 ) #pragma warning( disable : 4244 )
#pragma warning( disable : 4305 ) #pragma warning( disable : 4305 )
#endif #endif
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <signal.h> #include <signal.h>
#include <sched.h> #include <sched.h>
void sys_rmpollfn(int fd); void sys_rmpollfn(int fd);
void sys_addpollfn(int fd, void* fn, void *ptr); void sys_addpollfn(int fd, void* fn, void *ptr);
/* ------------------------ shell ----------------------------- */ /* ------------------------ shell ----------------------------- */
#define INBUFSIZE 1024 #define INBUFSIZE 1024
static t_class *shell_class; static t_class *shell_class;
static void drop_priority(void) static void drop_priority(void)
{ {
#ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_PRIORITY_SCHEDULING
struct sched_param par; struct sched_param par;
int p1 ,p2, p3; int p1 ,p2, p3;
par.sched_priority = 0; par.sched_priority = 0;
sched_setscheduler(0,SCHED_OTHER,&par); sched_setscheduler(0,SCHED_OTHER,&par);
#endif #endif
} }
typedef struct _shell typedef struct _shell
{ {
t_object x_obj; t_object x_obj;
int x_echo; int x_echo;
char *sr_inbuf; char *sr_inbuf;
int sr_inhead; int sr_inhead;
int sr_intail; int sr_intail;
void* x_binbuf; void* x_binbuf;
int fdpipe[2]; int fdpipe[2];
int fdinpipe[2]; int fdinpipe[2];
int pid; int pid;
int x_del; int x_del;
t_outlet* x_done; t_outlet* x_done;
t_clock* x_clock; t_clock* x_clock;
} t_shell; } t_shell;
static int shell_pid; static int shell_pid;
void shell_cleanup(t_shell* x) void shell_cleanup(t_shell* x)
{ {
sys_rmpollfn(x->fdpipe[0]); sys_rmpollfn(x->fdpipe[0]);
if (x->fdpipe[0]>0) close(x->fdpipe[0]); if (x->fdpipe[0]>0) close(x->fdpipe[0]);
if (x->fdpipe[1]>0) close(x->fdpipe[1]); if (x->fdpipe[1]>0) close(x->fdpipe[1]);
if (x->fdinpipe[0]>0) close(x->fdinpipe[0]); if (x->fdinpipe[0]>0) close(x->fdinpipe[0]);
if (x->fdinpipe[1]>0) close(x->fdinpipe[1]); if (x->fdinpipe[1]>0) close(x->fdinpipe[1]);
x->fdpipe[0] = -1; x->fdpipe[0] = -1;
x->fdpipe[1] = -1; x->fdpipe[1] = -1;
x->fdinpipe[0] = -1; x->fdinpipe[0] = -1;
x->fdinpipe[1] = -1; x->fdinpipe[1] = -1;
clock_unset(x->x_clock); clock_unset(x->x_clock);
} }
void shell_check(t_shell* x) void shell_check(t_shell* x)
{ {
int ret; int ret;
int status; int status;
ret = waitpid(x->pid,&status,WNOHANG); ret = waitpid(x->pid,&status,WNOHANG);
if (ret == x->pid) { if (ret == x->pid) {
shell_cleanup(x); shell_cleanup(x);
if (WIFEXITED(status)) { if (WIFEXITED(status)) {
outlet_float(x->x_done,WEXITSTATUS(status)); outlet_float(x->x_done,WEXITSTATUS(status));
} }
else outlet_float(x->x_done,0); else outlet_float(x->x_done,0);
} }
else { else {
if (x->x_del < 100) x->x_del+=2; /* increment poll times */ if (x->x_del < 100) x->x_del+=2; /* increment poll times */
clock_delay(x->x_clock,x->x_del); clock_delay(x->x_clock,x->x_del);
} }
} }
void shell_bang(t_shell *x) void shell_bang(t_shell *x)
{ {
post("bang"); post("bang");
} }
/* snippet from pd's code */ /* snippet from pd's code */
static void shell_doit(void *z, t_binbuf *b) static void shell_doit(void *z, t_binbuf *b)
{ {
t_shell *x = (t_shell *)z; t_shell *x = (t_shell *)z;
int msg, natom = binbuf_getnatom(b); int msg, natom = binbuf_getnatom(b);
t_atom *at = binbuf_getvec(b); t_atom *at = binbuf_getvec(b);
for (msg = 0; msg < natom;) for (msg = 0; msg < natom;)
{ {
int emsg; int emsg;
for (emsg = msg; emsg < natom && at[emsg].a_type != A_COMMA for (emsg = msg; emsg < natom && at[emsg].a_type != A_COMMA
&& at[emsg].a_type != A_SEMI; emsg++) && at[emsg].a_type != A_SEMI; emsg++)
; ;
if (emsg > msg) if (emsg > msg)
{ {
int i; int i;
for (i = msg; i < emsg; i++) for (i = msg; i < emsg; i++)
if (at[i].a_type == A_DOLLAR || at[i].a_type == A_DOLLSYM) if (at[i].a_type == A_DOLLAR || at[i].a_type == A_DOLLSYM)
{ {
pd_error(x, "netreceive: got dollar sign in message"); pd_error(x, "netreceive: got dollar sign in message");
goto nodice; goto nodice;
} }
if (at[msg].a_type == A_FLOAT) if (at[msg].a_type == A_FLOAT)
{ {
if (emsg > msg + 1) if (emsg > msg + 1)
outlet_list(x->x_obj.ob_outlet, 0, emsg-msg, at + msg); outlet_list(x->x_obj.ob_outlet, 0, emsg-msg, at + msg);
else outlet_float(x->x_obj.ob_outlet, at[msg].a_w.w_float); else outlet_float(x->x_obj.ob_outlet, at[msg].a_w.w_float);
} }
else if (at[msg].a_type == A_SYMBOL) else if (at[msg].a_type == A_SYMBOL)
outlet_anything(x->x_obj.ob_outlet, at[msg].a_w.w_symbol, outlet_anything(x->x_obj.ob_outlet, at[msg].a_w.w_symbol,
emsg-msg-1, at + msg + 1); emsg-msg-1, at + msg + 1);
} }
nodice: nodice:
msg = emsg + 1; msg = emsg + 1;
} }
} }
void shell_read(t_shell *x, int fd) void shell_read(t_shell *x, int fd)
{ {
char buf[INBUFSIZE]; char buf[INBUFSIZE];
t_binbuf* bbuf = binbuf_new(); t_binbuf* bbuf = binbuf_new();
int i; int i;
int readto = int readto =
(x->sr_inhead >= x->sr_intail ? INBUFSIZE : x->sr_intail-1); (x->sr_inhead >= x->sr_intail ? INBUFSIZE : x->sr_intail-1);
int ret; int ret;
ret = read(fd, buf,INBUFSIZE-1); ret = read(fd, buf,INBUFSIZE-1);
buf[ret] = '\0'; buf[ret] = '\0';
for (i=0;i<ret;i++) for (i=0;i<ret;i++)
if (buf[i] == '\n') buf[i] = ';'; if (buf[i] == '\n') buf[i] = ';';
if (ret < 0) if (ret < 0)
{ {
error("shell: pipe read error"); error("shell: pipe read error");
sys_rmpollfn(fd); sys_rmpollfn(fd);
x->fdpipe[0] = -1; x->fdpipe[0] = -1;
close(fd); close(fd);
return; return;
} }
else if (ret == 0) else if (ret == 0)
{ {
post("EOF on socket %d\n", fd); post("EOF on socket %d\n", fd);
sys_rmpollfn(fd); sys_rmpollfn(fd);
x->fdpipe[0] = -1; x->fdpipe[0] = -1;
close(fd); close(fd);
return; return;
} }
else else
{ {
int natom; int natom;
t_atom *at; t_atom *at;
binbuf_text(bbuf, buf, strlen(buf)); binbuf_text(bbuf, buf, strlen(buf));
natom = binbuf_getnatom(bbuf); natom = binbuf_getnatom(bbuf);
at = binbuf_getvec(bbuf); at = binbuf_getvec(bbuf);
shell_doit(x,bbuf); shell_doit(x,bbuf);
} }
binbuf_free(bbuf); binbuf_free(bbuf);
} }
static void shell_send(t_shell *x, t_symbol *s,int ac, t_atom *at) static void shell_send(t_shell *x, t_symbol *s,int ac, t_atom *at)
{ {
int i; int i;
char tmp[MAXPDSTRING]; char tmp[MAXPDSTRING];
int size = 0; int size = 0;
if (x->fdinpipe[0] == -1) return; /* nothing to send to */ if (x->fdinpipe[0] == -1) return; /* nothing to send to */
for (i=0;i<ac;i++) { for (i=0;i<ac;i++) {
atom_string(at,tmp+size,MAXPDSTRING - size); atom_string(at,tmp+size,MAXPDSTRING - size);
at++; at++;
size=strlen(tmp); size=strlen(tmp);
tmp[size++] = ' '; tmp[size++] = ' ';
} }
tmp[size-1] = '\0'; tmp[size-1] = '\0';
post("sending %s",tmp); post("sending %s",tmp);
write(x->fdinpipe[0],tmp,strlen(tmp)); write(x->fdinpipe[0],tmp,strlen(tmp));
} }
static void shell_anything(t_shell *x, t_symbol *s, int ac, t_atom *at) static void shell_anything(t_shell *x, t_symbol *s, int ac, t_atom *at)
{ {
int i; int i;
char* argv[20]; char* argv[20];
t_symbol* sym; t_symbol* sym;
if (!strcmp(s->s_name,"send")) { if (!strcmp(s->s_name,"send")) {
post("send"); post("send");
shell_send(x,s,ac,at); shell_send(x,s,ac,at);
return; return;
} }
argv[0] = s->s_name; argv[0] = s->s_name;
if (x->fdpipe[0] != -1) { if (x->fdpipe[0] != -1) {
post("shell: old process still running"); post("shell: old process still running");
kill(x->pid,SIGKILL); kill(x->pid,SIGKILL);
shell_cleanup(x); shell_cleanup(x);
} }
if (pipe(x->fdpipe) < 0) { if (pipe(x->fdpipe) < 0) {
error("unable to create pipe"); error("unable to create pipe");
return; return;
} }
if (pipe(x->fdinpipe) < 0) { if (pipe(x->fdinpipe) < 0) {
error("unable to create input pipe"); error("unable to create input pipe");
return; return;
} }
sys_addpollfn(x->fdpipe[0],shell_read,x); sys_addpollfn(x->fdpipe[0],shell_read,x);
if (!(x->pid = fork())) { if (!(x->pid = fork())) {
int status; int status;
char* cmd = getbytes(1024); char* cmd = getbytes(1024);
char* tcmd = getbytes(1024); char* tcmd = getbytes(1024);
strcpy(cmd,s->s_name); strcpy(cmd,s->s_name);
#if 0 #if 0
for (i=1;i<=ac;i++) { for (i=1;i<=ac;i++) {
argv[i] = getbytes(255); argv[i] = getbytes(255);
atom_string(at,argv[i],255); atom_string(at,argv[i],255);
/* post("argument %s",argv[i]); */ /* post("argument %s",argv[i]); */
at++; at++;
} }
argv[i] = 0; argv[i] = 0;
#endif #endif
for (i=1;i<=ac;i++) { for (i=1;i<=ac;i++) {
atom_string(at,tcmd,255); atom_string(at,tcmd,255);
strcat(cmd," "); strcat(cmd," ");
strcat(cmd,tcmd); strcat(cmd,tcmd);
at++; at++;
} }
/* reassign stdout */ /* reassign stdout */
dup2(x->fdpipe[1],1); dup2(x->fdpipe[1],1);
dup2(x->fdinpipe[1],0); dup2(x->fdinpipe[1],0);
/* drop privileges */ /* drop privileges */
drop_priority(); drop_priority();
seteuid(getuid()); /* lose setuid priveliges */ seteuid(getuid()); /* lose setuid priveliges */
post("executing %s",cmd); post("executing %s",cmd);
system(cmd); system(cmd);
// execvp(s->s_name,argv); // execvp(s->s_name,argv);
exit(0); exit(0);
} }
x->x_del = 4; x->x_del = 4;
clock_delay(x->x_clock,x->x_del); clock_delay(x->x_clock,x->x_del);
if (x->x_echo) if (x->x_echo)
outlet_anything(x->x_obj.ob_outlet, s, ac, at); outlet_anything(x->x_obj.ob_outlet, s, ac, at);
} }
void shell_free(t_shell* x) void shell_free(t_shell* x)
{ {
binbuf_free(x->x_binbuf); binbuf_free(x->x_binbuf);
} }
static void *shell_new(void) static void *shell_new(void)
{ {
t_shell *x = (t_shell *)pd_new(shell_class); t_shell *x = (t_shell *)pd_new(shell_class);
x->x_echo = 0; x->x_echo = 0;
x->fdpipe[0] = -1; x->fdpipe[0] = -1;
x->fdpipe[1] = -1; x->fdpipe[1] = -1;
x->fdinpipe[0] = -1; x->fdinpipe[0] = -1;
x->fdinpipe[1] = -1; x->fdinpipe[1] = -1;
x->sr_inhead = x->sr_intail = 0; x->sr_inhead = x->sr_intail = 0;
if (!(x->sr_inbuf = (char*) malloc(INBUFSIZE))) bug("t_shell");; if (!(x->sr_inbuf = (char*) malloc(INBUFSIZE))) bug("t_shell");;
x->x_binbuf = binbuf_new(); x->x_binbuf = binbuf_new();
outlet_new(&x->x_obj, &s_list); outlet_new(&x->x_obj, &s_list);
x->x_done = outlet_new(&x->x_obj, &s_bang); x->x_done = outlet_new(&x->x_obj, &s_bang);
x->x_clock = clock_new(x, (t_method) shell_check); x->x_clock = clock_new(x, (t_method) shell_check);
return (x); return (x);
} }
void shell_setup(void) void shell_setup(void)
{ {
shell_class = class_new(gensym("shell"), (t_newmethod)shell_new, shell_class = class_new(gensym("shell"), (t_newmethod)shell_new,
(t_method)shell_free,sizeof(t_shell), 0,0); (t_method)shell_free,sizeof(t_shell), 0,0);
class_addbang(shell_class,shell_bang); class_addbang(shell_class,shell_bang);
class_addanything(shell_class, shell_anything); class_addanything(shell_class, shell_anything);
} }

View file

@ -65,12 +65,17 @@ static t_int *sigbiquad_perform(t_int *w)
static void sigbiquad_list(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv) static void sigbiquad_list(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
float fb1 = atom_getfloatarg(0, argc, argv); float fb1 = atom_getfloatarg(0, argc, argv);
float fb2 = atom_getfloatarg(1, argc, argv); float fb2 = atom_getfloatarg(1, argc, argv);
float ff1 = atom_getfloatarg(2, argc, argv); float ff1 = atom_getfloatarg(2, argc, argv);
float ff2 = atom_getfloatarg(3, argc, argv); float ff2 = atom_getfloatarg(3, argc, argv);
float ff3 = atom_getfloatarg(4, argc, argv); float ff3 = atom_getfloatarg(4, argc, argv);
float discriminant = fb1 * fb1 + 4 * fb2; float discriminant = fb1 * fb1 + 4 * fb2;
t_biquadctl *c = x->x_ctl; t_biquadctl *c = x->x_ctl;
if (discriminant < 0) /* imaginary roots -- resonant filter */ if (discriminant < 0) /* imaginary roots -- resonant filter */
{ {
@ -99,6 +104,9 @@ stable:
static void sigbiquad_set(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv) static void sigbiquad_set(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
t_biquadctl *c = x->x_ctl; t_biquadctl *c = x->x_ctl;
c->c_x1 = atom_getfloatarg(0, argc, argv); c->c_x1 = atom_getfloatarg(0, argc, argv);
c->c_x2 = atom_getfloatarg(1, argc, argv); c->c_x2 = atom_getfloatarg(1, argc, argv);

View file

@ -81,6 +81,9 @@ static void sigbp_ft2(t_sigbp *x, t_floatarg q)
static void sigbp_clear(t_sigbp *x, t_floatarg q) static void sigbp_clear(t_sigbp *x, t_floatarg q)
{ {
#ifdef ROCKBOX
(void) q;
#endif
x->x_ctl->c_x1 = x->x_ctl->c_x2 = 0; x->x_ctl->c_x1 = x->x_ctl->c_x2 = 0;
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -47,6 +47,9 @@ static t_int *cos_perform(t_int *w)
static void cos_dsp(t_cos *x, t_signal **sp) static void cos_dsp(t_cos *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
dsp_add(cos_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); dsp_add(cos_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
} }

View file

@ -1,3 +1,8 @@
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#endif
#include <m_pd.h> #include <m_pd.h>
#include <m_fixed.h> #include <m_fixed.h>
@ -39,6 +44,9 @@ static t_int *dbtopow_tilde_perform(t_int *w)
static void dbtopow_tilde_dsp(t_dbtopow_tilde *x, t_signal **sp) static void dbtopow_tilde_dsp(t_dbtopow_tilde *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
post("warning: %s not usable yet",__FUNCTION__); post("warning: %s not usable yet",__FUNCTION__);
dsp_add(dbtopow_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); dsp_add(dbtopow_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
} }

View file

@ -1,3 +1,8 @@
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#endif
#include <m_pd.h> #include <m_pd.h>
#include <m_fixed.h> #include <m_fixed.h>
@ -40,6 +45,9 @@ static t_int *dbtorms_tilde_perform(t_int *w)
static void dbtorms_tilde_dsp(t_dbtorms_tilde *x, t_signal **sp) static void dbtorms_tilde_dsp(t_dbtorms_tilde *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
post("warning: %s not usable yet",__FUNCTION__); post("warning: %s not usable yet",__FUNCTION__);
dsp_add(dbtorms_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); dsp_add(dbtorms_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
} }

View file

@ -1,11 +1,19 @@
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#endif
#include <m_pd.h> #include <m_pd.h>
#include <m_fixed.h> #include <m_fixed.h>
#include "delay.h"
extern int ugen_getsortno(void); extern int ugen_getsortno(void);
#include "delay.h"
#define DEFDELVS 64 /* LATER get this from canvas at DSP time */ #define DEFDELVS 64 /* LATER get this from canvas at DSP time */
#ifndef ROCKBOX
static int delread_zero = 0; /* four bytes of zero for delread~, vd~ */ static int delread_zero = 0; /* four bytes of zero for delread~, vd~ */
#endif
static t_class *sigdelread_class; static t_class *sigdelread_class;
@ -36,13 +44,17 @@ static void *sigdelread_new(t_symbol *s, t_floatarg f)
static void sigdelread_float(t_sigdelread *x, t_float f) static void sigdelread_float(t_sigdelread *x, t_float f)
{ {
#ifndef ROCKBOX
int samps; int samps;
#endif
t_sigdelwrite *delwriter = t_sigdelwrite *delwriter =
(t_sigdelwrite *)pd_findbyclass(x->x_sym, sigdelwrite_class); (t_sigdelwrite *)pd_findbyclass(x->x_sym, sigdelwrite_class);
x->x_deltime = f; x->x_deltime = f;
if (delwriter) if (delwriter)
{ {
#ifndef ROCKBOX
int delsize = delwriter->x_cspace.c_n; int delsize = delwriter->x_cspace.c_n;
#endif
x->x_delsamps = (int)(0.5 + x->x_sr * x->x_deltime) x->x_delsamps = (int)(0.5 + x->x_sr * x->x_deltime)
+ x->x_n - x->x_zerodel; + x->x_n - x->x_zerodel;
if (x->x_delsamps < x->x_n) x->x_delsamps = x->x_n; if (x->x_delsamps < x->x_n) x->x_delsamps = x->x_n;

View file

@ -4,7 +4,9 @@
extern int ugen_getsortno(void); extern int ugen_getsortno(void);
#define DEFDELVS 64 /* LATER get this from canvas at DSP time */ #define DEFDELVS 64 /* LATER get this from canvas at DSP time */
#ifndef ROCKBOX
static int delread_zero = 0; /* four bytes of zero for delread~, vd~ */ static int delread_zero = 0; /* four bytes of zero for delread~, vd~ */
#endif
#include "delay.h" #include "delay.h"

View file

@ -1,5 +1,9 @@
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#else /* ROCKBOX */
#define FIXEDPOINT #define FIXEDPOINT
#endif /* ROCKBOX */
#include <m_pd.h> #include <m_pd.h>
#include <m_fixed.h> #include <m_fixed.h>

View file

@ -1,3 +1,8 @@
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#endif
#include <m_pd.h> #include <m_pd.h>
#include <m_fixed.h> #include <m_fixed.h>
@ -19,7 +24,11 @@ static void *ftom_tilde_new(void)
static t_int *ftom_tilde_perform(t_int *w) static t_int *ftom_tilde_perform(t_int *w)
{ {
#ifdef ROCKBOX
t_sample *in = *(t_sample **)(w+1), *out = (t_sample*)*(t_float **)(w+2);
#else
t_sample *in = *(t_sample **)(w+1), *out = *(t_float **)(w+2); t_sample *in = *(t_sample **)(w+1), *out = *(t_float **)(w+2);
#endif
t_int n = *(t_int *)(w+3); t_int n = *(t_int *)(w+3);
for (; n--; *in++, out++) for (; n--; *in++, out++)
{ {
@ -31,6 +40,9 @@ static t_int *ftom_tilde_perform(t_int *w)
static void ftom_tilde_dsp(t_ftom_tilde *x, t_signal **sp) static void ftom_tilde_dsp(t_ftom_tilde *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
post("warning: %s not usable yet",__FUNCTION__); post("warning: %s not usable yet",__FUNCTION__);
dsp_add(ftom_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); dsp_add(ftom_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
} }

View file

@ -76,6 +76,9 @@ static void sighip_dsp(t_sighip *x, t_signal **sp)
static void sighip_clear(t_sighip *x, t_floatarg q) static void sighip_clear(t_sighip *x, t_floatarg q)
{ {
#ifdef ROCKBOX
(void) q;
#endif
x->x_cspace.c_x = 0; x->x_cspace.c_x = 0;
} }

View file

@ -1,7 +1,57 @@
#ifndef ROCKBOX
#include <stdio.h> #include <stdio.h>
#endif
void d_intern_setup() { #ifdef ROCKBOX
/* Get rid of warnings. */
void biquad_tilde_setup(void);
void bp_tilde_setup(void);
void clip_tilde_setup(void);
void cos_tilde_setup(void);
void dbtopow_tilde_setup(void);
void dbtorms_tilde_setup(void);
void delread_tilde_setup(void);
void delwrite_tilde_setup(void);
void env_tilde_setup(void);
void ftom_tilde_setup(void);
void hip_tilde_setup(void);
void line_tilde_setup(void);
void lop_tilde_setup(void);
void mtof_tilde_setup(void);
void noise_tilde_setup(void);
void osc_tilde_setup(void);
void phasor_tilde_setup(void);
void powtodb_tilde_setup(void);
void print_tilde_setup(void);
void rmstodb_tilde_setup(void);
void rsqrt_tilde_setup(void);
void samphold_tilde_setup(void);
void sfread_tilde_setup(void);
void sfwrite_tilde_setup(void);
void sig_tilde_setup(void);
void snapshot_tilde_setup(void);
void sqrt_tilde_setup(void);
void tabosc4_tilde_setup(void);
void tabplay_tilde_setup(void);
void tabread4_tilde_setup(void);
void tabread_tilde_setup(void);
void tabread_setup(void);
void tabreceive_tilde_setup(void);
void tabsend_tilde_setup(void);
void tabwrite_tilde_setup(void);
void tabwrite_setup(void);
void threshold_tilde_setup(void);
void vcf_tilde_setup(void);
void vd_tilde_setup(void);
void vline_tilde_setup(void);
void vsnapshot_tilde_setup(void);
void wrap_tilde_setup(void);
#endif /* ROCKBOX */
void d_intern_setup(void) {
#ifndef ROCKBOX
fprintf(stderr,"setup\n"); fprintf(stderr,"setup\n");
#endif
biquad_tilde_setup(); biquad_tilde_setup();
bp_tilde_setup(); bp_tilde_setup();
clip_tilde_setup(); clip_tilde_setup();

View file

@ -23,7 +23,9 @@ static t_int *line_perform(t_int *w)
t_line *x = (t_line *)(w[1]); t_line *x = (t_line *)(w[1]);
t_sample *out = (t_sample *)(w[2]); t_sample *out = (t_sample *)(w[2]);
int n = (int)(w[3]); int n = (int)(w[3]);
#ifndef ROCKBOX
t_sample f = x->x_value; t_sample f = x->x_value;
#endif
if (x->x_retarget) if (x->x_retarget)
{ {

View file

@ -46,6 +46,9 @@ static void siglop_ft1(t_siglop *x, t_floatarg f)
static void siglop_clear(t_siglop *x, t_floatarg q) static void siglop_clear(t_siglop *x, t_floatarg q)
{ {
#ifdef ROCKBOX
(void) q;
#endif
x->x_cspace.c_x = 0; x->x_cspace.c_x = 0;
} }

View file

@ -1,3 +1,8 @@
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#endif
#include <m_pd.h> #include <m_pd.h>
#include <m_fixed.h> #include <m_fixed.h>
@ -36,6 +41,9 @@ static t_int *mtof_tilde_perform(t_int *w)
static void mtof_tilde_dsp(t_mtof_tilde *x, t_signal **sp) static void mtof_tilde_dsp(t_mtof_tilde *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
post("warning: %s not usable yet",__FUNCTION__); post("warning: %s not usable yet",__FUNCTION__);
dsp_add(mtof_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); dsp_add(mtof_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
} }

View file

@ -6,7 +6,11 @@
/* ------------------------ osc~ ----------------------------- */ /* ------------------------ osc~ ----------------------------- */
#ifdef ROCKBOX
static t_class *osc_class;
#else
static t_class *osc_class, *scalarosc_class; static t_class *osc_class, *scalarosc_class;
#endif
typedef struct _osc typedef struct _osc
{ {

View file

@ -1,3 +1,8 @@
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#endif
#include <m_pd.h> #include <m_pd.h>
#include <m_fixed.h> #include <m_fixed.h>
@ -39,6 +44,9 @@ static t_int *powtodb_tilde_perform(t_int *w)
static void powtodb_tilde_dsp(t_powtodb_tilde *x, t_signal **sp) static void powtodb_tilde_dsp(t_powtodb_tilde *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
post("warning: %s not usable yet",__FUNCTION__); post("warning: %s not usable yet",__FUNCTION__);
dsp_add(powtodb_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); dsp_add(powtodb_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
} }

View file

@ -1,3 +1,8 @@
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#endif
#include <m_pd.h> #include <m_pd.h>
#include <m_fixed.h> #include <m_fixed.h>
@ -39,6 +44,9 @@ static t_int *rmstodb_tilde_perform(t_int *w)
static void rmstodb_tilde_dsp(t_rmstodb_tilde *x, t_signal **sp) static void rmstodb_tilde_dsp(t_rmstodb_tilde *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
post("warning: %s not usable yet",__FUNCTION__); post("warning: %s not usable yet",__FUNCTION__);
dsp_add(rmstodb_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); dsp_add(rmstodb_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
} }

View file

@ -1,3 +1,8 @@
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#endif
#include <m_pd.h> #include <m_pd.h>
#include <m_fixed.h> #include <m_fixed.h>
@ -89,6 +94,9 @@ static t_int *sigrsqrt_perform(t_int *w)
static void sigrsqrt_dsp(t_sigrsqrt *x, t_signal **sp) static void sigrsqrt_dsp(t_sigrsqrt *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
dsp_add(sigrsqrt_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); dsp_add(sigrsqrt_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
} }

View file

@ -1,3 +1,7 @@
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#else /* ROCKBOX */
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
@ -6,6 +10,7 @@
#include <unistd.h> #include <unistd.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/stat.h> #include <sys/stat.h>
#endif /* ROCKBOX */
#include <m_pd.h> #include <m_pd.h>
#include <m_fixed.h> #include <m_fixed.h>
@ -40,7 +45,9 @@ typedef struct _sfread
void sfread_open(t_sfread *x,t_symbol *filename) void sfread_open(t_sfread *x,t_symbol *filename)
{ {
#ifndef ROCKBOX
struct stat fstate; struct stat fstate;
#endif
char fname[MAXPDSTRING]; char fname[MAXPDSTRING];
if (filename == &s_) { if (filename == &s_) {
@ -54,7 +61,11 @@ void sfread_open(t_sfread *x,t_symbol *filename)
/* close the old file */ /* close the old file */
#ifdef ROCKBOX
if (x->x_mapaddr) freebytes(x->x_mapaddr, x->x_size);
#else
if (x->x_mapaddr) munmap(x->x_mapaddr,x->x_size); if (x->x_mapaddr) munmap(x->x_mapaddr,x->x_size);
#endif
if (x->x_fd >= 0) close(x->x_fd); if (x->x_fd >= 0) close(x->x_fd);
if ((x->x_fd = open(fname,O_RDONLY)) < 0) if ((x->x_fd = open(fname,O_RDONLY)) < 0)
@ -66,17 +77,35 @@ void sfread_open(t_sfread *x,t_symbol *filename)
} }
/* get the size */ /* get the size */
#ifdef ROCKBOX
x->x_size = rb->filesize(x->x_fd);
#else
fstat(x->x_fd,&fstate); fstat(x->x_fd,&fstate);
x->x_size = fstate.st_size; x->x_size = fstate.st_size;
#endif
/* map the file into memory */ /* map the file into memory */
#ifdef ROCKBOX
x->x_mapaddr = getbytes(x->x_size);
if (!x->x_mapaddr)
{
error("can't mmap %s",fname);
return;
}
int r = read(x->x_fd, x->x_mapaddr, x->x_size);
if (r != x->x_size)
{
error("can't mmap %s",fname);
return;
}
#else
if (!(x->x_mapaddr = mmap(NULL,x->x_size,PROT_READ,MAP_PRIVATE,x->x_fd,0))) if (!(x->x_mapaddr = mmap(NULL,x->x_size,PROT_READ,MAP_PRIVATE,x->x_fd,0)))
{ {
error("can't mmap %s",fname); error("can't mmap %s",fname);
return; return;
} }
#endif
} }
#define MAX_CHANS 4 #define MAX_CHANS 4
@ -236,6 +265,9 @@ static void sfread_offset(t_sfread* x, t_floatarg f)
static void *sfread_new(t_floatarg chan,t_floatarg skip) static void *sfread_new(t_floatarg chan,t_floatarg skip)
{ {
#ifdef ROCKBOX
(void) skip;
#endif
t_sfread *x = (t_sfread *)pd_new(sfread_class); t_sfread *x = (t_sfread *)pd_new(sfread_class);
t_int c = chan; t_int c = chan;

View file

@ -1,4 +1,7 @@
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#else /* ROCKBOX */
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
@ -7,6 +10,7 @@
#include <unistd.h> #include <unistd.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/stat.h> #include <sys/stat.h>
#endif /* ROCKBOX */
#include <m_pd.h> #include <m_pd.h>
#include <m_fixed.h> #include <m_fixed.h>
@ -87,7 +91,11 @@ static void sfwrite_open(t_sfwrite *x,t_symbol *filename)
sfwrite_close(x); sfwrite_close(x);
#ifdef ROCKBOX
if ((x->x_file = open(fname, O_RDWR | O_CREAT)) < 0)
#else
if ((x->x_file = open(fname,O_RDWR | O_CREAT,0664)) < 0) if ((x->x_file = open(fname,O_RDWR | O_CREAT,0664)) < 0)
#endif
{ {
error("can't create %s",fname); error("can't create %s",fname);
return; return;

View file

@ -1,6 +1,11 @@
#define DUMTAB1SIZE 256 #define DUMTAB1SIZE 256
#define DUMTAB2SIZE 1024 #define DUMTAB2SIZE 1024
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#endif
#include<m_pd.h> #include<m_pd.h>
#include<m_fixed.h> #include<m_fixed.h>
@ -62,6 +67,9 @@ t_int *sigsqrt_perform(t_int *w) /* not static; also used in d_fft.c */
static void sigsqrt_dsp(t_sigsqrt *x, t_signal **sp) static void sigsqrt_dsp(t_sigsqrt *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
dsp_add(sigsqrt_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); dsp_add(sigsqrt_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
} }

View file

@ -77,7 +77,11 @@ zero:
void tabosc4_tilde_set(t_tabosc4_tilde *x, t_symbol *s) void tabosc4_tilde_set(t_tabosc4_tilde *x, t_symbol *s)
{ {
t_garray *a; t_garray *a;
#ifdef ROCKBOX
int pointsinarray;
#else
int npoints, pointsinarray; int npoints, pointsinarray;
#endif
x->x_arrayname = s; x->x_arrayname = s;
if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
@ -93,7 +97,9 @@ void tabosc4_tilde_set(t_tabosc4_tilde *x, t_symbol *s)
} }
else else
{ {
#ifndef ROCKBOX
int i; int i;
#endif
x->x_fnpoints = pointsinarray; x->x_fnpoints = pointsinarray;
x->x_lognpoints = ilog2(pointsinarray); x->x_lognpoints = ilog2(pointsinarray);
post("tabosc~: using %d (log %d) points of array",x->x_fnpoints,x->x_lognpoints); post("tabosc~: using %d (log %d) points of array",x->x_fnpoints,x->x_lognpoints);

View file

@ -1,5 +1,8 @@
#ifndef ROCKBOX
#define FIXEDPOINT #define FIXEDPOINT
#endif
#include <m_pd.h> #include <m_pd.h>
#include <m_fixed.h> #include <m_fixed.h>
@ -94,6 +97,11 @@ static void tabplay_tilde_list(t_tabplay_tilde *x, t_symbol *s,
{ {
long start = atom_getfloatarg(0, argc, argv); long start = atom_getfloatarg(0, argc, argv);
long length = atom_getfloatarg(1, argc, argv); long length = atom_getfloatarg(1, argc, argv);
#ifdef ROCKBOX
(void) s;
#endif
if (start < 0) start = 0; if (start < 0) start = 0;
if (length <= 0) if (length <= 0)
x->x_limit = 0x7fffffff; x->x_limit = 0x7fffffff;

View file

@ -90,6 +90,9 @@ static void tabread4_tilde_dsp(t_tabread4_tilde *x, t_signal **sp)
static void tabread4_tilde_free(t_tabread4_tilde *x) static void tabread4_tilde_free(t_tabread4_tilde *x)
{ {
#ifdef ROCKBOX
(void) x;
#endif
} }
void tabread4_tilde_setup(void) void tabread4_tilde_setup(void)

View file

@ -1,4 +1,7 @@
#ifndef ROCKBOX
#define FIXEDPOINT #define FIXEDPOINT
#endif
#include <m_pd.h> #include <m_pd.h>
#include <m_fixed.h> #include <m_fixed.h>
@ -30,7 +33,11 @@ static t_int *tabread_tilde_perform(t_int *w)
t_sample *out = (t_sample *)(w[3]); t_sample *out = (t_sample *)(w[3]);
int n = (int)(w[4]); int n = (int)(w[4]);
int maxindex; int maxindex;
#ifdef ROCKBOX
t_sample *buf = x->x_vec;
#else
t_sample *buf = x->x_vec, *fp; t_sample *buf = x->x_vec, *fp;
#endif
int i; int i;
maxindex = x->x_npoints - 1; maxindex = x->x_npoints - 1;
@ -82,6 +89,9 @@ static void tabread_tilde_dsp(t_tabread_tilde *x, t_signal **sp)
static void tabread_tilde_free(t_tabread_tilde *x) static void tabread_tilde_free(t_tabread_tilde *x)
{ {
#ifdef ROCKBOX
(void) x;
#endif
} }
void tabread_tilde_setup(void) void tabread_tilde_setup(void)

View file

@ -54,7 +54,11 @@ bad:
static void tabsend_dsp(t_tabsend *x, t_signal **sp) static void tabsend_dsp(t_tabsend *x, t_signal **sp)
{ {
#ifdef ROCKBOX
int vecsize;
#else
int i, vecsize; int i, vecsize;
#endif
t_garray *a; t_garray *a;
if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))

View file

@ -24,7 +24,11 @@ static void tabwrite_tick(t_tabwrite *x)
static void tabwrite_float(t_tabwrite *x, t_float f) static void tabwrite_float(t_tabwrite *x, t_float f)
{ {
#ifdef ROCKBOX
int vecsize;
#else
int i, vecsize; int i, vecsize;
#endif
t_garray *a; t_garray *a;
t_sample *vec; t_sample *vec;

View file

@ -1,12 +1,14 @@
#include <m_pd.h> #include <m_pd.h>
#include <m_fixed.h> #include <m_fixed.h>
#include "delay.h"
extern int ugen_getsortno(void); extern int ugen_getsortno(void);
#include "delay.h"
#define DEFDELVS 64 /* LATER get this from canvas at DSP time */ #define DEFDELVS 64 /* LATER get this from canvas at DSP time */
#ifndef ROCKBOX
static int delread_zero = 0; /* four bytes of zero for delread~, vd~ */ static int delread_zero = 0; /* four bytes of zero for delread~, vd~ */
#endif
static t_class *sigvd_class; static t_class *sigvd_class;
@ -37,14 +39,18 @@ static t_int *sigvd_perform(t_int *w)
t_sample *in = (t_sample *)(w[1]); t_sample *in = (t_sample *)(w[1]);
t_sample *out = (t_sample *)(w[2]); t_sample *out = (t_sample *)(w[2]);
t_delwritectl *ctl = (t_delwritectl *)(w[3]); t_delwritectl *ctl = (t_delwritectl *)(w[3]);
#ifndef ROCKBOX
t_sigvd *x = (t_sigvd *)(w[4]); t_sigvd *x = (t_sigvd *)(w[4]);
#endif
int n = (int)(w[5]); int n = (int)(w[5]);
int nsamps = ctl->c_n; int nsamps = ctl->c_n;
int fn = n; int fn = n;
t_sample limit = nsamps - n - 1; t_sample limit = nsamps - n - 1;
t_sample *vp = ctl->c_vec, *bp, *wp = vp + ctl->c_phase; t_sample *vp = ctl->c_vec, *bp, *wp = vp + ctl->c_phase;
#ifndef ROCKBOX
t_sample zerodel = x->x_zerodel; t_sample zerodel = x->x_zerodel;
#endif
while (n--) while (n--)
{ {
t_time delsamps = ((long long) mult((*in++),ftofix(44.1)));//- itofix(zerodel); t_time delsamps = ((long long) mult((*in++),ftofix(44.1)));//- itofix(zerodel);

View file

@ -1,3 +1,8 @@
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#endif
#include <m_pd.h> #include <m_pd.h>
#include <m_fixed.h> #include <m_fixed.h>
@ -36,7 +41,9 @@ static t_int *vline_tilde_perform(t_int *w)
t_sample f = x->x_value; t_sample f = x->x_value;
t_sample inc = x->x_inc; t_sample inc = x->x_inc;
t_time msecpersamp = x->x_msecpersamp; t_time msecpersamp = x->x_msecpersamp;
#ifndef ROCKBOX
t_time samppermsec = x->x_samppermsec; t_time samppermsec = x->x_samppermsec;
#endif
t_time timenow = clock_gettimesince(x->x_referencetime) - n * msecpersamp; t_time timenow = clock_gettimesince(x->x_referencetime) - n * msecpersamp;
t_vseg *s = x->x_list; t_vseg *s = x->x_list;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
@ -58,7 +65,7 @@ static t_int *vline_tilde_perform(t_int *w)
} }
else else
{ {
t_time incpermsec = div((s->s_target - f), t_time incpermsec = idiv((s->s_target - f),
(s->s_targettime - s->s_starttime)); (s->s_targettime - s->s_starttime));
f = mult(f + incpermsec,(timenext - s->s_starttime)); f = mult(f + incpermsec,(timenext - s->s_starttime));
inc = mult(incpermsec,msecpersamp); inc = mult(incpermsec,msecpersamp);
@ -123,7 +130,7 @@ static void vline_tilde_float(t_vline *x, t_float f)
} }
else else
{ {
for (s1 = x->x_list; s2 = s1->s_next; s1 = s2) for (s1 = x->x_list; (s2 = s1->s_next); s1 = s2)
{ {
if (s2->s_starttime > starttime || if (s2->s_starttime > starttime ||
(s2->s_starttime == starttime && (s2->s_starttime == starttime &&

View file

@ -40,6 +40,9 @@ static t_int *sigwrap_perform(t_int *w)
static void sigwrap_dsp(t_sigwrap *x, t_signal **sp) static void sigwrap_dsp(t_sigwrap *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
dsp_add(sigwrap_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); dsp_add(sigwrap_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
} }

View file

@ -28,6 +28,9 @@ typedef struct _scalarplus
static void *plus_new(t_symbol *s, int argc, t_atom *argv) static void *plus_new(t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
if (argc > 1) post("+~: extra arguments ignored"); if (argc > 1) post("+~: extra arguments ignored");
if (argc) if (argc)
{ {
@ -115,6 +118,9 @@ void dsp_add_plus(t_sample *in1, t_sample *in2, t_sample *out, int n)
static void plus_dsp(t_plus *x, t_signal **sp) static void plus_dsp(t_plus *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
dsp_add_plus(sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); dsp_add_plus(sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
} }
@ -161,6 +167,9 @@ typedef struct _scalarminus
static void *minus_new(t_symbol *s, int argc, t_atom *argv) static void *minus_new(t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
if (argc > 1) post("-~: extra arguments ignored"); if (argc > 1) post("-~: extra arguments ignored");
if (argc) if (argc)
{ {
@ -240,6 +249,9 @@ t_int *scalarminus_perf8(t_int *w)
static void minus_dsp(t_minus *x, t_signal **sp) static void minus_dsp(t_minus *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
if (sp[0]->s_n&7) if (sp[0]->s_n&7)
dsp_add(minus_perform, 4, dsp_add(minus_perform, 4,
sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
@ -292,6 +304,9 @@ typedef struct _scalartimes
static void *times_new(t_symbol *s, int argc, t_atom *argv) static void *times_new(t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
if (argc > 1) post("*~: extra arguments ignored"); if (argc > 1) post("*~: extra arguments ignored");
if (argc) if (argc)
{ {
@ -371,6 +386,9 @@ t_int *scalartimes_perf8(t_int *w)
static void times_dsp(t_times *x, t_signal **sp) static void times_dsp(t_times *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
if (sp[0]->s_n&7) if (sp[0]->s_n&7)
dsp_add(times_perform, 4, dsp_add(times_perform, 4,
sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
@ -422,6 +440,9 @@ typedef struct _scalarover
static void *over_new(t_symbol *s, int argc, t_atom *argv) static void *over_new(t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
if (argc > 1) post("/~: extra arguments ignored"); if (argc > 1) post("/~: extra arguments ignored");
if (argc) if (argc)
{ {
@ -512,6 +533,9 @@ t_int *scalarover_perf8(t_int *w)
static void over_dsp(t_over *x, t_signal **sp) static void over_dsp(t_over *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
if (sp[0]->s_n&7) if (sp[0]->s_n&7)
dsp_add(over_perform, 4, dsp_add(over_perform, 4,
sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
@ -563,6 +587,9 @@ typedef struct _scalarmax
static void *max_new(t_symbol *s, int argc, t_atom *argv) static void *max_new(t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
if (argc > 1) post("max~: extra arguments ignored"); if (argc > 1) post("max~: extra arguments ignored");
if (argc) if (argc)
{ {
@ -654,6 +681,9 @@ t_int *scalarmax_perf8(t_int *w)
static void max_dsp(t_max *x, t_signal **sp) static void max_dsp(t_max *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
if (sp[0]->s_n&7) if (sp[0]->s_n&7)
dsp_add(max_perform, 4, dsp_add(max_perform, 4,
sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
@ -705,6 +735,9 @@ typedef struct _scalarmin
static void *min_new(t_symbol *s, int argc, t_atom *argv) static void *min_new(t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
if (argc > 1) post("min~: extra arguments ignored"); if (argc > 1) post("min~: extra arguments ignored");
if (argc) if (argc)
{ {
@ -796,6 +829,9 @@ t_int *scalarmin_perf8(t_int *w)
static void min_dsp(t_min *x, t_signal **sp) static void min_dsp(t_min *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
if (sp[0]->s_n&7) if (sp[0]->s_n&7)
dsp_add(min_perform, 4, dsp_add(min_perform, 4,
sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);

View file

@ -74,7 +74,10 @@ static void *sig_tilde_new(t_floatarg f)
return (x); return (x);
} }
static void sig_tilde_setup(void) #ifndef ROCKBOX
static
#endif
void sig_tilde_setup(void)
{ {
sig_tilde_class = class_new(gensym("sig~"), (t_newmethod)sig_tilde_new, 0, sig_tilde_class = class_new(gensym("sig~"), (t_newmethod)sig_tilde_new, 0,
sizeof(t_sig), 0, A_DEFFLOAT, 0); sizeof(t_sig), 0, A_DEFFLOAT, 0);

View file

@ -22,8 +22,17 @@ typedef struct _dac
static void *dac_new(t_symbol *s, int argc, t_atom *argv) static void *dac_new(t_symbol *s, int argc, t_atom *argv)
{ {
t_dac *x = (t_dac *)pd_new(dac_class); t_dac *x = (t_dac *)pd_new(dac_class);
#ifdef ROCKBOX
t_atom defarg[2];
#else
t_atom defarg[2], *ap; t_atom defarg[2], *ap;
#endif
int i; int i;
#ifdef ROCKBOX
(void) s;
#endif
if (!argc) if (!argc)
{ {
argv = defarg; argv = defarg;
@ -83,8 +92,17 @@ typedef struct _adc
static void *adc_new(t_symbol *s, int argc, t_atom *argv) static void *adc_new(t_symbol *s, int argc, t_atom *argv)
{ {
t_adc *x = (t_adc *)pd_new(adc_class); t_adc *x = (t_adc *)pd_new(adc_class);
#ifdef ROCKBOX
t_atom defarg[2];
#else
t_atom defarg[2], *ap; t_atom defarg[2], *ap;
#endif
int i; int i;
#ifdef ROCKBOX
(void) s;
#endif
if (!argc) if (!argc)
{ {
argv = defarg; argv = defarg;

View file

@ -67,6 +67,9 @@ static t_int *sigifft_perform(t_int *w)
static void sigfft_dspx(t_sigfft *x, t_signal **sp, t_int *(*f)(t_int *w)) static void sigfft_dspx(t_sigfft *x, t_signal **sp, t_int *(*f)(t_int *w))
{ {
#ifdef ROCKBOX
(void) x;
#endif
int n = sp[0]->s_n; int n = sp[0]->s_n;
t_sample *in1 = sp[0]->s_vec; t_sample *in1 = sp[0]->s_vec;
t_sample *in2 = sp[1]->s_vec; t_sample *in2 = sp[1]->s_vec;
@ -150,6 +153,9 @@ static t_int *sigrfft_perform(t_int *w)
static void sigrfft_dsp(t_sigrfft *x, t_signal **sp) static void sigrfft_dsp(t_sigrfft *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
int n = sp[0]->s_n, n2 = (n>>1); int n = sp[0]->s_n, n2 = (n>>1);
t_sample *in1 = sp[0]->s_vec; t_sample *in1 = sp[0]->s_vec;
t_sample *out1 = sp[1]->s_vec; t_sample *out1 = sp[1]->s_vec;
@ -213,6 +219,9 @@ static t_int *sigrifft_perform(t_int *w)
static void sigrifft_dsp(t_sigrifft *x, t_signal **sp) static void sigrifft_dsp(t_sigrifft *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
#endif
int n = sp[0]->s_n, n2 = (n>>1); int n = sp[0]->s_n, n2 = (n>>1);
t_sample *in1 = sp[0]->s_vec; t_sample *in1 = sp[0]->s_vec;
t_sample *in2 = sp[1]->s_vec; t_sample *in2 = sp[1]->s_vec;

View file

@ -84,9 +84,14 @@
/* INCLUDE FILES */ /* INCLUDE FILES */
/*****************************************************************************/ /*****************************************************************************/
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#else /* ROCKBOX */
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
#endif /* ROCKBOX */
/* the following is needed only to declare pd_fft() as exportable in MSW */ /* the following is needed only to declare pd_fft() as exportable in MSW */
#include "m_pd.h" #include "m_pd.h"
@ -280,7 +285,7 @@ void fft_clear(void)
nextnet = thisnet->next; nextnet = thisnet->next;
net_dealloc(thisnet); net_dealloc(thisnet);
free((char *)thisnet); free((char *)thisnet);
} while (thisnet = nextnet); } while ((thisnet = nextnet));
} }
} }
@ -485,14 +490,21 @@ void load_registers(FFT_NET *fft_net, float *buf, int buf_form,
{ {
int *load_index = fft_net->load_index; int *load_index = fft_net->load_index;
#ifdef ROCKBOX
SAMPLE *window = NULL;
int index, i = 0;
#else
SAMPLE *window; SAMPLE *window;
int index, i = 0, n = fft_net->n; int index, i = 0, n = fft_net->n;
#endif
if (trnsfrm_dir==FORWARD) window = fft_net->window; if (trnsfrm_dir==FORWARD) window = fft_net->window;
else if (trnsfrm_dir==INVERSE) window = fft_net->inv_window; else if (trnsfrm_dir==INVERSE) window = fft_net->inv_window;
else { else {
#ifndef ROCKBOX
fprintf(stderr, "load_registers:illegal transform direction\n"); fprintf(stderr, "load_registers:illegal transform direction\n");
exit(0); exit(0);
#endif
} }
fft_net->direction = trnsfrm_dir; fft_net->direction = trnsfrm_dir;
@ -539,8 +551,10 @@ void load_registers(FFT_NET *fft_net, float *buf, int buf_form,
} break; } break;
default: { default: {
#ifndef ROCKBOX
fprintf(stderr, "load_registers:illegal input form\n"); fprintf(stderr, "load_registers:illegal input form\n");
exit(0); exit(0);
#endif
} break; } break;
} }
} break; } break;
@ -591,15 +605,19 @@ void load_registers(FFT_NET *fft_net, float *buf, int buf_form,
} break; } break;
default: { default: {
#ifndef ROCKBOX
fprintf(stderr, "load_registers:illegal input form\n"); fprintf(stderr, "load_registers:illegal input form\n");
exit(0); exit(0);
#endif
} break; } break;
} }
} break; } break;
default: { default: {
#ifndef ROCKBOX
fprintf(stderr, "load_registers:illegal input scale\n"); fprintf(stderr, "load_registers:illegal input scale\n");
exit(0); exit(0);
#endif
} break; } break;
} }
} }
@ -616,8 +634,15 @@ void store_registers(FFT_NET *fft_net, float *buf, int buf_form,
*/ */
{ {
#ifdef ROCKBOX
(void) debug;
#endif
int i; int i;
#ifdef ROCKBOX
SAMPLE real, imag;
#else
SAMPLE real, imag, mag, phase; SAMPLE real, imag, mag, phase;
#endif
int n; int n;
i = 0; i = 0;
@ -661,12 +686,21 @@ void store_registers(FFT_NET *fft_net, float *buf, int buf_form,
if (real > .00001) if (real > .00001)
*buf++ = (float)atan2(imag, real); *buf++ = (float)atan2(imag, real);
else { /* deal with bad case */ else { /* deal with bad case */
#ifdef ROCKBOX
if (imag > 0){ *buf++ = PI / 2.;
}
else if (imag < 0){ *buf++ = -PI / 2.;
}
else { *buf++ = 0;
}
#else
if (imag > 0){ *buf++ = PI / 2.; if (imag > 0){ *buf++ = PI / 2.;
if(debug) fprintf(stderr,"real=0 and imag > 0\n");} if(debug) fprintf(stderr,"real=0 and imag > 0\n");}
else if (imag < 0){ *buf++ = -PI / 2.; else if (imag < 0){ *buf++ = -PI / 2.;
if(debug) fprintf(stderr,"real=0 and imag < 0\n");} if(debug) fprintf(stderr,"real=0 and imag < 0\n");}
else { *buf++ = 0; else { *buf++ = 0;
if(debug) fprintf(stderr,"real=0 and imag=0\n");} if(debug) fprintf(stderr,"real=0 and imag=0\n");}
#endif
} }
} while (++i < n); } while (++i < n);
} break; } break;
@ -687,8 +721,10 @@ void store_registers(FFT_NET *fft_net, float *buf, int buf_form,
} break; } break;
default: { default: {
#ifndef ROCKBOX
fprintf(stderr, "store_registers:illegal output form\n"); fprintf(stderr, "store_registers:illegal output form\n");
exit(0); exit(0);
#endif
} break; } break;
} }
} break; } break;
@ -753,15 +789,19 @@ void store_registers(FFT_NET *fft_net, float *buf, int buf_form,
} break; } break;
default: { default: {
#ifndef ROCKBOX
fprintf(stderr, "store_registers:illegal output form\n"); fprintf(stderr, "store_registers:illegal output form\n");
exit(0); exit(0);
#endif
} break; } break;
} }
} break; } break;
default: { default: {
#ifndef ROCKBOX
fprintf(stderr, "store_registers:illegal output scale\n"); fprintf(stderr, "store_registers:illegal output scale\n");
exit(0); exit(0);
#endif
} break; } break;
} }
} }
@ -992,7 +1032,11 @@ void short_to_float(short *short_buf, float *float_buf, int n)
void pd_fft(float *buf, int npoints, int inverse) void pd_fft(float *buf, int npoints, int inverse)
{ {
double renorm; double renorm;
#ifdef ROCKBOX
float *fp;
#else
float *fp, *fp2; float *fp, *fp2;
#endif
int i; int i;
renorm = (inverse ? npoints : 1.); renorm = (inverse ? npoints : 1.);
cfft((inverse ? INVERSE : FORWARD), npoints, RECTANGULAR, cfft((inverse ? INVERSE : FORWARD), npoints, RECTANGULAR,

View file

@ -4,8 +4,16 @@
/* send~, receive~, throw~, catch~ */ /* send~, receive~, throw~, catch~ */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#endif
#include "m_pd.h" #include "m_pd.h"
#ifndef ROCKBOX
#include <string.h> #include <string.h>
#endif
#define DEFSENDVS 64 /* LATER get send to get this from canvas */ #define DEFSENDVS 64 /* LATER get send to get this from canvas */

View file

@ -95,7 +95,9 @@ char mtrig_algorithm[] = "Simple";
#define TRIG_TAB_SIZE 22 #define TRIG_TAB_SIZE 22
#ifndef ROCKBOX
static long long halsec[TRIG_TAB_SIZE]= {1,2,3}; static long long halsec[TRIG_TAB_SIZE]= {1,2,3};
#endif
#define FFTmult(x,y) mult(x,y) #define FFTmult(x,y) mult(x,y)
@ -286,7 +288,11 @@ void imayer_ifft(int n, t_fixed *real, t_fixed *imag)
void imayer_realfft(int n, t_fixed *real) void imayer_realfft(int n, t_fixed *real)
{ {
#ifdef ROCKBOX
t_fixed a,b;
#else
t_fixed a,b,c,d; t_fixed a,b,c,d;
#endif
int i,j,k; int i,j,k;
imayer_fht(real,n); imayer_fht(real,n);
for (i=1,j=n-1,k=n/2;i<k;i++,j--) { for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
@ -299,7 +305,11 @@ void imayer_realfft(int n, t_fixed *real)
void imayer_realifft(int n, t_fixed *real) void imayer_realifft(int n, t_fixed *real)
{ {
#ifdef ROCKBOX
t_fixed a,b;
#else
t_fixed a,b,c,d; t_fixed a,b,c,d;
#endif
int i,j,k; int i,j,k;
for (i=1,j=n-1,k=n/2;i<k;i++,j--) { for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
a = real[i]; a = real[i];

View file

@ -394,7 +394,11 @@ void mayer_ifft(int n, REAL *real, REAL *imag)
void mayer_realfft(int n, REAL *real) void mayer_realfft(int n, REAL *real)
{ {
#ifdef ROCKBOX
REAL a,b;
#else
REAL a,b,c,d; REAL a,b,c,d;
#endif
int i,j,k; int i,j,k;
mayer_fht(real,n); mayer_fht(real,n);
for (i=1,j=n-1,k=n/2;i<k;i++,j--) { for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
@ -407,7 +411,11 @@ void mayer_realfft(int n, REAL *real)
void mayer_realifft(int n, REAL *real) void mayer_realifft(int n, REAL *real)
{ {
#ifdef ROCKBOX
REAL a,b;
#else
REAL a,b,c,d; REAL a,b,c,d;
#endif
int i,j,k; int i,j,k;
for (i=1,j=n-1,k=n/2;i<k;i++,j--) { for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
a = real[i]; a = real[i];

View file

@ -5,9 +5,17 @@
/* miscellaneous: print~; more to come. /* miscellaneous: print~; more to come.
*/ */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#endif
#include "m_pd.h" #include "m_pd.h"
#ifndef ROCKBOX
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#endif
/* ------------------------- print~ -------------------------- */ /* ------------------------- print~ -------------------------- */
static t_class *print_class; static t_class *print_class;
@ -69,7 +77,10 @@ static void *print_new(t_symbol *s)
return (x); return (x);
} }
static void print_setup(void) #ifndef ROCKBOX
static
#endif
void print_setup(void)
{ {
print_class = class_new(gensym("print~"), (t_newmethod)print_new, 0, print_class = class_new(gensym("print~"), (t_newmethod)print_new, 0,
sizeof(t_print), 0, A_DEFSYM, 0); sizeof(t_print), 0, A_DEFSYM, 0);
@ -118,7 +129,11 @@ static void scope_dsp(t_scope *x, t_signal **sp)
static void scope_erase(t_scope *x) static void scope_erase(t_scope *x)
{ {
#ifdef ROCKBOX
(void) x;
#else
if (x->x_drawn) sys_vgui(".x%x.c delete gumbo\n", x->x_canvas); if (x->x_drawn) sys_vgui(".x%x.c delete gumbo\n", x->x_canvas);
#endif
} }
#define X1 10. #define X1 10.
@ -126,6 +141,7 @@ static void scope_erase(t_scope *x)
#define YC 5. #define YC 5.
static void scope_bang(t_scope *x) static void scope_bang(t_scope *x)
{ {
#ifndef ROCKBOX
int n, phase; int n, phase;
char hugebuf[10000], *s = hugebuf; char hugebuf[10000], *s = hugebuf;
scope_erase(x); scope_erase(x);
@ -142,6 +158,7 @@ static void scope_bang(t_scope *x)
} }
sprintf(s, "-tags gumbo\n"); sprintf(s, "-tags gumbo\n");
sys_gui(hugebuf); sys_gui(hugebuf);
#endif
x->x_drawn = 1; x->x_drawn = 1;
} }
@ -152,6 +169,9 @@ static void scope_free(t_scope *x)
static void *scope_new(t_symbol *s) static void *scope_new(t_symbol *s)
{ {
#ifdef ROCKBOX
(void) s;
#endif
t_scope *x = (t_scope *)pd_new(scope_class); t_scope *x = (t_scope *)pd_new(scope_class);
error("scope: this is now obsolete; use arrays and tabwrite~ instead"); error("scope: this is now obsolete; use arrays and tabwrite~ instead");
x->x_phase = 0; x->x_phase = 0;
@ -188,6 +208,9 @@ static t_int *bang_tilde_perform(t_int *w)
static void bang_tilde_dsp(t_bang *x, t_signal **sp) static void bang_tilde_dsp(t_bang *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) sp;
#endif
dsp_add(bang_tilde_perform, 1, x); dsp_add(bang_tilde_perform, 1, x);
} }
@ -203,6 +226,9 @@ static void bang_tilde_free(t_bang *x)
static void *bang_tilde_new(t_symbol *s) static void *bang_tilde_new(t_symbol *s)
{ {
#ifdef ROCKBOX
(void) s;
#endif
t_bang *x = (t_bang *)pd_new(bang_tilde_class); t_bang *x = (t_bang *)pd_new(bang_tilde_class);
x->x_clock = clock_new(x, (t_method)bang_tilde_tick); x->x_clock = clock_new(x, (t_method)bang_tilde_tick);
outlet_new(&x->x_obj, &s_bang); outlet_new(&x->x_obj, &s_bang);
@ -233,6 +259,9 @@ static void samplerate_tilde_bang(t_samplerate *x)
static void *samplerate_tilde_new(t_symbol *s) static void *samplerate_tilde_new(t_symbol *s)
{ {
#ifdef ROCKBOX
(void) s;
#endif
t_samplerate *x = (t_samplerate *)pd_new(samplerate_tilde_class); t_samplerate *x = (t_samplerate *)pd_new(samplerate_tilde_class);
outlet_new(&x->x_obj, &s_float); outlet_new(&x->x_obj, &s_float);
return (x); return (x);

View file

@ -11,6 +11,10 @@ readsf~ and writesf~ are defined which confine disk operations to a separate
thread so that they can be used in real time. The readsf~ and writesf~ thread so that they can be used in real time. The readsf~ and writesf~
objects use Posix-like threads. */ objects use Posix-like threads. */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#else /* ROCKBOX */
#ifdef UNIX #ifdef UNIX
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
@ -22,6 +26,7 @@ objects use Posix-like threads. */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#endif /* ROCKBOX */
#include "m_pd.h" #include "m_pd.h"
@ -198,9 +203,15 @@ int open_soundfile(const char *dirname, const char *filename, int headersize,
long skipframes) long skipframes)
{ {
char buf[OBUFSIZE], *bufptr; char buf[OBUFSIZE], *bufptr;
#ifdef ROCKBOX
int fd, nchannels, bigendian, bytespersamp, swap, sysrtn;
#else
int fd, format, nchannels, bigendian, bytespersamp, swap, sysrtn; int fd, format, nchannels, bigendian, bytespersamp, swap, sysrtn;
#endif
long bytelimit = 0x7fffffff; long bytelimit = 0x7fffffff;
#ifndef ROCKBOX
errno = 0; errno = 0;
#endif
fd = open_via_path(dirname, filename, fd = open_via_path(dirname, filename,
"", buf, &bufptr, MAXPDSTRING, 1); "", buf, &bufptr, MAXPDSTRING, 1);
if (fd < 0) if (fd < 0)
@ -239,7 +250,9 @@ int open_soundfile(const char *dirname, const char *filename, int headersize,
swap = (bigendian != garray_ambigendian()); swap = (bigendian != garray_ambigendian());
if (format == FORMAT_NEXT) /* nextstep header */ if (format == FORMAT_NEXT) /* nextstep header */
{ {
#ifndef ROCKBOX
uint32 param; uint32 param;
#endif
if (bytesread < (int)sizeof(t_nextstep)) if (bytesread < (int)sizeof(t_nextstep))
goto badheader; goto badheader;
nchannels = swap4(((t_nextstep *)buf)->ns_nchans, swap); nchannels = swap4(((t_nextstep *)buf)->ns_nchans, swap);
@ -381,7 +394,9 @@ int open_soundfile(const char *dirname, const char *filename, int headersize,
badheader: badheader:
/* the header wasn't recognized. We're threadable here so let's not /* the header wasn't recognized. We're threadable here so let's not
print out the error... */ print out the error... */
#ifndef ROCKBOX
errno = EIO; errno = EIO;
#endif
return (-1); return (-1);
} }
@ -705,7 +720,11 @@ static int create_soundfile(t_canvas *canvas, const char *filename,
canvas_makefilename(canvas, filenamebuf, buf2, MAXPDSTRING); canvas_makefilename(canvas, filenamebuf, buf2, MAXPDSTRING);
sys_bashfilename(buf2, buf2); sys_bashfilename(buf2, buf2);
#ifdef ROCKBOX
if ((fd = open(buf2, BINCREATE)) < 0)
#else
if ((fd = open(buf2, BINCREATE, 0666)) < 0) if ((fd = open(buf2, BINCREATE, 0666)) < 0)
#endif
return (-1); return (-1);
if (write(fd, headerbuf, headersize) < headersize) if (write(fd, headerbuf, headersize) < headersize)
@ -771,7 +790,11 @@ static void soundfile_finishwrite(void *obj, char *filename, int fd,
} }
return; return;
baddonewrite: baddonewrite:
#ifdef ROCKBOX
post("%s: error", filename);
#else
post("%s: %s", filename, strerror(errno)); post("%s: %s", filename, strerror(errno));
#endif
} }
static void soundfile_xferout(int nchannels, t_sample **vecs, static void soundfile_xferout(int nchannels, t_sample **vecs,
@ -920,9 +943,16 @@ static t_soundfiler *soundfiler_new(void)
static void soundfiler_read(t_soundfiler *x, t_symbol *s, static void soundfiler_read(t_soundfiler *x, t_symbol *s,
int argc, t_atom *argv) int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
int headersize = -1, channels = 0, bytespersamp = 0, bigendian = 0, int headersize = -1, channels = 0, bytespersamp = 0, bigendian = 0,
resize = 0, i, j; resize = 0, i, j;
#ifdef ROCKBOX
long skipframes = 0, nframes = 0, finalsize = 0,
#else
long skipframes = 0, nframes = 0, finalsize = 0, itemsleft, long skipframes = 0, nframes = 0, finalsize = 0, itemsleft,
#endif
maxsize = DEFMAXSIZE, itemsread = 0, bytelimit = 0x7fffffff; maxsize = DEFMAXSIZE, itemsread = 0, bytelimit = 0x7fffffff;
int fd = -1; int fd = -1;
char endianness, *filename; char endianness, *filename;
@ -930,7 +960,11 @@ static void soundfiler_read(t_soundfiler *x, t_symbol *s,
t_sample *vecs[MAXSFCHANS]; t_sample *vecs[MAXSFCHANS];
char sampbuf[SAMPBUFSIZE]; char sampbuf[SAMPBUFSIZE];
int bufframes, nitems; int bufframes, nitems;
#ifdef ROCKBOX
int fp;
#else
FILE *fp; FILE *fp;
#endif
while (argc > 0 && argv->a_type == A_SYMBOL && while (argc > 0 && argv->a_type == A_SYMBOL &&
*argv->a_w.w_symbol->s_name == '-') *argv->a_w.w_symbol->s_name == '-')
{ {
@ -1019,8 +1053,14 @@ static void soundfiler_read(t_soundfiler *x, t_symbol *s,
if (fd < 0) if (fd < 0)
{ {
#ifdef ROCKBOX
pd_error(x, "soundfiler_read: %s: %s",
filename,
"unknown or bad header format");
#else
pd_error(x, "soundfiler_read: %s: %s", filename, (errno == EIO ? pd_error(x, "soundfiler_read: %s: %s", filename, (errno == EIO ?
"unknown or bad header format" : strerror(errno))); "unknown or bad header format" : strerror(errno)));
#endif
goto done; goto done;
} }
@ -1065,14 +1105,22 @@ static void soundfiler_read(t_soundfiler *x, t_symbol *s,
if (!finalsize) finalsize = 0x7fffffff; if (!finalsize) finalsize = 0x7fffffff;
if (finalsize > bytelimit / (channels * bytespersamp)) if (finalsize > bytelimit / (channels * bytespersamp))
finalsize = bytelimit / (channels * bytespersamp); finalsize = bytelimit / (channels * bytespersamp);
#ifdef ROCKBOX
fp = open(filename, O_RDONLY);
#else
fp = fdopen(fd, "rb"); fp = fdopen(fd, "rb");
#endif
bufframes = SAMPBUFSIZE / (channels * bytespersamp); bufframes = SAMPBUFSIZE / (channels * bytespersamp);
for (itemsread = 0; itemsread < finalsize; ) for (itemsread = 0; itemsread < finalsize; )
{ {
int thisread = finalsize - itemsread; int thisread = finalsize - itemsread;
thisread = (thisread > bufframes ? bufframes : thisread); thisread = (thisread > bufframes ? bufframes : thisread);
#ifdef ROCKBOX
nitems = read(fp, sampbuf, thisread * bytespersamp * channels);
#else
nitems = fread(sampbuf, channels * bytespersamp, thisread, fp); nitems = fread(sampbuf, channels * bytespersamp, thisread, fp);
#endif
if (nitems <= 0) break; if (nitems <= 0) break;
soundfile_xferin(channels, argc, vecs, itemsread, soundfile_xferin(channels, argc, vecs, itemsread,
(unsigned char *)sampbuf, nitems, bytespersamp, bigendian); (unsigned char *)sampbuf, nitems, bytespersamp, bigendian);
@ -1082,7 +1130,11 @@ static void soundfiler_read(t_soundfiler *x, t_symbol *s,
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
{ {
#ifdef ROCKBOX
int vecsize;
#else
int nzero, vecsize; int nzero, vecsize;
#endif
garray_getfloatarray(garrays[i], &vecsize, &vecs[i]); garray_getfloatarray(garrays[i], &vecsize, &vecs[i]);
for (j = itemsread; j < vecsize; j++) for (j = itemsread; j < vecsize; j++)
vecs[i][j] = 0; vecs[i][j] = 0;
@ -1099,7 +1151,11 @@ static void soundfiler_read(t_soundfiler *x, t_symbol *s,
/* do all graphics updates */ /* do all graphics updates */
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
garray_redraw(garrays[i]); garray_redraw(garrays[i]);
#ifdef ROCKBOX
close(fp);
#else
fclose(fp); fclose(fp);
#endif
fd = -1; fd = -1;
goto done; goto done;
usage: usage:
@ -1118,14 +1174,25 @@ done:
long soundfiler_dowrite(void *obj, t_canvas *canvas, long soundfiler_dowrite(void *obj, t_canvas *canvas,
int argc, t_atom *argv) int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
int bytespersamp, bigendian,
swap, filetype, normalize, i, j, nchannels;
long onset, nframes,
itemswritten = 0;
#else
int headersize, bytespersamp, bigendian, int headersize, bytespersamp, bigendian,
endianness, swap, filetype, normalize, i, j, nchannels; endianness, swap, filetype, normalize, i, j, nchannels;
long onset, nframes, itemsleft, long onset, nframes, itemsleft,
maxsize = DEFMAXSIZE, itemswritten = 0; maxsize = DEFMAXSIZE, itemswritten = 0;
#endif
t_garray *garrays[MAXSFCHANS]; t_garray *garrays[MAXSFCHANS];
t_sample *vecs[MAXSFCHANS]; t_sample *vecs[MAXSFCHANS];
char sampbuf[SAMPBUFSIZE]; char sampbuf[SAMPBUFSIZE];
#ifdef ROCKBOX
int bufframes;
#else
int bufframes, nitems; int bufframes, nitems;
#endif
int fd = -1; int fd = -1;
float normfactor, biggest = 0, samplerate; float normfactor, biggest = 0, samplerate;
t_symbol *filesym; t_symbol *filesym;
@ -1174,7 +1241,11 @@ long soundfiler_dowrite(void *obj, t_canvas *canvas,
nframes, bytespersamp, bigendian, nchannels, nframes, bytespersamp, bigendian, nchannels,
swap, samplerate)) < 0) swap, samplerate)) < 0)
{ {
#ifdef ROCKBOX
post("%s: %s\n", filesym->s_name, "error");
#else
post("%s: %s\n", filesym->s_name, strerror(errno)); post("%s: %s\n", filesym->s_name, strerror(errno));
#endif
goto fail; goto fail;
} }
if (!normalize) if (!normalize)
@ -1194,14 +1265,22 @@ long soundfiler_dowrite(void *obj, t_canvas *canvas,
for (itemswritten = 0; itemswritten < nframes; ) for (itemswritten = 0; itemswritten < nframes; )
{ {
#ifdef ROCKBOX
int thiswrite = nframes - itemswritten, nbytes;
#else
int thiswrite = nframes - itemswritten, nitems, nbytes; int thiswrite = nframes - itemswritten, nitems, nbytes;
#endif
thiswrite = (thiswrite > bufframes ? bufframes : thiswrite); thiswrite = (thiswrite > bufframes ? bufframes : thiswrite);
soundfile_xferout(argc, vecs, (unsigned char *)sampbuf, thiswrite, soundfile_xferout(argc, vecs, (unsigned char *)sampbuf, thiswrite,
onset, bytespersamp, bigendian, normfactor); onset, bytespersamp, bigendian, normfactor);
nbytes = write(fd, sampbuf, nchannels * bytespersamp * thiswrite); nbytes = write(fd, sampbuf, nchannels * bytespersamp * thiswrite);
if (nbytes < nchannels * bytespersamp * thiswrite) if (nbytes < nchannels * bytespersamp * thiswrite)
{ {
#ifdef ROCKBOX
post("%s: %s", filesym->s_name, "error");
#else
post("%s: %s", filesym->s_name, strerror(errno)); post("%s: %s", filesym->s_name, strerror(errno));
#endif
if (nbytes > 0) if (nbytes > 0)
itemswritten += nbytes / (nchannels * bytespersamp); itemswritten += nbytes / (nchannels * bytespersamp);
break; break;
@ -1230,6 +1309,9 @@ fail:
static void soundfiler_write(t_soundfiler *x, t_symbol *s, static void soundfiler_write(t_soundfiler *x, t_symbol *s,
int argc, t_atom *argv) int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
long bozo = soundfiler_dowrite(x, x->x_canvas, long bozo = soundfiler_dowrite(x, x->x_canvas,
argc, argv); argc, argv);
outlet_float(x->x_obj.ob_outlet, (float)bozo); outlet_float(x->x_obj.ob_outlet, (float)bozo);

View file

@ -21,11 +21,17 @@
* *
*/ */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "m_imp.h"
#else /* ROCKBOX */
#include "m_pd.h" #include "m_pd.h"
#include "m_imp.h" #include "m_imp.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#endif /* ROCKBOX */
extern t_class *vinlet_class, *voutlet_class, *canvas_class; extern t_class *vinlet_class, *voutlet_class, *canvas_class;
t_sample *obj_findsignalscalar(t_object *x, int m); t_sample *obj_findsignalscalar(t_object *x, int m);
@ -258,6 +264,10 @@ static t_int *block_epilog(t_int *w)
static void block_dsp(t_block *x, t_signal **sp) static void block_dsp(t_block *x, t_signal **sp)
{ {
#ifdef ROCKBOX
(void) x;
(void) sp;
#endif
/* do nothing here */ /* do nothing here */
} }
@ -303,6 +313,7 @@ void dsp_tick(void)
t_int *ip; t_int *ip;
for (ip = dsp_chain; *ip; ) ip = (*(t_perfroutine)(*ip))(ip); for (ip = dsp_chain; *ip; ) ip = (*(t_perfroutine)(*ip))(ip);
dsp_phase++; dsp_phase++;
printf("%d\n", dsp_phase);
} }
} }
@ -330,9 +341,13 @@ static t_signal *signal_usedlist;
/* call this when DSP is stopped to free all the signals */ /* call this when DSP is stopped to free all the signals */
void signal_cleanup(void) void signal_cleanup(void)
{ {
#ifdef ROCKBOX
t_signal *sig;
#else
t_signal **svec, *sig, *sig2; t_signal **svec, *sig, *sig2;
#endif
int i; int i;
while (sig = signal_usedlist) while((sig = signal_usedlist))
{ {
signal_usedlist = sig->s_nextused; signal_usedlist = sig->s_nextused;
if (!sig->s_isborrowed) if (!sig->s_isborrowed)
@ -397,9 +412,15 @@ void signal_makereusable(t_signal *sig)
t_signal *signal_new(int n, float sr) t_signal *signal_new(int n, float sr)
{ {
#ifdef ROCKBOX
int logn;
#else
int logn, n2; int logn, n2;
#endif
t_signal *ret, **whichlist; t_signal *ret, **whichlist;
#ifndef ROCKBOX
t_sample *fp; t_sample *fp;
#endif
logn = ilog2(n); logn = ilog2(n);
if (n) if (n)
{ {
@ -413,7 +434,7 @@ t_signal *signal_new(int n, float sr)
whichlist = &signal_freeborrowed; whichlist = &signal_freeborrowed;
/* first try to reclaim one from the free list */ /* first try to reclaim one from the free list */
if (ret = *whichlist) if((ret = *whichlist))
*whichlist = ret->s_nextfree; *whichlist = ret->s_nextfree;
else else
{ {
@ -520,8 +541,10 @@ static t_dspcontext *ugen_currentcontext;
void ugen_stop(void) void ugen_stop(void)
{ {
#ifndef ROCKBOX
t_signal *s; t_signal *s;
int i; int i;
#endif
if (dsp_chain) if (dsp_chain)
{ {
freebytes(dsp_chain, dsp_chainsize * sizeof (t_int)); freebytes(dsp_chain, dsp_chainsize * sizeof (t_int));
@ -577,8 +600,10 @@ t_dspcontext *ugen_start_graph(int toplevel, t_signal **sp,
int ninlets, int noutlets) int ninlets, int noutlets)
{ {
t_dspcontext *dc = (t_dspcontext *)getbytes(sizeof(*dc)); t_dspcontext *dc = (t_dspcontext *)getbytes(sizeof(*dc));
#ifndef ROCKBOX
float parent_srate, srate; float parent_srate, srate;
int parent_vecsize, vecsize; int parent_vecsize, vecsize;
#endif
if (ugen_loud) post("ugen_start_graph..."); if (ugen_loud) post("ugen_start_graph...");
@ -672,7 +697,11 @@ static void ugen_doit(t_dspcontext *dc, t_ugenbox *u)
{ {
t_sigoutlet *uout; t_sigoutlet *uout;
t_siginlet *uin; t_siginlet *uin;
#ifdef ROCKBOX
t_sigoutconnect *oc;
#else
t_sigoutconnect *oc, *oc2; t_sigoutconnect *oc, *oc2;
#endif
t_class *class = pd_class(&u->u_obj->ob_pd); t_class *class = pd_class(&u->u_obj->ob_pd);
int i, n; int i, n;
/* suppress creating new signals for the outputs of signal /* suppress creating new signals for the outputs of signal
@ -681,13 +710,13 @@ static void ugen_doit(t_dspcontext *dc, t_ugenbox *u)
we delay new signal creation, which will be handled by calling we delay new signal creation, which will be handled by calling
signal_setborrowed in the ugen_done_graph routine below. */ signal_setborrowed in the ugen_done_graph routine below. */
int nonewsigs = (class == canvas_class || int nonewsigs = (class == canvas_class ||
(class == vinlet_class) && !(dc->dc_reblock)); ((class == vinlet_class) && !(dc->dc_reblock)));
/* when we encounter a subcanvas or a signal outlet, suppress freeing /* when we encounter a subcanvas or a signal outlet, suppress freeing
the input signals as they may be "borrowed" for the super or sub the input signals as they may be "borrowed" for the super or sub
patch; same exception as above, but also if we're "switched" we patch; same exception as above, but also if we're "switched" we
have to do a copy rather than a borrow. */ have to do a copy rather than a borrow. */
int nofreesigs = (class == canvas_class || int nofreesigs = (class == canvas_class ||
(class == voutlet_class) && !(dc->dc_reblock || dc->dc_switched)); ((class == voutlet_class) && !(dc->dc_reblock || dc->dc_switched)));
t_signal **insig, **outsig, **sig, *s1, *s2, *s3; t_signal **insig, **outsig, **sig, *s1, *s2, *s3;
t_ugenbox *u2; t_ugenbox *u2;
@ -701,7 +730,7 @@ static void ugen_doit(t_dspcontext *dc, t_ugenbox *u)
s3 = signal_new(dc->dc_vecsize, dc->dc_srate); s3 = signal_new(dc->dc_vecsize, dc->dc_srate);
/* post("%s: unconnected signal inlet set to zero", /* post("%s: unconnected signal inlet set to zero",
class_getname(u->u_obj->ob_pd)); */ class_getname(u->u_obj->ob_pd)); */
if (scalar = obj_findsignalscalar(u->u_obj, i)) if((scalar = obj_findsignalscalar(u->u_obj, i)))
dsp_add_scalarcopy(scalar, s3->s_vec, s3->s_n); dsp_add_scalarcopy(scalar, s3->s_vec, s3->s_n);
else else
dsp_add_zero(s3->s_vec, s3->s_n); dsp_add_zero(s3->s_vec, s3->s_n);
@ -781,7 +810,7 @@ static void ugen_doit(t_dspcontext *dc, t_ugenbox *u)
u2 = oc->oc_who; u2 = oc->oc_who;
uin = &u2->u_in[oc->oc_inno]; uin = &u2->u_in[oc->oc_inno];
/* if there's already someone here, sum the two */ /* if there's already someone here, sum the two */
if (s2 = uin->i_signal) if((s2 = uin->i_signal))
{ {
s1->s_refcount--; s1->s_refcount--;
s2->s_refcount--; s2->s_refcount--;
@ -825,7 +854,11 @@ static void ugen_doit(t_dspcontext *dc, t_ugenbox *u)
void ugen_done_graph(t_dspcontext *dc) void ugen_done_graph(t_dspcontext *dc)
{ {
#ifdef ROCKBOX
t_ugenbox *u;
#else
t_ugenbox *u, *u2; t_ugenbox *u, *u2;
#endif
t_sigoutlet *uout; t_sigoutlet *uout;
t_siginlet *uin; t_siginlet *uin;
t_sigoutconnect *oc, *oc2; t_sigoutconnect *oc, *oc2;
@ -966,7 +999,11 @@ void ugen_done_graph(t_dspcontext *dc)
for (u = dc->dc_ugenlist; u; u = u->u_next) for (u = dc->dc_ugenlist; u; u = u->u_next)
{ {
t_pd *zz = &u->u_obj->ob_pd; t_pd *zz = &u->u_obj->ob_pd;
#ifdef ROCKBOX
t_signal **outsigs = dc->dc_iosigs;
#else
t_signal **insigs = dc->dc_iosigs, **outsigs = dc->dc_iosigs; t_signal **insigs = dc->dc_iosigs, **outsigs = dc->dc_iosigs;
#endif
if (outsigs) outsigs += dc->dc_ninlets; if (outsigs) outsigs += dc->dc_ninlets;
if (pd_class(zz) == vinlet_class) if (pd_class(zz) == vinlet_class)

View file

@ -6,6 +6,14 @@
/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */ /* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "g_canvas.h"
#include "g_all_guis.h"
#define snprintf rb->snprintf
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -21,6 +29,7 @@
#else #else
#include <unistd.h> #include <unistd.h>
#endif #endif
#endif /* ROCKBOX */
/* #define GGEE_HSLIDER_COMPATIBLE */ /* #define GGEE_HSLIDER_COMPATIBLE */
@ -185,12 +194,20 @@ void iemgui_verify_snd_ne_rcv(t_iemgui *iemgui)
t_symbol *iemgui_new_dogetname(t_iemgui *iemgui, int indx, t_atom *argv) t_symbol *iemgui_new_dogetname(t_iemgui *iemgui, int indx, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) iemgui;
#endif
if (IS_A_SYMBOL(argv, indx)) if (IS_A_SYMBOL(argv, indx))
return (atom_getsymbolarg(indx, 100000, argv)); return (atom_getsymbolarg(indx, 100000, argv));
else if (IS_A_FLOAT(argv, indx)) else if (IS_A_FLOAT(argv, indx))
{ {
char str[80]; char str[80];
#ifdef ROCKBOX
snprintf(str, sizeof(str)-1,
"%d", (int)atom_getintarg(indx, 100000, argv));
#else
sprintf(str, "%d", (int)atom_getintarg(indx, 100000, argv)); sprintf(str, "%d", (int)atom_getintarg(indx, 100000, argv));
#endif
return (gensym(str)); return (gensym(str));
} }
else return (gensym("empty")); else return (gensym("empty"));
@ -261,6 +278,10 @@ void iemgui_all_sym2dollararg(t_iemgui *iemgui, t_symbol **srlsym)
void iemgui_first_dollararg2sym(t_iemgui *iemgui, t_symbol **srlsym) void iemgui_first_dollararg2sym(t_iemgui *iemgui, t_symbol **srlsym)
{ {
#ifdef ROCKBOX
(void) iemgui;
(void) srlsym;
#endif
/* delete this function */ /* delete this function */
} }
@ -341,8 +362,12 @@ void iemgui_all_raute2dollar(t_symbol **srlsym)
void iemgui_send(void *x, t_iemgui *iemgui, t_symbol *s) void iemgui_send(void *x, t_iemgui *iemgui, t_symbol *s)
{ {
t_symbol *snd; t_symbol *snd;
#ifdef ROCKBOX
int sndable=1, oldsndrcvable=0;
#else
int pargc, tail_len, nth_arg, sndable=1, oldsndrcvable=0; int pargc, tail_len, nth_arg, sndable=1, oldsndrcvable=0;
t_atom *pargv; t_atom *pargv;
#endif
if(iemgui->x_fsf.x_rcv_able) if(iemgui->x_fsf.x_rcv_able)
oldsndrcvable += IEM_GUI_OLD_RCV_FLAG; oldsndrcvable += IEM_GUI_OLD_RCV_FLAG;
@ -364,8 +389,12 @@ void iemgui_send(void *x, t_iemgui *iemgui, t_symbol *s)
void iemgui_receive(void *x, t_iemgui *iemgui, t_symbol *s) void iemgui_receive(void *x, t_iemgui *iemgui, t_symbol *s)
{ {
t_symbol *rcv; t_symbol *rcv;
#ifdef ROCKBOX
int rcvable=1, oldsndrcvable=0;
#else
int pargc, tail_len, nth_arg, rcvable=1, oldsndrcvable=0; int pargc, tail_len, nth_arg, rcvable=1, oldsndrcvable=0;
t_atom *pargv; t_atom *pargv;
#endif
if(iemgui->x_fsf.x_rcv_able) if(iemgui->x_fsf.x_rcv_able)
oldsndrcvable += IEM_GUI_OLD_RCV_FLAG; oldsndrcvable += IEM_GUI_OLD_RCV_FLAG;
@ -399,34 +428,55 @@ void iemgui_receive(void *x, t_iemgui *iemgui, t_symbol *s)
void iemgui_label(void *x, t_iemgui *iemgui, t_symbol *s) void iemgui_label(void *x, t_iemgui *iemgui, t_symbol *s)
{ {
t_symbol *lab; t_symbol *lab;
#ifndef ROCKBOX
int pargc, tail_len, nth_arg; int pargc, tail_len, nth_arg;
t_atom *pargv; t_atom *pargv;
#endif
#ifdef ROCKBOX
(void) x;
#endif
lab = iemgui_raute2dollar(s); lab = iemgui_raute2dollar(s);
iemgui->x_lab_unexpanded = lab; iemgui->x_lab_unexpanded = lab;
iemgui->x_lab = lab = canvas_realizedollar(iemgui->x_glist, lab); iemgui->x_lab = lab = canvas_realizedollar(iemgui->x_glist, lab);
#ifndef ROCKBOX
if(glist_isvisible(iemgui->x_glist)) if(glist_isvisible(iemgui->x_glist))
sys_vgui(".x%x.c itemconfigure %xLABEL -text {%s} \n", sys_vgui(".x%x.c itemconfigure %xLABEL -text {%s} \n",
glist_getcanvas(iemgui->x_glist), x, glist_getcanvas(iemgui->x_glist), x,
strcmp(s->s_name, "empty")?iemgui->x_lab->s_name:""); strcmp(s->s_name, "empty")?iemgui->x_lab->s_name:"");
#endif
} }
void iemgui_label_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) void iemgui_label_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) x;
(void) s;
#endif
iemgui->x_ldx = (int)atom_getintarg(0, ac, av); iemgui->x_ldx = (int)atom_getintarg(0, ac, av);
iemgui->x_ldy = (int)atom_getintarg(1, ac, av); iemgui->x_ldy = (int)atom_getintarg(1, ac, av);
#ifndef ROCKBOX
if(glist_isvisible(iemgui->x_glist)) if(glist_isvisible(iemgui->x_glist))
sys_vgui(".x%x.c coords %xLABEL %d %d\n", sys_vgui(".x%x.c coords %xLABEL %d %d\n",
glist_getcanvas(iemgui->x_glist), x, glist_getcanvas(iemgui->x_glist), x,
iemgui->x_obj.te_xpix+iemgui->x_ldx, iemgui->x_obj.te_xpix+iemgui->x_ldx,
iemgui->x_obj.te_ypix+iemgui->x_ldy); iemgui->x_obj.te_ypix+iemgui->x_ldy);
#endif
} }
void iemgui_label_font(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) void iemgui_label_font(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av)
{ {
int f = (int)atom_getintarg(0, ac, av); int f = (int)atom_getintarg(0, ac, av);
#ifdef ROCKBOX
(void) x;
(void) s;
#endif
if(f == 1) strcpy(iemgui->x_font, "helvetica"); if(f == 1) strcpy(iemgui->x_font, "helvetica");
else if(f == 2) strcpy(iemgui->x_font, "times"); else if(f == 2) strcpy(iemgui->x_font, "times");
else else
@ -439,9 +489,11 @@ void iemgui_label_font(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *a
if(f < 4) if(f < 4)
f = 4; f = 4;
iemgui->x_fontsize = f; iemgui->x_fontsize = f;
#ifndef ROCKBOX
if(glist_isvisible(iemgui->x_glist)) if(glist_isvisible(iemgui->x_glist))
sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold}\n", sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold}\n",
glist_getcanvas(iemgui->x_glist), x, iemgui->x_font, iemgui->x_fontsize); glist_getcanvas(iemgui->x_glist), x, iemgui->x_font, iemgui->x_fontsize);
#endif
} }
void iemgui_size(void *x, t_iemgui *iemgui) void iemgui_size(void *x, t_iemgui *iemgui)
@ -455,6 +507,9 @@ void iemgui_size(void *x, t_iemgui *iemgui)
void iemgui_delta(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) void iemgui_delta(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
#endif
iemgui->x_obj.te_xpix += (int)atom_getintarg(0, ac, av); iemgui->x_obj.te_xpix += (int)atom_getintarg(0, ac, av);
iemgui->x_obj.te_ypix += (int)atom_getintarg(1, ac, av); iemgui->x_obj.te_ypix += (int)atom_getintarg(1, ac, av);
if(glist_isvisible(iemgui->x_glist)) if(glist_isvisible(iemgui->x_glist))
@ -466,6 +521,9 @@ void iemgui_delta(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av)
void iemgui_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) void iemgui_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
#endif
iemgui->x_obj.te_xpix = (int)atom_getintarg(0, ac, av); iemgui->x_obj.te_xpix = (int)atom_getintarg(0, ac, av);
iemgui->x_obj.te_ypix = (int)atom_getintarg(1, ac, av); iemgui->x_obj.te_ypix = (int)atom_getintarg(1, ac, av);
if(glist_isvisible(iemgui->x_glist)) if(glist_isvisible(iemgui->x_glist))
@ -477,6 +535,9 @@ void iemgui_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av)
void iemgui_color(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) void iemgui_color(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
#endif
iemgui->x_bcol = iemgui_compatible_col(atom_getintarg(0, ac, av)); iemgui->x_bcol = iemgui_compatible_col(atom_getintarg(0, ac, av));
if(ac > 2) if(ac > 2)
{ {
@ -561,21 +622,36 @@ int iemgui_dialog(t_iemgui *iemgui, t_symbol **srl, int argc, t_atom *argv)
srl[0] = atom_getsymbolarg(7, argc, argv); srl[0] = atom_getsymbolarg(7, argc, argv);
else if(IS_A_FLOAT(argv,7)) else if(IS_A_FLOAT(argv,7))
{ {
#ifdef ROCKBOX
snprintf(str, sizeof(str)-1,
"%d", (int)atom_getintarg(7, argc, argv));
#else
sprintf(str, "%d", (int)atom_getintarg(7, argc, argv)); sprintf(str, "%d", (int)atom_getintarg(7, argc, argv));
#endif
srl[0] = gensym(str); srl[0] = gensym(str);
} }
if(IS_A_SYMBOL(argv,8)) if(IS_A_SYMBOL(argv,8))
srl[1] = atom_getsymbolarg(8, argc, argv); srl[1] = atom_getsymbolarg(8, argc, argv);
else if(IS_A_FLOAT(argv,8)) else if(IS_A_FLOAT(argv,8))
{ {
#ifdef ROCKBOX
snprintf(str, sizeof(str)-1,
"%d", (int)atom_getintarg(8, argc, argv));
#else
sprintf(str, "%d", (int)atom_getintarg(8, argc, argv)); sprintf(str, "%d", (int)atom_getintarg(8, argc, argv));
#endif
srl[1] = gensym(str); srl[1] = gensym(str);
} }
if(IS_A_SYMBOL(argv,9)) if(IS_A_SYMBOL(argv,9))
srl[2] = atom_getsymbolarg(9, argc, argv); srl[2] = atom_getsymbolarg(9, argc, argv);
else if(IS_A_FLOAT(argv,9)) else if(IS_A_FLOAT(argv,9))
{ {
#ifdef ROCKBOX
snprintf(str, sizeof(str)-1,
"%d", (int)atom_getintarg(9, argc, argv));
#else
sprintf(str, "%d", (int)atom_getintarg(9, argc, argv)); sprintf(str, "%d", (int)atom_getintarg(9, argc, argv));
#endif
srl[2] = gensym(str); srl[2] = gensym(str);
} }
if(init != 0) init = 1; if(init != 0) init = 1;

View file

@ -2,12 +2,22 @@
* For information on usage and redistribution, and for a DISCLAIMER OF ALL * For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "g_canvas.h"
#ifdef SIMULATOR
int printf(const char *fmt, ...);
#endif /* SIMULATOR */
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> /* for read/write to files */ #include <stdio.h> /* for read/write to files */
#include "m_pd.h" #include "m_pd.h"
#include "g_canvas.h" #include "g_canvas.h"
#include <math.h> #include <math.h>
#endif /* ROCKBOX */
/* see also the "plot" object in g_scalar.c which deals with graphing /* see also the "plot" object in g_scalar.c which deals with graphing
arrays which are fields in scalars. Someday we should unify the arrays which are fields in scalars. Someday we should unify the
@ -40,7 +50,9 @@ t_array *array_new(t_symbol *templatesym, t_gpointer *parent)
{ {
t_array *x = (t_array *)getbytes(sizeof (*x)); t_array *x = (t_array *)getbytes(sizeof (*x));
t_template *template; t_template *template;
#ifndef ROCKBOX
t_gpointer *gp; t_gpointer *gp;
#endif
template = template_findbyname(templatesym); template = template_findbyname(templatesym);
x->a_templatesym = templatesym; x->a_templatesym = templatesym;
x->a_n = 1; x->a_n = 1;
@ -59,7 +71,9 @@ t_array *array_new(t_symbol *templatesym, t_gpointer *parent)
void array_resize(t_array *x, t_template *template, int n) void array_resize(t_array *x, t_template *template, int n)
{ {
int elemsize, oldn; int elemsize, oldn;
#ifndef ROCKBOX
t_gpointer *gp; t_gpointer *gp;
#endif
if (n < 1) if (n < 1)
n = 1; n = 1;
@ -135,7 +149,11 @@ t_garray *graph_array(t_glist *gl, t_symbol *s, t_symbol *templatesym,
if (s == &s_) if (s == &s_)
{ {
char buf[40]; char buf[40];
#ifdef ROCKBOX
snprintf(buf, sizeof(buf)-1, "array%d", ++gcount);
#else
sprintf(buf, "array%d", ++gcount); sprintf(buf, "array%d", ++gcount);
#endif
s = gensym(buf); s = gensym(buf);
templatesym = &s_float; templatesym = &s_float;
n = 100; n = 100;
@ -179,7 +197,7 @@ t_garray *graph_array(t_glist *gl, t_symbol *s, t_symbol *templatesym,
x->x_glist = gl; x->x_glist = gl;
x->x_usedindsp = 0; x->x_usedindsp = 0;
x->x_saveit = (saveit != 0); x->x_saveit = (saveit != 0);
if (x2 = pd_findbyclass(gensym("#A"), garray_class)) if((x2 = pd_findbyclass(gensym("#A"), garray_class)))
pd_unbind(x2, gensym("#A")); pd_unbind(x2, gensym("#A"));
pd_bind(&x->x_gobj.g_pd, gensym("#A")); pd_bind(&x->x_gobj.g_pd, gensym("#A"));
@ -190,16 +208,23 @@ t_garray *graph_array(t_glist *gl, t_symbol *s, t_symbol *templatesym,
/* called from array menu item to create a new one */ /* called from array menu item to create a new one */
void canvas_menuarray(t_glist *canvas) void canvas_menuarray(t_glist *canvas)
{ {
#ifdef ROCKBOX
(void) canvas;
#else /* ROCKBOX */
t_glist *x = (t_glist *)canvas; t_glist *x = (t_glist *)canvas;
char cmdbuf[200]; char cmdbuf[200];
sprintf(cmdbuf, "pdtk_array_dialog %%s array%d 100 1 1\n", sprintf(cmdbuf, "pdtk_array_dialog %%s array%d 100 1 1\n",
++gcount); ++gcount);
gfxstub_new(&x->gl_pd, x, cmdbuf); gfxstub_new(&x->gl_pd, x, cmdbuf);
#endif /* ROCKBOX */
} }
/* called from graph_dialog to set properties */ /* called from graph_dialog to set properties */
void garray_properties(t_garray *x) void garray_properties(t_garray *x)
{ {
#ifdef ROCKBOX
(void) x;
#else /* ROCKBOX */
char cmdbuf[200]; char cmdbuf[200];
gfxstub_deleteforkey(x); gfxstub_deleteforkey(x);
/* create dialog window. LATER fix this to escape '$' /* create dialog window. LATER fix this to escape '$'
@ -211,6 +236,7 @@ void garray_properties(t_garray *x)
else sprintf(cmdbuf, "pdtk_array_dialog %%s %s %d %d 0\n", else sprintf(cmdbuf, "pdtk_array_dialog %%s %s %d %d 0\n",
x->x_name->s_name, x->x_n, x->x_saveit); x->x_name->s_name, x->x_n, x->x_saveit);
gfxstub_new(&x->x_gobj.g_pd, x, cmdbuf); gfxstub_new(&x->x_gobj.g_pd, x, cmdbuf);
#endif /* ROCKBOX */
} }
/* this is called back from the dialog window to create a garray. /* this is called back from the dialog window to create a garray.
@ -260,10 +286,12 @@ void garray_arraydialog(t_garray *x, t_symbol *name, t_floatarg fsize,
static void garray_free(t_garray *x) static void garray_free(t_garray *x)
{ {
t_pd *x2; t_pd *x2;
#ifndef ROCKBOX
gfxstub_deleteforkey(x); gfxstub_deleteforkey(x);
#endif
pd_unbind(&x->x_gobj.g_pd, x->x_realname); pd_unbind(&x->x_gobj.g_pd, x->x_realname);
/* LATER find a way to get #A unbound earlier (at end of load?) */ /* LATER find a way to get #A unbound earlier (at end of load?) */
while (x2 = pd_findbyclass(gensym("#A"), garray_class)) while((x2 = pd_findbyclass(gensym("#A"), garray_class)))
pd_unbind(x2, gensym("#A")); pd_unbind(x2, gensym("#A"));
freebytes(x->x_vec, x->x_n * x->x_elemsize); freebytes(x->x_vec, x->x_n * x->x_elemsize);
} }
@ -308,7 +336,9 @@ static t_word *array_motion_wp;
static t_template *array_motion_template; static t_template *array_motion_template;
static int array_motion_npoints; static int array_motion_npoints;
static int array_motion_elemsize; static int array_motion_elemsize;
#ifndef ROCKBOX
static int array_motion_altkey; static int array_motion_altkey;
#endif
static float array_motion_initx; static float array_motion_initx;
static float array_motion_xperpix; static float array_motion_xperpix;
static float array_motion_yperpix; static float array_motion_yperpix;
@ -320,6 +350,9 @@ static int array_motion_fatten;
static void array_motion(void *z, t_floatarg dx, t_floatarg dy) static void array_motion(void *z, t_floatarg dx, t_floatarg dy)
{ {
#ifdef ROCKBOX
(void) z;
#endif
array_motion_xcumulative += dx * array_motion_xperpix; array_motion_xcumulative += dx * array_motion_xperpix;
array_motion_ycumulative += dy * array_motion_yperpix; array_motion_ycumulative += dy * array_motion_yperpix;
if (*array_motion_xfield->s_name) if (*array_motion_xfield->s_name)
@ -402,6 +435,12 @@ int array_doclick(t_array *array, t_glist *glist, t_gobj *gobj,
t_template *elemtemplate; t_template *elemtemplate;
int elemsize, yonset, wonset, xonset, i; int elemsize, yonset, wonset, xonset, i;
#ifdef ROCKBOX
(void) linewidth;
(void) shift;
(void) dbl;
#endif
if (!array_getfields(elemtemplatesym, &elemtemplatecanvas, if (!array_getfields(elemtemplatesym, &elemtemplatecanvas,
&elemtemplate, &elemsize, &xonset, &yonset, &wonset)) &elemtemplate, &elemsize, &xonset, &yonset, &wonset))
{ {
@ -575,7 +614,11 @@ static void garray_getrect(t_gobj *z, t_glist *glist,
else incr = x->x_array.a_n / 300; else incr = x->x_array.a_n / 300;
for (i = 0; i < x->x_array.a_n; i += incr) for (i = 0; i < x->x_array.a_n; i += incr)
{ {
#ifdef ROCKBOX
float pxpix, pypix, pwpix;
#else /* ROCKBOX */
float pxpix, pypix, pwpix, dx, dy; float pxpix, pypix, pwpix, dx, dy;
#endif /* ROCKBOX */
array_getcoordinate(glist, (char *)(x->x_array.a_vec) + array_getcoordinate(glist, (char *)(x->x_array.a_vec) +
i * elemsize, i * elemsize,
xonset, yonset, wonset, i, 0, 0, 1, xonset, yonset, wonset, i, 0, 0, 1,
@ -600,21 +643,42 @@ static void garray_getrect(t_gobj *z, t_glist *glist,
static void garray_displace(t_gobj *z, t_glist *glist, int dx, int dy) static void garray_displace(t_gobj *z, t_glist *glist, int dx, int dy)
{ {
#ifdef ROCKBOX
(void) z;
(void) glist;
(void) dx;
(void) dy;
#endif
/* refuse */ /* refuse */
} }
static void garray_select(t_gobj *z, t_glist *glist, int state) static void garray_select(t_gobj *z, t_glist *glist, int state)
{ {
#ifdef ROCKBOX
(void) z;
(void) glist;
(void) state;
#else /* ROCKBOX */
t_garray *x = (t_garray *)z; t_garray *x = (t_garray *)z;
#endif /* ROCKBOX */
/* fill in later */ /* fill in later */
} }
static void garray_activate(t_gobj *z, t_glist *glist, int state) static void garray_activate(t_gobj *z, t_glist *glist, int state)
{ {
#ifdef ROCKBOX
(void) z;
(void) glist;
(void) state;
#endif
} }
static void garray_delete(t_gobj *z, t_glist *glist) static void garray_delete(t_gobj *z, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) z;
(void) glist;
#endif
/* nothing to do */ /* nothing to do */
} }
@ -633,9 +697,11 @@ static void garray_vis(t_gobj *z, t_glist *glist, int vis)
{ {
error("%s: needs floating-point 'y' field", error("%s: needs floating-point 'y' field",
x->x_templatesym->s_name); x->x_templatesym->s_name);
#ifndef ROCKBOX
sys_vgui(".x%x.c create text 50 50 -text foo\ sys_vgui(".x%x.c create text 50 50 -text foo\
-tags .x%x.a%x\n", -tags .x%x.a%x\n",
glist_getcanvas(glist), glist_getcanvas(glist), x); glist_getcanvas(glist), glist_getcanvas(glist), x);
#endif
} }
else if (!template_find_field(template, gensym("x"), &xonset, &type, else if (!template_find_field(template, gensym("x"), &xonset, &type,
&arraytype) || type != DT_FLOAT) &arraytype) || type != DT_FLOAT)
@ -644,7 +710,9 @@ static void garray_vis(t_gobj *z, t_glist *glist, int vis)
int lastpixel = -1, ndrawn = 0; int lastpixel = -1, ndrawn = 0;
float yval = 0, xpix; float yval = 0, xpix;
int ixpix = 0; int ixpix = 0;
#ifndef ROCKBOX
sys_vgui(".x%x.c create line \\\n", glist_getcanvas(glist)); sys_vgui(".x%x.c create line \\\n", glist_getcanvas(glist));
#endif
for (i = 0; i < x->x_n; i++) for (i = 0; i < x->x_n; i++)
{ {
yval = fixtof(*(t_sample *)(x->x_vec + yval = fixtof(*(t_sample *)(x->x_vec +
@ -653,8 +721,10 @@ static void garray_vis(t_gobj *z, t_glist *glist, int vis)
ixpix = xpix + 0.5; ixpix = xpix + 0.5;
if (ixpix != lastpixel) if (ixpix != lastpixel)
{ {
#ifndef ROCKBOX
sys_vgui("%d %f \\\n", ixpix, sys_vgui("%d %f \\\n", ixpix,
glist_ytopixels(glist, yval)); glist_ytopixels(glist, yval));
#endif
ndrawn++; ndrawn++;
} }
lastpixel = ixpix; lastpixel = ixpix;
@ -662,11 +732,14 @@ static void garray_vis(t_gobj *z, t_glist *glist, int vis)
xcum += x->x_xinc; xcum += x->x_xinc;
} }
/* TK will complain if there aren't at least 2 points... */ /* TK will complain if there aren't at least 2 points... */
#ifndef ROCKBOX
if (ndrawn == 0) sys_vgui("0 0 0 0 \\\n"); if (ndrawn == 0) sys_vgui("0 0 0 0 \\\n");
else if (ndrawn == 1) sys_vgui("%d %f \\\n", ixpix, else if (ndrawn == 1) sys_vgui("%d %f \\\n", ixpix,
glist_ytopixels(glist, yval)); glist_ytopixels(glist, yval));
sys_vgui("-tags .x%x.a%x\n", glist_getcanvas(glist), x); sys_vgui("-tags .x%x.a%x\n", glist_getcanvas(glist), x);
#endif
firsty = fixtof(*(t_sample *)(x->x_vec + yonset)); firsty = fixtof(*(t_sample *)(x->x_vec + yonset));
#ifndef ROCKBOX
sys_vgui(".x%x.c create text %f %f -text {%s} -anchor e\ sys_vgui(".x%x.c create text %f %f -text {%s} -anchor e\
-font -*-courier-bold--normal--%d-* -tags .x%x.a%x\n", -font -*-courier-bold--normal--%d-* -tags .x%x.a%x\n",
glist_getcanvas(glist), glist_getcanvas(glist),
@ -674,6 +747,7 @@ static void garray_vis(t_gobj *z, t_glist *glist, int vis)
glist_ytopixels(glist, firsty), glist_ytopixels(glist, firsty),
x->x_name->s_name, glist_getfont(glist), x->x_name->s_name, glist_getfont(glist),
glist_getcanvas(glist), x); glist_getcanvas(glist), x);
#endif
} }
else else
{ {
@ -682,8 +756,10 @@ static void garray_vis(t_gobj *z, t_glist *glist, int vis)
} }
else else
{ {
#ifndef ROCKBOX
sys_vgui(".x%x.c delete .x%x.a%x\n", sys_vgui(".x%x.c delete .x%x.a%x\n",
glist_getcanvas(glist), glist_getcanvas(glist), x); glist_getcanvas(glist), glist_getcanvas(glist), x);
#endif
} }
} }
@ -702,7 +778,13 @@ static void garray_save(t_gobj *z, t_binbuf *b)
t_garray *x = (t_garray *)z; t_garray *x = (t_garray *)z;
binbuf_addv(b, "sssisi;", gensym("#X"), gensym("array"), binbuf_addv(b, "sssisi;", gensym("#X"), gensym("array"),
x->x_name, x->x_n, x->x_templatesym, x->x_saveit); x->x_name, x->x_n, x->x_templatesym, x->x_saveit);
#ifdef ROCKBOX
#ifdef SIMULATOR
printf("array save\n");
#endif /* SIMULATOR */
#else /* ROCKBOX */
fprintf(stderr,"array save\n"); fprintf(stderr,"array save\n");
#endif /* ROCKBOX */
if (x->x_saveit) if (x->x_saveit)
{ {
int n = x->x_n, n2 = 0; int n = x->x_n, n2 = 0;
@ -877,7 +959,11 @@ static void garray_dofo(t_garray *x, int npoints, float dcval,
static void garray_sinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv) static void garray_sinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#else
t_template *template = garray_template(x); t_template *template = garray_template(x);
#endif
t_float *svec = (t_float *)t_getbytes(sizeof(t_float) * argc); t_float *svec = (t_float *)t_getbytes(sizeof(t_float) * argc);
int npoints, i; int npoints, i;
@ -902,7 +988,11 @@ static void garray_sinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv)
static void garray_cosinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv) static void garray_cosinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#else
t_template *template = garray_template(x); t_template *template = garray_template(x);
#endif
t_float *svec = (t_float *)t_getbytes(sizeof(t_float) * argc); t_float *svec = (t_float *)t_getbytes(sizeof(t_float) * argc);
int npoints, i; int npoints, i;
@ -928,7 +1018,11 @@ static void garray_cosinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv)
static void garray_normalize(t_garray *x, t_float f) static void garray_normalize(t_garray *x, t_float f)
{ {
t_template *template = garray_template(x); t_template *template = garray_template(x);
#ifdef ROCKBOX
int yonset, type, i;
#else
int yonset, type, npoints, i; int yonset, type, npoints, i;
#endif
double maxv, renormer; double maxv, renormer;
t_symbol *arraytype; t_symbol *arraytype;
@ -968,6 +1062,9 @@ static void garray_list(t_garray *x, t_symbol *s, int argc, t_atom *argv)
t_template *template = garray_template(x); t_template *template = garray_template(x);
int yonset, type, i; int yonset, type, i;
t_symbol *arraytype; t_symbol *arraytype;
#ifdef ROCKBOX
(void) s;
#endif
if (!template_find_field(template, gensym("y"), &yonset, if (!template_find_field(template, gensym("y"), &yonset,
&type, &arraytype) || type != DT_FLOAT) &type, &arraytype) || type != DT_FLOAT)
error("%s: needs floating-point 'y' field", error("%s: needs floating-point 'y' field",
@ -1038,7 +1135,11 @@ static void garray_rename(t_garray *x, t_symbol *s)
static void garray_read(t_garray *x, t_symbol *filename) static void garray_read(t_garray *x, t_symbol *filename)
{ {
int nelem = x->x_n, filedesc; int nelem = x->x_n, filedesc;
#ifdef ROCKBOX
int fd = 0;
#else
FILE *fd; FILE *fd;
#endif
char buf[MAXPDSTRING], *bufptr; char buf[MAXPDSTRING], *bufptr;
t_template *template = garray_template(x); t_template *template = garray_template(x);
int yonset, type, i; int yonset, type, i;
@ -1052,15 +1153,23 @@ static void garray_read(t_garray *x, t_symbol *filename)
if ((filedesc = open_via_path( if ((filedesc = open_via_path(
canvas_getdir(glist_getcanvas(x->x_glist))->s_name, canvas_getdir(glist_getcanvas(x->x_glist))->s_name,
filename->s_name, "", buf, &bufptr, MAXPDSTRING, 0)) < 0 filename->s_name, "", buf, &bufptr, MAXPDSTRING, 0)) < 0
#ifdef ROCKBOX
)
#else
|| !(fd = fdopen(filedesc, "r"))) || !(fd = fdopen(filedesc, "r")))
#endif
{ {
error("%s: can't open", filename->s_name); error("%s: can't open", filename->s_name);
return; return;
} }
for (i = 0; i < nelem; i++) for (i = 0; i < nelem; i++)
{ {
#ifdef ROCKBOX
if(rb_fscanf_f(fd, (float*)((x->x_vec + sizeof(t_word) * i) + yonset)))
#else
if (!fscanf(fd, "%f", (float *)((x->x_vec + sizeof(t_word) * i) + if (!fscanf(fd, "%f", (float *)((x->x_vec + sizeof(t_word) * i) +
yonset))) yonset)))
#endif
{ {
post("%s: read %d elements into table of size %d", post("%s: read %d elements into table of size %d",
filename->s_name, i, nelem); filename->s_name, i, nelem);
@ -1069,7 +1178,11 @@ static void garray_read(t_garray *x, t_symbol *filename)
} }
while (i < nelem) while (i < nelem)
*(float *)((x->x_vec + sizeof(t_word) * i) + yonset) = 0, i++; *(float *)((x->x_vec + sizeof(t_word) * i) + yonset) = 0, i++;
#ifdef ROCKBOX
close(fd);
#else
fclose(fd); fclose(fd);
#endif
garray_redraw(x); garray_redraw(x);
} }
@ -1090,7 +1203,11 @@ static void garray_read16(t_garray *x, t_symbol *filename,
int skip = fskip, filedesc; int skip = fskip, filedesc;
int i, nelem; int i, nelem;
t_sample *vec; t_sample *vec;
#ifdef ROCKBOX
int fd = 0;
#else
FILE *fd; FILE *fd;
#endif
char buf[MAXPDSTRING], *bufptr; char buf[MAXPDSTRING], *bufptr;
short s; short s;
int cpubig = garray_ambigendian(), swap = 0; int cpubig = garray_ambigendian(), swap = 0;
@ -1116,25 +1233,41 @@ static void garray_read16(t_garray *x, t_symbol *filename,
if ((filedesc = open_via_path( if ((filedesc = open_via_path(
canvas_getdir(glist_getcanvas(x->x_glist))->s_name, canvas_getdir(glist_getcanvas(x->x_glist))->s_name,
filename->s_name, "", buf, &bufptr, MAXPDSTRING, 1)) < 0 filename->s_name, "", buf, &bufptr, MAXPDSTRING, 1)) < 0
#ifdef ROCKBOX
)
#else
|| !(fd = fdopen(filedesc, BINREADMODE))) || !(fd = fdopen(filedesc, BINREADMODE)))
#endif
{ {
error("%s: can't open", filename->s_name); error("%s: can't open", filename->s_name);
return; return;
} }
if (skip) if (skip)
{ {
#ifdef ROCKBOX
long pos = lseek(fd, (long)skip, SEEK_SET);
#else
long pos = fseek(fd, (long)skip, SEEK_SET); long pos = fseek(fd, (long)skip, SEEK_SET);
#endif
if (pos < 0) if (pos < 0)
{ {
error("%s: can't seek to byte %d", buf, skip); error("%s: can't seek to byte %d", buf, skip);
#ifdef ROCKBOX
close(fd);
#else
fclose(fd); fclose(fd);
#endif
return; return;
} }
} }
for (i = 0; i < nelem; i++) for (i = 0; i < nelem; i++)
{ {
#ifdef ROCKBOX
if(read(fd, &s, sizeof(s)) < 1)
#else
if (fread(&s, sizeof(s), 1, fd) < 1) if (fread(&s, sizeof(s), 1, fd) < 1)
#endif
{ {
post("%s: read %d elements into table of size %d", post("%s: read %d elements into table of size %d",
filename->s_name, i, nelem); filename->s_name, i, nelem);
@ -1144,13 +1277,21 @@ static void garray_read16(t_garray *x, t_symbol *filename,
vec[i] = s * (1./32768.); vec[i] = s * (1./32768.);
} }
while (i < nelem) vec[i++] = 0; while (i < nelem) vec[i++] = 0;
#ifdef ROCKBOX
close(fd);
#else
fclose(fd); fclose(fd);
#endif
garray_redraw(x); garray_redraw(x);
} }
static void garray_write(t_garray *x, t_symbol *filename) static void garray_write(t_garray *x, t_symbol *filename)
{ {
#ifdef ROCKBOX
int fd;
#else
FILE *fd; FILE *fd;
#endif
char buf[MAXPDSTRING]; char buf[MAXPDSTRING];
t_template *template = garray_template(x); t_template *template = garray_template(x);
int yonset, type, i; int yonset, type, i;
@ -1164,21 +1305,33 @@ static void garray_write(t_garray *x, t_symbol *filename)
canvas_makefilename(glist_getcanvas(x->x_glist), filename->s_name, canvas_makefilename(glist_getcanvas(x->x_glist), filename->s_name,
buf, MAXPDSTRING); buf, MAXPDSTRING);
sys_bashfilename(buf, buf); sys_bashfilename(buf, buf);
#ifdef ROCKBOX
if(!(fd = open(buf, O_WRONLY|O_CREAT|O_TRUNC)))
#else
if (!(fd = fopen(buf, "w"))) if (!(fd = fopen(buf, "w")))
#endif
{ {
error("%s: can't create", buf); error("%s: can't create", buf);
return; return;
} }
for (i = 0; i < x->x_n; i++) for (i = 0; i < x->x_n; i++)
{ {
#ifdef ROCKBOX
if(rb_fprintf_f(fd,
#else /* ROCKBOX */
if (fprintf(fd, "%g\n", if (fprintf(fd, "%g\n",
#endif /* ROCKBOX */
*(float *)((x->x_vec + sizeof(t_word) * i) + yonset)) < 1) *(float *)((x->x_vec + sizeof(t_word) * i) + yonset)) < 1)
{ {
post("%s: write error", filename->s_name); post("%s: write error", filename->s_name);
break; break;
} }
} }
#ifdef ROCKBOX
close(fd);
#else
fclose(fd); fclose(fd);
#endif
} }
static unsigned char waveheader[] = { static unsigned char waveheader[] = {
@ -1203,7 +1356,11 @@ static void garray_write16(t_garray *x, t_symbol *filename, t_symbol *format)
t_template *template = garray_template(x); t_template *template = garray_template(x);
int yonset, type, i; int yonset, type, i;
t_symbol *arraytype; t_symbol *arraytype;
#ifdef ROCKBOX
int fd;
#else
FILE *fd; FILE *fd;
#endif
int aiff = (format == gensym("aiff")); int aiff = (format == gensym("aiff"));
char filenamebuf[MAXPDSTRING], buf2[MAXPDSTRING]; char filenamebuf[MAXPDSTRING], buf2[MAXPDSTRING];
int swap = garray_ambigendian(); /* wave is only little endian */ int swap = garray_ambigendian(); /* wave is only little endian */
@ -1230,7 +1387,11 @@ static void garray_write16(t_garray *x, t_symbol *filename, t_symbol *format)
canvas_makefilename(glist_getcanvas(x->x_glist), filenamebuf, canvas_makefilename(glist_getcanvas(x->x_glist), filenamebuf,
buf2, MAXPDSTRING); buf2, MAXPDSTRING);
sys_bashfilename(buf2, buf2); sys_bashfilename(buf2, buf2);
#ifdef ROCKBOX
if(!(fd = open(buf2, O_WRONLY|O_CREAT|O_TRUNC)))
#else
if (!(fd = fopen(buf2, BINWRITEMODE))) if (!(fd = fopen(buf2, BINWRITEMODE)))
#endif
{ {
error("%s: can't create", buf2); error("%s: can't create", buf2);
return; return;
@ -1251,7 +1412,11 @@ static void garray_write16(t_garray *x, t_symbol *filename, t_symbol *format)
xxx = foo[1]; foo[1] = foo[2]; foo[2] = xxx; xxx = foo[1]; foo[1] = foo[2]; foo[2] = xxx;
} }
memcpy((void *)(waveheader + 40), (void *)(&intbuf), 4); memcpy((void *)(waveheader + 40), (void *)(&intbuf), 4);
#ifdef ROCKBOX
if(write(fd, waveheader, sizeof(waveheader)) < 1)
#else
if (fwrite(waveheader, sizeof(waveheader), 1, fd) < 1) if (fwrite(waveheader, sizeof(waveheader), 1, fd) < 1)
#endif
{ {
post("%s: write error", buf2); post("%s: write error", buf2);
goto closeit; goto closeit;
@ -1268,21 +1433,31 @@ static void garray_write16(t_garray *x, t_symbol *filename, t_symbol *format)
unsigned char *foo = (unsigned char *)&sh, xxx; unsigned char *foo = (unsigned char *)&sh, xxx;
xxx = foo[0]; foo[0] = foo[1]; foo[1] = xxx; xxx = foo[0]; foo[0] = foo[1]; foo[1] = xxx;
} }
#ifdef ROCKBOX
if(write(fd, &sh, sizeof(sh)) < 1)
#else
if (fwrite(&sh, sizeof(sh), 1, fd) < 1) if (fwrite(&sh, sizeof(sh), 1, fd) < 1)
#endif
{ {
post("%s: write error", buf2); post("%s: write error", buf2);
goto closeit; goto closeit;
} }
} }
closeit: closeit:
#ifdef ROCKBOX
close(fd);
#else
fclose(fd); fclose(fd);
#endif
} }
void garray_resize(t_garray *x, t_floatarg f) void garray_resize(t_garray *x, t_floatarg f)
{ {
int was = x->x_n, elemsize; int was = x->x_n, elemsize;
t_glist *gl; t_glist *gl;
#ifndef ROCKBOX
int dspwas; int dspwas;
#endif
int n = f; int n = f;
char *nvec; char *nvec;
@ -1309,7 +1484,9 @@ void garray_resize(t_garray *x, t_floatarg f)
vmess(&gl->gl_pd, gensym("bounds"), "ffff", vmess(&gl->gl_pd, gensym("bounds"), "ffff",
0., gl->gl_y1, (double)(n > 1 ? n-1 : 1), gl->gl_y2); 0., gl->gl_y1, (double)(n > 1 ? n-1 : 1), gl->gl_y2);
/* close any dialogs that might have the wrong info now... */ /* close any dialogs that might have the wrong info now... */
#ifndef ROCKBOX
gfxstub_deleteforkey(gl); gfxstub_deleteforkey(gl);
#endif
} }
else garray_redraw(x); else garray_redraw(x);
if (x->x_usedindsp) canvas_update_dsp(); if (x->x_usedindsp) canvas_update_dsp();

View file

@ -5,7 +5,13 @@
/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */ /* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */ /* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "g_canvas.h"
#include "g_all_guis.h"
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -21,6 +27,7 @@
#else #else
#include <unistd.h> #include <unistd.h>
#endif #endif
#endif /* ROCKBOX */
/* --------------- bng gui-bang ------------------------- */ /* --------------- bng gui-bang ------------------------- */
@ -33,15 +40,24 @@ static t_class *bng_class;
void bng_draw_update(t_bng *x, t_glist *glist) void bng_draw_update(t_bng *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
if(glist_isvisible(glist)) if(glist_isvisible(glist))
{ {
sys_vgui(".x%x.c itemconfigure %xBUT -fill #%6.6x\n", glist_getcanvas(glist), x, sys_vgui(".x%x.c itemconfigure %xBUT -fill #%6.6x\n", glist_getcanvas(glist), x,
x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol); x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol);
} }
#endif /* ROCKBOX */
} }
void bng_draw_new(t_bng *x, t_glist *glist) void bng_draw_new(t_bng *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
@ -69,10 +85,15 @@ void bng_draw_new(t_bng *x, t_glist *glist)
sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n", sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
canvas, xpos, ypos, canvas, xpos, ypos,
xpos + IOWIDTH, ypos+1, x, 0); xpos + IOWIDTH, ypos+1, x, 0);
#endif /* ROCKBOX */
} }
void bng_draw_move(t_bng *x, t_glist *glist) void bng_draw_move(t_bng *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
@ -96,10 +117,15 @@ void bng_draw_move(t_bng *x, t_glist *glist)
sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n", sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
canvas, x, 0, xpos, ypos, canvas, x, 0, xpos, ypos,
xpos + IOWIDTH, ypos+1); xpos + IOWIDTH, ypos+1);
#endif /* ROCKBOX */
} }
void bng_draw_erase(t_bng* x, t_glist* glist) void bng_draw_erase(t_bng* x, t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
sys_vgui(".x%x.c delete %xBASE\n", canvas, x); sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
@ -109,10 +135,15 @@ void bng_draw_erase(t_bng* x, t_glist* glist)
sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
if(!x->x_gui.x_fsf.x_rcv_able) if(!x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
#endif /* ROCKBOX */
} }
void bng_draw_config(t_bng* x, t_glist* glist) void bng_draw_config(t_bng* x, t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n", sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
@ -122,10 +153,16 @@ void bng_draw_config(t_bng* x, t_glist* glist)
sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol); sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);
sys_vgui(".x%x.c itemconfigure %xBUT -fill #%6.6x\n", canvas, x, sys_vgui(".x%x.c itemconfigure %xBUT -fill #%6.6x\n", canvas, x,
x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol); x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol);
#endif /* ROCKBOX */
} }
void bng_draw_io(t_bng* x, t_glist* glist, int old_snd_rcv_flags) void bng_draw_io(t_bng* x, t_glist* glist, int old_snd_rcv_flags)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
(void) old_snd_rcv_flags;
#else /* ROCKBOX */
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
@ -143,10 +180,15 @@ void bng_draw_io(t_bng* x, t_glist* glist, int old_snd_rcv_flags)
xpos + IOWIDTH, ypos+1, x, 0); xpos + IOWIDTH, ypos+1, x, 0);
if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
#endif /* ROCKBOX */
} }
void bng_draw_select(t_bng* x, t_glist* glist) void bng_draw_select(t_bng* x, t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
if(x->x_gui.x_fsf.x_selected) if(x->x_gui.x_fsf.x_selected)
@ -161,6 +203,7 @@ void bng_draw_select(t_bng* x, t_glist* glist)
sys_vgui(".x%x.c itemconfigure %xBUT -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL); sys_vgui(".x%x.c itemconfigure %xBUT -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
} }
#endif /* ROCKBOX */
} }
void bng_draw(t_bng *x, t_glist *glist, int mode) void bng_draw(t_bng *x, t_glist *glist, int mode)
@ -232,6 +275,10 @@ void bng_check_minmax(t_bng *x, int ftbreak, int fthold)
static void bng_properties(t_gobj *z, t_glist *owner) static void bng_properties(t_gobj *z, t_glist *owner)
{ {
#ifdef ROCKBOX
(void) z;
(void) owner;
#else /* ROCKBOX */
t_bng *x = (t_bng *)z; t_bng *x = (t_bng *)z;
char buf[800]; char buf[800];
t_symbol *srl[3]; t_symbol *srl[3];
@ -253,6 +300,7 @@ static void bng_properties(t_gobj *z, t_glist *owner)
x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
#endif /* ROCKBOX */
} }
static void bng_set(t_bng *x) static void bng_set(t_bng *x)
@ -316,6 +364,9 @@ static void bng_bang2(t_bng *x)/*wird immer gesendet, wenn moeglich*/
static void bng_dialog(t_bng *x, t_symbol *s, int argc, t_atom *argv) static void bng_dialog(t_bng *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
t_symbol *srl[3]; t_symbol *srl[3];
int a = (int)atom_getintarg(0, argc, argv); int a = (int)atom_getintarg(0, argc, argv);
int fthold = (int)atom_getintarg(2, argc, argv); int fthold = (int)atom_getintarg(2, argc, argv);
@ -333,33 +384,84 @@ static void bng_dialog(t_bng *x, t_symbol *s, int argc, t_atom *argv)
static void bng_click(t_bng *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt) static void bng_click(t_bng *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
{ {
#ifdef ROCKBOX
(void) xpos;
(void) ypos;
(void) shift;
(void) ctrl;
(void) alt;
#endif
bng_set(x); bng_set(x);
bng_bout2(x); bng_bout2(x);
} }
static int bng_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) static int bng_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
{ {
#ifdef ROCKBOX
(void) glist;
(void) dbl;
#endif
if(doit) if(doit)
bng_click((t_bng *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt); bng_click((t_bng *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt);
return (1); return (1);
} }
static void bng_float(t_bng *x, t_floatarg f) static void bng_float(t_bng *x, t_floatarg f)
#ifdef ROCKBOX
{
(void) f;
bng_bang2(x);
}
#else /* ROCKBOX */
{bng_bang2(x);} {bng_bang2(x);}
#endif /* ROCKBOX */
static void bng_symbol(t_bng *x, t_symbol *s) static void bng_symbol(t_bng *x, t_symbol *s)
#ifdef ROCKBOX
{
(void) s;
bng_bang2(x);
}
#else /* ROCKBOX */
{bng_bang2(x);} {bng_bang2(x);}
#endif /* ROCKBOX */
static void bng_pointer(t_bng *x, t_gpointer *gp) static void bng_pointer(t_bng *x, t_gpointer *gp)
#ifdef ROCKBOX
{
(void) gp;
bng_bang2(x);
}
#else /* ROCKBOX */
{bng_bang2(x);} {bng_bang2(x);}
#endif /* ROCKBOX */
static void bng_list(t_bng *x, t_symbol *s, int ac, t_atom *av) static void bng_list(t_bng *x, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
(void) ac;
(void) av;
#endif /* ROCKBOX */
bng_bang2(x); bng_bang2(x);
} }
static void bng_anything(t_bng *x, t_symbol *s, int argc, t_atom *argv) static void bng_anything(t_bng *x, t_symbol *s, int argc, t_atom *argv)
#ifdef ROCKBOX
{
(void) s;
(void) argc;
(void) argv;
bng_bang2(x);
}
#else /* ROCKBOX */
{bng_bang2(x);} {bng_bang2(x);}
#endif /* ROCKBOX */
static void bng_loadbang(t_bng *x) static void bng_loadbang(t_bng *x)
{ {
@ -372,6 +474,9 @@ static void bng_loadbang(t_bng *x)
static void bng_size(t_bng *x, t_symbol *s, int ac, t_atom *av) static void bng_size(t_bng *x, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
#endif
x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
x->x_gui.x_h = x->x_gui.x_w; x->x_gui.x_h = x->x_gui.x_w;
iemgui_size((void *)x, &x->x_gui); iemgui_size((void *)x, &x->x_gui);
@ -385,6 +490,9 @@ static void bng_pos(t_bng *x, t_symbol *s, int ac, t_atom *av)
static void bng_flashtime(t_bng *x, t_symbol *s, int ac, t_atom *av) static void bng_flashtime(t_bng *x, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
#endif
bng_check_minmax(x, (int)atom_getintarg(0, ac, av), bng_check_minmax(x, (int)atom_getintarg(0, ac, av),
(int)atom_getintarg(1, ac, av)); (int)atom_getintarg(1, ac, av));
} }
@ -437,7 +545,11 @@ static void *bng_new(t_symbol *s, int argc, t_atom *argv)
int fs=8; int fs=8;
int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME,
fthold=IEM_BNG_DEFAULTHOLDFLASHTIME; fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
#ifdef ROCKBOX
(void) s;
#else
char str[144]; char str[144];
#endif
iem_inttosymargs(&x->x_gui.x_isa, 0); iem_inttosymargs(&x->x_gui.x_isa, 0);
iem_inttofstyle(&x->x_gui.x_fsf, 0); iem_inttofstyle(&x->x_gui.x_fsf, 0);
@ -511,7 +623,9 @@ static void bng_ff(t_bng *x)
clock_free(x->x_clock_lck); clock_free(x->x_clock_lck);
clock_free(x->x_clock_brk); clock_free(x->x_clock_brk);
clock_free(x->x_clock_hld); clock_free(x->x_clock_hld);
#ifndef ROCKBOX
gfxstub_deleteforkey(x); gfxstub_deleteforkey(x);
#endif
} }
void g_bang_setup(void) void g_bang_setup(void)

View file

@ -18,6 +18,15 @@ to be different but are now unified except for some fossilized names.) */
* changes marked with IOhannes * changes marked with IOhannes
*/ */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "m_imp.h"
#include "s_stuff.h"
#include "g_canvas.h"
#include "g_all_guis.h"
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "m_pd.h" #include "m_pd.h"
@ -26,6 +35,7 @@ to be different but are now unified except for some fossilized names.) */
#include "g_canvas.h" #include "g_canvas.h"
#include <string.h> #include <string.h>
#include "g_all_guis.h" #include "g_all_guis.h"
#endif /* ROCKBOX */
struct _canvasenvironment struct _canvasenvironment
{ {
@ -83,7 +93,12 @@ static void glist_doupdatewindowlist(t_glist *gl, char *sbuf)
if (strlen(sbuf) + strlen(gl->gl_name->s_name) + 100 <= 1024) if (strlen(sbuf) + strlen(gl->gl_name->s_name) + 100 <= 1024)
{ {
char tbuf[1024]; char tbuf[1024];
#ifdef ROCKBOX
snprintf(tbuf, sizeof(tbuf)-1,
"{%s .x%x} ", gl->gl_name->s_name, (t_int)canvas);
#else /* ROCKBOX */
sprintf(tbuf, "{%s .x%x} ", gl->gl_name->s_name, (t_int)canvas); sprintf(tbuf, "{%s .x%x} ", gl->gl_name->s_name, (t_int)canvas);
#endif /* ROCKBOX */
strcat(sbuf, tbuf); strcat(sbuf, tbuf);
} }
} }
@ -107,7 +122,9 @@ void canvas_updatewindowlist( void)
glist_doupdatewindowlist(x, sbuf); glist_doupdatewindowlist(x, sbuf);
/* next line updates the window menu state before -postcommand tries it */ /* next line updates the window menu state before -postcommand tries it */
strcat(sbuf, "}\npdtk_fixwindowmenu\n"); strcat(sbuf, "}\npdtk_fixwindowmenu\n");
#ifndef ROCKBOX
sys_gui(sbuf); sys_gui(sbuf);
#endif
} }
/* add a glist the list of "root" canvases (toplevels without parents.) */ /* add a glist the list of "root" canvases (toplevels without parents.) */
@ -144,6 +161,9 @@ void canvas_setargs(int argc, t_atom *argv)
void glob_setfilename(void *dummy, t_symbol *filesym, t_symbol *dirsym) void glob_setfilename(void *dummy, t_symbol *filesym, t_symbol *dirsym)
{ {
#ifdef ROCKBOX
(void) dummy;
#endif
canvas_newfilename = filesym; canvas_newfilename = filesym;
canvas_newdirectory = dirsym; canvas_newdirectory = dirsym;
} }
@ -286,7 +306,7 @@ t_outconnect *linetraverser_next(t_linetraverser *t)
if (!t->tr_ob) y = t->tr_x->gl_list; if (!t->tr_ob) y = t->tr_x->gl_list;
else y = t->tr_ob->ob_g.g_next; else y = t->tr_ob->ob_g.g_next;
for (; y; y = y->g_next) for (; y; y = y->g_next)
if (ob = pd_checkobject(&y->g_pd)) break; if((ob = pd_checkobject(&y->g_pd))) break;
if (!ob) return (0); if (!ob) return (0);
t->tr_ob = ob; t->tr_ob = ob;
t->tr_nout = obj_noutlets(ob); t->tr_nout = obj_noutlets(ob);
@ -357,7 +377,13 @@ t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv)
t_symbol *s = &s_; t_symbol *s = &s_;
int vis = 0, width = GLIST_DEFCANVASWIDTH, height = GLIST_DEFCANVASHEIGHT; int vis = 0, width = GLIST_DEFCANVASWIDTH, height = GLIST_DEFCANVASHEIGHT;
int xloc = 0, yloc = GLIST_DEFCANVASYLOC; int xloc = 0, yloc = GLIST_DEFCANVASYLOC;
#ifdef ROCKBOX
(void) dummy;
(void) sel;
int font = 10;
#else /* ROCKBOX */
int font = (owner ? owner->gl_font : sys_defaultfont); int font = (owner ? owner->gl_font : sys_defaultfont);
#endif /* ROCKBOX */
glist_init(x); glist_init(x);
x->gl_obj.te_type = T_OBJECT; x->gl_obj.te_type = T_OBJECT;
if (!owner) if (!owner)
@ -415,7 +441,11 @@ t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv)
x->gl_loading = 1; x->gl_loading = 1;
x->gl_willvis = vis; x->gl_willvis = vis;
x->gl_edit = !strncmp(x->gl_name->s_name, "Untitled", 8); x->gl_edit = !strncmp(x->gl_name->s_name, "Untitled", 8);
#ifdef ROCKBOX
x->gl_font = 10;
#else /* ROCKBOX */
x->gl_font = sys_nearestfontsize(font); x->gl_font = sys_nearestfontsize(font);
#endif /* ROCKBOX */
pd_pushsym(&x->gl_pd); pd_pushsym(&x->gl_pd);
return(x); return(x);
} }
@ -424,6 +454,9 @@ void canvas_setgraph(t_glist *x, int flag);
static void canvas_coords(t_glist *x, t_symbol *s, int argc, t_atom *argv) static void canvas_coords(t_glist *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
x->gl_x1 = atom_getfloatarg(0, argc, argv); x->gl_x1 = atom_getfloatarg(0, argc, argv);
x->gl_y1 = atom_getfloatarg(1, argc, argv); x->gl_y1 = atom_getfloatarg(1, argc, argv);
x->gl_x2 = atom_getfloatarg(2, argc, argv); x->gl_x2 = atom_getfloatarg(2, argc, argv);
@ -449,7 +482,11 @@ t_glist *glist_addglist(t_glist *g, t_symbol *sym,
if (!*sym->s_name) if (!*sym->s_name)
{ {
char buf[40]; char buf[40];
#ifdef ROCKBOX
snprintf(buf, sizeof(buf)-1, "graph%d", ++gcount);
#else /* ROCKBOX */
sprintf(buf, "graph%d", ++gcount); sprintf(buf, "graph%d", ++gcount);
#endif /* ROCKBOX */
sym = gensym(buf); sym = gensym(buf);
menu = 1; menu = 1;
} }
@ -484,8 +521,12 @@ t_glist *glist_addglist(t_glist *g, t_symbol *sym,
x->gl_obj.te_ypix = py1; x->gl_obj.te_ypix = py1;
x->gl_pixwidth = px2 - px1; x->gl_pixwidth = px2 - px1;
x->gl_pixheight = py2 - py1; x->gl_pixheight = py2 - py1;
#ifdef ROCKBOX
x->gl_font = 10;
#else /* ROCKBOX */
x->gl_font = (canvas_getcurrent() ? x->gl_font = (canvas_getcurrent() ?
canvas_getcurrent()->gl_font : sys_defaultfont); canvas_getcurrent()->gl_font : sys_defaultfont);
#endif /* ROCKBOX */
x->gl_screenx1 = x->gl_screeny1 = 0; x->gl_screenx1 = x->gl_screeny1 = 0;
x->gl_screenx2 = 240; x->gl_screenx2 = 240;
x->gl_screeny2 = 300; x->gl_screeny2 = 300;
@ -507,6 +548,9 @@ t_glist *glist_addglist(t_glist *g, t_symbol *sym,
/* call glist_addglist from a Pd message */ /* call glist_addglist from a Pd message */
void glist_glist(t_glist *g, t_symbol *s, int argc, t_atom *argv) void glist_glist(t_glist *g, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
t_symbol *sym = atom_getsymbolarg(0, argc, argv); t_symbol *sym = atom_getsymbolarg(0, argc, argv);
float x1 = atom_getfloatarg(1, argc, argv); float x1 = atom_getfloatarg(1, argc, argv);
float y1 = atom_getfloatarg(2, argc, argv); float y1 = atom_getfloatarg(2, argc, argv);
@ -584,9 +628,11 @@ void canvas_reflecttitle(t_canvas *x)
strcat(namebuf, ")"); strcat(namebuf, ")");
} }
else namebuf[0] = 0; else namebuf[0] = 0;
#ifndef ROCKBOX
sys_vgui("wm title .x%x {%s%c%s - %s}\n", sys_vgui("wm title .x%x {%s%c%s - %s}\n",
x, x->gl_name->s_name, (x->gl_dirty? '*' : ' '), namebuf, x, x->gl_name->s_name, (x->gl_dirty? '*' : ' '), namebuf,
canvas_getdir(x)->s_name); canvas_getdir(x)->s_name);
#endif
} }
void canvas_dirty(t_canvas *x, t_int n) void canvas_dirty(t_canvas *x, t_int n)
@ -624,7 +670,9 @@ void canvas_map(t_canvas *x, t_floatarg f)
canvas_drawlines(x); canvas_drawlines(x);
/* simulate a mouse up so u_main will calculate scrollbars... /* simulate a mouse up so u_main will calculate scrollbars...
ugly! */ ugly! */
#ifndef ROCKBOX
sys_vgui("pdtk_canvas_mouseup .x%x.c 0 0 0\n", x); sys_vgui("pdtk_canvas_mouseup .x%x.c 0 0 0\n", x);
#endif
} }
} }
else else
@ -632,7 +680,9 @@ void canvas_map(t_canvas *x, t_floatarg f)
if (glist_isvisible(x)) if (glist_isvisible(x))
{ {
/* just clear out the whole canvas... */ /* just clear out the whole canvas... */
#ifndef ROCKBOX
sys_vgui(".x%x.c delete all\n", x); sys_vgui(".x%x.c delete all\n", x);
#endif
/* alternatively, we could have erased them one by one... /* alternatively, we could have erased them one by one...
for (y = x->gl_list; y; y = y->g_next) for (y = x->gl_list; y; y = y->g_next)
gobj_vis(y, x, 0); gobj_vis(y, x, 0);
@ -661,7 +711,11 @@ static t_editor *editor_new(t_glist *owner)
x->e_connectbuf = binbuf_new(); x->e_connectbuf = binbuf_new();
x->e_deleted = binbuf_new(); x->e_deleted = binbuf_new();
x->e_glist = owner; x->e_glist = owner;
#ifdef ROCKBOX
snprintf(buf, sizeof(buf)-1, ".x%x", (t_int)owner);
#else /* ROCKBOX */
sprintf(buf, ".x%x", (t_int)owner); sprintf(buf, ".x%x", (t_int)owner);
#endif /* ROCKBOX */
x->e_guiconnect = guiconnect_new(&owner->gl_pd, gensym(buf)); x->e_guiconnect = guiconnect_new(&owner->gl_pd, gensym(buf));
return (x); return (x);
} }
@ -689,7 +743,7 @@ void canvas_create_editor(t_glist *x, int createit)
{ {
x->gl_editor = editor_new(x); x->gl_editor = editor_new(x);
for (y = x->gl_list; y; y = y->g_next) for (y = x->gl_list; y; y = y->g_next)
if (ob = pd_checkobject(&y->g_pd)) if((ob = pd_checkobject(&y->g_pd)))
rtext_new(x, ob); rtext_new(x, ob);
} }
} }
@ -700,7 +754,7 @@ void canvas_create_editor(t_glist *x, int createit)
else else
{ {
for (y = x->gl_list; y; y = y->g_next) for (y = x->gl_list; y; y = y->g_next)
if (ob = pd_checkobject(&y->g_pd)) if((ob = pd_checkobject(&y->g_pd)))
rtext_free(glist_findrtext(x, ob)); rtext_free(glist_findrtext(x, ob));
editor_free(x->gl_editor, x); editor_free(x->gl_editor, x);
x->gl_editor = 0; x->gl_editor = 0;
@ -717,7 +771,9 @@ void canvas_create_editor(t_glist *x, int createit)
the window. */ the window. */
void canvas_vis(t_canvas *x, t_floatarg f) void canvas_vis(t_canvas *x, t_floatarg f)
{ {
#ifndef ROCKBOX
char buf[30]; char buf[30];
#endif
int flag = (f != 0); int flag = (f != 0);
if (flag) if (flag)
{ {
@ -728,19 +784,23 @@ void canvas_vis(t_canvas *x, t_floatarg f)
canvas_vis(x, 0); canvas_vis(x, 0);
canvas_vis(x, 1); canvas_vis(x, 1);
#else #else
#ifndef ROCKBOX
sys_vgui("raise .x%x\n", x); sys_vgui("raise .x%x\n", x);
sys_vgui("focus .x%x.c\n", x); sys_vgui("focus .x%x.c\n", x);
sys_vgui("wm deiconify .x%x\n", x); sys_vgui("wm deiconify .x%x\n", x);
#endif /* ROCKBOX */
#endif #endif
} }
else else
{ {
canvas_create_editor(x, 1); canvas_create_editor(x, 1);
#ifndef ROCKBOX
sys_vgui("pdtk_canvas_new .x%x %d %d +%d+%d %d\n", x, sys_vgui("pdtk_canvas_new .x%x %d %d +%d+%d %d\n", x,
(int)(x->gl_screenx2 - x->gl_screenx1), (int)(x->gl_screenx2 - x->gl_screenx1),
(int)(x->gl_screeny2 - x->gl_screeny1), (int)(x->gl_screeny2 - x->gl_screeny1),
(int)(x->gl_screenx1), (int)(x->gl_screeny1), (int)(x->gl_screenx1), (int)(x->gl_screeny1),
x->gl_edit); x->gl_edit);
#endif /* ROCKBOX */
canvas_reflecttitle(x); canvas_reflecttitle(x);
x->gl_havewindow = 1; x->gl_havewindow = 1;
canvas_updatewindowlist(); canvas_updatewindowlist();
@ -765,10 +825,14 @@ void canvas_vis(t_canvas *x, t_floatarg f)
if (glist_isvisible(x)) if (glist_isvisible(x))
canvas_map(x, 0); canvas_map(x, 0);
canvas_create_editor(x, 0); canvas_create_editor(x, 0);
#ifndef ROCKBOX
sys_vgui("destroy .x%x\n", x); sys_vgui("destroy .x%x\n", x);
#endif
for (i = 1, x2 = x; x2; x2 = x2->gl_next, i++) for (i = 1, x2 = x; x2; x2 = x2->gl_next, i++)
; ;
#ifndef ROCKBOX
sys_vgui(".mbar.find delete %d\n", i); sys_vgui(".mbar.find delete %d\n", i);
#endif
/* if we're a graph on our parent, and if the parent exists /* if we're a graph on our parent, and if the parent exists
and is visible, show ourselves on parent. */ and is visible, show ourselves on parent. */
if (glist_isgraph(x) && x->gl_owner) if (glist_isgraph(x) && x->gl_owner)
@ -837,7 +901,7 @@ void canvas_free(t_canvas *x)
if (canvas_whichfind == x) if (canvas_whichfind == x)
canvas_whichfind = 0; canvas_whichfind = 0;
glist_noselect(x); glist_noselect(x);
while (y = x->gl_list) while((y = x->gl_list))
glist_delete(x, y); glist_delete(x, y);
canvas_vis(x, 0); canvas_vis(x, 0);
@ -850,7 +914,9 @@ void canvas_free(t_canvas *x)
} }
canvas_resume_dsp(dspstate); canvas_resume_dsp(dspstate);
glist_cleanup(x); glist_cleanup(x);
#ifndef ROCKBOX
gfxstub_deleteforkey(x); /* probably unnecessary */ gfxstub_deleteforkey(x); /* probably unnecessary */
#endif
if (!x->gl_owner) if (!x->gl_owner)
canvas_takeofflist(x); canvas_takeofflist(x);
} }
@ -863,12 +929,16 @@ static void canvas_drawlines(t_canvas *x)
t_outconnect *oc; t_outconnect *oc;
{ {
linetraverser_start(&t, x); linetraverser_start(&t, x);
while (oc = linetraverser_next(&t)) while((oc = linetraverser_next(&t)))
#ifdef ROCKBOX
;
#else /* ROCKBOX */
sys_vgui(".x%x.c create line %d %d %d %d -width %d -tags l%x\n", sys_vgui(".x%x.c create line %d %d %d %d -width %d -tags l%x\n",
glist_getcanvas(x), glist_getcanvas(x),
t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2, t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2,
(outlet_getsymbol(t.tr_outlet) == &s_signal ? 2:1), (outlet_getsymbol(t.tr_outlet) == &s_signal ? 2:1),
oc); oc);
#endif /* ROCKBOX */
} }
} }
@ -878,13 +948,15 @@ void canvas_fixlinesfor(t_canvas *x, t_text *text)
t_outconnect *oc; t_outconnect *oc;
linetraverser_start(&t, x); linetraverser_start(&t, x);
while (oc = linetraverser_next(&t)) while((oc = linetraverser_next(&t)))
{ {
if (t.tr_ob == text || t.tr_ob2 == text) if (t.tr_ob == text || t.tr_ob2 == text)
{ {
#ifndef ROCKBOX
sys_vgui(".x%x.c coords l%x %d %d %d %d\n", sys_vgui(".x%x.c coords l%x %d %d %d %d\n",
glist_getcanvas(x), oc, glist_getcanvas(x), oc,
t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2); t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2);
#endif
} }
} }
} }
@ -895,14 +967,16 @@ void canvas_deletelinesfor(t_canvas *x, t_text *text)
t_linetraverser t; t_linetraverser t;
t_outconnect *oc; t_outconnect *oc;
linetraverser_start(&t, x); linetraverser_start(&t, x);
while (oc = linetraverser_next(&t)) while((oc = linetraverser_next(&t)))
{ {
if (t.tr_ob == text || t.tr_ob2 == text) if (t.tr_ob == text || t.tr_ob2 == text)
{ {
if (x->gl_editor) if (x->gl_editor)
{ {
#ifndef ROCKBOX
sys_vgui(".x%x.c delete l%x\n", sys_vgui(".x%x.c delete l%x\n",
glist_getcanvas(x), oc); glist_getcanvas(x), oc);
#endif
} }
obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno); obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
} }
@ -916,15 +990,17 @@ void canvas_deletelinesforio(t_canvas *x, t_text *text,
t_linetraverser t; t_linetraverser t;
t_outconnect *oc; t_outconnect *oc;
linetraverser_start(&t, x); linetraverser_start(&t, x);
while (oc = linetraverser_next(&t)) while((oc = linetraverser_next(&t)))
{ {
if ((t.tr_ob == text && t.tr_outlet == outp) || if ((t.tr_ob == text && t.tr_outlet == outp) ||
(t.tr_ob2 == text && t.tr_inlet == inp)) (t.tr_ob2 == text && t.tr_inlet == inp))
{ {
if (x->gl_editor) if (x->gl_editor)
{ {
#ifndef ROCKBOX
sys_vgui(".x%x.c delete l%x\n", sys_vgui(".x%x.c delete l%x\n",
glist_getcanvas(x), oc); glist_getcanvas(x), oc);
#endif
} }
obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno); obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
} }
@ -947,6 +1023,9 @@ void canvas_objfor(t_glist *gl, t_text *x, int argc, t_atom *argv);
void canvas_restore(t_canvas *x, t_symbol *s, int argc, t_atom *argv) void canvas_restore(t_canvas *x, t_symbol *s, int argc, t_atom *argv)
{ /* IOhannes */ { /* IOhannes */
t_pd *z; t_pd *z;
#ifdef ROCKBOX
(void) s;
#endif
/* this should be unnecessary, but sometimes the canvas's name gets /* this should be unnecessary, but sometimes the canvas's name gets
out of sync with the owning box's argument; this fixes that */ out of sync with the owning box's argument; this fixes that */
if (argc > 3) if (argc > 3)
@ -992,7 +1071,9 @@ void canvas_restore(t_canvas *x, t_symbol *s, int argc, t_atom *argv)
static void canvas_loadbangabstractions(t_canvas *x) static void canvas_loadbangabstractions(t_canvas *x)
{ {
t_gobj *y; t_gobj *y;
#ifndef ROCKBOX
t_symbol *s = gensym("loadbang"); t_symbol *s = gensym("loadbang");
#endif
for (y = x->gl_list; y; y = y->g_next) for (y = x->gl_list; y; y = y->g_next)
if (pd_class(&y->g_pd) == canvas_class) if (pd_class(&y->g_pd) == canvas_class)
{ {
@ -1021,7 +1102,9 @@ void canvas_loadbangsubpatches(t_canvas *x)
void canvas_loadbang(t_canvas *x) void canvas_loadbang(t_canvas *x)
{ {
#ifndef ROCKBOX
t_gobj *y; t_gobj *y;
#endif
canvas_loadbangabstractions(x); canvas_loadbangabstractions(x);
canvas_loadbangsubpatches(x); canvas_loadbangsubpatches(x);
} }
@ -1042,6 +1125,11 @@ void canvas_loadbang(t_canvas *x)
static void canvas_relocate(t_canvas *x, t_symbol *canvasgeom, static void canvas_relocate(t_canvas *x, t_symbol *canvasgeom,
t_symbol *topgeom) t_symbol *topgeom)
{ {
#ifdef ROCKBOX
(void) x;
(void) canvasgeom;
(void) topgeom;
#else /* ROCKBOX */
int cxpix, cypix, cw, ch, txpix, typix, tw, th; int cxpix, cypix, cw, ch, txpix, typix, tw, th;
if (sscanf(canvasgeom->s_name, "%dx%d+%d+%d", &cw, &ch, &cxpix, &cypix) if (sscanf(canvasgeom->s_name, "%dx%d+%d+%d", &cw, &ch, &cxpix, &cypix)
< 4 || < 4 ||
@ -1052,6 +1140,7 @@ static void canvas_relocate(t_canvas *x, t_symbol *canvasgeom,
if (cw > 5 && ch > 5) if (cw > 5 && ch > 5)
canvas_setbounds(x, txpix, typix, canvas_setbounds(x, txpix, typix,
txpix + cw - HORIZBORDER, typix + ch - VERTBORDER); txpix + cw - HORIZBORDER, typix + ch - VERTBORDER);
#endif /* ROCKBOX */
} }
void canvas_popabstraction(t_canvas *x) void canvas_popabstraction(t_canvas *x)
@ -1065,6 +1154,9 @@ void canvas_popabstraction(t_canvas *x)
void canvas_logerror(t_object *y) void canvas_logerror(t_object *y)
{ {
#ifdef ROCKBOX
(void) y;
#endif
#ifdef LATER #ifdef LATER
canvas_vis(x, 1); canvas_vis(x, 1);
if (!glist_isselected(x, &y->ob_g)) if (!glist_isselected(x, &y->ob_g))
@ -1095,6 +1187,13 @@ static void canvas_click(t_canvas *x,
t_floatarg xpos, t_floatarg ypos, t_floatarg xpos, t_floatarg ypos,
t_floatarg shift, t_floatarg ctrl, t_floatarg alt) t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
{ {
#ifdef ROCKBOX
(void) xpos;
(void) ypos;
(void) shift;
(void) ctrl;
(void) alt;
#endif
canvas_vis(x, 1); canvas_vis(x, 1);
} }
@ -1103,13 +1202,22 @@ static void canvas_click(t_canvas *x,
void canvas_fattensub(t_canvas *x, void canvas_fattensub(t_canvas *x,
int *xp1, int *yp1, int *xp2, int *yp2) int *xp1, int *yp1, int *xp2, int *yp2)
{ {
#ifdef ROCKBOX
(void) x;
(void) xp1;
(void) yp1;
#else /* ROCKBOX */
t_gobj *y; t_gobj *y;
#endif /* ROCKBOX */
*xp2 += 50; /* fake for now */ *xp2 += 50; /* fake for now */
*yp2 += 50; *yp2 += 50;
} }
static void canvas_rename_method(t_canvas *x, t_symbol *s, int ac, t_atom *av) static void canvas_rename_method(t_canvas *x, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
#endif
if (ac && av->a_type == A_SYMBOL) if (ac && av->a_type == A_SYMBOL)
canvas_rename(x, av->a_w.w_symbol, 0); canvas_rename(x, av->a_w.w_symbol, 0);
else canvas_rename(x, gensym("Pd"), 0); else canvas_rename(x, gensym("Pd"), 0);
@ -1128,7 +1236,11 @@ static void *table_new(t_symbol *s, t_floatarg f)
{ {
char tabname[255]; char tabname[255];
t_symbol *t = gensym("table"); t_symbol *t = gensym("table");
#ifdef ROCKBOX
snprintf(tabname, sizeof(tabname)-1, "%s%d", t->s_name, tabcount++);
#else /* ROCKBOX */
sprintf(tabname, "%s%d", t->s_name, tabcount++); sprintf(tabname, "%s%d", t->s_name, tabcount++);
#endif /* ROCKBOX */
s = gensym(tabname); s = gensym(tabname);
} }
if (f <= 1) if (f <= 1)
@ -1239,7 +1351,7 @@ static void canvas_dodsp(t_canvas *x, int toplevel, t_signal **sp)
/* ... and all dsp interconnections */ /* ... and all dsp interconnections */
linetraverser_start(&t, x); linetraverser_start(&t, x);
while (oc = linetraverser_next(&t)) while((oc = linetraverser_next(&t)))
if (obj_issignaloutlet(t.tr_ob, t.tr_outno)) if (obj_issignaloutlet(t.tr_ob, t.tr_outno))
ugen_connect(dc, t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno); ugen_connect(dc, t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
@ -1252,7 +1364,9 @@ static void canvas_start_dsp(void)
{ {
t_canvas *x; t_canvas *x;
if (canvas_dspstate) ugen_stop(); if (canvas_dspstate) ugen_stop();
#ifndef ROCKBOX
else sys_gui("pdtk_pd_dsp ON\n"); else sys_gui("pdtk_pd_dsp ON\n");
#endif
ugen_start(); ugen_start();
for (x = canvas_list; x; x = x->gl_next) for (x = canvas_list; x; x = x->gl_next)
@ -1266,7 +1380,9 @@ static void canvas_stop_dsp(void)
if (canvas_dspstate) if (canvas_dspstate)
{ {
ugen_stop(); ugen_stop();
#ifndef ROCKBOX
sys_gui("pdtk_pd_dsp OFF\n"); sys_gui("pdtk_pd_dsp OFF\n");
#endif
canvas_dspstate = 0; canvas_dspstate = 0;
} }
} }
@ -1297,6 +1413,10 @@ void canvas_update_dsp(void)
void glob_dsp(void *dummy, t_symbol *s, int argc, t_atom *argv) void glob_dsp(void *dummy, t_symbol *s, int argc, t_atom *argv)
{ {
int newstate; int newstate;
#ifdef ROCKBOX
(void) dummy;
(void) s;
#endif
if (argc) if (argc)
{ {
newstate = atom_getintarg(0, argc, argv); newstate = atom_getintarg(0, argc, argv);
@ -1333,7 +1453,9 @@ static void glist_redrawall(t_glist *gl)
int vis = glist_isvisible(gl); int vis = glist_isvisible(gl);
for (g = gl->gl_list; g; g = g->g_next) for (g = gl->gl_list; g; g = g->g_next)
{ {
#ifndef ROCKBOX
t_class *cl; t_class *cl;
#endif
if (vis && g->g_pd == scalar_class) if (vis && g->g_pd == scalar_class)
glist_redrawitem(gl, g); glist_redrawitem(gl, g);
else if (g->g_pd == canvas_class) else if (g->g_pd == canvas_class)
@ -1345,6 +1467,9 @@ static void glist_redrawall(t_glist *gl)
void canvas_redrawallfortemplate(t_canvas *templatecanvas) void canvas_redrawallfortemplate(t_canvas *templatecanvas)
{ {
t_canvas *x; t_canvas *x;
#ifdef ROCKBOX
(void) templatecanvas;
#endif
/* find all root canvases */ /* find all root canvases */
for (x = canvas_list; x; x = x->gl_next) for (x = canvas_list; x; x = x->gl_next)
glist_redrawall(x); glist_redrawall(x);

View file

@ -2,6 +2,14 @@
* For information on usage and redistribution, and for a DISCLAIMER OF ALL * For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "m_imp.h"
#include "s_stuff.h"
#include "g_canvas.h"
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "m_pd.h" #include "m_pd.h"
@ -9,6 +17,7 @@
#include "s_stuff.h" #include "s_stuff.h"
#include "g_canvas.h" #include "g_canvas.h"
#include <string.h> #include <string.h>
#endif /* ROCKBOX */
void glist_readfrombinbuf(t_glist *x, t_binbuf *b, char *filename, void glist_readfrombinbuf(t_glist *x, t_binbuf *b, char *filename,
int selectem); int selectem);
@ -88,8 +97,10 @@ void glist_selectline(t_glist *x, t_outconnect *oc, int index1,
x->gl_editor->e_selectline_index2 = index2; x->gl_editor->e_selectline_index2 = index2;
x->gl_editor->e_selectline_inno = inno; x->gl_editor->e_selectline_inno = inno;
x->gl_editor->e_selectline_tag = oc; x->gl_editor->e_selectline_tag = oc;
#ifndef ROCKBOX
sys_vgui(".x%x.c itemconfigure l%x -fill blue\n", sys_vgui(".x%x.c itemconfigure l%x -fill blue\n",
x, x->gl_editor->e_selectline_tag); x, x->gl_editor->e_selectline_tag);
#endif
} }
} }
@ -98,8 +109,10 @@ void glist_deselectline(t_glist *x)
if (x->gl_editor) if (x->gl_editor)
{ {
x->gl_editor->e_selectedline = 0; x->gl_editor->e_selectedline = 0;
#ifndef ROCKBOX
sys_vgui(".x%x.c itemconfigure l%x -fill black\n", sys_vgui(".x%x.c itemconfigure l%x -fill black\n",
x, x->gl_editor->e_selectline_tag); x, x->gl_editor->e_selectline_tag);
#endif
} }
} }
@ -166,7 +179,7 @@ void glist_deselect(t_glist *x, t_gobj *y)
} }
else else
{ {
for (sel = x->gl_editor->e_selection; sel2 = sel->sel_next; for(sel = x->gl_editor->e_selection; (sel2 = sel->sel_next);
sel = sel2) sel = sel2)
{ {
if (sel2->sel_what == y) if (sel2->sel_what == y)
@ -217,7 +230,7 @@ void glist_selectall(t_glist *x)
x->gl_editor->e_selection = sel; x->gl_editor->e_selection = sel;
sel->sel_what = y; sel->sel_what = y;
gobj_select(y, x, 1); gobj_select(y, x, 1);
while (y = y->g_next) while((y = y->g_next))
{ {
t_selection *sel2 = (t_selection *)getbytes(sizeof(*sel2)); t_selection *sel2 = (t_selection *)getbytes(sizeof(*sel2));
sel->sel_next = sel2; sel->sel_next = sel2;
@ -290,11 +303,13 @@ void canvas_setundo(t_canvas *x, t_undofn undofn, void *buf,
canvas_undo_buf = buf; canvas_undo_buf = buf;
canvas_undo_whatnext = UNDO_UNDO; canvas_undo_whatnext = UNDO_UNDO;
canvas_undo_name = name; canvas_undo_name = name;
#ifndef ROCKBOX
if (x && glist_isvisible(x) && glist_istoplevel(x)) if (x && glist_isvisible(x) && glist_istoplevel(x))
/* enable undo in menu */ /* enable undo in menu */
sys_vgui("pdtk_undomenu .x%x %s no\n", x, name); sys_vgui("pdtk_undomenu .x%x %s no\n", x, name);
else if (hadone) else if (hadone)
sys_vgui("pdtk_undomenu nobody no no\n"); sys_vgui("pdtk_undomenu nobody no no\n");
#endif
} }
/* clear undo if it happens to be for the canvas x. /* clear undo if it happens to be for the canvas x.
@ -316,8 +331,10 @@ static void canvas_undo(t_canvas *x)
/* post("undo"); */ /* post("undo"); */
(*canvas_undo_fn)(canvas_undo_canvas, canvas_undo_buf, UNDO_UNDO); (*canvas_undo_fn)(canvas_undo_canvas, canvas_undo_buf, UNDO_UNDO);
/* enable redo in menu */ /* enable redo in menu */
#ifndef ROCKBOX
if (glist_isvisible(x) && glist_istoplevel(x)) if (glist_isvisible(x) && glist_istoplevel(x))
sys_vgui("pdtk_undomenu .x%x no %s\n", x, canvas_undo_name); sys_vgui("pdtk_undomenu .x%x no %s\n", x, canvas_undo_name);
#endif
canvas_undo_whatnext = UNDO_REDO; canvas_undo_whatnext = UNDO_REDO;
} }
} }
@ -333,8 +350,10 @@ static void canvas_redo(t_canvas *x)
/* post("redo"); */ /* post("redo"); */
(*canvas_undo_fn)(canvas_undo_canvas, canvas_undo_buf, UNDO_REDO); (*canvas_undo_fn)(canvas_undo_canvas, canvas_undo_buf, UNDO_REDO);
/* enable undo in menu */ /* enable undo in menu */
#ifndef ROCKBOX
if (glist_isvisible(x) && glist_istoplevel(x)) if (glist_isvisible(x) && glist_istoplevel(x))
sys_vgui("pdtk_undomenu .x%x %s no\n", x, canvas_undo_name); sys_vgui("pdtk_undomenu .x%x %s no\n", x, canvas_undo_name);
#endif
canvas_undo_whatnext = UNDO_UNDO; canvas_undo_whatnext = UNDO_UNDO;
} }
} }
@ -352,6 +371,9 @@ typedef struct _undo_connect
static void *canvas_undo_set_disconnect(t_canvas *x, static void *canvas_undo_set_disconnect(t_canvas *x,
int index1, int outno, int index2, int inno) int index1, int outno, int index2, int inno)
{ {
#ifdef ROCKBOX
(void) x;
#endif
t_undo_connect *buf = (t_undo_connect *)getbytes(sizeof(*buf)); t_undo_connect *buf = (t_undo_connect *)getbytes(sizeof(*buf));
buf->u_index1 = index1; buf->u_index1 = index1;
buf->u_outletno = outno; buf->u_outletno = outno;
@ -366,14 +388,16 @@ void canvas_disconnect(t_canvas *x,
t_linetraverser t; t_linetraverser t;
t_outconnect *oc; t_outconnect *oc;
linetraverser_start(&t, x); linetraverser_start(&t, x);
while (oc = linetraverser_next(&t)) while((oc = linetraverser_next(&t)))
{ {
int srcno = canvas_getindex(x, &t.tr_ob->ob_g); int srcno = canvas_getindex(x, &t.tr_ob->ob_g);
int sinkno = canvas_getindex(x, &t.tr_ob2->ob_g); int sinkno = canvas_getindex(x, &t.tr_ob2->ob_g);
if (srcno == index1 && t.tr_outno == outno && if (srcno == index1 && t.tr_outno == outno &&
sinkno == index2 && t.tr_inno == inno) sinkno == index2 && t.tr_inno == inno)
{ {
#ifndef ROCKBOX
sys_vgui(".x%x.c delete l%x\n", x, oc); sys_vgui(".x%x.c delete l%x\n", x, oc);
#endif
obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno); obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
break; break;
} }
@ -432,7 +456,9 @@ typedef struct _undo_cut
static void *canvas_undo_set_cut(t_canvas *x, int mode) static void *canvas_undo_set_cut(t_canvas *x, int mode)
{ {
t_undo_cut *buf; t_undo_cut *buf;
#ifndef ROCKBOX
t_gobj *y; t_gobj *y;
#endif
t_linetraverser t; t_linetraverser t;
t_outconnect *oc; t_outconnect *oc;
int nnotsel= glist_selectionindex(x, 0, 0); int nnotsel= glist_selectionindex(x, 0, 0);
@ -443,7 +469,7 @@ static void *canvas_undo_set_cut(t_canvas *x, int mode)
/* store connections into/out of the selection */ /* store connections into/out of the selection */
buf->u_reconnectbuf = binbuf_new(); buf->u_reconnectbuf = binbuf_new();
linetraverser_start(&t, x); linetraverser_start(&t, x);
while (oc = linetraverser_next(&t)) while((oc = linetraverser_next(&t)))
{ {
int issel1 = glist_isselected(x, &t.tr_ob->ob_g); int issel1 = glist_isselected(x, &t.tr_ob->ob_g);
int issel2 = glist_isselected(x, &t.tr_ob2->ob_g); int issel2 = glist_isselected(x, &t.tr_ob2->ob_g);
@ -488,7 +514,7 @@ static void canvas_undo_cut(t_canvas *x, void *z, int action)
{ {
t_gobj *y1, *y2; t_gobj *y1, *y2;
glist_noselect(x); glist_noselect(x);
for (y1 = x->gl_list; y2 = y1->g_next; y1 = y2) for(y1 = x->gl_list; (y2 = y1->g_next); y1 = y2)
; ;
if (y1) if (y1)
{ {
@ -514,7 +540,7 @@ static void canvas_undo_cut(t_canvas *x, void *z, int action)
else if (mode == UCUT_TEXT) else if (mode == UCUT_TEXT)
{ {
t_gobj *y1, *y2; t_gobj *y1, *y2;
for (y1 = x->gl_list; y2 = y1->g_next; y1 = y2) for(y1 = x->gl_list; (y2 = y1->g_next); y1 = y2)
; ;
if (y1) if (y1)
glist_delete(x, y1); glist_delete(x, y1);
@ -738,7 +764,9 @@ void canvas_setcursor(t_canvas *x, unsigned int cursornum)
} }
if (xwas != x || cursorwas != cursornum) if (xwas != x || cursorwas != cursornum)
{ {
#ifndef ROCKBOX
sys_vgui(".x%x configure -cursor %s\n", x, cursorlist[cursornum]); sys_vgui(".x%x configure -cursor %s\n", x, cursorlist[cursornum]);
#endif
xwas = x; xwas = x;
cursorwas = cursornum; cursorwas = cursornum;
} }
@ -784,8 +812,14 @@ static void canvas_rightclick(t_canvas *x, int xpos, int ypos, t_gobj *y)
int canprop, canopen; int canprop, canopen;
canprop = (!y || (y && class_getpropertiesfn(pd_class(&y->g_pd)))); canprop = (!y || (y && class_getpropertiesfn(pd_class(&y->g_pd))));
canopen = (y && zgetfn(&y->g_pd, gensym("menu-open"))); canopen = (y && zgetfn(&y->g_pd, gensym("menu-open")));
#ifdef ROCKBOX
(void) x;
(void) xpos;
(void) ypos;
#else /* ROCKBOX */
sys_vgui("pdtk_canvas_popup .x%x %d %d %d %d\n", sys_vgui("pdtk_canvas_popup .x%x %d %d %d %d\n",
x, xpos, ypos, canprop, canopen); x, xpos, ypos, canprop, canopen);
#endif /* ROCKBOX */
} }
/* tell GUI to create a properties dialog on the canvas. We tell /* tell GUI to create a properties dialog on the canvas. We tell
@ -793,11 +827,15 @@ static void canvas_rightclick(t_canvas *x, int xpos, int ypos, t_gobj *y)
naturally upward, whereas pixels grow downward. */ naturally upward, whereas pixels grow downward. */
static void canvas_properties(t_glist *x) static void canvas_properties(t_glist *x)
{ {
#ifdef ROCKBOX
(void) x;
#else /* ROCKBOX */
char graphbuf[200]; char graphbuf[200];
sprintf(graphbuf, "pdtk_canvas_dialog %%s %g %g %g %g \n", sprintf(graphbuf, "pdtk_canvas_dialog %%s %g %g %g %g \n",
glist_dpixtodx(x, 1), -glist_dpixtody(x, 1), glist_dpixtodx(x, 1), -glist_dpixtody(x, 1),
(float)glist_isgraph(x), (float)x->gl_stretch); (float)glist_isgraph(x), (float)x->gl_stretch);
gfxstub_new(&x->gl_pd, x, graphbuf); gfxstub_new(&x->gl_pd, x, graphbuf);
#endif /* ROCKBOX */
} }
@ -885,7 +923,11 @@ static void canvas_donecanvasdialog(t_glist *x, t_floatarg xperpix,
"open," or "help." */ "open," or "help." */
static void canvas_done_popup(t_canvas *x, float which, float xpos, float ypos) static void canvas_done_popup(t_canvas *x, float which, float xpos, float ypos)
{ {
#ifdef ROCKBOX
char namebuf[MAXPDSTRING];
#else
char pathbuf[MAXPDSTRING], namebuf[MAXPDSTRING]; char pathbuf[MAXPDSTRING], namebuf[MAXPDSTRING];
#endif
t_gobj *y; t_gobj *y;
for (y = x->gl_list; y; y = y->g_next) for (y = x->gl_list; y; y = y->g_next)
{ {
@ -936,9 +978,11 @@ static void canvas_done_popup(t_canvas *x, float which, float xpos, float ypos)
canvas_properties(x); canvas_properties(x);
else if (which == 2) else if (which == 2)
{ {
#ifndef ROCKBOX
strcpy(pathbuf, sys_libdir->s_name); strcpy(pathbuf, sys_libdir->s_name);
strcat(pathbuf, "/doc/5.reference/0.INTRO.txt"); strcat(pathbuf, "/doc/5.reference/0.INTRO.txt");
sys_vgui("menu_opentext %s\n", pathbuf); sys_vgui("menu_opentext %s\n", pathbuf);
#endif
} }
} }
@ -967,7 +1011,11 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
t_gobj *y; t_gobj *y;
int shiftmod, runmode, altmod, rightclick; int shiftmod, runmode, altmod, rightclick;
int x1, y1, x2, y2, clickreturned = 0; int x1, y1, x2, y2, clickreturned = 0;
#ifdef ROCKBOX
(void) which;
#endif
if (!x->gl_editor) if (!x->gl_editor)
{ {
bug("editor"); bug("editor");
@ -1027,7 +1075,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
return; return;
} }
/* if not a runmode left click, fall here. */ /* if not a runmode left click, fall here. */
if (y = canvas_findhitbox(x, xpos, ypos, &x1, &y1, &x2, &y2)) if((y = canvas_findhitbox(x, xpos, ypos, &x1, &y1, &x2, &y2)))
{ {
t_object *ob = pd_checkobject(&y->g_pd); t_object *ob = pd_checkobject(&y->g_pd);
/* check you're in the rectangle */ /* check you're in the rectangle */
@ -1071,14 +1119,18 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
{ {
if (doit) if (doit)
{ {
#ifndef ROCKBOX
int issignal = obj_issignaloutlet(ob, closest); int issignal = obj_issignaloutlet(ob, closest);
#endif
x->gl_editor->e_onmotion = MA_CONNECT; x->gl_editor->e_onmotion = MA_CONNECT;
x->gl_editor->e_xwas = xpos; x->gl_editor->e_xwas = xpos;
x->gl_editor->e_ywas = ypos; x->gl_editor->e_ywas = ypos;
#ifndef ROCKBOX
sys_vgui( sys_vgui(
".x%x.c create line %d %d %d %d -width %d -tags x\n", ".x%x.c create line %d %d %d %d -width %d -tags x\n",
x, xpos, ypos, xpos, ypos, x, xpos, ypos, xpos, ypos,
(issignal ? 2 : 1)); (issignal ? 2 : 1));
#endif
} }
else canvas_setcursor(x, CURSOR_EDITMODE_CONNECT); else canvas_setcursor(x, CURSOR_EDITMODE_CONNECT);
} }
@ -1134,7 +1186,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
float fx = xpos, fy = ypos; float fx = xpos, fy = ypos;
t_glist *glist2 = glist_getcanvas(x); t_glist *glist2 = glist_getcanvas(x);
linetraverser_start(&t, glist2); linetraverser_start(&t, glist2);
while (oc = linetraverser_next(&t)) while((oc = linetraverser_next(&t)))
{ {
float lx1 = t.tr_lx1, ly1 = t.tr_ly1, float lx1 = t.tr_lx1, ly1 = t.tr_ly1,
lx2 = t.tr_lx2, ly2 = t.tr_ly2; lx2 = t.tr_lx2, ly2 = t.tr_ly2;
@ -1158,8 +1210,10 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
if (doit) if (doit)
{ {
if (!shiftmod) glist_noselect(x); if (!shiftmod) glist_noselect(x);
#ifndef ROCKBOX
sys_vgui(".x%x.c create rectangle %d %d %d %d -tags x\n", sys_vgui(".x%x.c create rectangle %d %d %d %d -tags x\n",
x, xpos, ypos, xpos, ypos); x, xpos, ypos, xpos, ypos);
#endif
x->gl_editor->e_xwas = xpos; x->gl_editor->e_xwas = xpos;
x->gl_editor->e_ywas = ypos; x->gl_editor->e_ywas = ypos;
x->gl_editor->e_onmotion = MA_REGION; x->gl_editor->e_onmotion = MA_REGION;
@ -1178,7 +1232,7 @@ int canvas_isconnected (t_canvas *x, t_text *ob1, int n1,
t_linetraverser t; t_linetraverser t;
t_outconnect *oc; t_outconnect *oc;
linetraverser_start(&t, x); linetraverser_start(&t, x);
while (oc = linetraverser_next(&t)) while((oc = linetraverser_next(&t)))
if (t.tr_ob == ob1 && t.tr_outno == n1 && if (t.tr_ob == ob1 && t.tr_outno == n1 &&
t.tr_ob2 == ob2 && t.tr_inno == n2) t.tr_ob2 == ob2 && t.tr_inno == n2)
return (1); return (1);
@ -1193,10 +1247,15 @@ void canvas_doconnect(t_canvas *x, int xpos, int ypos, int which, int doit)
t_gobj *y2; t_gobj *y2;
int xwas = x->gl_editor->e_xwas, int xwas = x->gl_editor->e_xwas,
ywas = x->gl_editor->e_ywas; ywas = x->gl_editor->e_ywas;
#ifdef ROCKBOX
(void) which;
#endif /* ROCKBOX */
#ifndef ROCKBOX
if (doit) sys_vgui(".x%x.c delete x\n", x); if (doit) sys_vgui(".x%x.c delete x\n", x);
else sys_vgui(".x%x.c coords x %d %d %d %d\n", else sys_vgui(".x%x.c coords x %d %d %d %d\n",
x, x->gl_editor->e_xwas, x, x->gl_editor->e_xwas,
x->gl_editor->e_ywas, xpos, ypos); x->gl_editor->e_ywas, xpos, ypos);
#endif /* ROCKBOX */
if ((y1 = canvas_findhitbox(x, xwas, ywas, &x11, &y11, &x12, &y12)) if ((y1 = canvas_findhitbox(x, xwas, ywas, &x11, &y11, &x12, &y12))
&& (y2 = canvas_findhitbox(x, xpos, ypos, &x21, &y21, &x22, &y22))) && (y2 = canvas_findhitbox(x, xpos, ypos, &x21, &y21, &x22, &y22)))
@ -1258,10 +1317,12 @@ void canvas_doconnect(t_canvas *x, int xpos, int ypos, int which, int doit)
((x22-x21-IOWIDTH) * closest2)/(ninlet2-1) : 0) ((x22-x21-IOWIDTH) * closest2)/(ninlet2-1) : 0)
+ IOMIDDLE; + IOMIDDLE;
ly2 = y21; ly2 = y21;
#ifndef ROCKBOX
sys_vgui(".x%x.c create line %d %d %d %d -width %d -tags l%x\n", sys_vgui(".x%x.c create line %d %d %d %d -width %d -tags l%x\n",
glist_getcanvas(x), glist_getcanvas(x),
lx1, ly1, lx2, ly2, lx1, ly1, lx2, ly2,
(obj_issignaloutlet(ob1, closest1) ? 2 : 1), oc); (obj_issignaloutlet(ob1, closest1) ? 2 : 1), oc);
#endif /* ROCKBOX */
canvas_setundo(x, canvas_undo_connect, canvas_setundo(x, canvas_undo_connect,
canvas_undo_set_connect(x, canvas_undo_set_connect(x,
canvas_getindex(x, &ob1->ob_g), closest1, canvas_getindex(x, &ob1->ob_g), closest1,
@ -1300,12 +1361,16 @@ static void canvas_doregion(t_canvas *x, int xpos, int ypos, int doit)
loy = x->gl_editor->e_ywas, hiy = ypos; loy = x->gl_editor->e_ywas, hiy = ypos;
else hiy = x->gl_editor->e_ywas, loy = ypos; else hiy = x->gl_editor->e_ywas, loy = ypos;
canvas_selectinrect(x, lox, loy, hix, hiy); canvas_selectinrect(x, lox, loy, hix, hiy);
#ifndef ROCKBOX
sys_vgui(".x%x.c delete x\n", x); sys_vgui(".x%x.c delete x\n", x);
#endif
x->gl_editor->e_onmotion = 0; x->gl_editor->e_onmotion = 0;
} }
#ifndef ROCKBOX
else sys_vgui(".x%x.c coords x %d %d %d %d\n", else sys_vgui(".x%x.c coords x %d %d %d %d\n",
x, x->gl_editor->e_xwas, x, x->gl_editor->e_xwas,
x->gl_editor->e_ywas, xpos, ypos); x->gl_editor->e_ywas, xpos, ypos);
#endif
} }
void canvas_mouseup(t_canvas *x, void canvas_mouseup(t_canvas *x,
@ -1395,7 +1460,11 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
t_symbol *gotkeysym; t_symbol *gotkeysym;
int down, shift; int down, shift;
#ifdef ROCKBOX
(void) s;
#endif
if (ac < 3) if (ac < 3)
return; return;
if (!x->gl_editor) if (!x->gl_editor)
@ -1411,7 +1480,11 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
else if (av[1].a_type == A_FLOAT) else if (av[1].a_type == A_FLOAT)
{ {
char buf[3]; char buf[3];
#ifdef ROCKBOX
snprintf(buf, sizeof(buf)-1, "%c", (int)(av[1].a_w.w_float));
#else /* ROCKBOX */
sprintf(buf, "%c", (int)(av[1].a_w.w_float)); sprintf(buf, "%c", (int)(av[1].a_w.w_float));
#endif /* ROCKBOX */
gotkeysym = gensym(buf); gotkeysym = gensym(buf);
} }
else gotkeysym = gensym("?"); else gotkeysym = gensym("?");
@ -1559,8 +1632,13 @@ void canvas_startmotion(t_canvas *x)
void canvas_print(t_canvas *x, t_symbol *s) void canvas_print(t_canvas *x, t_symbol *s)
{ {
#ifdef ROCKBOX
(void) x;
(void) s;
#else /* ROCKBOX */
if (*s->s_name) sys_vgui(".x%x.c postscript -file %s\n", x, s->s_name); if (*s->s_name) sys_vgui(".x%x.c postscript -file %s\n", x, s->s_name);
else sys_vgui(".x%x.c postscript -file x.ps\n", x); else sys_vgui(".x%x.c postscript -file x.ps\n", x);
#endif /* ROCKBOX */
} }
void canvas_menuclose(t_canvas *x, t_floatarg force) void canvas_menuclose(t_canvas *x, t_floatarg force)
@ -1569,18 +1647,24 @@ void canvas_menuclose(t_canvas *x, t_floatarg force)
canvas_vis(x, 0); canvas_vis(x, 0);
else if ((force != 0) || (!x->gl_dirty)) else if ((force != 0) || (!x->gl_dirty))
pd_free(&x->gl_pd); pd_free(&x->gl_pd);
#ifndef ROCKBOX
else sys_vgui("pdtk_check {This window has been modified. Close anyway?}\ else sys_vgui("pdtk_check {This window has been modified. Close anyway?}\
{.x%x menuclose 1;\n}\n", x); {.x%x menuclose 1;\n}\n", x);
#endif
} }
/* put up a dialog which may call canvas_font back to do the work */ /* put up a dialog which may call canvas_font back to do the work */
static void canvas_menufont(t_canvas *x) static void canvas_menufont(t_canvas *x)
{ {
#ifdef ROCKBOX
(void) x;
#else /* ROCKBOX */
char buf[80]; char buf[80];
t_canvas *x2 = canvas_getrootfor(x); t_canvas *x2 = canvas_getrootfor(x);
gfxstub_deleteforkey(x2); gfxstub_deleteforkey(x2);
sprintf(buf, "pdtk_canvas_dofont %%s %d\n", x2->gl_font); sprintf(buf, "pdtk_canvas_dofont %%s %d\n", x2->gl_font);
gfxstub_new(&x2->gl_pd, &x2->gl_pd, buf); gfxstub_new(&x2->gl_pd, &x2->gl_pd, buf);
#endif /* ROCKBOX */
} }
static int canvas_find_index1, canvas_find_index2; static int canvas_find_index1, canvas_find_index2;
@ -1598,13 +1682,13 @@ static int canvas_dofind(t_canvas *x, int *myindex1p)
y = y->g_next, myindex2++) y = y->g_next, myindex2++)
{ {
t_object *ob = 0; t_object *ob = 0;
if (ob = pd_checkobject(&y->g_pd)) if((ob = pd_checkobject(&y->g_pd)))
{ {
if (binbuf_match(ob->ob_binbuf, canvas_findbuf)) if (binbuf_match(ob->ob_binbuf, canvas_findbuf))
{ {
if (myindex1 > canvas_find_index1 || if (myindex1 > canvas_find_index1 ||
myindex1 == canvas_find_index1 && (myindex1 == canvas_find_index1 &&
myindex2 > canvas_find_index2) myindex2 > canvas_find_index2))
{ {
canvas_find_index1 = myindex1; canvas_find_index1 = myindex1;
canvas_find_index2 = myindex2; canvas_find_index2 = myindex2;
@ -1633,6 +1717,9 @@ static int canvas_dofind(t_canvas *x, int *myindex1p)
static void canvas_find(t_canvas *x, t_symbol *s, int ac, t_atom *av) static void canvas_find(t_canvas *x, t_symbol *s, int ac, t_atom *av)
{ {
int myindex1 = 0, i; int myindex1 = 0, i;
#ifdef ROCKBOX
(void) s;
#endif
for (i = 0; i < ac; i++) for (i = 0; i < ac; i++)
{ {
if (av[i].a_type == A_SYMBOL) if (av[i].a_type == A_SYMBOL)
@ -1660,6 +1747,9 @@ static void canvas_find(t_canvas *x, t_symbol *s, int ac, t_atom *av)
static void canvas_find_again(t_canvas *x) static void canvas_find_again(t_canvas *x)
{ {
int myindex1 = 0; int myindex1 = 0;
#ifdef ROCKBOX
(void) x;
#endif
if (!canvas_findbuf || !canvas_whichfind) if (!canvas_findbuf || !canvas_whichfind)
return; return;
if (!canvas_dofind(canvas_whichfind, &myindex1)) if (!canvas_dofind(canvas_whichfind, &myindex1))
@ -1756,7 +1846,7 @@ void canvas_stowconnections(t_canvas *x)
/* add connections to binbuf */ /* add connections to binbuf */
binbuf_clear(x->gl_editor->e_connectbuf); binbuf_clear(x->gl_editor->e_connectbuf);
linetraverser_start(&t, x); linetraverser_start(&t, x);
while (oc = linetraverser_next(&t)) while((oc = linetraverser_next(&t)))
{ {
int s1 = glist_isselected(x, &t.tr_ob->ob_g); int s1 = glist_isselected(x, &t.tr_ob->ob_g);
int s2 = glist_isselected(x, &t.tr_ob2->ob_g); int s2 = glist_isselected(x, &t.tr_ob2->ob_g);
@ -1787,7 +1877,7 @@ static t_binbuf *canvas_docopy(t_canvas *x)
gobj_save(y, b); gobj_save(y, b);
} }
linetraverser_start(&t, x); linetraverser_start(&t, x);
while (oc = linetraverser_next(&t)) while((oc = linetraverser_next(&t)))
{ {
if (glist_isselected(x, &t.tr_ob->ob_g) if (glist_isselected(x, &t.tr_ob->ob_g)
&& glist_isselected(x, &t.tr_ob2->ob_g)) && glist_isselected(x, &t.tr_ob2->ob_g))
@ -1912,7 +2002,11 @@ static void glist_donewloadbangs(t_glist *x)
static void canvas_dopaste(t_canvas *x, t_binbuf *b) static void canvas_dopaste(t_canvas *x, t_binbuf *b)
{ {
#ifdef ROCKBOX
t_gobj *g2;
#else /* ROCKBOX */
t_gobj *newgobj, *last, *g2; t_gobj *newgobj, *last, *g2;
#endif /* ROCKBOX */
int dspstate = canvas_suspend_dsp(), nbox, count; int dspstate = canvas_suspend_dsp(), nbox, count;
canvas_editmode(x, 1.); canvas_editmode(x, 1.);
@ -1987,9 +2081,11 @@ void canvas_connect(t_canvas *x, t_floatarg fwhoout, t_floatarg foutno,
if (!(oc = obj_connect(objsrc, outno, objsink, inno))) goto bad; if (!(oc = obj_connect(objsrc, outno, objsink, inno))) goto bad;
if (glist_isvisible(x)) if (glist_isvisible(x))
{ {
#ifndef ROCKBOX
sys_vgui(".x%x.c create line %d %d %d %d -width %d -tags l%x\n", sys_vgui(".x%x.c create line %d %d %d %d -width %d -tags l%x\n",
glist_getcanvas(x), 0, 0, 0, 0, glist_getcanvas(x), 0, 0, 0, 0,
(obj_issignaloutlet(objsrc, outno) ? 2 : 1),oc); (obj_issignaloutlet(objsrc, outno) ? 2 : 1),oc);
#endif
canvas_fixlinesfor(x, objsrc); canvas_fixlinesfor(x, objsrc);
} }
return; return;
@ -2008,7 +2104,11 @@ bad:
/* LATER might have to speed this up */ /* LATER might have to speed this up */
static void canvas_tidy(t_canvas *x) static void canvas_tidy(t_canvas *x)
{ {
#ifdef ROCKBOX
t_gobj *y, *y2;
#else /* ROCKBOX */
t_gobj *y, *y2, *y3; t_gobj *y, *y2, *y3;
#endif /* ROCKBOX */
int ax1, ay1, ax2, ay2, bx1, by1, bx2, by2; int ax1, ay1, ax2, ay2, bx1, by1, bx2, by2;
int histogram[NHIST], *ip, i, besthist, bestdist; int histogram[NHIST], *ip, i, besthist, bestdist;
/* if nobody is selected, this means do it to all boxes; /* if nobody is selected, this means do it to all boxes;
@ -2114,15 +2214,19 @@ static void canvas_texteditor(t_canvas *x)
t_rtext *foo; t_rtext *foo;
char *buf; char *buf;
int bufsize; int bufsize;
if (foo = x->gl_editor->e_textedfor) if((foo = x->gl_editor->e_textedfor))
rtext_gettext(foo, &buf, &bufsize); rtext_gettext(foo, &buf, &bufsize);
else buf = "", bufsize = 0; else buf = "", bufsize = 0;
#ifndef ROCKBOX
sys_vgui("pdtk_pd_texteditor {%.*s}\n", bufsize, buf); sys_vgui("pdtk_pd_texteditor {%.*s}\n", bufsize, buf);
#endif
} }
void glob_key(void *dummy, t_symbol *s, int ac, t_atom *av) void glob_key(void *dummy, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) dummy;
#endif
/* canvas_editing can be zero; canvas_key checks for that */ /* canvas_editing can be zero; canvas_key checks for that */
canvas_key(canvas_editing, s, ac, av); canvas_key(canvas_editing, s, ac, av);
} }
@ -2141,8 +2245,10 @@ void canvas_editmode(t_canvas *x, t_floatarg fyesplease)
if (glist_isvisible(x) && glist_istoplevel(x)) if (glist_isvisible(x) && glist_istoplevel(x))
canvas_setcursor(x, CURSOR_RUNMODE_NOTHING); canvas_setcursor(x, CURSOR_RUNMODE_NOTHING);
} }
#ifndef ROCKBOX
sys_vgui("pdtk_canvas_editval .x%x %d\n", sys_vgui("pdtk_canvas_editval .x%x %d\n",
glist_getcanvas(x), x->gl_edit); glist_getcanvas(x), x->gl_edit);
#endif
} }
/* called by canvas_font below */ /* called by canvas_font below */
@ -2188,7 +2294,9 @@ static void canvas_font(t_canvas *x, t_floatarg font, t_floatarg resize,
if (whichresize != 3) realresx = realresize; if (whichresize != 3) realresx = realresize;
if (whichresize != 2) realresy = realresize; if (whichresize != 2) realresy = realresize;
canvas_dofont(x2, font, realresx, realresy); canvas_dofont(x2, font, realresx, realresy);
#ifndef ROCKBOX
sys_defaultfont = font; sys_defaultfont = font;
#endif
} }
static t_glist *canvas_last_glist; static t_glist *canvas_last_glist;

View file

@ -6,12 +6,21 @@
"graphs" inside another glist. LATER move the inlet/outlet code of g_canvas.c "graphs" inside another glist. LATER move the inlet/outlet code of g_canvas.c
to this file... */ to this file... */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "g_canvas.h"
#define snprintf rb->snprintf
#define atof rb_atof
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include "m_pd.h" #include "m_pd.h"
#include "t_tk.h" #include "t_tk.h"
#include "g_canvas.h" #include "g_canvas.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#endif /* ROCKBOX */
/* ---------------------- forward definitions ----------------- */ /* ---------------------- forward definitions ----------------- */
@ -80,7 +89,11 @@ void glist_delete(t_glist *x, t_gobj *y)
if (gl->gl_isgraph) if (gl->gl_isgraph)
{ {
char tag[80]; char tag[80];
#ifdef ROCKBOX
snprintf(tag, sizeof(tag)-1, "graph%x", (int)gl);
#else /* ROCKBOX */
sprintf(tag, "graph%x", (int)gl); sprintf(tag, "graph%x", (int)gl);
#endif /* ROCKBOX */
glist_eraseiofor(x, &gl->gl_obj, tag); glist_eraseiofor(x, &gl->gl_obj, tag);
} }
else else
@ -112,16 +125,22 @@ void glist_delete(t_glist *x, t_gobj *y)
/* remove every object from a glist. Experimental. */ /* remove every object from a glist. Experimental. */
void glist_clear(t_glist *x) void glist_clear(t_glist *x)
{ {
#ifdef ROCKBOX
t_gobj *y;
#else
t_gobj *y, *y2; t_gobj *y, *y2;
#endif
int dspstate = canvas_suspend_dsp(); int dspstate = canvas_suspend_dsp();
while (y = x->gl_list) while((y = x->gl_list))
glist_delete(x, y); glist_delete(x, y);
canvas_resume_dsp(dspstate); canvas_resume_dsp(dspstate);
} }
void glist_retext(t_glist *glist, t_text *y) void glist_retext(t_glist *glist, t_text *y)
{ {
#ifndef ROCKBOX
t_canvas *c = glist_getcanvas(glist); t_canvas *c = glist_getcanvas(glist);
#endif
/* check that we have built rtexts yet. LATER need a better test. */ /* check that we have built rtexts yet. LATER need a better test. */
if (glist->gl_editor && glist->gl_editor->e_rtext) if (glist->gl_editor && glist->gl_editor->e_rtext)
{ {
@ -167,6 +186,9 @@ static t_gobj *glist_merge(t_glist *x, t_gobj *g1, t_gobj *g2)
{ {
t_gobj *g = 0, *g9 = 0; t_gobj *g = 0, *g9 = 0;
float f1 = 0, f2 = 0; float f1 = 0, f2 = 0;
#ifdef ROCKBOX
(void) x;
#endif
if (g1) if (g1)
f1 = gobj_getxforsort(g1); f1 = gobj_getxforsort(g1);
if (g2) if (g2)
@ -190,7 +212,7 @@ static t_gobj *glist_merge(t_glist *x, t_gobj *g1, t_gobj *g2)
if (g9) if (g9)
g9->g_next = g1, g9 = g1; g9->g_next = g1, g9 = g1;
else g9 = g = g1; else g9 = g = g1;
if (g1 = g1->g_next) if((g1 = g1->g_next))
f1 = gobj_getxforsort(g1); f1 = gobj_getxforsort(g1);
g9->g_next = 0; g9->g_next = 0;
continue; continue;
@ -198,7 +220,7 @@ static t_gobj *glist_merge(t_glist *x, t_gobj *g1, t_gobj *g2)
if (g9) if (g9)
g9->g_next = g2, g9 = g2; g9->g_next = g2, g9 = g2;
else g9 = g = g2; else g9 = g = g2;
if (g2 = g2->g_next) if((g2 = g2->g_next))
f2 = gobj_getxforsort(g2); f2 = gobj_getxforsort(g2);
g9->g_next = 0; g9->g_next = 0;
continue; continue;
@ -333,6 +355,9 @@ void canvas_resortinlets(t_canvas *x)
t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *s) t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *s)
{ {
t_outlet *op = outlet_new(&x->gl_obj, s); t_outlet *op = outlet_new(&x->gl_obj, s);
#ifdef ROCKBOX
(void) who;
#endif
if (!x->gl_loading && x->gl_owner && glist_isvisible(x->gl_owner)) if (!x->gl_loading && x->gl_owner && glist_isvisible(x->gl_owner))
{ {
gobj_vis(&x->gl_gobj, x->gl_owner, 0); gobj_vis(&x->gl_gobj, x->gl_owner, 0);
@ -444,6 +469,9 @@ static void graph_yticks(t_glist *x,
static void graph_xlabel(t_glist *x, t_symbol *s, int argc, t_atom *argv) static void graph_xlabel(t_glist *x, t_symbol *s, int argc, t_atom *argv)
{ {
int i; int i;
#ifdef ROCKBOX
(void) s;
#endif
if (argc < 1) error("graph_xlabel: no y value given"); if (argc < 1) error("graph_xlabel: no y value given");
else else
{ {
@ -460,6 +488,9 @@ static void graph_xlabel(t_glist *x, t_symbol *s, int argc, t_atom *argv)
static void graph_ylabel(t_glist *x, t_symbol *s, int argc, t_atom *argv) static void graph_ylabel(t_glist *x, t_symbol *s, int argc, t_atom *argv)
{ {
int i; int i;
#ifdef ROCKBOX
(void) s;
#endif
if (argc < 1) error("graph_ylabel: no x value given"); if (argc < 1) error("graph_ylabel: no x value given");
else else
{ {
@ -613,10 +644,14 @@ void glist_redraw(t_glist *x)
} }
/* redraw all the lines */ /* redraw all the lines */
linetraverser_start(&t, x); linetraverser_start(&t, x);
while (oc = linetraverser_next(&t)) while((oc = linetraverser_next(&t)))
#ifdef ROCKBOX
;
#else /* ROCKBOX */
sys_vgui(".x%x.c coords l%x %d %d %d %d\n", sys_vgui(".x%x.c coords l%x %d %d %d %d\n",
glist_getcanvas(x), oc, glist_getcanvas(x), oc,
t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2); t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2);
#endif /* ROCKBOX */
} }
if (x->gl_owner) if (x->gl_owner)
{ {
@ -651,7 +686,11 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
if (!vis) if (!vis)
rtext_erase(glist_findrtext(parent_glist, &x->gl_obj)); rtext_erase(glist_findrtext(parent_glist, &x->gl_obj));
#ifdef ROCKBOX
snprintf(tag, sizeof(tag)-1, "graph%x", (int) x);
#else
sprintf(tag, "graph%x", (int)x); sprintf(tag, "graph%x", (int)x);
#endif
if (vis) if (vis)
glist_drawiofor(parent_glist, &x->gl_obj, 1, glist_drawiofor(parent_glist, &x->gl_obj, 1,
tag, x1, y1, x2, y2); tag, x1, y1, x2, y2);
@ -660,6 +699,7 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
just show the bounding rectangle */ just show the bounding rectangle */
if (x->gl_havewindow) if (x->gl_havewindow)
{ {
#ifndef ROCKBOX
if (vis) if (vis)
{ {
sys_vgui(".x%x.c create polygon\ sys_vgui(".x%x.c create polygon\
@ -672,6 +712,7 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
sys_vgui(".x%x.c delete %s\n", sys_vgui(".x%x.c delete %s\n",
glist_getcanvas(x->gl_owner), tag); glist_getcanvas(x->gl_owner), tag);
} }
#endif
return; return;
} }
/* otherwise draw (or erase) us as a graph inside another glist. */ /* otherwise draw (or erase) us as a graph inside another glist. */
@ -681,10 +722,12 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
float f; float f;
/* draw a rectangle around the graph */ /* draw a rectangle around the graph */
#ifndef ROCKBOX
sys_vgui(".x%x.c create line\ sys_vgui(".x%x.c create line\
%d %d %d %d %d %d %d %d %d %d -tags %s\n", %d %d %d %d %d %d %d %d %d %d -tags %s\n",
glist_getcanvas(x->gl_owner), glist_getcanvas(x->gl_owner),
x1, y1, x1, y2, x2, y2, x2, y1, x1, y1, tag); x1, y1, x1, y2, x2, y2, x2, y1, x1, y1, tag);
#endif
/* draw ticks on horizontal borders. If lperb field is /* draw ticks on horizontal borders. If lperb field is
zero, this is disabled. */ zero, this is disabled. */
@ -698,6 +741,7 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
f < 0.99 * x->gl_x2 + 0.01*x->gl_x1; i++, f < 0.99 * x->gl_x2 + 0.01*x->gl_x1; i++,
f += x->gl_xtick.k_inc) f += x->gl_xtick.k_inc)
{ {
#ifndef ROCKBOX
int tickpix = (i % x->gl_xtick.k_lperb ? 2 : 4); int tickpix = (i % x->gl_xtick.k_lperb ? 2 : 4);
sys_vgui(".x%x.c create line %d %d %d %d -tags %s\n", sys_vgui(".x%x.c create line %d %d %d %d -tags %s\n",
glist_getcanvas(x->gl_owner), glist_getcanvas(x->gl_owner),
@ -707,11 +751,13 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
glist_getcanvas(x->gl_owner), glist_getcanvas(x->gl_owner),
(int)glist_xtopixels(x, f), (int)lpix, (int)glist_xtopixels(x, f), (int)lpix,
(int)glist_xtopixels(x, f), (int)lpix + tickpix, tag); (int)glist_xtopixels(x, f), (int)lpix + tickpix, tag);
#endif
} }
for (i = 1, f = x->gl_xtick.k_point - x->gl_xtick.k_inc; for (i = 1, f = x->gl_xtick.k_point - x->gl_xtick.k_inc;
f > 0.99 * x->gl_x1 + 0.01*x->gl_x2; f > 0.99 * x->gl_x1 + 0.01*x->gl_x2;
i++, f -= x->gl_xtick.k_inc) i++, f -= x->gl_xtick.k_inc)
{ {
#ifndef ROCKBOX
int tickpix = (i % x->gl_xtick.k_lperb ? 2 : 4); int tickpix = (i % x->gl_xtick.k_lperb ? 2 : 4);
sys_vgui(".x%x.c create line %d %d %d %d -tags %s\n", sys_vgui(".x%x.c create line %d %d %d %d -tags %s\n",
glist_getcanvas(x->gl_owner), glist_getcanvas(x->gl_owner),
@ -721,6 +767,7 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
glist_getcanvas(x->gl_owner), glist_getcanvas(x->gl_owner),
(int)glist_xtopixels(x, f), (int)lpix, (int)glist_xtopixels(x, f), (int)lpix,
(int)glist_xtopixels(x, f), (int)lpix + tickpix, tag); (int)glist_xtopixels(x, f), (int)lpix + tickpix, tag);
#endif
} }
} }
@ -735,6 +782,7 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
f < 0.99 * ubound + 0.01 * lbound; f < 0.99 * ubound + 0.01 * lbound;
i++, f += x->gl_ytick.k_inc) i++, f += x->gl_ytick.k_inc)
{ {
#ifndef ROCKBOX
int tickpix = (i % x->gl_ytick.k_lperb ? 2 : 4); int tickpix = (i % x->gl_ytick.k_lperb ? 2 : 4);
sys_vgui(".x%x.c create line %d %d %d %d -tags %s\n", sys_vgui(".x%x.c create line %d %d %d %d -tags %s\n",
glist_getcanvas(x->gl_owner), glist_getcanvas(x->gl_owner),
@ -744,11 +792,13 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
glist_getcanvas(x->gl_owner), glist_getcanvas(x->gl_owner),
x2, (int)glist_ytopixels(x, f), x2, (int)glist_ytopixels(x, f),
x2 - tickpix, (int)glist_ytopixels(x, f), tag); x2 - tickpix, (int)glist_ytopixels(x, f), tag);
#endif
} }
for (i = 1, f = x->gl_ytick.k_point - x->gl_ytick.k_inc; for (i = 1, f = x->gl_ytick.k_point - x->gl_ytick.k_inc;
f > 0.99 * lbound + 0.01 * ubound; f > 0.99 * lbound + 0.01 * ubound;
i++, f -= x->gl_ytick.k_inc) i++, f -= x->gl_ytick.k_inc)
{ {
#ifndef ROCKBOX
int tickpix = (i % x->gl_ytick.k_lperb ? 2 : 4); int tickpix = (i % x->gl_ytick.k_lperb ? 2 : 4);
sys_vgui(".x%x.c create line %d %d %d %d -tags %s\n", sys_vgui(".x%x.c create line %d %d %d %d -tags %s\n",
glist_getcanvas(x->gl_owner), glist_getcanvas(x->gl_owner),
@ -758,19 +808,27 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
glist_getcanvas(x->gl_owner), glist_getcanvas(x->gl_owner),
x2, (int)glist_ytopixels(x, f), x2, (int)glist_ytopixels(x, f),
x2 - tickpix, (int)glist_ytopixels(x, f), tag); x2 - tickpix, (int)glist_ytopixels(x, f), tag);
#endif
} }
} }
/* draw x labels */ /* draw x labels */
for (i = 0; i < x->gl_nxlabels; i++) for (i = 0; i < x->gl_nxlabels; i++)
#ifdef ROCKBOX
;
#else /* ROCKBOX */
sys_vgui(".x%x.c create text\ sys_vgui(".x%x.c create text\
%d %d -text {%s} -font -*-courier-bold--normal--%d-* -tags %s\n", %d %d -text {%s} -font -*-courier-bold--normal--%d-* -tags %s\n",
glist_getcanvas(x), glist_getcanvas(x),
(int)glist_xtopixels(x, atof(x->gl_xlabel[i]->s_name)), (int)glist_xtopixels(x, atof(x->gl_xlabel[i]->s_name)),
(int)glist_ytopixels(x, x->gl_xlabely), x->gl_xlabel[i]->s_name, (int)glist_ytopixels(x, x->gl_xlabely), x->gl_xlabel[i]->s_name,
glist_getfont(x), tag); glist_getfont(x), tag);
#endif /* ROCKBOX */
/* draw y labels */ /* draw y labels */
for (i = 0; i < x->gl_nylabels; i++) for (i = 0; i < x->gl_nylabels; i++)
#ifdef ROCKBOX
;
#else /* ROCKBOX */
sys_vgui(".x%x.c create text\ sys_vgui(".x%x.c create text\
%d %d -text {%s} -font -*-courier-bold--normal--%d-* -tags %s\n", %d %d -text {%s} -font -*-courier-bold--normal--%d-* -tags %s\n",
glist_getcanvas(x), glist_getcanvas(x),
@ -778,6 +836,7 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
(int)glist_ytopixels(x, atof(x->gl_ylabel[i]->s_name)), (int)glist_ytopixels(x, atof(x->gl_ylabel[i]->s_name)),
x->gl_ylabel[i]->s_name, x->gl_ylabel[i]->s_name,
glist_getfont(x), tag); glist_getfont(x), tag);
#endif /* ROCKBOX */
/* draw contents of graph as glist */ /* draw contents of graph as glist */
for (g = x->gl_list; g; g = g->g_next) for (g = x->gl_list; g; g = g->g_next)
@ -785,8 +844,10 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
} }
else else
{ {
#ifndef ROCKBOX
sys_vgui(".x%x.c delete %s\n", sys_vgui(".x%x.c delete %s\n",
glist_getcanvas(x->gl_owner), tag); glist_getcanvas(x->gl_owner), tag);
#endif
for (g = x->gl_list; g; g = g->g_next) for (g = x->gl_list; g; g = g->g_next)
gobj_vis(g, x, 0); gobj_vis(g, x, 0);
} }
@ -904,10 +965,12 @@ static void graph_select(t_gobj *z, t_glist *glist, int state)
t_rtext *y = glist_findrtext(glist, &x->gl_obj); t_rtext *y = glist_findrtext(glist, &x->gl_obj);
if (canvas_showtext(x)) if (canvas_showtext(x))
rtext_select(y, state); rtext_select(y, state);
#ifndef ROCKBOX
sys_vgui(".x%x.c itemconfigure %sR -fill %s\n", glist, sys_vgui(".x%x.c itemconfigure %sR -fill %s\n", glist,
rtext_gettag(y), (state? "blue" : "black")); rtext_gettag(y), (state? "blue" : "black"));
sys_vgui(".x%x.c itemconfigure graph%x -fill %s\n", sys_vgui(".x%x.c itemconfigure graph%x -fill %s\n",
glist_getcanvas(glist), z, (state? "blue" : "black")); glist_getcanvas(glist), z, (state? "blue" : "black"));
#endif
} }
} }
@ -941,10 +1004,11 @@ static void graph_delete(t_gobj *z, t_glist *glist)
t_glist *x = (t_glist *)z; t_glist *x = (t_glist *)z;
t_gobj *y; t_gobj *y;
text_widgetbehavior.w_deletefn(z, glist); text_widgetbehavior.w_deletefn(z, glist);
while (y = x->gl_list) while((y = x->gl_list))
glist_delete(x, y); glist_delete(x, y);
} }
#ifndef ROCKBOX
static float graph_lastxpix, graph_lastypix; static float graph_lastxpix, graph_lastypix;
static void graph_motion(void *z, t_floatarg dx, t_floatarg dy) static void graph_motion(void *z, t_floatarg dx, t_floatarg dy)
@ -986,6 +1050,7 @@ static void graph_motion(void *z, t_floatarg dx, t_floatarg dy)
else vec[newx] = newy; else vec[newx] = newy;
garray_redraw(a); garray_redraw(a);
} }
#endif
static int graph_click(t_gobj *z, struct _glist *glist, static int graph_click(t_gobj *z, struct _glist *glist,
int xpix, int ypix, int shift, int alt, int dbl, int doit) int xpix, int ypix, int shift, int alt, int dbl, int doit)
@ -1037,11 +1102,16 @@ void graph_properties(t_gobj *z, t_glist *owner)
t_glist *x = (t_glist *)z; t_glist *x = (t_glist *)z;
{ {
t_gobj *y; t_gobj *y;
#ifdef ROCKBOX
(void) owner;
#else /* ROCKBOX */
char graphbuf[200]; char graphbuf[200];
sprintf(graphbuf, "pdtk_graph_dialog %%s %g %g %g %g %d %d\n", sprintf(graphbuf, "pdtk_graph_dialog %%s %g %g %g %g %d %d\n",
x->gl_x1, x->gl_y1, x->gl_x2, x->gl_y2, x->gl_x1, x->gl_y1, x->gl_x2, x->gl_y2,
x->gl_pixwidth, x->gl_pixheight); x->gl_pixwidth, x->gl_pixheight);
gfxstub_new(&x->gl_pd, x, graphbuf); gfxstub_new(&x->gl_pd, x, graphbuf);
#endif /* ROCKBOX */
for (y = x->gl_list; y; y = y->g_next) for (y = x->gl_list; y; y = y->g_next)
if (pd_class(&y->g_pd) == garray_class) if (pd_class(&y->g_pd) == garray_class)
@ -1071,6 +1141,9 @@ static void graph_dialog(t_glist *x, t_symbol *s, int argc, t_atom *argv)
t_float y2 = atom_getfloatarg(3, argc, argv); t_float y2 = atom_getfloatarg(3, argc, argv);
t_float xpix = atom_getfloatarg(4, argc, argv); t_float xpix = atom_getfloatarg(4, argc, argv);
t_float ypix = atom_getfloatarg(5, argc, argv); t_float ypix = atom_getfloatarg(5, argc, argv);
#ifdef ROCKBOX
(void) s;
#endif
if (x1 != x->gl_x1 || x2 != x->gl_x2 || if (x1 != x->gl_x1 || x2 != x->gl_x2 ||
y1 != x->gl_y1 || y2 != x->gl_y2) y1 != x->gl_y1 || y2 != x->gl_y2)
graph_bounds(x, x1, y1, x2, y2); graph_bounds(x, x1, y1, x2, y2);

View file

@ -8,6 +8,13 @@
/* name change to hradio by MSP and changed to /* name change to hradio by MSP and changed to
put out a "float" as in sliders, toggles, etc. */ put out a "float" as in sliders, toggles, etc. */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "g_canvas.h"
#include "g_all_guis.h"
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -23,6 +30,7 @@ put out a "float" as in sliders, toggles, etc. */
#else #else
#include <unistd.h> #include <unistd.h>
#endif #endif
#endif /* ROCKBOX */
/* ------------- hdl gui-horicontal dial ---------------------- */ /* ------------- hdl gui-horicontal dial ---------------------- */
@ -33,6 +41,10 @@ static t_class *hradio_class, *hradio_old_class;
void hradio_draw_update(t_hradio *x, t_glist *glist) void hradio_draw_update(t_hradio *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
if(glist_isvisible(glist)) if(glist_isvisible(glist))
{ {
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
@ -44,10 +56,15 @@ void hradio_draw_update(t_hradio *x, t_glist *glist)
canvas, x, x->x_on, canvas, x, x->x_on,
x->x_gui.x_fcol, x->x_gui.x_fcol); x->x_gui.x_fcol, x->x_gui.x_fcol);
} }
#endif /* ROCKBOX */
} }
void hradio_draw_new(t_hradio *x, t_glist *glist) void hradio_draw_new(t_hradio *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
int n=x->x_number, i, dx=x->x_gui.x_w, s4=dx/4; int n=x->x_number, i, dx=x->x_gui.x_w, s4=dx/4;
int yy11=text_ypix(&x->x_gui.x_obj, glist), yy12=yy11+dx; int yy11=text_ypix(&x->x_gui.x_obj, glist), yy12=yy11+dx;
@ -55,7 +72,6 @@ void hradio_draw_new(t_hradio *x, t_glist *glist)
int xx11b=text_xpix(&x->x_gui.x_obj, glist), xx11=xx11b, xx21=xx11b+s4; int xx11b=text_xpix(&x->x_gui.x_obj, glist), xx11=xx11b, xx21=xx11b+s4;
int xx22=xx11b+dx-s4; int xx22=xx11b+dx-s4;
for(i=0; i<n; i++) for(i=0; i<n; i++)
{ {
sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE%d\n", sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE%d\n",
@ -81,11 +97,15 @@ void hradio_draw_new(t_hradio *x, t_glist *glist)
if(!x->x_gui.x_fsf.x_rcv_able) if(!x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n", sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
canvas, xx11b, yy11, xx11b + IOWIDTH, yy11+1, x, 0); canvas, xx11b, yy11, xx11b + IOWIDTH, yy11+1, x, 0);
#endif /* ROCKBOX */
} }
void hradio_draw_move(t_hradio *x, t_glist *glist) void hradio_draw_move(t_hradio *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
int n=x->x_number, i, dx=x->x_gui.x_w, s4=dx/4; int n=x->x_number, i, dx=x->x_gui.x_w, s4=dx/4;
int yy11=text_ypix(&x->x_gui.x_obj, glist), yy12=yy11+dx; int yy11=text_ypix(&x->x_gui.x_obj, glist), yy12=yy11+dx;
@ -114,10 +134,15 @@ void hradio_draw_move(t_hradio *x, t_glist *glist)
if(!x->x_gui.x_fsf.x_rcv_able) if(!x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n", sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
canvas, x, 0, xx11b, yy11, xx11b + IOWIDTH, yy11+1); canvas, x, 0, xx11b, yy11, xx11b + IOWIDTH, yy11+1);
#endif /* ROCKBOX */
} }
void hradio_draw_erase(t_hradio* x, t_glist* glist) void hradio_draw_erase(t_hradio* x, t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
int n=x->x_number, i; int n=x->x_number, i;
@ -131,10 +156,15 @@ void hradio_draw_erase(t_hradio* x, t_glist* glist)
sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
if(!x->x_gui.x_fsf.x_rcv_able) if(!x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
#endif /* ROCKBOX */
} }
void hradio_draw_config(t_hradio* x, t_glist* glist) void hradio_draw_config(t_hradio* x, t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
int n=x->x_number, i; int n=x->x_number, i;
@ -150,10 +180,16 @@ void hradio_draw_config(t_hradio* x, t_glist* glist)
(x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol,
(x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol); (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol);
} }
#endif
} }
void hradio_draw_io(t_hradio* x, t_glist* glist, int old_snd_rcv_flags) void hradio_draw_io(t_hradio* x, t_glist* glist, int old_snd_rcv_flags)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
(void) old_snd_rcv_flags;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
@ -173,10 +209,15 @@ void hradio_draw_io(t_hradio* x, t_glist* glist, int old_snd_rcv_flags)
xpos + IOWIDTH, ypos+1, x, 0); xpos + IOWIDTH, ypos+1, x, 0);
if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
#endif /* ROCKBOX */
} }
void hradio_draw_select(t_hradio* x, t_glist* glist) void hradio_draw_select(t_hradio* x, t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
int n=x->x_number, i; int n=x->x_number, i;
@ -199,6 +240,7 @@ void hradio_draw_select(t_hradio* x, t_glist* glist)
sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x,
x->x_gui.x_lcol); x->x_gui.x_lcol);
} }
#endif /* ROCKBOX */
} }
void hradio_draw(t_hradio *x, t_glist *glist, int mode) void hradio_draw(t_hradio *x, t_glist *glist, int mode)
@ -254,6 +296,10 @@ static void hradio_save(t_gobj *z, t_binbuf *b)
static void hradio_properties(t_gobj *z, t_glist *owner) static void hradio_properties(t_gobj *z, t_glist *owner)
{ {
#ifdef ROCKBOX
(void) z;
(void) owner;
#else /* ROCKBOX */
t_hradio *x = (t_hradio *)z; t_hradio *x = (t_hradio *)z;
char buf[800]; char buf[800];
t_symbol *srl[3]; t_symbol *srl[3];
@ -278,6 +324,7 @@ static void hradio_properties(t_gobj *z, t_glist *owner)
x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
#endif /* ROCKBOX */
} }
static void hradio_dialog(t_hradio *x, t_symbol *s, int argc, t_atom *argv) static void hradio_dialog(t_hradio *x, t_symbol *s, int argc, t_atom *argv)
@ -288,6 +335,10 @@ static void hradio_dialog(t_hradio *x, t_symbol *s, int argc, t_atom *argv)
int num = (int)atom_getintarg(6, argc, argv); int num = (int)atom_getintarg(6, argc, argv);
int sr_flags; int sr_flags;
#ifdef ROCKBOX
(void) s;
#endif
if(chg != 0) chg = 1; if(chg != 0) chg = 1;
x->x_change = chg; x->x_change = chg;
sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv); sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
@ -462,11 +513,22 @@ static void hradio_click(t_hradio *x, t_floatarg xpos, t_floatarg ypos, t_floata
{ {
int xx = (int)xpos - (int)text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist); int xx = (int)xpos - (int)text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
#ifdef ROCKBOX
(void) ypos;
(void) shift;
(void) ctrl;
(void) alt;
#endif
hradio_fout(x, (float)(xx / x->x_gui.x_w)); hradio_fout(x, (float)(xx / x->x_gui.x_w));
} }
static int hradio_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) static int hradio_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
{ {
#ifdef ROCKBOX
(void) glist;
(void) dbl;
#endif
if(doit) if(doit)
hradio_click((t_hradio *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt); hradio_click((t_hradio *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt);
return (1); return (1);
@ -499,6 +561,9 @@ static void hradio_number(t_hradio *x, t_floatarg num)
static void hradio_size(t_hradio *x, t_symbol *s, int ac, t_atom *av) static void hradio_size(t_hradio *x, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
#endif
x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
x->x_gui.x_h = x->x_gui.x_w; x->x_gui.x_h = x->x_gui.x_w;
iemgui_size((void *)x, &x->x_gui); iemgui_size((void *)x, &x->x_gui);
@ -543,11 +608,21 @@ static void *hradio_donew(t_symbol *s, int argc, t_atom *argv, int old)
{ {
t_hradio *x = (t_hradio *)pd_new(old? hradio_old_class : hradio_class); t_hradio *x = (t_hradio *)pd_new(old? hradio_old_class : hradio_class);
int bflcol[]={-262144, -1, -1}; int bflcol[]={-262144, -1, -1};
#ifdef ROCKBOX
int a=IEM_GUI_DEFAULTSIZE, on=0;
#else
int a=IEM_GUI_DEFAULTSIZE, on=0, f=0; int a=IEM_GUI_DEFAULTSIZE, on=0, f=0;
#endif
int ldx=0, ldy=-6, chg=1, num=8; int ldx=0, ldy=-6, chg=1, num=8;
int fs=8; int fs=8;
#ifndef ROCKBOX
int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME; int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
char str[144]; char str[144];
#endif
#ifdef ROCKBOX
(void) s;
#endif
iem_inttosymargs(&x->x_gui.x_isa, 0); iem_inttosymargs(&x->x_gui.x_isa, 0);
iem_inttofstyle(&x->x_gui.x_fsf, 0); iem_inttofstyle(&x->x_gui.x_fsf, 0);
@ -632,7 +707,9 @@ static void hradio_ff(t_hradio *x)
{ {
if(x->x_gui.x_fsf.x_rcv_able) if(x->x_gui.x_fsf.x_rcv_able)
pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
#ifndef ROCKBOX
gfxstub_deleteforkey(x); gfxstub_deleteforkey(x);
#endif
} }
void g_hradio_setup(void) void g_hradio_setup(void)

View file

@ -6,6 +6,13 @@
/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */ /* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "g_canvas.h"
#include "g_all_guis.h"
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -21,7 +28,7 @@
#else #else
#include <unistd.h> #include <unistd.h>
#endif #endif
#endif /* ROCKBOX */
/* ------------ hsl gui-horicontal slider ----------------------- */ /* ------------ hsl gui-horicontal slider ----------------------- */
@ -32,6 +39,10 @@ static t_class *hslider_class;
static void hslider_draw_update(t_hslider *x, t_glist *glist) static void hslider_draw_update(t_hslider *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
@ -58,10 +69,15 @@ static void hslider_draw_update(t_hslider *x, t_glist *glist)
} }
} }
} }
#endif /* ROCKBOX */
} }
static void hslider_draw_new(t_hslider *x, t_glist *glist) static void hslider_draw_new(t_hslider *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
int r = xpos + (x->x_val + 50)/100; int r = xpos + (x->x_val + 50)/100;
@ -88,10 +104,15 @@ static void hslider_draw_new(t_hslider *x, t_glist *glist)
sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n", sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
canvas, xpos-3, ypos, canvas, xpos-3, ypos,
xpos+4, ypos+1, x, 0); xpos+4, ypos+1, x, 0);
#endif /* ROCKBOX */
} }
static void hslider_draw_move(t_hslider *x, t_glist *glist) static void hslider_draw_move(t_hslider *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
int r = xpos + (x->x_val + 50)/100; int r = xpos + (x->x_val + 50)/100;
@ -116,10 +137,15 @@ static void hslider_draw_move(t_hslider *x, t_glist *glist)
canvas, x, 0, canvas, x, 0,
xpos-3, ypos, xpos-3, ypos,
xpos+4, ypos+1); xpos+4, ypos+1);
#endif /* ROCKBOX */
} }
static void hslider_draw_erase(t_hslider* x,t_glist* glist) static void hslider_draw_erase(t_hslider* x,t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
sys_vgui(".x%x.c delete %xBASE\n", canvas, x); sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
@ -129,10 +155,15 @@ static void hslider_draw_erase(t_hslider* x,t_glist* glist)
sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
if(!x->x_gui.x_fsf.x_rcv_able) if(!x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
#endif /* ROCKBOX */
} }
static void hslider_draw_config(t_hslider* x,t_glist* glist) static void hslider_draw_config(t_hslider* x,t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n", sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
@ -141,10 +172,16 @@ static void hslider_draw_config(t_hslider* x,t_glist* glist)
strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
sys_vgui(".x%x.c itemconfigure %xKNOB -fill #%6.6x\n", canvas, x, x->x_gui.x_fcol); sys_vgui(".x%x.c itemconfigure %xKNOB -fill #%6.6x\n", canvas, x, x->x_gui.x_fcol);
sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol); sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);
#endif /* ROCKBOX */
} }
static void hslider_draw_io(t_hslider* x,t_glist* glist, int old_snd_rcv_flags) static void hslider_draw_io(t_hslider* x,t_glist* glist, int old_snd_rcv_flags)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
(void) old_snd_rcv_flags;
#else /* ROCKBOX */
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
@ -161,10 +198,15 @@ static void hslider_draw_io(t_hslider* x,t_glist* glist, int old_snd_rcv_flags)
xpos+4, ypos+1, x, 0); xpos+4, ypos+1, x, 0);
if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
#endif /* ROCKBOX */
} }
static void hslider_draw_select(t_hslider* x,t_glist* glist) static void hslider_draw_select(t_hslider* x,t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
if(x->x_gui.x_fsf.x_selected) if(x->x_gui.x_fsf.x_selected)
@ -177,6 +219,7 @@ static void hslider_draw_select(t_hslider* x,t_glist* glist)
sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL); sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
} }
#endif /* ROCKBOX */
} }
void hslider_draw(t_hslider *x, t_glist *glist, int mode) void hslider_draw(t_hslider *x, t_glist *glist, int mode)
@ -279,6 +322,10 @@ void hslider_check_minmax(t_hslider *x, double min, double max)
static void hslider_properties(t_gobj *z, t_glist *owner) static void hslider_properties(t_gobj *z, t_glist *owner)
{ {
#ifdef ROCKBOX
(void) z;
(void) owner;
#else /* ROCKBOX */
t_hslider *x = (t_hslider *)z; t_hslider *x = (t_hslider *)z;
char buf[800]; char buf[800];
t_symbol *srl[3]; t_symbol *srl[3];
@ -300,6 +347,7 @@ static void hslider_properties(t_gobj *z, t_glist *owner)
x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
#endif /* ROCKBOX */
} }
static void hslider_set(t_hslider *x, t_floatarg f) /* bugfix */ static void hslider_set(t_hslider *x, t_floatarg f) /* bugfix */
@ -355,6 +403,10 @@ static void hslider_dialog(t_hslider *x, t_symbol *s, int argc, t_atom *argv)
int steady = (int)atom_getintarg(17, argc, argv); int steady = (int)atom_getintarg(17, argc, argv);
int sr_flags; int sr_flags;
#ifdef ROCKBOX
(void) s;
#endif
if(lilo != 0) lilo = 1; if(lilo != 0) lilo = 1;
x->x_lin0_log1 = lilo; x->x_lin0_log1 = lilo;
if(steady) if(steady)
@ -375,6 +427,10 @@ static void hslider_motion(t_hslider *x, t_floatarg dx, t_floatarg dy)
{ {
int old = x->x_val; int old = x->x_val;
#ifdef ROCKBOX
(void) dy;
#endif
if(x->x_gui.x_fsf.x_finemoved) if(x->x_gui.x_fsf.x_finemoved)
x->x_pos += (int)dx; x->x_pos += (int)dx;
else else
@ -402,6 +458,11 @@ static void hslider_motion(t_hslider *x, t_floatarg dx, t_floatarg dy)
static void hslider_click(t_hslider *x, t_floatarg xpos, t_floatarg ypos, static void hslider_click(t_hslider *x, t_floatarg xpos, t_floatarg ypos,
t_floatarg shift, t_floatarg ctrl, t_floatarg alt) t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
{ {
#ifdef ROCKBOX
(void) shift;
(void) ctrl;
(void) alt;
#endif
if(!x->x_steady) if(!x->x_steady)
x->x_val = (int)(100.0 * (xpos - text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist))); x->x_val = (int)(100.0 * (xpos - text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist)));
if(x->x_val > (100*x->x_gui.x_w - 100)) if(x->x_val > (100*x->x_gui.x_w - 100))
@ -420,6 +481,11 @@ static int hslider_newclick(t_gobj *z, struct _glist *glist,
{ {
t_hslider* x = (t_hslider *)z; t_hslider* x = (t_hslider *)z;
#ifdef ROCKBOX
(void) glist;
(void) dbl;
#endif
if(doit) if(doit)
{ {
hslider_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, hslider_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift,
@ -434,6 +500,9 @@ static int hslider_newclick(t_gobj *z, struct _glist *glist,
static void hslider_size(t_hslider *x, t_symbol *s, int ac, t_atom *av) static void hslider_size(t_hslider *x, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
#endif
hslider_check_width(x, (int)atom_getintarg(0, ac, av)); hslider_check_width(x, (int)atom_getintarg(0, ac, av));
if(ac > 1) if(ac > 1)
x->x_gui.x_h = iemgui_clip_size((int)atom_getintarg(1, ac, av)); x->x_gui.x_h = iemgui_clip_size((int)atom_getintarg(1, ac, av));
@ -448,6 +517,9 @@ static void hslider_pos(t_hslider *x, t_symbol *s, int ac, t_atom *av)
static void hslider_range(t_hslider *x, t_symbol *s, int ac, t_atom *av) static void hslider_range(t_hslider *x, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
#endif
hslider_check_minmax(x, (double)atom_getfloatarg(0, ac, av), hslider_check_minmax(x, (double)atom_getfloatarg(0, ac, av),
(double)atom_getfloatarg(1, ac, av)); (double)atom_getfloatarg(1, ac, av));
} }
@ -525,10 +597,20 @@ static void *hslider_new(t_symbol *s, int argc, t_atom *argv)
t_hslider *x = (t_hslider *)pd_new(hslider_class); t_hslider *x = (t_hslider *)pd_new(hslider_class);
int bflcol[]={-262144, -1, -1}; int bflcol[]={-262144, -1, -1};
int w=IEM_SL_DEFAULTSIZE, h=IEM_GUI_DEFAULTSIZE; int w=IEM_SL_DEFAULTSIZE, h=IEM_GUI_DEFAULTSIZE;
#ifdef ROCKBOX
int lilo=0, ldx=-2, ldy=-6, v=0, steady=1;
#else
int lilo=0, ldx=-2, ldy=-6, f=0, v=0, steady=1; int lilo=0, ldx=-2, ldy=-6, f=0, v=0, steady=1;
#endif
int fs=8; int fs=8;
double min=0.0, max=(double)(IEM_SL_DEFAULTSIZE-1); double min=0.0, max=(double)(IEM_SL_DEFAULTSIZE-1);
#ifndef ROCKBOX
char str[144]; char str[144];
#endif
#ifdef ROCKBOX
(void) s;
#endif
iem_inttosymargs(&x->x_gui.x_isa, 0); iem_inttosymargs(&x->x_gui.x_isa, 0);
iem_inttofstyle(&x->x_gui.x_fsf, 0); iem_inttofstyle(&x->x_gui.x_fsf, 0);
@ -607,7 +689,9 @@ static void hslider_free(t_hslider *x)
{ {
if(x->x_gui.x_fsf.x_rcv_able) if(x->x_gui.x_fsf.x_rcv_able)
pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
#ifndef ROCKBOX
gfxstub_deleteforkey(x); gfxstub_deleteforkey(x);
#endif
} }
void g_hslider_setup(void) void g_hslider_setup(void)

View file

@ -22,9 +22,17 @@ life elsewhere. */
* *
*/ */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "g_canvas.h"
#else
#include "m_pd.h" #include "m_pd.h"
#include "g_canvas.h" #include "g_canvas.h"
#include <string.h> #include <string.h>
#endif
void signal_setborrowed(t_signal *sig, t_signal *sig2); void signal_setborrowed(t_signal *sig, t_signal *sig2);
void signal_makereusable(t_signal *sig); void signal_makereusable(t_signal *sig);
@ -51,6 +59,9 @@ typedef struct _vinlet
static void *vinlet_new(t_symbol *s) static void *vinlet_new(t_symbol *s)
{ {
#ifdef ROCKBOX
(void) s;
#endif
t_vinlet *x = (t_vinlet *)pd_new(vinlet_class); t_vinlet *x = (t_vinlet *)pd_new(vinlet_class);
x->x_canvas = canvas_getcurrent(); x->x_canvas = canvas_getcurrent();
x->x_inlet = canvas_addinlet(x->x_canvas, &x->x_obj.ob_pd, 0); x->x_inlet = canvas_addinlet(x->x_canvas, &x->x_obj.ob_pd, 0);
@ -108,7 +119,9 @@ int vinlet_issignal(t_vinlet *x)
return (x->x_buf != 0); return (x->x_buf != 0);
} }
#ifndef ROCKBOX
static int tot; static int tot;
#endif
t_int *vinlet_perform(t_int *w) t_int *vinlet_perform(t_int *w)
{ {
@ -176,7 +189,13 @@ void vinlet_dspprolog(t_vinlet *x, t_signal **parentsigs,
int myvecsize, int phase, int period, int frequency, int downsample, int upsample/* IOhannes */, int reblock, int myvecsize, int phase, int period, int frequency, int downsample, int upsample/* IOhannes */, int reblock,
int switched) int switched)
{ {
#ifdef ROCKBOX
t_signal *insig;
(void) frequency;
(void) switched;
#else
t_signal *insig, *outsig; t_signal *insig, *outsig;
#endif
x->x_updown.downsample = downsample; x->x_updown.downsample = downsample;
x->x_updown.upsample = upsample; x->x_updown.upsample = upsample;
@ -318,6 +337,9 @@ typedef struct _voutlet
static void *voutlet_new(t_symbol *s) static void *voutlet_new(t_symbol *s)
{ {
#ifdef ROCKBOX
(void) s;
#endif
t_voutlet *x = (t_voutlet *)pd_new(voutlet_class); t_voutlet *x = (t_voutlet *)pd_new(voutlet_class);
x->x_canvas = canvas_getcurrent(); x->x_canvas = canvas_getcurrent();
x->x_parentoutlet = canvas_addoutlet(x->x_canvas, &x->x_obj.ob_pd, 0); x->x_parentoutlet = canvas_addoutlet(x->x_canvas, &x->x_obj.ob_pd, 0);
@ -445,6 +467,12 @@ void voutlet_dspprolog(t_voutlet *x, t_signal **parentsigs,
int myvecsize, int phase, int period, int frequency, int downsample, int upsample /* IOhannes */, int reblock, int myvecsize, int phase, int period, int frequency, int downsample, int upsample /* IOhannes */, int reblock,
int switched) int switched)
{ {
#ifdef ROCKBOX
(void) myvecsize;
(void) phase;
(void) period;
(void) frequency;
#endif
x->x_updown.downsample=downsample; x->x_updown.upsample=upsample; /* IOhannes */ x->x_updown.downsample=downsample; x->x_updown.upsample=upsample; /* IOhannes */
x->x_justcopyout = (switched && !reblock); x->x_justcopyout = (switched && !reblock);
if (reblock) if (reblock)
@ -488,7 +516,11 @@ void voutlet_dspepilog(t_voutlet *x, t_signal **parentsigs,
x->x_updown.downsample=downsample; x->x_updown.upsample=upsample; /* IOhannes */ x->x_updown.downsample=downsample; x->x_updown.upsample=upsample; /* IOhannes */
if (reblock) if (reblock)
{ {
#ifdef ROCKBOX
t_signal *outsig;
#else
t_signal *insig, *outsig; t_signal *insig, *outsig;
#endif
int parentvecsize, bufsize, oldbufsize; int parentvecsize, bufsize, oldbufsize;
int re_parentvecsize; /* IOhannes */ int re_parentvecsize; /* IOhannes */
int bigperiod, epilogphase, blockphase; int bigperiod, epilogphase, blockphase;

View file

@ -6,6 +6,13 @@
/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */ /* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "g_canvas.h"
#include "g_all_guis.h"
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -21,6 +28,7 @@
#else #else
#include <unistd.h> #include <unistd.h>
#endif #endif
#endif /* ROCKBOX */
/* ---------- cnv my gui-canvas for a window ---------------- */ /* ---------- cnv my gui-canvas for a window ---------------- */
@ -31,6 +39,10 @@ static t_class *my_canvas_class;
void my_canvas_draw_new(t_my_canvas *x, t_glist *glist) void my_canvas_draw_new(t_my_canvas *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
@ -48,10 +60,15 @@ void my_canvas_draw_new(t_my_canvas *x, t_glist *glist)
canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy, canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy,
strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x); x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x);
#endif /* ROCKBOX */
} }
void my_canvas_draw_move(t_my_canvas *x, t_glist *glist) void my_canvas_draw_move(t_my_canvas *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
@ -65,19 +82,29 @@ void my_canvas_draw_move(t_my_canvas *x, t_glist *glist)
sys_vgui(".x%x.c coords %xLABEL %d %d\n", sys_vgui(".x%x.c coords %xLABEL %d %d\n",
canvas, x, xpos+x->x_gui.x_ldx, canvas, x, xpos+x->x_gui.x_ldx,
ypos+x->x_gui.x_ldy); ypos+x->x_gui.x_ldy);
#endif /* ROCKBOX */
} }
void my_canvas_draw_erase(t_my_canvas* x, t_glist* glist) void my_canvas_draw_erase(t_my_canvas* x, t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
sys_vgui(".x%x.c delete %xBASE\n", canvas, x); sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
sys_vgui(".x%x.c delete %xRECT\n", canvas, x); sys_vgui(".x%x.c delete %xRECT\n", canvas, x);
sys_vgui(".x%x.c delete %xLABEL\n", canvas, x); sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
#endif /* ROCKBOX */
} }
void my_canvas_draw_config(t_my_canvas* x, t_glist* glist) void my_canvas_draw_config(t_my_canvas* x, t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
sys_vgui(".x%x.c itemconfigure %xRECT -fill #%6.6x -outline #%6.6x\n", canvas, x, sys_vgui(".x%x.c itemconfigure %xRECT -fill #%6.6x -outline #%6.6x\n", canvas, x,
@ -87,10 +114,15 @@ void my_canvas_draw_config(t_my_canvas* x, t_glist* glist)
sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n", sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol,
strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
#endif /* ROCKBOX */
} }
void my_canvas_draw_select(t_my_canvas* x, t_glist* glist) void my_canvas_draw_select(t_my_canvas* x, t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
if(x->x_gui.x_fsf.x_selected) if(x->x_gui.x_fsf.x_selected)
@ -101,6 +133,7 @@ void my_canvas_draw_select(t_my_canvas* x, t_glist* glist)
{ {
sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, x->x_gui.x_bcol); sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, x->x_gui.x_bcol);
} }
#endif /* ROCKBOX */
} }
void my_canvas_draw(t_my_canvas *x, t_glist *glist, int mode) void my_canvas_draw(t_my_canvas *x, t_glist *glist, int mode)
@ -147,6 +180,10 @@ static void my_canvas_save(t_gobj *z, t_binbuf *b)
static void my_canvas_properties(t_gobj *z, t_glist *owner) static void my_canvas_properties(t_gobj *z, t_glist *owner)
{ {
#ifdef ROCKBOX
(void) z;
(void) owner;
#else /* ROCKBOX */
t_my_canvas *x = (t_my_canvas *)z; t_my_canvas *x = (t_my_canvas *)z;
char buf[800]; char buf[800];
t_symbol *srl[3]; t_symbol *srl[3];
@ -168,6 +205,7 @@ static void my_canvas_properties(t_gobj *z, t_glist *owner)
x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
0xffffff & x->x_gui.x_bcol, -1/*no frontcolor*/, 0xffffff & x->x_gui.x_lcol); 0xffffff & x->x_gui.x_bcol, -1/*no frontcolor*/, 0xffffff & x->x_gui.x_lcol);
gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
#endif /* ROCKBOX */
} }
static void my_canvas_get_pos(t_my_canvas *x) static void my_canvas_get_pos(t_my_canvas *x)
@ -182,11 +220,19 @@ static void my_canvas_get_pos(t_my_canvas *x)
static void my_canvas_dialog(t_my_canvas *x, t_symbol *s, int argc, t_atom *argv) static void my_canvas_dialog(t_my_canvas *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifndef ROCKBOX
t_symbol *srl[3]; t_symbol *srl[3];
#endif
int a = (int)atom_getintarg(0, argc, argv); int a = (int)atom_getintarg(0, argc, argv);
int w = (int)atom_getintarg(2, argc, argv); int w = (int)atom_getintarg(2, argc, argv);
int h = (int)atom_getintarg(3, argc, argv); int h = (int)atom_getintarg(3, argc, argv);
#ifndef ROCKBOX
int sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv); int sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
#endif
#ifdef ROCKBOX
(void) s;
#endif
x->x_gui.x_isa.x_loadinit = 0; x->x_gui.x_isa.x_loadinit = 0;
if(a < 1) if(a < 1)
@ -207,6 +253,10 @@ static void my_canvas_size(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
{ {
int i = (int)atom_getintarg(0, ac, av); int i = (int)atom_getintarg(0, ac, av);
#ifdef ROCKBOX
(void) s;
#endif
if(i < 1) if(i < 1)
i = 1; i = 1;
x->x_gui.x_w = i; x->x_gui.x_w = i;
@ -224,6 +274,10 @@ static void my_canvas_vis_size(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
{ {
int i; int i;
#ifdef ROCKBOX
(void) s;
#endif
i = (int)atom_getintarg(0, ac, av); i = (int)atom_getintarg(0, ac, av);
if(i < 1) if(i < 1)
i = 1; i = 1;
@ -262,9 +316,19 @@ static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv)
t_my_canvas *x = (t_my_canvas *)pd_new(my_canvas_class); t_my_canvas *x = (t_my_canvas *)pd_new(my_canvas_class);
int bflcol[]={-233017, -1, -66577}; int bflcol[]={-233017, -1, -66577};
int a=IEM_GUI_DEFAULTSIZE, w=100, h=60; int a=IEM_GUI_DEFAULTSIZE, w=100, h=60;
#ifdef ROCKBOX
int ldx=20, ldy=12, i=0;
#else
int ldx=20, ldy=12, f=2, i=0; int ldx=20, ldy=12, f=2, i=0;
#endif
int fs=14; int fs=14;
#ifndef ROCKBOX
char str[144]; char str[144];
#endif
#ifdef ROCKBOX
(void) s;
#endif
iem_inttosymargs(&x->x_gui.x_isa, 0); iem_inttosymargs(&x->x_gui.x_isa, 0);
iem_inttofstyle(&x->x_gui.x_fsf, 0); iem_inttofstyle(&x->x_gui.x_fsf, 0);
@ -350,7 +414,9 @@ static void my_canvas_ff(t_my_canvas *x)
{ {
if(x->x_gui.x_fsf.x_rcv_able) if(x->x_gui.x_fsf.x_rcv_able)
pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
#ifndef ROCKBOX
gfxstub_deleteforkey(x); gfxstub_deleteforkey(x);
#endif
} }
void g_mycanvas_setup(void) void g_mycanvas_setup(void)

View file

@ -4,6 +4,13 @@
/* my_numbox.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */ /* my_numbox.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "g_canvas.h"
#include "g_all_guis.h"
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -19,6 +26,7 @@
#else #else
#include <unistd.h> #include <unistd.h>
#endif #endif
#endif /* ROCKBOX */
/*------------------ global varaibles -------------------------*/ /*------------------ global varaibles -------------------------*/
@ -76,7 +84,11 @@ void my_numbox_ftoa(t_my_numbox *x)
double f=x->x_val; double f=x->x_val;
int bufsize, is_exp=0, i, idecimal; int bufsize, is_exp=0, i, idecimal;
#ifdef ROCKBOX
ftoan(f, x->x_buf, 10);
#else
sprintf(x->x_buf, "%g", f); sprintf(x->x_buf, "%g", f);
#endif
bufsize = strlen(x->x_buf); bufsize = strlen(x->x_buf);
if(bufsize >= 5)/* if it is in exponential mode */ if(bufsize >= 5)/* if it is in exponential mode */
{ {
@ -130,6 +142,10 @@ void my_numbox_ftoa(t_my_numbox *x)
static void my_numbox_draw_update(t_my_numbox *x, t_glist *glist) static void my_numbox_draw_update(t_my_numbox *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
if (glist_isvisible(glist)) if (glist_isvisible(glist))
{ {
if(x->x_gui.x_fsf.x_change) if(x->x_gui.x_fsf.x_change)
@ -169,10 +185,15 @@ static void my_numbox_draw_update(t_my_numbox *x, t_glist *glist)
x->x_buf[0] = 0; x->x_buf[0] = 0;
} }
} }
#endif /* ROCKBOX */
} }
static void my_numbox_draw_new(t_my_numbox *x, t_glist *glist) static void my_numbox_draw_new(t_my_numbox *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
int half=x->x_gui.x_h/2, d=1+x->x_gui.x_h/34; int half=x->x_gui.x_h/2, d=1+x->x_gui.x_h/34;
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
@ -215,10 +236,15 @@ static void my_numbox_draw_new(t_my_numbox *x, t_glist *glist)
xpos, ypos, xpos, ypos,
xpos+IOWIDTH, ypos+1, xpos+IOWIDTH, ypos+1,
x, 0); x, 0);
#endif /* ROCKBOX */
} }
static void my_numbox_draw_move(t_my_numbox *x, t_glist *glist) static void my_numbox_draw_move(t_my_numbox *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
int half = x->x_gui.x_h/2, d=1+x->x_gui.x_h/34; int half = x->x_gui.x_h/2, d=1+x->x_gui.x_h/34;
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
@ -248,10 +274,15 @@ static void my_numbox_draw_move(t_my_numbox *x, t_glist *glist)
canvas, x, 0, canvas, x, 0,
xpos, ypos, xpos, ypos,
xpos+IOWIDTH, ypos+1); xpos+IOWIDTH, ypos+1);
#endif /* ROCKBOX */
} }
static void my_numbox_draw_erase(t_my_numbox* x,t_glist* glist) static void my_numbox_draw_erase(t_my_numbox* x,t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
sys_vgui(".x%x.c delete %xBASE1\n", canvas, x); sys_vgui(".x%x.c delete %xBASE1\n", canvas, x);
@ -262,10 +293,15 @@ static void my_numbox_draw_erase(t_my_numbox* x,t_glist* glist)
sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
if(!x->x_gui.x_fsf.x_rcv_able) if(!x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
#endif /* ROCKBOX */
} }
static void my_numbox_draw_config(t_my_numbox* x,t_glist* glist) static void my_numbox_draw_config(t_my_numbox* x,t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n", sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
@ -279,10 +315,16 @@ static void my_numbox_draw_config(t_my_numbox* x,t_glist* glist)
x, x->x_gui.x_bcol); x, x->x_gui.x_bcol);
sys_vgui(".x%x.c itemconfigure %xBASE2 -fill #%6.6x\n", canvas, sys_vgui(".x%x.c itemconfigure %xBASE2 -fill #%6.6x\n", canvas,
x, x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_fcol); x, x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_fcol);
#endif /* ROCKBOX */
} }
static void my_numbox_draw_io(t_my_numbox* x,t_glist* glist, int old_snd_rcv_flags) static void my_numbox_draw_io(t_my_numbox* x,t_glist* glist, int old_snd_rcv_flags)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
(void) old_snd_rcv_flags;
#else /* ROCKBOX */
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
@ -303,10 +345,15 @@ static void my_numbox_draw_io(t_my_numbox* x,t_glist* glist, int old_snd_rcv_fla
x, 0); x, 0);
if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
#endif /* ROCKBOX */
} }
static void my_numbox_draw_select(t_my_numbox *x, t_glist *glist) static void my_numbox_draw_select(t_my_numbox *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
if(x->x_gui.x_fsf.x_selected) if(x->x_gui.x_fsf.x_selected)
@ -338,6 +385,7 @@ static void my_numbox_draw_select(t_my_numbox *x, t_glist *glist)
sys_vgui(".x%x.c itemconfigure %xNUMBER -fill #%6.6x\n", sys_vgui(".x%x.c itemconfigure %xNUMBER -fill #%6.6x\n",
canvas, x, x->x_gui.x_fcol); canvas, x, x->x_gui.x_fcol);
} }
#endif /* ROCKBOX */
} }
void my_numbox_draw(t_my_numbox *x, t_glist *glist, int mode) void my_numbox_draw(t_my_numbox *x, t_glist *glist, int mode)
@ -440,6 +488,10 @@ int my_numbox_check_minmax(t_my_numbox *x, double min, double max)
static void my_numbox_properties(t_gobj *z, t_glist *owner) static void my_numbox_properties(t_gobj *z, t_glist *owner)
{ {
#ifdef ROCKBOX
(void) z;
(void) owner;
#else /* ROCKBOX */
t_my_numbox *x = (t_my_numbox *)z; t_my_numbox *x = (t_my_numbox *)z;
char buf[800]; char buf[800];
t_symbol *srl[3]; t_symbol *srl[3];
@ -471,6 +523,7 @@ static void my_numbox_properties(t_gobj *z, t_glist *owner)
0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol,
0xffffff & x->x_gui.x_lcol); 0xffffff & x->x_gui.x_lcol);
gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
#endif /* ROCKBOX */
} }
static void my_numbox_bang(t_my_numbox *x) static void my_numbox_bang(t_my_numbox *x)
@ -492,6 +545,10 @@ static void my_numbox_dialog(t_my_numbox *x, t_symbol *s, int argc,
int log_height = (int)atom_getintarg(6, argc, argv); int log_height = (int)atom_getintarg(6, argc, argv);
int sr_flags; int sr_flags;
#ifdef ROCKBOX
(void) s;
#endif
if(lilo != 0) lilo = 1; if(lilo != 0) lilo = 1;
x->x_lin0_log1 = lilo; x->x_lin0_log1 = lilo;
sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv); sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
@ -519,6 +576,10 @@ static void my_numbox_motion(t_my_numbox *x, t_floatarg dx, t_floatarg dy)
{ {
double k2=1.0; double k2=1.0;
#ifdef ROCKBOX
(void) dx;
#endif
if(x->x_gui.x_fsf.x_finemoved) if(x->x_gui.x_fsf.x_finemoved)
k2 = 0.01; k2 = 0.01;
if(x->x_lin0_log1) if(x->x_lin0_log1)
@ -534,6 +595,11 @@ static void my_numbox_motion(t_my_numbox *x, t_floatarg dx, t_floatarg dy)
static void my_numbox_click(t_my_numbox *x, t_floatarg xpos, t_floatarg ypos, static void my_numbox_click(t_my_numbox *x, t_floatarg xpos, t_floatarg ypos,
t_floatarg shift, t_floatarg ctrl, t_floatarg alt) t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
{ {
#ifdef ROCKBOX
(void) shift;
(void) ctrl;
(void) alt;
#endif
glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g, glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g,
(t_glistmotionfn)my_numbox_motion, my_numbox_key, xpos, ypos); (t_glistmotionfn)my_numbox_motion, my_numbox_key, xpos, ypos);
} }
@ -543,6 +609,11 @@ static int my_numbox_newclick(t_gobj *z, struct _glist *glist,
{ {
t_my_numbox* x = (t_my_numbox *)z; t_my_numbox* x = (t_my_numbox *)z;
#ifdef ROCKBOX
(void) glist;
(void) dbl;
#endif
if(doit) if(doit)
{ {
my_numbox_click( x, (t_floatarg)xpix, (t_floatarg)ypix, my_numbox_click( x, (t_floatarg)xpix, (t_floatarg)ypix,
@ -603,6 +674,10 @@ static void my_numbox_size(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
{ {
int h, w; int h, w;
#ifdef ROCKBOX
(void) s;
#endif
w = (int)atom_getintarg(0, ac, av); w = (int)atom_getintarg(0, ac, av);
if(w < 1) if(w < 1)
w = 1; w = 1;
@ -626,6 +701,9 @@ static void my_numbox_pos(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
static void my_numbox_range(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) static void my_numbox_range(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
#endif
if(my_numbox_check_minmax(x, (double)atom_getfloatarg(0, ac, av), if(my_numbox_check_minmax(x, (double)atom_getfloatarg(0, ac, av),
(double)atom_getfloatarg(1, ac, av))) (double)atom_getfloatarg(1, ac, av)))
{ {
@ -742,6 +820,9 @@ static void my_numbox_key(void *z, t_floatarg fkey)
static void my_numbox_list(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) static void my_numbox_list(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
#endif
if (IS_A_FLOAT(av,0)) if (IS_A_FLOAT(av,0))
{ {
my_numbox_set(x, atom_getfloatarg(0, ac, av)); my_numbox_set(x, atom_getfloatarg(0, ac, av));
@ -754,11 +835,21 @@ static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv)
t_my_numbox *x = (t_my_numbox *)pd_new(my_numbox_class); t_my_numbox *x = (t_my_numbox *)pd_new(my_numbox_class);
int bflcol[]={-262144, -1, -1}; int bflcol[]={-262144, -1, -1};
int w=5, h=14; int w=5, h=14;
#ifdef ROCKBOX
int lilo=0, ldx=0, ldy=-6;
#else
int lilo=0, f=0, ldx=0, ldy=-6; int lilo=0, f=0, ldx=0, ldy=-6;
#endif
int fs=10; int fs=10;
int log_height=256; int log_height=256;
double min=-1.0e+37, max=1.0e+37,v=0.0; double min=-1.0e+37, max=1.0e+37,v=0.0;
#ifndef ROCKBOX
char str[144]; char str[144];
#endif
#ifdef ROCKBOX
(void) s;
#endif
if((argc >= 17)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1) if((argc >= 17)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
&&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3) &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3)
@ -843,7 +934,9 @@ static void my_numbox_free(t_my_numbox *x)
pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
clock_free(x->x_clock_reset); clock_free(x->x_clock_reset);
clock_free(x->x_clock_wait); clock_free(x->x_clock_wait);
#ifndef ROCKBOX
gfxstub_deleteforkey(x); gfxstub_deleteforkey(x);
#endif
} }
void g_numbox_setup(void) void g_numbox_setup(void)

View file

@ -8,18 +8,29 @@ collection of "scalar" objects. Routines here can save collections of
scalars into a file and reload them; also, support is included here for scalars into a file and reload them; also, support is included here for
*/ */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "g_canvas.h"
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "m_pd.h" #include "m_pd.h"
#include "g_canvas.h" #include "g_canvas.h"
#include <string.h> #include <string.h>
#endif /* ROCKBOX */
/* the following routines read "scalars" from a file into a canvas. */ /* the following routines read "scalars" from a file into a canvas. */
static int canvas_scanbinbuf(int natoms, t_atom *vec, int *p_indexout, static int canvas_scanbinbuf(int natoms, t_atom *vec, int *p_indexout,
int *p_next) int *p_next)
{ {
#ifdef ROCKBOX
int i;
#else
int i, j; int i, j;
#endif
int indexwas = *p_next; int indexwas = *p_next;
*p_indexout = indexwas; *p_indexout = indexwas;
if (indexwas >= natoms) if (indexwas >= natoms)
@ -38,6 +49,9 @@ int glist_readscalar(t_glist *x, int natoms, t_atom *vec,
static void canvas_readerror(int natoms, t_atom *vec, int message, static void canvas_readerror(int natoms, t_atom *vec, int message,
int nline, char *s) int nline, char *s)
{ {
#ifdef ROCKBOX
(void) natoms;
#endif
error(s); error(s);
startpost("line was:"); startpost("line was:");
postatom(nline, vec + message); postatom(nline, vec + message);
@ -49,7 +63,11 @@ static void canvas_readerror(int natoms, t_atom *vec, int message,
static void glist_readatoms(t_glist *x, int natoms, t_atom *vec, static void glist_readatoms(t_glist *x, int natoms, t_atom *vec,
int *p_nextmsg, t_symbol *templatesym, t_word *w, int argc, t_atom *argv) int *p_nextmsg, t_symbol *templatesym, t_word *w, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
int message, n, i;
#else
int message, nline, n, i; int message, nline, n, i;
#endif
t_template *template = template_findbyname(templatesym); t_template *template = template_findbyname(templatesym);
if (!template) if (!template)
@ -64,7 +82,9 @@ static void glist_readatoms(t_glist *x, int natoms, t_atom *vec,
{ {
if (template->t_vec[i].ds_type == DT_ARRAY) if (template->t_vec[i].ds_type == DT_ARRAY)
{ {
#ifndef ROCKBOX
int j; int j;
#endif
t_array *a = w[i].w_array; t_array *a = w[i].w_array;
int elemsize = a->a_elemsize, nitems = 0; int elemsize = a->a_elemsize, nitems = 0;
t_symbol *arraytemplatesym = template->t_vec[i].ds_arraytemplate; t_symbol *arraytemplatesym = template->t_vec[i].ds_arraytemplate;
@ -104,7 +124,11 @@ static void glist_readatoms(t_glist *x, int natoms, t_atom *vec,
int glist_readscalar(t_glist *x, int natoms, t_atom *vec, int glist_readscalar(t_glist *x, int natoms, t_atom *vec,
int *p_nextmsg, int selectit) int *p_nextmsg, int selectit)
{ {
#ifdef ROCKBOX
int message, nline;
#else
int message, i, j, nline; int message, i, j, nline;
#endif
t_template *template; t_template *template;
t_symbol *templatesym; t_symbol *templatesym;
t_scalar *sc; t_scalar *sc;
@ -159,10 +183,16 @@ int glist_readscalar(t_glist *x, int natoms, t_atom *vec,
void glist_readfrombinbuf(t_glist *x, t_binbuf *b, char *filename, int selectem) void glist_readfrombinbuf(t_glist *x, t_binbuf *b, char *filename, int selectem)
{ {
#ifdef ROCKBOX
int natoms, nline, message, nextmsg = 0;
#else
t_canvas *canvas = glist_getcanvas(x); t_canvas *canvas = glist_getcanvas(x);
int cr = 0, natoms, nline, message, nextmsg = 0, i, j, nitems; int cr = 0, natoms, nline, message, nextmsg = 0, i, j, nitems;
#endif
t_atom *vec; t_atom *vec;
#ifndef ROCKBOX
t_gobj *gobj; t_gobj *gobj;
#endif
natoms = binbuf_getnatom(b); natoms = binbuf_getnatom(b);
vec = binbuf_getvec(b); vec = binbuf_getvec(b);
@ -244,8 +274,12 @@ static void glist_doread(t_glist *x, t_symbol *filename, t_symbol *format,
t_binbuf *b = binbuf_new(); t_binbuf *b = binbuf_new();
t_canvas *canvas = glist_getcanvas(x); t_canvas *canvas = glist_getcanvas(x);
int wasvis = glist_isvisible(canvas); int wasvis = glist_isvisible(canvas);
#ifdef ROCKBOX
int cr = 0;
#else
int cr = 0, natoms, nline, message, nextmsg = 0, i, j; int cr = 0, natoms, nline, message, nextmsg = 0, i, j;
t_atom *vec; t_atom *vec;
#endif
if (!strcmp(format->s_name, "cr")) if (!strcmp(format->s_name, "cr"))
cr = 1; cr = 1;
@ -302,7 +336,7 @@ void canvas_dataproperties(t_canvas *x, t_scalar *sc, t_binbuf *b)
/* take the new object off the list */ /* take the new object off the list */
if (ntotal) if (ntotal)
{ {
for (y = x->gl_list, nnew = 1; y2 = y->g_next; for(y = x->gl_list, nnew = 1; (y2 = y->g_next);
y = y2, nnew++) y = y2, nnew++)
if (nnew == ntotal) if (nnew == ntotal)
{ {
@ -360,7 +394,9 @@ static void glist_writelist(t_gobj *y, t_binbuf *b);
void canvas_writescalar(t_symbol *templatesym, t_word *w, t_binbuf *b, void canvas_writescalar(t_symbol *templatesym, t_word *w, t_binbuf *b,
int amarrayelement) int amarrayelement)
{ {
#ifndef ROCKBOX
t_dataslot *ds; t_dataslot *ds;
#endif
t_template *template = template_findbyname(templatesym); t_template *template = template_findbyname(templatesym);
t_atom *a = (t_atom *)t_getbytes(0); t_atom *a = (t_atom *)t_getbytes(0);
int i, n = template->t_n, natom = 0; int i, n = template->t_n, natom = 0;
@ -532,12 +568,18 @@ t_binbuf *glist_writetobinbuf(t_glist *x, int wholething)
static void glist_write(t_glist *x, t_symbol *filename, t_symbol *format) static void glist_write(t_glist *x, t_symbol *filename, t_symbol *format)
{ {
#ifdef ROCKBOX
int cr = 0;
#else
int cr = 0, i; int cr = 0, i;
#endif
t_binbuf *b; t_binbuf *b;
char buf[MAXPDSTRING]; char buf[MAXPDSTRING];
#ifndef ROCKBOX
t_symbol **templatevec = getbytes(0); t_symbol **templatevec = getbytes(0);
int ntemplates = 0; int ntemplates = 0;
t_gobj *y; t_gobj *y;
#endif
t_canvas *canvas = glist_getcanvas(x); t_canvas *canvas = glist_getcanvas(x);
canvas_makefilename(canvas, filename->s_name, buf, MAXPDSTRING); canvas_makefilename(canvas, filename->s_name, buf, MAXPDSTRING);
if (!strcmp(format->s_name, "cr")) if (!strcmp(format->s_name, "cr"))
@ -586,7 +628,7 @@ static void canvas_saveto(t_canvas *x, t_binbuf *b)
gobj_save(y, b); gobj_save(y, b);
linetraverser_start(&t, x); linetraverser_start(&t, x);
while (oc = linetraverser_next(&t)) while((oc = linetraverser_next(&t)))
{ {
int srcno = canvas_getindex(x, &t.tr_ob->ob_g); int srcno = canvas_getindex(x, &t.tr_ob->ob_g);
int sinkno = canvas_getindex(x, &t.tr_ob2->ob_g); int sinkno = canvas_getindex(x, &t.tr_ob2->ob_g);
@ -629,7 +671,9 @@ static void canvas_savetemplatesto(t_canvas *x, t_binbuf *b, int wholething)
{ {
t_symbol **templatevec = getbytes(0); t_symbol **templatevec = getbytes(0);
int i, ntemplates = 0; int i, ntemplates = 0;
#ifndef ROCKBOX
t_gobj *y; t_gobj *y;
#endif
canvas_collecttemplatesfor(x, &ntemplates, &templatevec, wholething); canvas_collecttemplatesfor(x, &ntemplates, &templatevec, wholething);
for (i = 0; i < ntemplates; i++) for (i = 0; i < ntemplates; i++)
{ {
@ -687,9 +731,13 @@ static void canvas_savetofile(t_canvas *x, t_symbol *filename, t_symbol *dir)
static void canvas_menusaveas(t_canvas *x) static void canvas_menusaveas(t_canvas *x)
{ {
#ifdef ROCKBOX
(void) x;
#else /* ROCKBOX */
t_canvas *x2 = canvas_getrootfor(x); t_canvas *x2 = canvas_getrootfor(x);
sys_vgui("pdtk_canvas_saveas .x%x \"%s\" \"%s\"\n", x2, sys_vgui("pdtk_canvas_saveas .x%x \"%s\" \"%s\"\n", x2,
x2->gl_name->s_name, canvas_getdir(x2)->s_name); x2->gl_name->s_name, canvas_getdir(x2)->s_name);
#endif /* ROCKBOX */
} }
static void canvas_menusave(t_canvas *x) static void canvas_menusave(t_canvas *x)

View file

@ -6,6 +6,14 @@
/* have to insert gui-objects into editor-list */ /* have to insert gui-objects into editor-list */
/* all changes are labeled with iemlib */ /* all changes are labeled with iemlib */
#ifdef ROCKBOX
#include "plugin.h"
#include "ctype.h"
#include "pdbox.h"
#include "m_pd.h"
#include "g_canvas.h"
#define snprintf rb->snprintf
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -14,6 +22,7 @@
#include "s_stuff.h" #include "s_stuff.h"
#include "g_canvas.h" #include "g_canvas.h"
#include "t_tk.h" #include "t_tk.h"
#endif /* ROCKBOX */
#define LMARGIN 1 #define LMARGIN 1
#define RMARGIN 1 #define RMARGIN 1
@ -44,7 +53,9 @@ struct _rtext
t_rtext *rtext_new(t_glist *glist, t_text *who) t_rtext *rtext_new(t_glist *glist, t_text *who)
{ {
t_rtext *x = (t_rtext *)getbytes(sizeof *x); t_rtext *x = (t_rtext *)getbytes(sizeof *x);
#ifndef ROCKBOX
int w = 0, h = 0, indx; int w = 0, h = 0, indx;
#endif
x->x_height = -1; x->x_height = -1;
x->x_text = who; x->x_text = who;
x->x_glist = glist; x->x_glist = glist;
@ -53,8 +64,13 @@ t_rtext *rtext_new(t_glist *glist, t_text *who)
x->x_drawnwidth = x->x_drawnheight = 0; x->x_drawnwidth = x->x_drawnheight = 0;
binbuf_gettext(who->te_binbuf, &x->x_buf, &x->x_bufsize); binbuf_gettext(who->te_binbuf, &x->x_buf, &x->x_bufsize);
glist->gl_editor->e_rtext = x; glist->gl_editor->e_rtext = x;
#ifdef ROCKBOX
snprintf(x->x_tag, strlen(x->x_tag),
".x%x.t%x", (t_int)glist_getcanvas(x->x_glist), (t_int)x);
#else /* ROCKBOX */
sprintf(x->x_tag, ".x%x.t%x", (t_int)glist_getcanvas(x->x_glist), sprintf(x->x_tag, ".x%x.t%x", (t_int)glist_getcanvas(x->x_glist),
(t_int)x); (t_int)x);
#endif /* ROCKBOX */
return (x); return (x);
} }
@ -149,12 +165,18 @@ static void rtext_senditup(t_rtext *x, int action, int *widthp, int *heightp,
char tempbuf[UPBUFSIZE], *tp = tempbuf, *bp = x->x_buf; char tempbuf[UPBUFSIZE], *tp = tempbuf, *bp = x->x_buf;
int outchars, inchars = x->x_bufsize, nlines = 0, ncolumns = 0, int outchars, inchars = x->x_bufsize, nlines = 0, ncolumns = 0,
pixwide, pixhigh; pixwide, pixhigh;
#ifdef ROCKBOX
int fontwidth = 8, fontheight = 10;
#else
int font = glist_getfont(x->x_glist); int font = glist_getfont(x->x_glist);
int fontwidth = sys_fontwidth(font), fontheight = sys_fontheight(font); int fontwidth = sys_fontwidth(font), fontheight = sys_fontheight(font);
#endif
int findx = (*widthp + (fontwidth/2)) / fontwidth, int findx = (*widthp + (fontwidth/2)) / fontwidth,
findy = *heightp / fontheight; findy = *heightp / fontheight;
int reportedindex = 0; int reportedindex = 0;
#ifndef ROCKBOX
t_canvas *canvas = glist_getcanvas(x->x_glist); t_canvas *canvas = glist_getcanvas(x->x_glist);
#endif
int widthspec = x->x_text->te_width; int widthspec = x->x_text->te_width;
int widthlimit = (widthspec ? widthspec : BOXWIDTH); int widthlimit = (widthspec ? widthspec : BOXWIDTH);
while (inchars) while (inchars)
@ -214,16 +236,22 @@ static void rtext_senditup(t_rtext *x, int action, int *widthp, int *heightp,
pixhigh = nlines * fontheight + (TMARGIN + BMARGIN); pixhigh = nlines * fontheight + (TMARGIN + BMARGIN);
if (action == SEND_FIRST) if (action == SEND_FIRST)
#ifdef ROCKBOX
;
#else /* ROCKBOX */
sys_vgui("pdtk_text_new .x%x.c %s %f %f {%.*s} %d %s\n", sys_vgui("pdtk_text_new .x%x.c %s %f %f {%.*s} %d %s\n",
canvas, x->x_tag, canvas, x->x_tag,
dispx + LMARGIN, dispy + TMARGIN, dispx + LMARGIN, dispy + TMARGIN,
outchars, tempbuf, sys_hostfontsize(font), outchars, tempbuf, sys_hostfontsize(font),
(glist_isselected(x->x_glist, (glist_isselected(x->x_glist,
&x->x_glist->gl_gobj)? "blue" : "black")); &x->x_glist->gl_gobj)? "blue" : "black"));
#endif /* ROCKBOX */
else if (action == SEND_UPDATE) else if (action == SEND_UPDATE)
{ {
#ifndef ROCKBOX
sys_vgui("pdtk_text_set .x%x.c %s {%.*s}\n", sys_vgui("pdtk_text_set .x%x.c %s {%.*s}\n",
canvas, x->x_tag, outchars, tempbuf); canvas, x->x_tag, outchars, tempbuf);
#endif
if (pixwide != x->x_drawnwidth || pixhigh != x->x_drawnheight) if (pixwide != x->x_drawnwidth || pixhigh != x->x_drawnheight)
text_drawborder(x->x_text, x->x_glist, x->x_tag, text_drawborder(x->x_text, x->x_glist, x->x_tag,
pixwide, pixhigh, 0); pixwide, pixhigh, 0);
@ -231,18 +259,22 @@ static void rtext_senditup(t_rtext *x, int action, int *widthp, int *heightp,
{ {
if (x->x_selend > x->x_selstart) if (x->x_selend > x->x_selstart)
{ {
#ifndef ROCKBOX
sys_vgui(".x%x.c select from %s %d\n", canvas, sys_vgui(".x%x.c select from %s %d\n", canvas,
x->x_tag, x->x_selstart); x->x_tag, x->x_selstart);
sys_vgui(".x%x.c select to %s %d\n", canvas, sys_vgui(".x%x.c select to %s %d\n", canvas,
x->x_tag, x->x_selend + (sys_oldtclversion ? 0 : -1)); x->x_tag, x->x_selend + (sys_oldtclversion ? 0 : -1));
sys_vgui(".x%x.c focus \"\"\n", canvas); sys_vgui(".x%x.c focus \"\"\n", canvas);
#endif
} }
else else
{ {
#ifndef ROCKBOX
sys_vgui(".x%x.c select clear\n", canvas); sys_vgui(".x%x.c select clear\n", canvas);
sys_vgui(".x%x.c icursor %s %d\n", canvas, x->x_tag, sys_vgui(".x%x.c icursor %s %d\n", canvas, x->x_tag,
x->x_selstart); x->x_selstart);
sys_vgui(".x%x.c focus %s\n", canvas, x->x_tag); sys_vgui(".x%x.c focus %s\n", canvas, x->x_tag);
#endif
} }
} }
} }
@ -273,7 +305,9 @@ void rtext_retext(t_rtext *x)
int wantreduce = bufsize - text->te_width; int wantreduce = bufsize - text->te_width;
char *decimal = 0, *nextchar, *ebuf = x->x_buf + bufsize, char *decimal = 0, *nextchar, *ebuf = x->x_buf + bufsize,
*s1, *s2; *s1, *s2;
#ifndef ROCKBOX
int ndecimals; int ndecimals;
#endif
for (decimal = x->x_buf; decimal < ebuf; decimal++) for (decimal = x->x_buf; decimal < ebuf; decimal++)
if (*decimal == '.') if (*decimal == '.')
break; break;
@ -339,21 +373,35 @@ void rtext_draw(t_rtext *x)
void rtext_erase(t_rtext *x) void rtext_erase(t_rtext *x)
{ {
#ifdef ROCKBOX
(void) x;
#else
sys_vgui(".x%x.c delete %s\n", glist_getcanvas(x->x_glist), x->x_tag); sys_vgui(".x%x.c delete %s\n", glist_getcanvas(x->x_glist), x->x_tag);
#endif
} }
void rtext_displace(t_rtext *x, int dx, int dy) void rtext_displace(t_rtext *x, int dx, int dy)
{ {
#ifdef ROCKBOX
(void) x;
(void) dx;
(void) dy;
#else /* ROCKBOX */
sys_vgui(".x%x.c move %s %d %d\n", glist_getcanvas(x->x_glist), sys_vgui(".x%x.c move %s %d %d\n", glist_getcanvas(x->x_glist),
x->x_tag, dx, dy); x->x_tag, dx, dy);
#endif /* ROCKBOX */
} }
void rtext_select(t_rtext *x, int state) void rtext_select(t_rtext *x, int state)
{ {
t_glist *glist = x->x_glist; t_glist *glist = x->x_glist;
t_canvas *canvas = glist_getcanvas(glist); t_canvas *canvas = glist_getcanvas(glist);
#ifdef ROCKBOX
(void) state;
#else /* ROCKBOX */
sys_vgui(".x%x.c itemconfigure %s -fill %s\n", canvas, sys_vgui(".x%x.c itemconfigure %s -fill %s\n", canvas,
x->x_tag, (state? "blue" : "black")); x->x_tag, (state? "blue" : "black"));
#endif /* ROCKBOX */
canvas_editing = canvas; canvas_editing = canvas;
} }
@ -361,10 +409,14 @@ void rtext_activate(t_rtext *x, int state)
{ {
int w = 0, h = 0, indx; int w = 0, h = 0, indx;
t_glist *glist = x->x_glist; t_glist *glist = x->x_glist;
#ifndef ROCKBOX
t_canvas *canvas = glist_getcanvas(glist); t_canvas *canvas = glist_getcanvas(glist);
#endif
if (state) if (state)
{ {
#ifndef ROCKBOX
sys_vgui(".x%x.c focus %s\n", canvas, x->x_tag); sys_vgui(".x%x.c focus %s\n", canvas, x->x_tag);
#endif
glist->gl_editor->e_textedfor = x; glist->gl_editor->e_textedfor = x;
glist->gl_editor->e_textdirty = 0; glist->gl_editor->e_textdirty = 0;
x->x_dragfrom = x->x_selstart = 0; x->x_dragfrom = x->x_selstart = 0;
@ -373,8 +425,10 @@ void rtext_activate(t_rtext *x, int state)
} }
else else
{ {
#ifndef ROCKBOX
sys_vgui("selection clear .x%x.c\n", canvas); sys_vgui("selection clear .x%x.c\n", canvas);
sys_vgui(".x%x.c focus \"\"\n", canvas); sys_vgui(".x%x.c focus \"\"\n", canvas);
#endif
if (glist->gl_editor->e_textedfor == x) if (glist->gl_editor->e_textedfor == x)
glist->gl_editor->e_textedfor = 0; glist->gl_editor->e_textedfor = 0;
x->x_active = 0; x->x_active = 0;
@ -385,7 +439,9 @@ void rtext_activate(t_rtext *x, int state)
void rtext_key(t_rtext *x, int keynum, t_symbol *keysym) void rtext_key(t_rtext *x, int keynum, t_symbol *keysym)
{ {
int w = 0, h = 0, indx, i, newsize, ndel; int w = 0, h = 0, indx, i, newsize, ndel;
#ifndef ROCKBOX
char *s1, *s2; char *s1, *s2;
#endif
if (keynum) if (keynum)
{ {
int n = keynum; int n = keynum;

View file

@ -19,11 +19,18 @@ control their appearances by adding stuff to draw.
* added Krzysztof Czajas fix to avoid crashing... * added Krzysztof Czajas fix to avoid crashing...
*/ */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "g_canvas.h"
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> /* for read/write to files */ #include <stdio.h> /* for read/write to files */
#include "m_pd.h" #include "m_pd.h"
#include "g_canvas.h" #include "g_canvas.h"
#endif /* ROCKBOX */
t_class *scalar_class; t_class *scalar_class;
@ -139,6 +146,9 @@ void glist_scalar(t_glist *glist,
t_binbuf *b; t_binbuf *b;
int natoms, nextmsg = 0; int natoms, nextmsg = 0;
t_atom *vec; t_atom *vec;
#ifdef ROCKBOX
(void) classname;
#endif
if (!template_findbyname(templatesym)) if (!template_findbyname(templatesym))
{ {
pd_error(glist, "%s: no such template", pd_error(glist, "%s: no such template",
@ -167,7 +177,9 @@ static void scalar_getrect(t_gobj *z, t_glist *owner,
int *xp1, int *yp1, int *xp2, int *yp2) int *xp1, int *yp1, int *xp2, int *yp2)
{ {
t_scalar *x = (t_scalar *)z; t_scalar *x = (t_scalar *)z;
#ifndef ROCKBOX
int hit = 0; int hit = 0;
#endif
t_template *template = template_findbyname(x->sc_template); t_template *template = template_findbyname(x->sc_template);
t_canvas *templatecanvas = template_findcanvas(template); t_canvas *templatecanvas = template_findcanvas(template);
int x1 = 0x7fffffff, x2 = -0x7fffffff, y1 = 0x7fffffff, y2 = -0x7fffffff; int x1 = 0x7fffffff, x2 = -0x7fffffff, y1 = 0x7fffffff, y2 = -0x7fffffff;
@ -213,7 +225,9 @@ static void scalar_getrect(t_gobj *z, t_glist *owner,
static void scalar_select(t_gobj *z, t_glist *owner, int state) static void scalar_select(t_gobj *z, t_glist *owner, int state)
{ {
#ifndef ROCKBOX
t_scalar *x = (t_scalar *)z; t_scalar *x = (t_scalar *)z;
#endif
/* post("scalar_select %d", state); */ /* post("scalar_select %d", state); */
/* later */ /* later */
if (state) if (state)
@ -221,12 +235,16 @@ static void scalar_select(t_gobj *z, t_glist *owner, int state)
int x1, y1, x2, y2; int x1, y1, x2, y2;
scalar_getrect(z, owner, &x1, &y1, &x2, &y2); scalar_getrect(z, owner, &x1, &y1, &x2, &y2);
x1--; x2++; y1--; y2++; x1--; x2++; y1--; y2++;
#ifndef ROCKBOX
sys_vgui(".x%x.c create line %d %d %d %d %d %d %d %d %d %d \ sys_vgui(".x%x.c create line %d %d %d %d %d %d %d %d %d %d \
-width 0 -fill blue -tags select%x\n", -width 0 -fill blue -tags select%x\n",
glist_getcanvas(owner), x1, y1, x1, y2, x2, y2, x2, y1, x1, y1, glist_getcanvas(owner), x1, y1, x1, y2, x2, y2, x2, y1, x1, y1,
x); x);
#endif
} }
#ifndef ROCKBOX
else sys_vgui(".x%x.c delete select%x\n", glist_getcanvas(owner), x); else sys_vgui(".x%x.c delete select%x\n", glist_getcanvas(owner), x);
#endif
} }
static void scalar_displace(t_gobj *z, t_glist *glist, int dx, int dy) static void scalar_displace(t_gobj *z, t_glist *glist, int dx, int dy)
@ -263,12 +281,21 @@ static void scalar_displace(t_gobj *z, t_glist *glist, int dx, int dy)
static void scalar_activate(t_gobj *z, t_glist *owner, int state) static void scalar_activate(t_gobj *z, t_glist *owner, int state)
{ {
#ifdef ROCKBOX
(void) z;
(void) owner;
(void) state;
#endif
/* post("scalar_activate %d", state); */ /* post("scalar_activate %d", state); */
/* later */ /* later */
} }
static void scalar_delete(t_gobj *z, t_glist *glist) static void scalar_delete(t_gobj *z, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) z;
(void) glist;
#endif
/* nothing to do */ /* nothing to do */
} }
@ -285,12 +312,16 @@ static void scalar_vis(t_gobj *z, t_glist *owner, int vis)
{ {
if (vis) if (vis)
{ {
#ifndef ROCKBOX
int x1 = glist_xtopixels(owner, basex); int x1 = glist_xtopixels(owner, basex);
int y1 = glist_ytopixels(owner, basey); int y1 = glist_ytopixels(owner, basey);
sys_vgui(".x%x.c create rectangle %d %d %d %d -tags scalar%x\n", sys_vgui(".x%x.c create rectangle %d %d %d %d -tags scalar%x\n",
glist_getcanvas(owner), x1-1, y1-1, x1+1, y1+1, x); glist_getcanvas(owner), x1-1, y1-1, x1+1, y1+1, x);
#endif
} }
#ifndef ROCKBOX
else sys_vgui(".x%x.c delete scalar%x\n", glist_getcanvas(owner), x); else sys_vgui(".x%x.c delete scalar%x\n", glist_getcanvas(owner), x);
#endif
return; return;
} }
@ -316,9 +347,9 @@ static int scalar_click(t_gobj *z, struct _glist *owner,
{ {
t_parentwidgetbehavior *wb = pd_getparentwidget(&y->g_pd); t_parentwidgetbehavior *wb = pd_getparentwidget(&y->g_pd);
if (!wb) continue; if (!wb) continue;
if (hit = (*wb->w_parentclickfn)(y, owner, if((hit = (*wb->w_parentclickfn)(y, owner,
x, template, basex, basey, x, template, basex, basey,
xpix, ypix, shift, alt, dbl, doit)) xpix, ypix, shift, alt, dbl, doit)))
return (hit); return (hit);
} }
return (0); return (0);
@ -331,8 +362,10 @@ static void scalar_save(t_gobj *z, t_binbuf *b)
{ {
t_scalar *x = (t_scalar *)z; t_scalar *x = (t_scalar *)z;
t_binbuf *b2 = binbuf_new(); t_binbuf *b2 = binbuf_new();
#ifndef ROCKBOX
t_atom a, *argv; t_atom a, *argv;
int i, argc; int i, argc;
#endif
canvas_writescalar(x->sc_template, x->sc_vec, b2, 0); canvas_writescalar(x->sc_template, x->sc_vec, b2, 0);
binbuf_addv(b, "ss", &s__X, gensym("scalar")); binbuf_addv(b, "ss", &s__X, gensym("scalar"));
binbuf_addbinbuf(b, b2); binbuf_addbinbuf(b, b2);
@ -342,6 +375,10 @@ static void scalar_save(t_gobj *z, t_binbuf *b)
static void scalar_properties(t_gobj *z, struct _glist *owner) static void scalar_properties(t_gobj *z, struct _glist *owner)
{ {
#ifdef ROCKBOX
(void) z;
(void) owner;
#else /* ROCKBOX */
t_scalar *x = (t_scalar *)z; t_scalar *x = (t_scalar *)z;
char *buf, buf2[80]; char *buf, buf2[80];
int bufsize; int bufsize;
@ -358,6 +395,7 @@ static void scalar_properties(t_gobj *z, struct _glist *owner)
sys_gui(buf); sys_gui(buf);
sys_gui("}\n"); sys_gui("}\n");
t_freebytes(buf, bufsize+1); t_freebytes(buf, bufsize+1);
#endif /* ROCKBOX */
} }
static t_widgetbehavior scalar_widgetbehavior = static t_widgetbehavior scalar_widgetbehavior =
@ -373,8 +411,10 @@ static t_widgetbehavior scalar_widgetbehavior =
static void scalar_free(t_scalar *x) static void scalar_free(t_scalar *x)
{ {
#ifndef ROCKBOX
int i; int i;
t_dataslot *datatypes, *dt; t_dataslot *datatypes, *dt;
#endif
t_symbol *templatesym = x->sc_template; t_symbol *templatesym = x->sc_template;
t_template *template = template_findbyname(templatesym); t_template *template = template_findbyname(templatesym);
if (!template) if (!template)
@ -383,7 +423,9 @@ static void scalar_free(t_scalar *x)
return; return;
} }
word_free(x->sc_vec, template); word_free(x->sc_vec, template);
#ifndef ROCKBOX
gfxstub_deleteforkey(x); gfxstub_deleteforkey(x);
#endif
/* the "size" field in the class is zero, so Pd doesn't try to free /* the "size" field in the class is zero, so Pd doesn't try to free
us automatically (see pd_free()) */ us automatically (see pd_free()) */
freebytes(x, sizeof(t_scalar) + (template->t_n - 1) * sizeof(*x->sc_vec)); freebytes(x, sizeof(t_scalar) + (template->t_n - 1) * sizeof(*x->sc_vec));

View file

@ -2,6 +2,14 @@
* For information on usage and redistribution, and for a DISCLAIMER OF ALL * For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "s_stuff.h"
#include "g_canvas.h"
#define snprintf rb->snprintf
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -9,6 +17,7 @@
#include "m_pd.h" #include "m_pd.h"
#include "s_stuff.h" /* for sys_hostfontsize */ #include "s_stuff.h" /* for sys_hostfontsize */
#include "g_canvas.h" #include "g_canvas.h"
#endif /* ROCKBOX */
/* /*
This file contains text objects you would put in a canvas to define a This file contains text objects you would put in a canvas to define a
@ -140,7 +149,9 @@ int template_size(t_template *x)
int template_find_field(t_template *x, t_symbol *name, int *p_onset, int template_find_field(t_template *x, t_symbol *name, int *p_onset,
int *p_type, t_symbol **p_arraytype) int *p_type, t_symbol **p_arraytype)
{ {
#ifndef ROCKBOX
t_template *t; t_template *t;
#endif
int i, n; int i, n;
if (!x) if (!x)
{ {
@ -262,7 +273,13 @@ elements might still be old ones.
static void template_conformwords(t_template *tfrom, t_template *tto, static void template_conformwords(t_template *tfrom, t_template *tto,
int *conformaction, t_word *wfrom, t_word *wto) int *conformaction, t_word *wfrom, t_word *wto)
{ {
#ifdef ROCKBOX
int nto = tto->t_n, i;
(void) tfrom;
#else
int nfrom = tfrom->t_n, nto = tto->t_n, i; int nfrom = tfrom->t_n, nto = tto->t_n, i;
#endif
for (i = 0; i < nto; i++) for (i = 0; i < nto; i++)
{ {
if (conformaction[i] >= 0) if (conformaction[i] >= 0)
@ -282,7 +299,11 @@ static t_scalar *template_conformscalar(t_template *tfrom, t_template *tto,
{ {
t_scalar *x; t_scalar *x;
t_gpointer gp; t_gpointer gp;
#ifdef ROCKBOX
int i;
#else
int nto = tto->t_n, nfrom = tfrom->t_n, i; int nto = tto->t_n, nfrom = tfrom->t_n, i;
#endif
t_template *scalartemplate; t_template *scalartemplate;
/* post("conform scalar"); */ /* post("conform scalar"); */
/* possibly replace the scalar */ /* possibly replace the scalar */
@ -311,7 +332,7 @@ static t_scalar *template_conformscalar(t_template *tfrom, t_template *tto,
else else
{ {
t_gobj *y, *y2; t_gobj *y, *y2;
for (y = glist->gl_list; y2 = y->g_next; y = y2) for (y = glist->gl_list; (y2 = y->g_next); y = y2)
if (y2 == &scfrom->sc_gobj) if (y2 == &scfrom->sc_gobj)
{ {
x->sc_gobj.g_next = y2->g_next; x->sc_gobj.g_next = y2->g_next;
@ -447,7 +468,9 @@ void template_conform(t_template *tfrom, t_template *tto)
t_template *template_findbyname(t_symbol *s) t_template *template_findbyname(t_symbol *s)
{ {
#ifndef ROCKBOX
int i; int i;
#endif
if (s == &s_float) if (s == &s_float)
return (&template_float); return (&template_float);
else return ((t_template *)pd_findbyclass(s, template_class)); else return ((t_template *)pd_findbyclass(s, template_class));
@ -477,6 +500,10 @@ static void *template_usetemplate(void *dummy, t_symbol *s,
t_template *x; t_template *x;
t_symbol *templatesym = t_symbol *templatesym =
canvas_makebindsym(atom_getsymbolarg(0, argc, argv)); canvas_makebindsym(atom_getsymbolarg(0, argc, argv));
#ifdef ROCKBOX
(void) dummy;
(void) s;
#endif
if (!argc) if (!argc)
return (0); return (0);
argc--; argv++; argc--; argv++;
@ -540,7 +567,9 @@ static void *gtemplate_donew(t_symbol *sym, int argc, t_atom *argv)
t_gtemplate *x = (t_gtemplate *)pd_new(gtemplate_class); t_gtemplate *x = (t_gtemplate *)pd_new(gtemplate_class);
t_template *t = template_findbyname(sym); t_template *t = template_findbyname(sym);
int i; int i;
#ifndef ROCKBOX
t_symbol *sx = gensym("x"); t_symbol *sx = gensym("x");
#endif
x->x_owner = canvas_getcurrent(); x->x_owner = canvas_getcurrent();
x->x_next = 0; x->x_next = 0;
x->x_sym = sym; x->x_sym = sym;
@ -559,7 +588,7 @@ static void *gtemplate_donew(t_symbol *sym, int argc, t_atom *argv)
if (t->t_list) if (t->t_list)
{ {
t_gtemplate *x2, *x3; t_gtemplate *x2, *x3;
for (x2 = x->x_template->t_list; x3 = x2->x_next; x2 = x3) for(x2 = x->x_template->t_list; (x3 = x2->x_next); x2 = x3)
; ;
x2->x_next = x; x2->x_next = x;
post("template %s: warning: already exists.", sym->s_name); post("template %s: warning: already exists.", sym->s_name);
@ -593,8 +622,13 @@ static void *gtemplate_donew(t_symbol *sym, int argc, t_atom *argv)
static void *gtemplate_new(t_symbol *s, int argc, t_atom *argv) static void *gtemplate_new(t_symbol *s, int argc, t_atom *argv)
{ {
#ifndef ROCKBOX
t_gtemplate *x = (t_gtemplate *)pd_new(gtemplate_class); t_gtemplate *x = (t_gtemplate *)pd_new(gtemplate_class);
#endif
t_symbol *sym = atom_getsymbolarg(0, argc, argv); t_symbol *sym = atom_getsymbolarg(0, argc, argv);
#ifdef ROCKBOX
(void) s;
#endif
if (argc >= 1) if (argc >= 1)
argc--; argv++; argc--; argv++;
return (gtemplate_donew(canvas_makebindsym(sym), argc, argv)); return (gtemplate_donew(canvas_makebindsym(sym), argc, argv));
@ -603,9 +637,14 @@ static void *gtemplate_new(t_symbol *s, int argc, t_atom *argv)
/* old version (0.34) -- delete 2003 or so */ /* old version (0.34) -- delete 2003 or so */
static void *gtemplate_new_old(t_symbol *s, int argc, t_atom *argv) static void *gtemplate_new_old(t_symbol *s, int argc, t_atom *argv)
{ {
#ifndef ROCKBOX
t_gtemplate *x = (t_gtemplate *)pd_new(gtemplate_class); t_gtemplate *x = (t_gtemplate *)pd_new(gtemplate_class);
#endif
t_symbol *sym = canvas_makebindsym(canvas_getcurrent()->gl_name); t_symbol *sym = canvas_makebindsym(canvas_getcurrent()->gl_name);
static int warned; static int warned;
#ifdef ROCKBOX
(void) s;
#endif
if (!warned) if (!warned)
{ {
post("warning -- 'template' (%s) is obsolete; replace with 'struct'", post("warning -- 'template' (%s) is obsolete; replace with 'struct'",
@ -643,7 +682,7 @@ static void gtemplate_free(t_gtemplate *x)
else else
{ {
t_gtemplate *x2, *x3; t_gtemplate *x2, *x3;
for (x2 = t->t_list; x3 = x2->x_next; x2 = x3) for(x2 = t->t_list; (x3 = x2->x_next); x2 = x3)
{ {
if (x == x3) if (x == x3)
{ {
@ -829,6 +868,16 @@ static void curve_displace(t_gobj *z, t_glist *glist,
t_word *data, t_template *template, float basex, float basey, t_word *data, t_template *template, float basex, float basey,
int dx, int dy) int dx, int dy)
{ {
#ifdef ROCKBOX
(void) z;
(void) glist;
(void) data;
(void) template;
(void) basex;
(void) basey;
(void) dx;
(void) dy;
#endif
/* refuse */ /* refuse */
} }
@ -836,6 +885,15 @@ static void curve_select(t_gobj *z, t_glist *glist,
t_word *data, t_template *template, float basex, float basey, t_word *data, t_template *template, float basex, float basey,
int state) int state)
{ {
#ifdef ROCKBOX
(void) z;
(void) glist;
(void) data;
(void) template;
(void) basex;
(void) basey;
(void) state;
#endif
/* fill in later */ /* fill in later */
} }
@ -843,6 +901,15 @@ static void curve_activate(t_gobj *z, t_glist *glist,
t_word *data, t_template *template, float basex, float basey, t_word *data, t_template *template, float basex, float basey,
int state) int state)
{ {
#ifdef ROCKBOX
(void) z;
(void) glist;
(void) data;
(void) template;
(void) basex;
(void) basey;
(void) state;
#endif
/* fill in later */ /* fill in later */
} }
@ -861,8 +928,13 @@ static void numbertocolor(int n, char *s)
red = n / 100; red = n / 100;
blue = ((n / 10) % 10); blue = ((n / 10) % 10);
green = n % 10; green = n % 10;
#ifdef ROCKBOX
snprintf(s, 8, "#%2.2x%2.2x%2.2x",
rangecolor(red), rangecolor(blue), rangecolor(green));
#else
sprintf(s, "#%2.2x%2.2x%2.2x", rangecolor(red), rangecolor(blue), sprintf(s, "#%2.2x%2.2x%2.2x", rangecolor(red), rangecolor(blue),
rangecolor(green)); rangecolor(green));
#endif
} }
static void curve_vis(t_gobj *z, t_glist *glist, static void curve_vis(t_gobj *z, t_glist *glist,
@ -872,12 +944,22 @@ static void curve_vis(t_gobj *z, t_glist *glist,
t_curve *x = (t_curve *)z; t_curve *x = (t_curve *)z;
int i, n = x->x_npoints; int i, n = x->x_npoints;
t_fielddesc *f = x->x_vec; t_fielddesc *f = x->x_vec;
#ifdef ROCKBOX
(void) glist;
(void) basex;
(void) basey;
#endif
if (vis) if (vis)
{ {
if (n > 1) if (n > 1)
{ {
#ifdef ROCKBOX
int flags = x->x_flags;
#else
int flags = x->x_flags, closed = (flags & CLOSED); int flags = x->x_flags, closed = (flags & CLOSED);
#endif
float width = fielddesc_getfloat(&x->x_width, template, data, 1); float width = fielddesc_getfloat(&x->x_width, template, data, 1);
char outline[20], fill[20]; char outline[20], fill[20];
if (width < 1) width = 1; if (width < 1) width = 1;
@ -889,19 +971,26 @@ static void curve_vis(t_gobj *z, t_glist *glist,
numbertocolor( numbertocolor(
fielddesc_getfloat(&x->x_fillcolor, template, data, 1), fielddesc_getfloat(&x->x_fillcolor, template, data, 1),
fill); fill);
#ifndef ROCKBOX
sys_vgui(".x%x.c create polygon\\\n", sys_vgui(".x%x.c create polygon\\\n",
glist_getcanvas(glist)); glist_getcanvas(glist));
#endif
} }
#ifndef ROCKBOX
else sys_vgui(".x%x.c create line\\\n", else sys_vgui(".x%x.c create line\\\n",
glist_getcanvas(glist)); glist_getcanvas(glist));
#endif
for (i = 0, f = x->x_vec; i < n; i++, f += 2) for (i = 0, f = x->x_vec; i < n; i++, f += 2)
{ {
#ifndef ROCKBOX
float xloc = glist_xtopixels(glist, float xloc = glist_xtopixels(glist,
basex + fielddesc_getfloat(f, template, data, 1)); basex + fielddesc_getfloat(f, template, data, 1));
float yloc = glist_ytopixels(glist, float yloc = glist_ytopixels(glist,
basey + fielddesc_getfloat(f+1, template, data, 1)); basey + fielddesc_getfloat(f+1, template, data, 1));
sys_vgui("%d %d\\\n", (int)xloc, (int)yloc); sys_vgui("%d %d\\\n", (int)xloc, (int)yloc);
#endif
} }
#ifndef ROCKBOX
sys_vgui("-width %f\\\n", sys_vgui("-width %f\\\n",
fielddesc_getfloat(&x->x_width, template, data, 1)); fielddesc_getfloat(&x->x_width, template, data, 1));
if (flags & CLOSED) sys_vgui("-fill %s -outline %s\\\n", if (flags & CLOSED) sys_vgui("-fill %s -outline %s\\\n",
@ -909,13 +998,16 @@ static void curve_vis(t_gobj *z, t_glist *glist,
else sys_vgui("-fill %s\\\n", outline); else sys_vgui("-fill %s\\\n", outline);
if (flags & BEZ) sys_vgui("-smooth 1\\\n"); if (flags & BEZ) sys_vgui("-smooth 1\\\n");
sys_vgui("-tags curve%x\n", data); sys_vgui("-tags curve%x\n", data);
#endif
} }
else post("warning: curves need at least two points to be graphed"); else post("warning: curves need at least two points to be graphed");
} }
else else
{ {
#ifndef ROCKBOX
if (n > 1) sys_vgui(".x%x.c delete curve%x\n", if (n > 1) sys_vgui(".x%x.c delete curve%x\n",
glist_getcanvas(glist), data); glist_getcanvas(glist), data);
#endif
} }
} }
@ -969,6 +1061,13 @@ static int curve_click(t_gobj *z, t_glist *glist,
int besterror = 0x7fffffff; int besterror = 0x7fffffff;
t_fielddesc *f = x->x_vec; t_fielddesc *f = x->x_vec;
t_word *data = sc->sc_vec; t_word *data = sc->sc_vec;
#ifdef ROCKBOX
(void) shift;
(void) alt;
(void) dbl;
#endif
for (i = 0, f = x->x_vec; i < n; i++, f += 2) for (i = 0, f = x->x_vec; i < n; i++, f += 2)
{ {
int xloc = glist_xtopixels(glist, int xloc = glist_xtopixels(glist,
@ -1060,9 +1159,16 @@ static void *plot_new(t_symbol *classsym, t_int argc, t_atom *argv)
{ {
t_plot *x = (t_plot *)pd_new(plot_class); t_plot *x = (t_plot *)pd_new(plot_class);
int flags = 0; int flags = 0;
#ifndef ROCKBOX
int nxy, i; int nxy, i;
t_fielddesc *fd; t_fielddesc *fd;
#endif
t_symbol *firstarg = atom_getsymbolarg(0, argc, argv); t_symbol *firstarg = atom_getsymbolarg(0, argc, argv);
#ifdef ROCKBOX
(void) classsym;
#endif
if (!strcmp(firstarg->s_name, "curve")) if (!strcmp(firstarg->s_name, "curve"))
{ {
flags |= BEZ; flags |= BEZ;
@ -1132,7 +1238,11 @@ int array_getfields(t_symbol *elemtemplatesym,
t_template **elemtemplatep, int *elemsizep, t_template **elemtemplatep, int *elemsizep,
int *xonsetp, int *yonsetp, int *wonsetp) int *xonsetp, int *yonsetp, int *wonsetp)
{ {
#ifdef ROCKBOX
int elemsize, yonset, wonset, xonset, type;
#else
int arrayonset, elemsize, yonset, wonset, xonset, type; int arrayonset, elemsize, yonset, wonset, xonset, type;
#endif
t_template *elemtemplate; t_template *elemtemplate;
t_symbol *dummy; t_symbol *dummy;
t_canvas *elemtemplatecanvas = 0; t_canvas *elemtemplatecanvas = 0;
@ -1219,6 +1329,16 @@ static void plot_displace(t_gobj *z, t_glist *glist,
t_word *data, t_template *template, float basex, float basey, t_word *data, t_template *template, float basex, float basey,
int dx, int dy) int dx, int dy)
{ {
#ifdef ROCKBOX
(void) z;
(void) glist;
(void) data;
(void) template;
(void) basex;
(void) basey;
(void) dx;
(void) dy;
#endif
/* not yet */ /* not yet */
} }
@ -1226,6 +1346,15 @@ static void plot_select(t_gobj *z, t_glist *glist,
t_word *data, t_template *template, float basex, float basey, t_word *data, t_template *template, float basex, float basey,
int state) int state)
{ {
#ifdef ROCKBOX
(void) z;
(void) glist;
(void) data;
(void) template;
(void) basex;
(void) basey;
(void) state;
#endif
/* not yet */ /* not yet */
} }
@ -1233,6 +1362,15 @@ static void plot_activate(t_gobj *z, t_glist *glist,
t_word *data, t_template *template, float basex, float basey, t_word *data, t_template *template, float basex, float basey,
int state) int state)
{ {
#ifdef ROCKBOX
(void) z;
(void) glist;
(void) data;
(void) template;
(void) basex;
(void) basey;
(void) state;
#endif
/* not yet */ /* not yet */
} }
@ -1270,8 +1408,10 @@ static void plot_vis(t_gobj *z, t_glist *glist,
{ {
/* found "w" field which controls linewidth. The trace is /* found "w" field which controls linewidth. The trace is
a filled polygon with 2n points. */ a filled polygon with 2n points. */
#ifndef ROCKBOX
sys_vgui(".x%x.c create polygon \\\n", sys_vgui(".x%x.c create polygon \\\n",
glist_getcanvas(glist)); glist_getcanvas(glist));
#endif
for (i = 0, xsum = xloc; i < nelem; i++) for (i = 0, xsum = xloc; i < nelem; i++)
{ {
@ -1287,9 +1427,11 @@ static void plot_vis(t_gobj *z, t_glist *glist,
ixpix = xpix + 0.5; ixpix = xpix + 0.5;
if (xonset >= 0 || ixpix != lastpixel) if (xonset >= 0 || ixpix != lastpixel)
{ {
#ifndef ROCKBOX
sys_vgui("%d %f \\\n", ixpix, sys_vgui("%d %f \\\n", ixpix,
glist_ytopixels(glist, glist_ytopixels(glist,
basey + yloc + yval - wval)); basey + yloc + yval - wval));
#endif
ndrawn++; ndrawn++;
} }
lastpixel = ixpix; lastpixel = ixpix;
@ -1310,8 +1452,10 @@ static void plot_vis(t_gobj *z, t_glist *glist,
ixpix = xpix + 0.5; ixpix = xpix + 0.5;
if (xonset >= 0 || ixpix != lastpixel) if (xonset >= 0 || ixpix != lastpixel)
{ {
#ifndef ROCKBOX
sys_vgui("%d %f \\\n", ixpix, glist_ytopixels(glist, sys_vgui("%d %f \\\n", ixpix, glist_ytopixels(glist,
basey + yloc + yval + wval)); basey + yloc + yval + wval));
#endif
ndrawn++; ndrawn++;
} }
lastpixel = ixpix; lastpixel = ixpix;
@ -1321,23 +1465,31 @@ static void plot_vis(t_gobj *z, t_glist *glist,
should be at least two already. */ should be at least two already. */
if (ndrawn < 4) if (ndrawn < 4)
{ {
#ifndef ROCKBOX
sys_vgui("%d %f \\\n", ixpix + 10, glist_ytopixels(glist, sys_vgui("%d %f \\\n", ixpix + 10, glist_ytopixels(glist,
basey + yloc + yval + wval)); basey + yloc + yval + wval));
sys_vgui("%d %f \\\n", ixpix + 10, glist_ytopixels(glist, sys_vgui("%d %f \\\n", ixpix + 10, glist_ytopixels(glist,
basey + yloc + yval - wval)); basey + yloc + yval - wval));
#endif
} }
ouch: ouch:
#ifdef ROCKBOX
;
#else /* ROCKBOX */
sys_vgui(" -width 1 -fill %s -outline %s\\\n", outline, outline); sys_vgui(" -width 1 -fill %s -outline %s\\\n", outline, outline);
if (x->x_flags & BEZ) sys_vgui("-smooth 1\\\n"); if (x->x_flags & BEZ) sys_vgui("-smooth 1\\\n");
sys_vgui("-tags plot%x\n", data); sys_vgui("-tags plot%x\n", data);
#endif /* ROCKBOX */
} }
else if (linewidth > 0) else if (linewidth > 0)
{ {
/* no "w" field. If the linewidth is positive, draw a /* no "w" field. If the linewidth is positive, draw a
segmented line with the requested width; otherwise don't segmented line with the requested width; otherwise don't
draw the trace at all. */ draw the trace at all. */
#ifndef ROCKBOX
sys_vgui(".x%x.c create line \\\n", glist_getcanvas(glist)); sys_vgui(".x%x.c create line \\\n", glist_getcanvas(glist));
#endif
for (xsum = xloc, i = 0; i < nelem; i++) for (xsum = xloc, i = 0; i < nelem; i++)
{ {
@ -1352,14 +1504,17 @@ static void plot_vis(t_gobj *z, t_glist *glist,
ixpix = xpix + 0.5; ixpix = xpix + 0.5;
if (xonset >= 0 || ixpix != lastpixel) if (xonset >= 0 || ixpix != lastpixel)
{ {
#ifndef ROCKBOX
sys_vgui("%d %f \\\n", ixpix, sys_vgui("%d %f \\\n", ixpix,
glist_ytopixels(glist, basey + yloc + yval)); glist_ytopixels(glist, basey + yloc + yval));
#endif
ndrawn++; ndrawn++;
} }
lastpixel = ixpix; lastpixel = ixpix;
if (ndrawn >= 1000) break; if (ndrawn >= 1000) break;
} }
/* TK will complain if there aren't at least 2 points... */ /* TK will complain if there aren't at least 2 points... */
#ifndef ROCKBOX
if (ndrawn == 0) sys_vgui("0 0 0 0 \\\n"); if (ndrawn == 0) sys_vgui("0 0 0 0 \\\n");
else if (ndrawn == 1) sys_vgui("%d %f \\\n", ixpix + 10, else if (ndrawn == 1) sys_vgui("%d %f \\\n", ixpix + 10,
glist_ytopixels(glist, basey + yloc + yval)); glist_ytopixels(glist, basey + yloc + yval));
@ -1369,6 +1524,7 @@ static void plot_vis(t_gobj *z, t_glist *glist,
if (x->x_flags & BEZ) sys_vgui("-smooth 1\\\n"); if (x->x_flags & BEZ) sys_vgui("-smooth 1\\\n");
sys_vgui("-tags plot%x\n", data); sys_vgui("-tags plot%x\n", data);
#endif
} }
/* We're done with the outline; now draw all the points. /* We're done with the outline; now draw all the points.
This code is inefficient since the template has to be This code is inefficient since the template has to be
@ -1413,8 +1569,10 @@ static void plot_vis(t_gobj *z, t_glist *glist,
} }
} }
/* and then the trace */ /* and then the trace */
#ifndef ROCKBOX
sys_vgui(".x%x.c delete plot%x\n", sys_vgui(".x%x.c delete plot%x\n",
glist_getcanvas(glist), data); glist_getcanvas(glist), data);
#endif
} }
} }
@ -1526,8 +1684,12 @@ static void drawnumber_getrect(t_gobj *z, t_glist *glist,
basex + fielddesc_getfloat(&x->x_xloc, template, data, 0)); basex + fielddesc_getfloat(&x->x_xloc, template, data, 0));
int yloc = glist_ytopixels(glist, int yloc = glist_ytopixels(glist,
basey + fielddesc_getfloat(&x->x_yloc, template, data, 0)); basey + fielddesc_getfloat(&x->x_yloc, template, data, 0));
#ifdef ROCKBOX
int fontwidth = 8, fontheight = 10;
#else
int font = glist_getfont(glist); int font = glist_getfont(glist);
int fontwidth = sys_fontwidth(font), fontheight = sys_fontheight(font); int fontwidth = sys_fontwidth(font), fontheight = sys_fontheight(font);
#endif
char buf[DRAWNUMBER_BUFSIZE]; char buf[DRAWNUMBER_BUFSIZE];
if (x->x_flags & DRAW_SYMBOL) if (x->x_flags & DRAW_SYMBOL)
SETSYMBOL(&at, fielddesc_getsymbol(&x->x_value, template, data, 0)); SETSYMBOL(&at, fielddesc_getsymbol(&x->x_value, template, data, 0));
@ -1543,6 +1705,16 @@ static void drawnumber_displace(t_gobj *z, t_glist *glist,
t_word *data, t_template *template, float basex, float basey, t_word *data, t_template *template, float basex, float basey,
int dx, int dy) int dx, int dy)
{ {
#ifdef ROCKBOX
(void) z;
(void) glist;
(void) data;
(void) template;
(void) basex;
(void) basey;
(void) dx;
(void) dy;
#endif
/* refuse */ /* refuse */
} }
@ -1550,6 +1722,14 @@ static void drawnumber_select(t_gobj *z, t_glist *glist,
t_word *data, t_template *template, float basex, float basey, t_word *data, t_template *template, float basex, float basey,
int state) int state)
{ {
#ifdef ROCKBOX
(void) z;
(void) glist;
(void) data;
(void) template;
(void) basex;
(void) basey;
#endif
post("drawnumber_select %d", state); post("drawnumber_select %d", state);
/* fill in later */ /* fill in later */
} }
@ -1558,6 +1738,14 @@ static void drawnumber_activate(t_gobj *z, t_glist *glist,
t_word *data, t_template *template, float basex, float basey, t_word *data, t_template *template, float basex, float basey,
int state) int state)
{ {
#ifdef ROCKBOX
(void) z;
(void) glist;
(void) data;
(void) template;
(void) basex;
(void) basey;
#endif
post("drawnumber_activate %d", state); post("drawnumber_activate %d", state);
} }
@ -1566,14 +1754,22 @@ static void drawnumber_vis(t_gobj *z, t_glist *glist,
int vis) int vis)
{ {
t_drawnumber *x = (t_drawnumber *)z; t_drawnumber *x = (t_drawnumber *)z;
#ifdef ROCKBOX
(void) glist;
(void) basex;
(void) basey;
#endif
if (vis) if (vis)
{ {
t_atom at; t_atom at;
#ifndef ROCKBOX
int xloc = glist_xtopixels(glist, int xloc = glist_xtopixels(glist,
basex + fielddesc_getfloat(&x->x_xloc, template, data, 0)); basex + fielddesc_getfloat(&x->x_xloc, template, data, 0));
int yloc = glist_ytopixels(glist, int yloc = glist_ytopixels(glist,
basey + fielddesc_getfloat(&x->x_yloc, template, data, 0)); basey + fielddesc_getfloat(&x->x_yloc, template, data, 0));
#endif
char colorstring[20], buf[DRAWNUMBER_BUFSIZE]; char colorstring[20], buf[DRAWNUMBER_BUFSIZE];
numbertocolor(fielddesc_getfloat(&x->x_color, template, data, 1), numbertocolor(fielddesc_getfloat(&x->x_color, template, data, 1),
colorstring); colorstring);
@ -1581,13 +1777,17 @@ static void drawnumber_vis(t_gobj *z, t_glist *glist,
SETSYMBOL(&at, fielddesc_getsymbol(&x->x_value, template, data, 0)); SETSYMBOL(&at, fielddesc_getsymbol(&x->x_value, template, data, 0));
else SETFLOAT(&at, fielddesc_getfloat(&x->x_value, template, data, 0)); else SETFLOAT(&at, fielddesc_getfloat(&x->x_value, template, data, 0));
drawnumber_sprintf(x, buf, &at); drawnumber_sprintf(x, buf, &at);
#ifndef ROCKBOX
sys_vgui(".x%x.c create text %d %d -anchor nw -fill %s -text {%s}", sys_vgui(".x%x.c create text %d %d -anchor nw -fill %s -text {%s}",
glist_getcanvas(glist), xloc, yloc, colorstring, buf); glist_getcanvas(glist), xloc, yloc, colorstring, buf);
sys_vgui(" -font -*-courier-bold--normal--%d-*", sys_vgui(" -font -*-courier-bold--normal--%d-*",
sys_hostfontsize(glist_getfont(glist))); sys_hostfontsize(glist_getfont(glist)));
sys_vgui(" -tags drawnumber%x\n", data); sys_vgui(" -tags drawnumber%x\n", data);
#endif
} }
#ifndef ROCKBOX
else sys_vgui(".x%x.c delete drawnumber%x\n", glist_getcanvas(glist), data); else sys_vgui(".x%x.c delete drawnumber%x\n", glist_getcanvas(glist), data);
#endif
} }
static float drawnumber_motion_ycumulative; static float drawnumber_motion_ycumulative;
@ -1604,6 +1804,9 @@ static void drawnumber_motion(void *z, t_floatarg dx, t_floatarg dy)
t_drawnumber *x = (t_drawnumber *)z; t_drawnumber *x = (t_drawnumber *)z;
t_fielddesc *f = &x->x_value; t_fielddesc *f = &x->x_value;
drawnumber_motion_ycumulative -= dy; drawnumber_motion_ycumulative -= dy;
#ifdef ROCKBOX
(void) dx;
#endif
template_setfloat(drawnumber_motion_template, template_setfloat(drawnumber_motion_template,
f->fd_un.fd_varsym, f->fd_un.fd_varsym,
drawnumber_motion_wp, drawnumber_motion_wp,
@ -1619,6 +1822,11 @@ static int drawnumber_click(t_gobj *z, t_glist *glist,
t_drawnumber *x = (t_drawnumber *)z; t_drawnumber *x = (t_drawnumber *)z;
int x1, y1, x2, y2; int x1, y1, x2, y2;
t_word *data = sc->sc_vec; t_word *data = sc->sc_vec;
#ifdef ROCKBOX
(void) shift;
(void) alt;
(void) dbl;
#endif
drawnumber_getrect(z, glist, drawnumber_getrect(z, glist,
sc->sc_vec, template, basex, basey, sc->sc_vec, template, basex, basey,
&x1, &y1, &x2, &y2); &x1, &y1, &x2, &y2);
@ -1652,6 +1860,9 @@ t_parentwidgetbehavior drawnumber_widgetbehavior =
static void drawnumber_free(t_drawnumber *x) static void drawnumber_free(t_drawnumber *x)
{ {
#ifdef ROCKBOX
(void) x;
#endif
} }
static void drawnumber_setup(void) static void drawnumber_setup(void)
@ -1678,3 +1889,4 @@ void g_template_setup(void)
} }

View file

@ -6,15 +6,21 @@
/* the methods for calling the gui-objects from menu are implemented */ /* the methods for calling the gui-objects from menu are implemented */
/* all changes are labeled with iemlib */ /* all changes are labeled with iemlib */
#include <stdlib.h>
#include "m_pd.h" #include "m_pd.h"
#include "m_imp.h" #include "m_imp.h"
#include "s_stuff.h" #include "s_stuff.h"
#include "t_tk.h" #include "t_tk.h"
#include "g_canvas.h" #include "g_canvas.h"
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#else /* ROCKBOX */
#include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#endif /* ROCKBOX */
static t_class *text_class; static t_class *text_class;
static t_class *message_class; static t_class *message_class;
@ -39,6 +45,11 @@ void glist_text(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
{ {
t_text *x = (t_text *)pd_new(text_class); t_text *x = (t_text *)pd_new(text_class);
t_atom at; t_atom at;
#ifdef ROCKBOX
(void) s;
#endif
x->te_width = 0; /* don't know it yet. */ x->te_width = 0; /* don't know it yet. */
x->te_type = T_TEXT; x->te_type = T_TEXT;
x->te_binbuf = binbuf_new(); x->te_binbuf = binbuf_new();
@ -138,7 +149,12 @@ static void canvas_objtext(t_glist *gl, int xpix, int ypix, int selected,
void canvas_obj(t_glist *gl, t_symbol *s, int argc, t_atom *argv) void canvas_obj(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#else
t_text *x; t_text *x;
#endif
if (argc >= 2) if (argc >= 2)
{ {
t_binbuf *b = binbuf_new(); t_binbuf *b = binbuf_new();
@ -178,56 +194,111 @@ void canvas_iemguis(t_glist *gl, t_symbol *guiobjname)
void canvas_bng(t_glist *gl, t_symbol *s, int argc, t_atom *argv) void canvas_bng(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
(void) argc;
(void) argv;
#endif
canvas_iemguis(gl, gensym("bng")); canvas_iemguis(gl, gensym("bng"));
} }
void canvas_toggle(t_glist *gl, t_symbol *s, int argc, t_atom *argv) void canvas_toggle(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
(void) argc;
(void) argv;
#endif
canvas_iemguis(gl, gensym("tgl")); canvas_iemguis(gl, gensym("tgl"));
} }
void canvas_vslider(t_glist *gl, t_symbol *s, int argc, t_atom *argv) void canvas_vslider(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
(void) argc;
(void) argv;
#endif
canvas_iemguis(gl, gensym("vsl")); canvas_iemguis(gl, gensym("vsl"));
} }
void canvas_hslider(t_glist *gl, t_symbol *s, int argc, t_atom *argv) void canvas_hslider(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
(void) argc;
(void) argv;
#endif
canvas_iemguis(gl, gensym("hsl")); canvas_iemguis(gl, gensym("hsl"));
} }
void canvas_hdial(t_glist *gl, t_symbol *s, int argc, t_atom *argv) void canvas_hdial(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
(void) argc;
(void) argv;
#endif
canvas_iemguis(gl, gensym("hdl")); canvas_iemguis(gl, gensym("hdl"));
} }
void canvas_vdial(t_glist *gl, t_symbol *s, int argc, t_atom *argv) void canvas_vdial(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
(void) argc;
(void) argv;
#endif
canvas_iemguis(gl, gensym("vdl")); canvas_iemguis(gl, gensym("vdl"));
} }
void canvas_hradio(t_glist *gl, t_symbol *s, int argc, t_atom *argv) void canvas_hradio(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
(void) argc;
(void) argv;
#endif
canvas_iemguis(gl, gensym("hradio")); canvas_iemguis(gl, gensym("hradio"));
} }
void canvas_vradio(t_glist *gl, t_symbol *s, int argc, t_atom *argv) void canvas_vradio(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
(void) argc;
(void) argv;
#endif
canvas_iemguis(gl, gensym("vradio")); canvas_iemguis(gl, gensym("vradio"));
} }
void canvas_vumeter(t_glist *gl, t_symbol *s, int argc, t_atom *argv) void canvas_vumeter(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
(void) argc;
(void) argv;
#endif
canvas_iemguis(gl, gensym("vu")); canvas_iemguis(gl, gensym("vu"));
} }
void canvas_mycnv(t_glist *gl, t_symbol *s, int argc, t_atom *argv) void canvas_mycnv(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
(void) argc;
(void) argv;
#endif
canvas_iemguis(gl, gensym("cnv")); canvas_iemguis(gl, gensym("cnv"));
} }
void canvas_numbox(t_glist *gl, t_symbol *s, int argc, t_atom *argv) void canvas_numbox(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
(void) argc;
(void) argv;
#endif
canvas_iemguis(gl, gensym("nbx")); canvas_iemguis(gl, gensym("nbx"));
} }
@ -310,11 +381,17 @@ static void message_symbol(t_message *x, t_symbol *s)
static void message_list(t_message *x, t_symbol *s, int argc, t_atom *argv) static void message_list(t_message *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
binbuf_eval(x->m_text.te_binbuf, &x->m_messresponder.mr_pd, argc, argv); binbuf_eval(x->m_text.te_binbuf, &x->m_messresponder.mr_pd, argc, argv);
} }
static void message_set(t_message *x, t_symbol *s, int argc, t_atom *argv) static void message_set(t_message *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
binbuf_clear(x->m_text.te_binbuf); binbuf_clear(x->m_text.te_binbuf);
binbuf_add(x->m_text.te_binbuf, argc, argv); binbuf_add(x->m_text.te_binbuf, argc, argv);
glist_retext(x->m_glist, &x->m_text); glist_retext(x->m_glist, &x->m_text);
@ -322,12 +399,18 @@ static void message_set(t_message *x, t_symbol *s, int argc, t_atom *argv)
static void message_add2(t_message *x, t_symbol *s, int argc, t_atom *argv) static void message_add2(t_message *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
binbuf_add(x->m_text.te_binbuf, argc, argv); binbuf_add(x->m_text.te_binbuf, argc, argv);
glist_retext(x->m_glist, &x->m_text); glist_retext(x->m_glist, &x->m_text);
} }
static void message_add(t_message *x, t_symbol *s, int argc, t_atom *argv) static void message_add(t_message *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
binbuf_add(x->m_text.te_binbuf, argc, argv); binbuf_add(x->m_text.te_binbuf, argc, argv);
binbuf_addsemi(x->m_text.te_binbuf); binbuf_addsemi(x->m_text.te_binbuf);
glist_retext(x->m_glist, &x->m_text); glist_retext(x->m_glist, &x->m_text);
@ -337,12 +420,21 @@ static void message_click(t_message *x,
t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg xpos, t_floatarg ypos, t_floatarg shift,
t_floatarg ctrl, t_floatarg alt) t_floatarg ctrl, t_floatarg alt)
{ {
#ifdef ROCKBOX
(void) xpos;
(void) ypos;
(void) shift;
(void) ctrl;
(void) alt;
#endif
message_float(x, 0); message_float(x, 0);
if (glist_isvisible(x->m_glist)) if (glist_isvisible(x->m_glist))
{ {
#ifndef ROCKBOX
t_rtext *y = glist_findrtext(x->m_glist, &x->m_text); t_rtext *y = glist_findrtext(x->m_glist, &x->m_text);
sys_vgui(".x%x.c itemconfigure %sR -width 5\n", sys_vgui(".x%x.c itemconfigure %sR -width 5\n",
glist_getcanvas(x->m_glist), rtext_gettag(y)); glist_getcanvas(x->m_glist), rtext_gettag(y));
#endif
clock_delay(x->m_clock, 120); clock_delay(x->m_clock, 120);
} }
} }
@ -351,9 +443,11 @@ static void message_tick(t_message *x)
{ {
if (glist_isvisible(x->m_glist)) if (glist_isvisible(x->m_glist))
{ {
#ifndef ROCKBOX
t_rtext *y = glist_findrtext(x->m_glist, &x->m_text); t_rtext *y = glist_findrtext(x->m_glist, &x->m_text);
sys_vgui(".x%x.c itemconfigure %sR -width 1\n", sys_vgui(".x%x.c itemconfigure %sR -width 1\n",
glist_getcanvas(x->m_glist), rtext_gettag(y)); glist_getcanvas(x->m_glist), rtext_gettag(y));
#endif
} }
} }
@ -364,6 +458,9 @@ static void message_free(t_message *x)
void canvas_msg(t_glist *gl, t_symbol *s, int argc, t_atom *argv) void canvas_msg(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
t_message *x = (t_message *)pd_new(message_class); t_message *x = (t_message *)pd_new(message_class);
x->m_messresponder.mr_pd = messresponder_class; x->m_messresponder.mr_pd = messresponder_class;
x->m_messresponder.mr_outlet = outlet_new(&x->m_text, &s_float); x->m_messresponder.mr_outlet = outlet_new(&x->m_text, &s_float);
@ -467,6 +564,9 @@ static void gatom_set(t_gatom *x, t_symbol *s, int argc, t_atom *argv)
{ {
t_atom oldatom = x->a_atom; t_atom oldatom = x->a_atom;
int senditup = 0; int senditup = 0;
#ifdef ROCKBOX
(void) s;
#endif
if (!argc) return; if (!argc) return;
if (x->a_atom.a_type == A_FLOAT) if (x->a_atom.a_type == A_FLOAT)
x->a_atom.a_w.w_float = atom_getfloat(argv), x->a_atom.a_w.w_float = atom_getfloat(argv),
@ -538,6 +638,9 @@ static void gatom_symbol(t_gatom *x, t_symbol *s)
static void gatom_motion(void *z, t_floatarg dx, t_floatarg dy) static void gatom_motion(void *z, t_floatarg dx, t_floatarg dy)
{ {
#ifdef ROCKBOX
(void) dx;
#endif
t_gatom *x = (t_gatom *)z; t_gatom *x = (t_gatom *)z;
if (dy == 0) return; if (dy == 0) return;
if (x->a_atom.a_type == A_FLOAT) if (x->a_atom.a_type == A_FLOAT)
@ -597,7 +700,7 @@ static void gatom_key(void *z, t_floatarg f)
{ {
/* for numbers, only let reasonable characters through */ /* for numbers, only let reasonable characters through */
if ((x->a_atom.a_type == A_SYMBOL) || if ((x->a_atom.a_type == A_SYMBOL) ||
(c >= '0' && c <= '9' || c == '.' || c == '-' ((c >= '0' && c <= '9') || c == '.' || c == '-'
|| c == 'e' || c == 'E')) || c == 'e' || c == 'E'))
{ {
x->a_buf[len] = c; x->a_buf[len] = c;
@ -608,7 +711,11 @@ static void gatom_key(void *z, t_floatarg f)
return; return;
redraw: redraw:
/* LATER figure out how to avoid creating all these symbols! */ /* LATER figure out how to avoid creating all these symbols! */
#ifdef ROCKBOX
snprintf(sbuf, sizeof(sbuf)-1, "%s...", x->a_buf);
#else /* ROCKBOX */
sprintf(sbuf, "%s...", x->a_buf); sprintf(sbuf, "%s...", x->a_buf);
#endif
SETSYMBOL(&at, gensym(sbuf)); SETSYMBOL(&at, gensym(sbuf));
binbuf_clear(x->a_text.te_binbuf); binbuf_clear(x->a_text.te_binbuf);
binbuf_add(x->a_text.te_binbuf, 1, &at); binbuf_add(x->a_text.te_binbuf, 1, &at);
@ -619,6 +726,9 @@ static void gatom_click(t_gatom *x,
t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl,
t_floatarg alt) t_floatarg alt)
{ {
#ifdef ROCKBOX
(void) ctrl;
#endif
if (x->a_text.te_width == 1) if (x->a_text.te_width == 1)
{ {
if (x->a_atom.a_type == A_FLOAT) if (x->a_atom.a_type == A_FLOAT)
@ -655,6 +765,10 @@ static void gatom_param(t_gatom *x, t_symbol *sel, int argc, t_atom *argv)
t_symbol *symfrom = gatom_unescapit(atom_getsymbolarg(5, argc, argv)); t_symbol *symfrom = gatom_unescapit(atom_getsymbolarg(5, argc, argv));
t_symbol *symto = gatom_unescapit(atom_getsymbolarg(6, argc, argv)); t_symbol *symto = gatom_unescapit(atom_getsymbolarg(6, argc, argv));
#ifdef ROCKBOX
(void) sel;
#endif
gobj_vis(&x->a_text.te_g, x->a_glist, 0); gobj_vis(&x->a_text.te_g, x->a_glist, 0);
if (!*symfrom->s_name && *x->a_symfrom->s_name) if (!*symfrom->s_name && *x->a_symfrom->s_name)
inlet_new(&x->a_text, &x->a_text.te_pd, 0, 0); inlet_new(&x->a_text, &x->a_text.te_pd, 0, 0);
@ -708,7 +822,11 @@ static void gatom_getwherelabel(t_gatom *x, t_glist *glist, int *xp, int *yp)
{ {
*xp = x1 - 3 - *xp = x1 - 3 -
strlen(canvas_realizedollar(x->a_glist, x->a_label)->s_name) * strlen(canvas_realizedollar(x->a_glist, x->a_label)->s_name) *
#ifdef ROCKBOX
8;
#else
sys_fontwidth(glist_getfont(glist)); sys_fontwidth(glist_getfont(glist));
#endif
*yp = y1 + 2; *yp = y1 + 2;
} }
else if (x->a_wherelabel == ATOM_LABELRIGHT) else if (x->a_wherelabel == ATOM_LABELRIGHT)
@ -719,7 +837,11 @@ static void gatom_getwherelabel(t_gatom *x, t_glist *glist, int *xp, int *yp)
else if (x->a_wherelabel == ATOM_LABELUP) else if (x->a_wherelabel == ATOM_LABELUP)
{ {
*xp = x1 - 1; *xp = x1 - 1;
#ifdef ROCKBOX
*yp = y1 - 1 - 10;
#else
*yp = y1 - 1 - sys_fontheight(glist_getfont(glist));; *yp = y1 - 1 - sys_fontheight(glist_getfont(glist));;
#endif
} }
else else
{ {
@ -731,10 +853,14 @@ static void gatom_getwherelabel(t_gatom *x, t_glist *glist, int *xp, int *yp)
static void gatom_displace(t_gobj *z, t_glist *glist, static void gatom_displace(t_gobj *z, t_glist *glist,
int dx, int dy) int dx, int dy)
{ {
#ifndef ROCKBOX
t_gatom *x = (t_gatom*)z; t_gatom *x = (t_gatom*)z;
#endif
text_displace(z, glist, dx, dy); text_displace(z, glist, dx, dy);
#ifndef ROCKBOX
sys_vgui(".x%x.c move %x.l %d %d\n", glist_getcanvas(glist), sys_vgui(".x%x.c move %x.l %d %d\n", glist_getcanvas(glist),
x, dx, dy); x, dx, dy);
#endif
} }
static void gatom_vis(t_gobj *z, t_glist *glist, int vis) static void gatom_vis(t_gobj *z, t_glist *glist, int vis)
@ -747,14 +873,18 @@ static void gatom_vis(t_gobj *z, t_glist *glist, int vis)
{ {
int x1, y1; int x1, y1;
gatom_getwherelabel(x, glist, &x1, &y1); gatom_getwherelabel(x, glist, &x1, &y1);
#ifndef ROCKBOX
sys_vgui("pdtk_text_new .x%x.c %x.l %f %f {%s} %d %s\n", sys_vgui("pdtk_text_new .x%x.c %x.l %f %f {%s} %d %s\n",
glist_getcanvas(glist), x, glist_getcanvas(glist), x,
(double)x1, (double)y1, (double)x1, (double)y1,
canvas_realizedollar(x->a_glist, x->a_label)->s_name, canvas_realizedollar(x->a_glist, x->a_label)->s_name,
sys_hostfontsize(glist_getfont(glist)), sys_hostfontsize(glist_getfont(glist)),
"black"); "black");
#endif
} }
#ifndef ROCKBOX
else sys_vgui(".x%x.c delete %x.l\n", glist_getcanvas(glist), x); else sys_vgui(".x%x.c delete %x.l\n", glist_getcanvas(glist), x);
#endif
} }
} }
@ -763,6 +893,11 @@ void canvas_atom(t_glist *gl, t_atomtype type,
{ {
t_gatom *x = (t_gatom *)pd_new(gatom_class); t_gatom *x = (t_gatom *)pd_new(gatom_class);
t_atom at; t_atom at;
#ifdef ROCKBOX
(void) s;
#endif
x->a_text.te_width = 0; /* don't know it yet. */ x->a_text.te_width = 0; /* don't know it yet. */
x->a_text.te_type = T_ATOM; x->a_text.te_type = T_ATOM;
x->a_text.te_binbuf = binbuf_new(); x->a_text.te_binbuf = binbuf_new();
@ -850,11 +985,17 @@ static void gatom_free(t_gatom *x)
if (*x->a_symfrom->s_name) if (*x->a_symfrom->s_name)
pd_unbind(&x->a_text.te_pd, pd_unbind(&x->a_text.te_pd,
canvas_realizedollar(x->a_glist, x->a_symfrom)); canvas_realizedollar(x->a_glist, x->a_symfrom));
#ifndef ROCKBOX
gfxstub_deleteforkey(x); gfxstub_deleteforkey(x);
#endif
} }
static void gatom_properties(t_gobj *z, t_glist *owner) static void gatom_properties(t_gobj *z, t_glist *owner)
{ {
#ifdef ROCKBOX
(void) z;
(void) owner;
#else /* ROCKBOX */
t_gatom *x = (t_gatom *)z; t_gatom *x = (t_gatom *)z;
char buf[200]; char buf[200];
sprintf(buf, "pdtk_gatom_dialog %%s %d %g %g %d %s %s %s\n", sprintf(buf, "pdtk_gatom_dialog %%s %d %g %g %d %s %s %s\n",
@ -863,6 +1004,7 @@ static void gatom_properties(t_gobj *z, t_glist *owner)
gatom_escapit(x->a_symfrom)->s_name, gatom_escapit(x->a_symfrom)->s_name,
gatom_escapit(x->a_symto)->s_name); gatom_escapit(x->a_symto)->s_name);
gfxstub_new(&x->a_text.te_pd, x, buf); gfxstub_new(&x->a_text.te_pd, x, buf);
#endif /* ROCKBOX */
} }
@ -880,8 +1022,12 @@ static void text_getrect(t_gobj *z, t_glist *glist,
if (x->te_type == T_ATOM && x->te_width > 0) if (x->te_type == T_ATOM && x->te_width > 0)
{ {
#ifdef ROCKBOX
int fontwidth = 8, fontheight = 10;
#else
int font = glist_getfont(glist); int font = glist_getfont(glist);
int fontwidth = sys_fontwidth(font), fontheight = sys_fontheight(font); int fontwidth = sys_fontwidth(font), fontheight = sys_fontheight(font);
#endif
width = (x->te_width > 0 ? x->te_width : 6) * fontwidth + 2; width = (x->te_width > 0 ? x->te_width : 6) * fontwidth + 2;
height = fontheight + 1; /* borrowed from TMARGIN, etc, in g_rtext.c */ height = fontheight + 1; /* borrowed from TMARGIN, etc, in g_rtext.c */
} }
@ -933,8 +1079,13 @@ static void text_select(t_gobj *z, t_glist *glist, int state)
t_rtext *y = glist_findrtext(glist, x); t_rtext *y = glist_findrtext(glist, x);
rtext_select(y, state); rtext_select(y, state);
if (glist_isvisible(glist) && text_shouldvis(x, glist)) if (glist_isvisible(glist) && text_shouldvis(x, glist))
#ifdef ROCKBOX
{
}
#else /* ROCKBOX */
sys_vgui(".x%x.c itemconfigure %sR -fill %s\n", glist, sys_vgui(".x%x.c itemconfigure %sR -fill %s\n", glist,
rtext_gettag(y), (state? "blue" : "black")); rtext_gettag(y), (state? "blue" : "black"));
#endif /* ROCKBOX */
} }
static void text_activate(t_gobj *z, t_glist *glist, int state) static void text_activate(t_gobj *z, t_glist *glist, int state)
@ -988,6 +1139,10 @@ static void text_vis(t_gobj *z, t_glist *glist, int vis)
static int text_click(t_gobj *z, struct _glist *glist, static int text_click(t_gobj *z, struct _glist *glist,
int xpix, int ypix, int shift, int alt, int dbl, int doit) int xpix, int ypix, int shift, int alt, int dbl, int doit)
{ {
#ifdef ROCKBOX
(void) glist;
(void) dbl;
#endif
t_text *x = (t_text *)z; t_text *x = (t_text *)z;
if (x->te_type == T_OBJECT) if (x->te_type == T_OBJECT)
{ {
@ -1111,9 +1266,20 @@ void glist_drawiofor(t_glist *glist, t_object *ob, int firsttime,
char *tag, int x1, int y1, int x2, int y2) char *tag, int x1, int y1, int x2, int y2)
{ {
int n = obj_noutlets(ob), nplus = (n == 1 ? 1 : n-1), i; int n = obj_noutlets(ob), nplus = (n == 1 ? 1 : n-1), i;
#ifdef ROCKBOX
(void) glist;
(void) firsttime;
(void) tag;
(void) x1;
(void) y1;
(void) x2;
(void) y2;
#else /* ROCKBOX */
int width = x2 - x1; int width = x2 - x1;
#endif /* ROCKBOX */
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
#ifndef ROCKBOX
int onset = x1 + (width - IOWIDTH) * i / nplus; int onset = x1 + (width - IOWIDTH) * i / nplus;
if (firsttime) if (firsttime)
sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %so%d\n", sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %so%d\n",
@ -1126,11 +1292,13 @@ void glist_drawiofor(t_glist *glist, t_object *ob, int firsttime,
glist_getcanvas(glist), tag, i, glist_getcanvas(glist), tag, i,
onset, y2 - 1, onset, y2 - 1,
onset + IOWIDTH, y2); onset + IOWIDTH, y2);
#endif /* ROCKBOX */
} }
n = obj_ninlets(ob); n = obj_ninlets(ob);
nplus = (n == 1 ? 1 : n-1); nplus = (n == 1 ? 1 : n-1);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
#ifndef ROCKBOX
int onset = x1 + (width - IOWIDTH) * i / nplus; int onset = x1 + (width - IOWIDTH) * i / nplus;
if (firsttime) if (firsttime)
sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %si%d\n", sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %si%d\n",
@ -1143,6 +1311,7 @@ void glist_drawiofor(t_glist *glist, t_object *ob, int firsttime,
glist_getcanvas(glist), tag, i, glist_getcanvas(glist), tag, i,
onset, y1, onset, y1,
onset + IOWIDTH, y1 + EXTRAPIX); onset + IOWIDTH, y1 + EXTRAPIX);
#endif /* ROCKBOX */
} }
} }
@ -1151,11 +1320,18 @@ void text_drawborder(t_text *x, t_glist *glist,
{ {
t_object *ob; t_object *ob;
int x1, y1, x2, y2, width, height; int x1, y1, x2, y2, width, height;
#ifdef ROCKBOX
(void) width2;
(void) height2;
#endif
text_getrect(&x->te_g, glist, &x1, &y1, &x2, &y2); text_getrect(&x->te_g, glist, &x1, &y1, &x2, &y2);
width = x2 - x1; width = x2 - x1;
height = y2 - y1; height = y2 - y1;
if (x->te_type == T_OBJECT) if (x->te_type == T_OBJECT)
{ {
#ifndef ROCKBOX
if (firsttime) if (firsttime)
sys_vgui(".x%x.c create line\ sys_vgui(".x%x.c create line\
%d %d %d %d %d %d %d %d %d %d -tags %sR\n", %d %d %d %d %d %d %d %d %d %d -tags %sR\n",
@ -1166,9 +1342,11 @@ void text_drawborder(t_text *x, t_glist *glist,
%d %d %d %d %d %d %d %d %d %d\n", %d %d %d %d %d %d %d %d %d %d\n",
glist_getcanvas(glist), tag, glist_getcanvas(glist), tag,
x1, y1, x2, y1, x2, y2, x1, y2, x1, y1); x1, y1, x2, y1, x2, y2, x1, y2, x1, y1);
#endif
} }
else if (x->te_type == T_MESSAGE) else if (x->te_type == T_MESSAGE)
{ {
#ifndef ROCKBOX
if (firsttime) if (firsttime)
sys_vgui(".x%x.c create line\ sys_vgui(".x%x.c create line\
%d %d %d %d %d %d %d %d %d %d %d %d %d %d -tags %sR\n", %d %d %d %d %d %d %d %d %d %d %d %d %d %d -tags %sR\n",
@ -1182,9 +1360,11 @@ void text_drawborder(t_text *x, t_glist *glist,
glist_getcanvas(glist), tag, glist_getcanvas(glist), tag,
x1, y1, x2+4, y1, x2, y1+4, x2, y2-4, x2+4, y2, x1, y1, x2+4, y1, x2, y1+4, x2, y2-4, x2+4, y2,
x1, y2, x1, y1); x1, y2, x1, y1);
#endif
} }
else if (x->te_type == T_ATOM) else if (x->te_type == T_ATOM)
{ {
#ifndef ROCKBOX
if (firsttime) if (firsttime)
sys_vgui(".x%x.c create line\ sys_vgui(".x%x.c create line\
%d %d %d %d %d %d %d %d %d %d %d %d -tags %sR\n", %d %d %d %d %d %d %d %d %d %d %d %d -tags %sR\n",
@ -1196,31 +1376,46 @@ void text_drawborder(t_text *x, t_glist *glist,
%d %d %d %d %d %d %d %d %d %d %d %d\n", %d %d %d %d %d %d %d %d %d %d %d %d\n",
glist_getcanvas(glist), tag, glist_getcanvas(glist), tag,
x1, y1, x2-4, y1, x2, y1+4, x2, y2, x1, y2, x1, y1); x1, y1, x2-4, y1, x2, y1+4, x2, y2, x1, y2, x1, y1);
#endif
} }
/* draw inlets/outlets */ /* draw inlets/outlets */
if (ob = pd_checkobject(&x->te_pd)) if ((ob = pd_checkobject(&x->te_pd)))
glist_drawiofor(glist, ob, firsttime, tag, x1, y1, x2, y2); glist_drawiofor(glist, ob, firsttime, tag, x1, y1, x2, y2);
} }
void glist_eraseiofor(t_glist *glist, t_object *ob, char *tag) void glist_eraseiofor(t_glist *glist, t_object *ob, char *tag)
{ {
int i, n; int i, n;
#ifdef ROCKBOX
(void) glist;
(void) tag;
#endif
n = obj_noutlets(ob); n = obj_noutlets(ob);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
#ifdef ROCKBOX
;
#else /* ROCKBOX */
sys_vgui(".x%x.c delete %so%d\n", sys_vgui(".x%x.c delete %so%d\n",
glist_getcanvas(glist), tag, i); glist_getcanvas(glist), tag, i);
#endif /* ROCKBOX */
n = obj_ninlets(ob); n = obj_ninlets(ob);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
#ifdef ROCKBOX
;
#else /* ROCKBOX */
sys_vgui(".x%x.c delete %si%d\n", sys_vgui(".x%x.c delete %si%d\n",
glist_getcanvas(glist), tag, i); glist_getcanvas(glist), tag, i);
#endif /* ROCKBOX */
} }
void text_eraseborder(t_text *x, t_glist *glist, char *tag) void text_eraseborder(t_text *x, t_glist *glist, char *tag)
{ {
if (x->te_type == T_TEXT) return; if (x->te_type == T_TEXT) return;
#ifndef ROCKBOX
sys_vgui(".x%x.c delete %sR\n", sys_vgui(".x%x.c delete %sR\n",
glist_getcanvas(glist), tag); glist_getcanvas(glist), tag);
#endif
glist_eraseiofor(glist, x, tag); glist_eraseiofor(glist, x, tag);
} }

View file

@ -6,6 +6,13 @@
/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */ /* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "g_canvas.h"
#include "g_all_guis.h"
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -21,6 +28,7 @@
#else #else
#include <unistd.h> #include <unistd.h>
#endif #endif
#endif /* ROCKBOX */
/* --------------- tgl gui-toggle ------------------------- */ /* --------------- tgl gui-toggle ------------------------- */
@ -31,6 +39,10 @@ static t_class *toggle_class;
void toggle_draw_update(t_toggle *x, t_glist *glist) void toggle_draw_update(t_toggle *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
if(glist_isvisible(glist)) if(glist_isvisible(glist))
{ {
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
@ -40,10 +52,15 @@ void toggle_draw_update(t_toggle *x, t_glist *glist)
sys_vgui(".x%x.c itemconfigure %xX2 -fill #%6.6x\n", canvas, x, sys_vgui(".x%x.c itemconfigure %xX2 -fill #%6.6x\n", canvas, x,
(x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol); (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol);
} }
#endif /* ROCKBOX */
} }
void toggle_draw_new(t_toggle *x, t_glist *glist) void toggle_draw_new(t_toggle *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
int w=1, xx=text_xpix(&x->x_gui.x_obj, glist), yy=text_ypix(&x->x_gui.x_obj, glist); int w=1, xx=text_xpix(&x->x_gui.x_obj, glist), yy=text_ypix(&x->x_gui.x_obj, glist);
@ -72,10 +89,15 @@ void toggle_draw_new(t_toggle *x, t_glist *glist)
if(!x->x_gui.x_fsf.x_rcv_able) if(!x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n", sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
canvas, xx, yy, xx + IOWIDTH, yy+1, x, 0); canvas, xx, yy, xx + IOWIDTH, yy+1, x, 0);
#endif /* ROCKBOX */
} }
void toggle_draw_move(t_toggle *x, t_glist *glist) void toggle_draw_move(t_toggle *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
int w=1, xx=text_xpix(&x->x_gui.x_obj, glist), yy=text_ypix(&x->x_gui.x_obj, glist); int w=1, xx=text_xpix(&x->x_gui.x_obj, glist), yy=text_ypix(&x->x_gui.x_obj, glist);
@ -100,10 +122,15 @@ void toggle_draw_move(t_toggle *x, t_glist *glist)
if(!x->x_gui.x_fsf.x_rcv_able) if(!x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n", sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
canvas, x, 0, xx, yy, xx + IOWIDTH, yy+1); canvas, x, 0, xx, yy, xx + IOWIDTH, yy+1);
#endif /* ROCKBOX */
} }
void toggle_draw_erase(t_toggle* x, t_glist* glist) void toggle_draw_erase(t_toggle* x, t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
sys_vgui(".x%x.c delete %xBASE\n", canvas, x); sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
@ -114,10 +141,15 @@ void toggle_draw_erase(t_toggle* x, t_glist* glist)
sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
if(!x->x_gui.x_fsf.x_rcv_able) if(!x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
#endif /* ROCKBOX */
} }
void toggle_draw_config(t_toggle* x, t_glist* glist) void toggle_draw_config(t_toggle* x, t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n", sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
@ -130,10 +162,16 @@ void toggle_draw_config(t_toggle* x, t_glist* glist)
x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol); x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol);
sys_vgui(".x%x.c itemconfigure %xX2 -fill #%6.6x\n", canvas, x, sys_vgui(".x%x.c itemconfigure %xX2 -fill #%6.6x\n", canvas, x,
x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol); x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol);
#endif /* ROCKBOX */
} }
void toggle_draw_io(t_toggle* x, t_glist* glist, int old_snd_rcv_flags) void toggle_draw_io(t_toggle* x, t_glist* glist, int old_snd_rcv_flags)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
(void) old_snd_rcv_flags;
#else /* ROCKBOX */
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
@ -151,10 +189,15 @@ void toggle_draw_io(t_toggle* x, t_glist* glist, int old_snd_rcv_flags)
xpos + IOWIDTH, ypos+1, x, 0); xpos + IOWIDTH, ypos+1, x, 0);
if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
#endif /* ROCKBOX */
} }
void toggle_draw_select(t_toggle* x, t_glist* glist) void toggle_draw_select(t_toggle* x, t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
if(x->x_gui.x_fsf.x_selected) if(x->x_gui.x_fsf.x_selected)
@ -167,6 +210,7 @@ void toggle_draw_select(t_toggle* x, t_glist* glist)
sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL); sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
} }
#endif /* ROCKBOX */
} }
void toggle_draw(t_toggle *x, t_glist *glist, int mode) void toggle_draw(t_toggle *x, t_glist *glist, int mode)
@ -220,6 +264,10 @@ static void toggle_save(t_gobj *z, t_binbuf *b)
static void toggle_properties(t_gobj *z, t_glist *owner) static void toggle_properties(t_gobj *z, t_glist *owner)
{ {
#ifdef ROCKBOX
(void) z;
(void) owner;
#else /* ROCKBOX */
t_toggle *x = (t_toggle *)z; t_toggle *x = (t_toggle *)z;
char buf[800]; char buf[800];
t_symbol *srl[3]; t_symbol *srl[3];
@ -241,6 +289,7 @@ static void toggle_properties(t_gobj *z, t_glist *owner)
x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
#endif
} }
static void toggle_bang(t_toggle *x) static void toggle_bang(t_toggle *x)
@ -259,6 +308,10 @@ static void toggle_dialog(t_toggle *x, t_symbol *s, int argc, t_atom *argv)
float nonzero = (float)atom_getfloatarg(2, argc, argv); float nonzero = (float)atom_getfloatarg(2, argc, argv);
int sr_flags; int sr_flags;
#ifdef ROCKBOX
(void) s;
#endif
if(nonzero == 0.0) if(nonzero == 0.0)
nonzero = 1.0; nonzero = 1.0;
x->x_nonzero = nonzero; x->x_nonzero = nonzero;
@ -274,10 +327,26 @@ static void toggle_dialog(t_toggle *x, t_symbol *s, int argc, t_atom *argv)
} }
static void toggle_click(t_toggle *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt) static void toggle_click(t_toggle *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
#ifdef ROCKBOX
{
(void) xpos;
(void) ypos;
(void) shift;
(void) alt;
(void) ctrl;
toggle_bang(x);
}
#else /* ROCKBOX */
{toggle_bang(x);} {toggle_bang(x);}
#endif /* ROCKBOX */
static int toggle_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) static int toggle_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
{ {
#ifdef ROCKBOX
(void) glist;
(void) dbl;
#endif
if(doit) if(doit)
toggle_click((t_toggle *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt); toggle_click((t_toggle *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt);
return (1); return (1);
@ -318,6 +387,9 @@ static void toggle_loadbang(t_toggle *x)
static void toggle_size(t_toggle *x, t_symbol *s, int ac, t_atom *av) static void toggle_size(t_toggle *x, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
#endif
x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
x->x_gui.x_h = x->x_gui.x_w; x->x_gui.x_h = x->x_gui.x_w;
iemgui_size((void *)x, &x->x_gui); iemgui_size((void *)x, &x->x_gui);
@ -362,11 +434,21 @@ static void *toggle_new(t_symbol *s, int argc, t_atom *argv)
{ {
t_toggle *x = (t_toggle *)pd_new(toggle_class); t_toggle *x = (t_toggle *)pd_new(toggle_class);
int bflcol[]={-262144, -1, -1}; int bflcol[]={-262144, -1, -1};
#ifdef ROCKBOX
int a=IEM_GUI_DEFAULTSIZE;
#else
int a=IEM_GUI_DEFAULTSIZE, f=0; int a=IEM_GUI_DEFAULTSIZE, f=0;
#endif
int ldx=0, ldy=-6; int ldx=0, ldy=-6;
int fs=8; int fs=8;
float on=0.0, nonzero=1.0; float on=0.0, nonzero=1.0;
#ifndef ROCKBOX
char str[144]; char str[144];
#endif
#ifdef ROCKBOX
(void) s;
#endif
iem_inttosymargs(&x->x_gui.x_isa, 0); iem_inttosymargs(&x->x_gui.x_isa, 0);
iem_inttofstyle(&x->x_gui.x_fsf, 0); iem_inttofstyle(&x->x_gui.x_fsf, 0);
@ -433,7 +515,9 @@ static void toggle_ff(t_toggle *x)
{ {
if(x->x_gui.x_fsf.x_rcv_able) if(x->x_gui.x_fsf.x_rcv_able)
pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
#ifndef ROCKBOX
gfxstub_deleteforkey(x); gfxstub_deleteforkey(x);
#endif
} }
void g_toggle_setup(void) void g_toggle_setup(void)

View file

@ -16,11 +16,18 @@ sublist - get a pointer into a list which is an element of another scalar
*/ */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "g_canvas.h"
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> /* for read/write to files */ #include <stdio.h> /* for read/write to files */
#include "m_pd.h" #include "m_pd.h"
#include "g_canvas.h" #include "g_canvas.h"
#endif /* ROCKBOX */
/* ------------- gstubs and gpointers - safe pointing --------------- */ /* ------------- gstubs and gpointers - safe pointing --------------- */
@ -135,7 +142,7 @@ void gpointer_copy(const t_gpointer *gpfrom, t_gpointer *gpto)
void gpointer_unset(t_gpointer *gp) void gpointer_unset(t_gpointer *gp)
{ {
t_gstub *gs; t_gstub *gs;
if (gs = gp->gp_stub) if((gs = gp->gp_stub))
{ {
gstub_dis(gs); gstub_dis(gs);
gp->gp_stub = 0; gp->gp_stub = 0;
@ -145,7 +152,7 @@ void gpointer_unset(t_gpointer *gp)
void gpointer_setglist(t_gpointer *gp, t_glist *glist, t_scalar *x) void gpointer_setglist(t_gpointer *gp, t_glist *glist, t_scalar *x)
{ {
t_gstub *gs; t_gstub *gs;
if (gs = gp->gp_stub) gstub_dis(gs); if((gs = gp->gp_stub)) gstub_dis(gs);
gp->gp_stub = gs = glist->gl_stub; gp->gp_stub = gs = glist->gl_stub;
gp->gp_valid = glist->gl_valid; gp->gp_valid = glist->gl_valid;
gp->gp_un.gp_scalar = x; gp->gp_un.gp_scalar = x;
@ -155,7 +162,7 @@ void gpointer_setglist(t_gpointer *gp, t_glist *glist, t_scalar *x)
static void gpointer_setarray(t_gpointer *gp, t_array *array, t_word *w) static void gpointer_setarray(t_gpointer *gp, t_array *array, t_word *w)
{ {
t_gstub *gs; t_gstub *gs;
if (gs = gp->gp_stub) gstub_dis(gs); if((gs = gp->gp_stub)) gstub_dis(gs);
gp->gp_stub = gs = array->a_stub; gp->gp_stub = gs = array->a_stub;
gp->gp_valid = array->a_valid; gp->gp_valid = array->a_valid;
gp->gp_un.gp_w = w; gp->gp_un.gp_w = w;
@ -194,6 +201,9 @@ static void *ptrobj_new(t_symbol *classname, int argc, t_atom *argv)
t_ptrobj *x = (t_ptrobj *)pd_new(ptrobj_class); t_ptrobj *x = (t_ptrobj *)pd_new(ptrobj_class);
t_typedout *to; t_typedout *to;
int n; int n;
#ifdef ROCKBOX
(void) classname;
#endif
gpointer_init(&x->x_gp); gpointer_init(&x->x_gp);
x->x_typedout = to = (t_typedout *)getbytes(argc * sizeof (*to)); x->x_typedout = to = (t_typedout *)getbytes(argc * sizeof (*to));
x->x_ntypedout = n = argc; x->x_ntypedout = n = argc;
@ -285,10 +295,14 @@ static void ptrobj_next(t_ptrobj *x)
static void ptrobj_sendwindow(t_ptrobj *x, t_symbol *s, int argc, t_atom *argv) static void ptrobj_sendwindow(t_ptrobj *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#else /* ROCKBOX */
t_scalar *sc; t_scalar *sc;
t_symbol *templatesym; t_symbol *templatesym;
int n; int n;
t_typedout *to; t_typedout *to;
#endif /* ROCKBOX */
t_glist *glist; t_glist *glist;
t_pd *canvas; t_pd *canvas;
t_gstub *gs; t_gstub *gs;
@ -388,6 +402,9 @@ static void *get_new(t_symbol *why, int argc, t_atom *argv)
int i; int i;
t_getvariable *sp; t_getvariable *sp;
x->x_templatesym = canvas_makebindsym(atom_getsymbolarg(0, argc, argv)); x->x_templatesym = canvas_makebindsym(atom_getsymbolarg(0, argc, argv));
#ifdef ROCKBOX
(void) why;
#endif
if (argc) argc--, argv++; if (argc) argc--, argv++;
x->x_variables x->x_variables
= (t_getvariable *)getbytes(argc * sizeof (*x->x_variables)); = (t_getvariable *)getbytes(argc * sizeof (*x->x_variables));
@ -468,6 +485,9 @@ static void *set_new(t_symbol *why, int argc, t_atom *argv)
int i; int i;
t_setvariable *sp; t_setvariable *sp;
x->x_templatesym = canvas_makebindsym(atom_getsymbolarg(0, argc, argv)); x->x_templatesym = canvas_makebindsym(atom_getsymbolarg(0, argc, argv));
#ifdef ROCKBOX
(void) why;
#endif
if (argc) argc--, argv++; if (argc) argc--, argv++;
x->x_variables x->x_variables
= (t_setvariable *)getbytes(argc * sizeof (*x->x_variables)); = (t_setvariable *)getbytes(argc * sizeof (*x->x_variables));
@ -634,6 +654,9 @@ static void elem_float(t_elem *x, t_float f)
static void elem_free(t_elem *x, t_gpointer *gp) static void elem_free(t_elem *x, t_gpointer *gp)
{ {
#ifdef ROCKBOX
(void) gp;
#endif
gpointer_unset(&x->x_gp); gpointer_unset(&x->x_gp);
gpointer_unset(&x->x_gparent); gpointer_unset(&x->x_gparent);
} }
@ -667,13 +690,19 @@ static void *getsize_new(t_symbol *templatesym, t_symbol *fieldsym)
static void getsize_pointer(t_getsize *x, t_gpointer *gp) static void getsize_pointer(t_getsize *x, t_gpointer *gp)
{ {
#ifdef ROCKBOX
int onset, type;
#else /* ROCKBOX */
int nitems, onset, type; int nitems, onset, type;
#endif /* ROCKBOX */
t_symbol *templatesym = x->x_templatesym, *fieldsym = x->x_fieldsym, t_symbol *templatesym = x->x_templatesym, *fieldsym = x->x_fieldsym,
*elemtemplatesym; *elemtemplatesym;
t_template *template = template_findbyname(templatesym); t_template *template = template_findbyname(templatesym);
t_word *w; t_word *w;
t_array *array; t_array *array;
#ifndef ROCKBOX
int elemsize; int elemsize;
#endif
t_gstub *gs = gp->gp_stub; t_gstub *gs = gp->gp_stub;
if (!template) if (!template)
{ {
@ -731,6 +760,9 @@ typedef struct _setsize
static void *setsize_new(t_symbol *templatesym, t_symbol *fieldsym, static void *setsize_new(t_symbol *templatesym, t_symbol *fieldsym,
t_floatarg newsize) t_floatarg newsize)
{ {
#ifdef ROCKBOX
(void) newsize;
#endif
t_setsize *x = (t_setsize *)pd_new(setsize_class); t_setsize *x = (t_setsize *)pd_new(setsize_class);
x->x_templatesym = canvas_makebindsym(templatesym); x->x_templatesym = canvas_makebindsym(templatesym);
x->x_fieldsym = fieldsym; x->x_fieldsym = fieldsym;
@ -748,7 +780,9 @@ static void setsize_float(t_setsize *x, t_float f)
t_template *template = template_findbyname(templatesym); t_template *template = template_findbyname(templatesym);
t_template *elemtemplate; t_template *elemtemplate;
t_word *w; t_word *w;
#ifndef ROCKBOX
t_atom at; t_atom at;
#endif
t_array *array; t_array *array;
int elemsize; int elemsize;
int newsize = f; int newsize = f;
@ -830,7 +864,11 @@ static void setsize_float(t_setsize *x, t_float f)
if (newsize > nitems) if (newsize > nitems)
{ {
char *newelem = ((char *)array->a_vec) + nitems * elemsize; char *newelem = ((char *)array->a_vec) + nitems * elemsize;
#ifdef ROCKBOX
int nnew = newsize - nitems;
#else /* ROCKBOX */
int i = 0, nnew = newsize - nitems; int i = 0, nnew = newsize - nitems;
#endif /* ROCKBOX */
while (nnew--) while (nnew--)
{ {
@ -896,6 +934,9 @@ static void *append_new(t_symbol *why, int argc, t_atom *argv)
int i; int i;
t_appendvariable *sp; t_appendvariable *sp;
x->x_templatesym = canvas_makebindsym(atom_getsymbolarg(0, argc, argv)); x->x_templatesym = canvas_makebindsym(atom_getsymbolarg(0, argc, argv));
#ifdef ROCKBOX
(void) why;
#endif
if (argc) argc--, argv++; if (argc) argc--, argv++;
x->x_variables x->x_variables
= (t_appendvariable *)getbytes(argc * sizeof (*x->x_variables)); = (t_appendvariable *)getbytes(argc * sizeof (*x->x_variables));
@ -1023,8 +1064,10 @@ static void sublist_pointer(t_sublist *x, t_gpointer *gp)
t_symbol *templatesym = x->x_templatesym, *dummy; t_symbol *templatesym = x->x_templatesym, *dummy;
t_template *template = template_findbyname(templatesym); t_template *template = template_findbyname(templatesym);
t_gstub *gs = gp->gp_stub; t_gstub *gs = gp->gp_stub;
t_word *vec; #ifndef ROCKBOX
t_word *vec;
t_getvariable *vp; t_getvariable *vp;
#endif
int onset, type; int onset, type;
t_word *w; t_word *w;
@ -1059,6 +1102,9 @@ static void sublist_pointer(t_sublist *x, t_gpointer *gp)
static void sublist_free(t_sublist *x, t_gpointer *gp) static void sublist_free(t_sublist *x, t_gpointer *gp)
{ {
#ifdef ROCKBOX
(void) gp;
#endif
gpointer_unset(&x->x_gp); gpointer_unset(&x->x_gp);
} }

View file

@ -7,6 +7,13 @@
/* name change to vradio by MSP (it's a radio button really) and changed to /* name change to vradio by MSP (it's a radio button really) and changed to
put out a "float" as in sliders, toggles, etc. */ put out a "float" as in sliders, toggles, etc. */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "g_canvas.h"
#include "g_all_guis.h"
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -16,6 +23,7 @@ put out a "float" as in sliders, toggles, etc. */
#include "t_tk.h" #include "t_tk.h"
#include "g_all_guis.h" #include "g_all_guis.h"
#include <math.h> #include <math.h>
#endif /* ROCKBOX */
/*------------------ global variables -------------------------*/ /*------------------ global variables -------------------------*/
@ -34,6 +42,10 @@ static t_class *vradio_class, *vradio_old_class;
void vradio_draw_update(t_vradio *x, t_glist *glist) void vradio_draw_update(t_vradio *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
if(glist_isvisible(glist)) if(glist_isvisible(glist))
{ {
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
@ -45,10 +57,15 @@ void vradio_draw_update(t_vradio *x, t_glist *glist)
canvas, x, x->x_on, canvas, x, x->x_on,
x->x_gui.x_fcol, x->x_gui.x_fcol); x->x_gui.x_fcol, x->x_gui.x_fcol);
} }
#endif /* ROCKBOX */
} }
void vradio_draw_new(t_vradio *x, t_glist *glist) void vradio_draw_new(t_vradio *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
int n=x->x_number, i, dy=x->x_gui.x_h, s4=dy/4; int n=x->x_number, i, dy=x->x_gui.x_h, s4=dy/4;
int yy11b=text_ypix(&x->x_gui.x_obj, glist); int yy11b=text_ypix(&x->x_gui.x_obj, glist);
@ -83,10 +100,15 @@ void vradio_draw_new(t_vradio *x, t_glist *glist)
if(!x->x_gui.x_fsf.x_rcv_able) if(!x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n", sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
canvas, xx11, yy11b, xx11 + IOWIDTH, yy11b+1, x, 0); canvas, xx11, yy11b, xx11 + IOWIDTH, yy11b+1, x, 0);
#endif /* ROCKBOX */
} }
void vradio_draw_move(t_vradio *x, t_glist *glist) void vradio_draw_move(t_vradio *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
int n=x->x_number, i, dy=x->x_gui.x_h, s4=dy/4; int n=x->x_number, i, dy=x->x_gui.x_h, s4=dy/4;
int yy11b=text_ypix(&x->x_gui.x_obj, glist); int yy11b=text_ypix(&x->x_gui.x_obj, glist);
@ -114,10 +136,15 @@ void vradio_draw_move(t_vradio *x, t_glist *glist)
if(!x->x_gui.x_fsf.x_rcv_able) if(!x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n", sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
canvas, x, 0, xx11, yy11b, xx11 + IOWIDTH, yy11b+1); canvas, x, 0, xx11, yy11b, xx11 + IOWIDTH, yy11b+1);
#endif /* ROCKBOX */
} }
void vradio_draw_erase(t_vradio* x, t_glist* glist) void vradio_draw_erase(t_vradio* x, t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
int n=x->x_number, i; int n=x->x_number, i;
@ -131,10 +158,15 @@ void vradio_draw_erase(t_vradio* x, t_glist* glist)
sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
if(!x->x_gui.x_fsf.x_rcv_able) if(!x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
#endif /* ROCKBOX */
} }
void vradio_draw_config(t_vradio* x, t_glist* glist) void vradio_draw_config(t_vradio* x, t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
int n=x->x_number, i; int n=x->x_number, i;
@ -150,10 +182,16 @@ void vradio_draw_config(t_vradio* x, t_glist* glist)
(x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol,
(x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol); (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol);
} }
#endif /* ROCKBOX */
} }
void vradio_draw_io(t_vradio* x, t_glist* glist, int old_snd_rcv_flags) void vradio_draw_io(t_vradio* x, t_glist* glist, int old_snd_rcv_flags)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
(void) old_snd_rcv_flags;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
@ -173,10 +211,15 @@ void vradio_draw_io(t_vradio* x, t_glist* glist, int old_snd_rcv_flags)
x, 0); x, 0);
if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
#endif /* ROCKBOX */
} }
void vradio_draw_select(t_vradio* x, t_glist* glist) void vradio_draw_select(t_vradio* x, t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
int n=x->x_number, i; int n=x->x_number, i;
@ -199,6 +242,7 @@ void vradio_draw_select(t_vradio* x, t_glist* glist)
sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x,
x->x_gui.x_lcol); x->x_gui.x_lcol);
} }
#endif /* ROCKBOX */
} }
void vradio_draw(t_vradio *x, t_glist *glist, int mode) void vradio_draw(t_vradio *x, t_glist *glist, int mode)
@ -254,6 +298,10 @@ static void vradio_save(t_gobj *z, t_binbuf *b)
static void vradio_properties(t_gobj *z, t_glist *owner) static void vradio_properties(t_gobj *z, t_glist *owner)
{ {
#ifdef ROCKBOX
(void) z;
(void) owner;
#else /* ROCKBOX */
t_vradio *x = (t_vradio *)z; t_vradio *x = (t_vradio *)z;
char buf[800]; char buf[800];
t_symbol *srl[3]; t_symbol *srl[3];
@ -278,6 +326,7 @@ static void vradio_properties(t_gobj *z, t_glist *owner)
x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
#endif /* ROCKBOX */
} }
static void vradio_dialog(t_vradio *x, t_symbol *s, int argc, t_atom *argv) static void vradio_dialog(t_vradio *x, t_symbol *s, int argc, t_atom *argv)
@ -288,6 +337,10 @@ static void vradio_dialog(t_vradio *x, t_symbol *s, int argc, t_atom *argv)
int num = (int)atom_getintarg(6, argc, argv); int num = (int)atom_getintarg(6, argc, argv);
int sr_flags; int sr_flags;
#ifdef ROCKBOX
(void) s;
#endif
if(chg != 0) chg = 1; if(chg != 0) chg = 1;
x->x_change = chg; x->x_change = chg;
sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv); sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
@ -463,12 +516,23 @@ static void vradio_click(t_vradio *x, t_floatarg xpos, t_floatarg ypos,
{ {
int yy = (int)ypos - text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist); int yy = (int)ypos - text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
#ifdef ROCKBOX
(void) xpos;
(void) shift;
(void) ctrl;
(void) alt;
#endif
vradio_fout(x, (float)(yy / x->x_gui.x_h)); vradio_fout(x, (float)(yy / x->x_gui.x_h));
} }
static int vradio_newclick(t_gobj *z, struct _glist *glist, static int vradio_newclick(t_gobj *z, struct _glist *glist,
int xpix, int ypix, int shift, int alt, int dbl, int doit) int xpix, int ypix, int shift, int alt, int dbl, int doit)
{ {
#ifdef ROCKBOX
(void) glist;
(void) dbl;
#endif
if(doit) if(doit)
vradio_click((t_vradio *)z, (t_floatarg)xpix, (t_floatarg)ypix, vradio_click((t_vradio *)z, (t_floatarg)xpix, (t_floatarg)ypix,
(t_floatarg)shift, 0, (t_floatarg)alt); (t_floatarg)shift, 0, (t_floatarg)alt);
@ -502,6 +566,9 @@ static void vradio_number(t_vradio *x, t_floatarg num)
static void vradio_size(t_vradio *x, t_symbol *s, int ac, t_atom *av) static void vradio_size(t_vradio *x, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
#endif
x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
x->x_gui.x_h = x->x_gui.x_w; x->x_gui.x_h = x->x_gui.x_w;
iemgui_size((void *)x, &x->x_gui); iemgui_size((void *)x, &x->x_gui);
@ -546,11 +613,21 @@ static void *vradio_donew(t_symbol *s, int argc, t_atom *argv, int old)
{ {
t_vradio *x = (t_vradio *)pd_new(old? vradio_old_class : vradio_class); t_vradio *x = (t_vradio *)pd_new(old? vradio_old_class : vradio_class);
int bflcol[]={-262144, -1, -1}; int bflcol[]={-262144, -1, -1};
#ifdef ROCKBOX
int a=IEM_GUI_DEFAULTSIZE, on=0;
#else
int a=IEM_GUI_DEFAULTSIZE, on=0, f=0; int a=IEM_GUI_DEFAULTSIZE, on=0, f=0;
#endif
int ldx=0, ldy=-6, chg=1, num=8; int ldx=0, ldy=-6, chg=1, num=8;
int fs=8; int fs=8;
#ifndef ROCKBOX
int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME; int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
char str[144]; char str[144];
#endif
#ifdef ROCKBOX
(void) s;
#endif
if((argc == 15)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,2) if((argc == 15)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,2)
&&IS_A_FLOAT(argv,3) &&IS_A_FLOAT(argv,3)
@ -632,7 +709,9 @@ static void vradio_ff(t_vradio *x)
{ {
if(x->x_gui.x_fsf.x_rcv_able) if(x->x_gui.x_fsf.x_rcv_able)
pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
#ifndef ROCKBOX
gfxstub_deleteforkey(x); gfxstub_deleteforkey(x);
#endif
} }
void g_vradio_setup(void) void g_vradio_setup(void)

View file

@ -6,6 +6,13 @@
/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */ /* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "g_canvas.h"
#include "g_all_guis.h"
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -21,6 +28,7 @@
#else #else
#include <unistd.h> #include <unistd.h>
#endif #endif
#endif /* ROCKBOX */
/* ------------ vsl gui-vertical slider ----------------------- */ /* ------------ vsl gui-vertical slider ----------------------- */
@ -32,6 +40,10 @@ static t_class *vslider_class;
static void vslider_draw_update(t_vslider *x, t_glist *glist) static void vslider_draw_update(t_vslider *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
if (glist_isvisible(glist)) if (glist_isvisible(glist))
{ {
int r = text_ypix(&x->x_gui.x_obj, glist) + x->x_gui.x_h - (x->x_val + 50)/100; int r = text_ypix(&x->x_gui.x_obj, glist) + x->x_gui.x_h - (x->x_val + 50)/100;
@ -41,10 +53,15 @@ static void vslider_draw_update(t_vslider *x, t_glist *glist)
glist_getcanvas(glist), x, xpos+1, r, glist_getcanvas(glist), x, xpos+1, r,
xpos + x->x_gui.x_w, r); xpos + x->x_gui.x_w, r);
} }
#endif /* ROCKBOX */
} }
static void vslider_draw_new(t_vslider *x, t_glist *glist) static void vslider_draw_new(t_vslider *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
int r = ypos + x->x_gui.x_h - (x->x_val + 50)/100; int r = ypos + x->x_gui.x_h - (x->x_val + 50)/100;
@ -74,10 +91,15 @@ static void vslider_draw_new(t_vslider *x, t_glist *glist)
xpos, ypos-2, xpos, ypos-2,
xpos+7, ypos-1, xpos+7, ypos-1,
x, 0); x, 0);
#endif /* ROCKBOX */
} }
static void vslider_draw_move(t_vslider *x, t_glist *glist) static void vslider_draw_move(t_vslider *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
int r = ypos + x->x_gui.x_h - (x->x_val + 50)/100; int r = ypos + x->x_gui.x_h - (x->x_val + 50)/100;
@ -102,10 +124,15 @@ static void vslider_draw_move(t_vslider *x, t_glist *glist)
canvas, x, 0, canvas, x, 0,
xpos, ypos-2, xpos, ypos-2,
xpos+7, ypos-1); xpos+7, ypos-1);
#endif /* ROCKBOX */
} }
static void vslider_draw_erase(t_vslider* x,t_glist* glist) static void vslider_draw_erase(t_vslider* x,t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
sys_vgui(".x%x.c delete %xBASE\n", canvas, x); sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
@ -115,10 +142,15 @@ static void vslider_draw_erase(t_vslider* x,t_glist* glist)
sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
if(!x->x_gui.x_fsf.x_rcv_able) if(!x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
#endif /* ROCKBOX */
} }
static void vslider_draw_config(t_vslider* x,t_glist* glist) static void vslider_draw_config(t_vslider* x,t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n", sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
@ -129,10 +161,16 @@ static void vslider_draw_config(t_vslider* x,t_glist* glist)
x, x->x_gui.x_fcol); x, x->x_gui.x_fcol);
sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas,
x, x->x_gui.x_bcol); x, x->x_gui.x_bcol);
#endif /* ROCKBOX */
} }
static void vslider_draw_io(t_vslider* x,t_glist* glist, int old_snd_rcv_flags) static void vslider_draw_io(t_vslider* x,t_glist* glist, int old_snd_rcv_flags)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
(void) old_snd_rcv_flags;
#else /* ROCKBOX */
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
@ -153,10 +191,15 @@ static void vslider_draw_io(t_vslider* x,t_glist* glist, int old_snd_rcv_flags)
x, 0); x, 0);
if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
#endif /* ROCKBOX */
} }
static void vslider_draw_select(t_vslider *x, t_glist *glist) static void vslider_draw_select(t_vslider *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
if(x->x_gui.x_fsf.x_selected) if(x->x_gui.x_fsf.x_selected)
@ -169,6 +212,7 @@ static void vslider_draw_select(t_vslider *x, t_glist *glist)
sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL); sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
} }
#endif /* ROCKBOX */
} }
void vslider_draw(t_vslider *x, t_glist *glist, int mode) void vslider_draw(t_vslider *x, t_glist *glist, int mode)
@ -270,6 +314,10 @@ void vslider_check_minmax(t_vslider *x, double min, double max)
static void vslider_properties(t_gobj *z, t_glist *owner) static void vslider_properties(t_gobj *z, t_glist *owner)
{ {
#ifdef ROCKBOX
(void) z;
(void) owner;
#else /* ROCKBOX */
t_vslider *x = (t_vslider *)z; t_vslider *x = (t_vslider *)z;
char buf[800]; char buf[800];
t_symbol *srl[3]; t_symbol *srl[3];
@ -292,6 +340,7 @@ static void vslider_properties(t_gobj *z, t_glist *owner)
x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
#endif
} }
static void vslider_bang(t_vslider *x) static void vslider_bang(t_vslider *x)
@ -321,6 +370,10 @@ static void vslider_dialog(t_vslider *x, t_symbol *s, int argc, t_atom *argv)
int steady = (int)atom_getintarg(17, argc, argv); int steady = (int)atom_getintarg(17, argc, argv);
int sr_flags; int sr_flags;
#ifdef ROCKBOX
(void) s;
#endif
if(lilo != 0) lilo = 1; if(lilo != 0) lilo = 1;
x->x_lin0_log1 = lilo; x->x_lin0_log1 = lilo;
if(steady) if(steady)
@ -341,6 +394,10 @@ static void vslider_motion(t_vslider *x, t_floatarg dx, t_floatarg dy)
{ {
int old = x->x_val; int old = x->x_val;
#ifdef ROCKBOX
(void) dx;
#endif
if(x->x_gui.x_fsf.x_finemoved) if(x->x_gui.x_fsf.x_finemoved)
x->x_pos -= (int)dy; x->x_pos -= (int)dy;
else else
@ -368,6 +425,11 @@ static void vslider_motion(t_vslider *x, t_floatarg dx, t_floatarg dy)
static void vslider_click(t_vslider *x, t_floatarg xpos, t_floatarg ypos, static void vslider_click(t_vslider *x, t_floatarg xpos, t_floatarg ypos,
t_floatarg shift, t_floatarg ctrl, t_floatarg alt) t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
{ {
#ifdef ROCKBOX
(void) shift;
(void) ctrl;
(void) alt;
#endif
if(!x->x_steady) if(!x->x_steady)
x->x_val = (int)(100.0 * (x->x_gui.x_h + text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist) - ypos)); x->x_val = (int)(100.0 * (x->x_gui.x_h + text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist) - ypos));
if(x->x_val > (100*x->x_gui.x_h - 100)) if(x->x_val > (100*x->x_gui.x_h - 100))
@ -386,6 +448,11 @@ static int vslider_newclick(t_gobj *z, struct _glist *glist,
{ {
t_vslider* x = (t_vslider *)z; t_vslider* x = (t_vslider *)z;
#ifdef ROCKBOX
(void) glist;
(void) dbl;
#endif
if(doit) if(doit)
{ {
vslider_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, vslider_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift,
@ -434,6 +501,9 @@ static void vslider_float(t_vslider *x, t_floatarg f)
static void vslider_size(t_vslider *x, t_symbol *s, int ac, t_atom *av) static void vslider_size(t_vslider *x, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
#endif
x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
if(ac > 1) if(ac > 1)
vslider_check_height(x, (int)atom_getintarg(1, ac, av)); vslider_check_height(x, (int)atom_getintarg(1, ac, av));
@ -448,6 +518,9 @@ static void vslider_pos(t_vslider *x, t_symbol *s, int ac, t_atom *av)
static void vslider_range(t_vslider *x, t_symbol *s, int ac, t_atom *av) static void vslider_range(t_vslider *x, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
#endif
vslider_check_minmax(x, (double)atom_getfloatarg(0, ac, av), vslider_check_minmax(x, (double)atom_getfloatarg(0, ac, av),
(double)atom_getfloatarg(1, ac, av)); (double)atom_getfloatarg(1, ac, av));
} }
@ -506,10 +579,20 @@ static void *vslider_new(t_symbol *s, int argc, t_atom *argv)
t_vslider *x = (t_vslider *)pd_new(vslider_class); t_vslider *x = (t_vslider *)pd_new(vslider_class);
int bflcol[]={-262144, -1, -1}; int bflcol[]={-262144, -1, -1};
int w=IEM_GUI_DEFAULTSIZE, h=IEM_SL_DEFAULTSIZE; int w=IEM_GUI_DEFAULTSIZE, h=IEM_SL_DEFAULTSIZE;
#ifdef ROCKBOX
int lilo=0, ldx=0, ldy=-8;
#else
int lilo=0, f=0, ldx=0, ldy=-8; int lilo=0, f=0, ldx=0, ldy=-8;
#endif
int fs=8, v=0, steady=1; int fs=8, v=0, steady=1;
double min=0.0, max=(double)(IEM_SL_DEFAULTSIZE-1); double min=0.0, max=(double)(IEM_SL_DEFAULTSIZE-1);
#ifndef ROCKBOX
char str[144]; char str[144];
#endif
#ifdef ROCKBOX
(void) s;
#endif
iem_inttosymargs(&x->x_gui.x_isa, 0); iem_inttosymargs(&x->x_gui.x_isa, 0);
iem_inttofstyle(&x->x_gui.x_fsf, 0); iem_inttofstyle(&x->x_gui.x_fsf, 0);
@ -581,7 +664,9 @@ static void vslider_free(t_vslider *x)
{ {
if(x->x_gui.x_fsf.x_rcv_able) if(x->x_gui.x_fsf.x_rcv_able)
pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
#ifndef ROCKBOX
gfxstub_deleteforkey(x); gfxstub_deleteforkey(x);
#endif
} }
void g_vslider_setup(void) void g_vslider_setup(void)

View file

@ -5,7 +5,13 @@
/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */ /* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */ /* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "g_canvas.h"
#include "g_all_guis.h"
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -21,6 +27,7 @@
#else #else
#include <unistd.h> #include <unistd.h>
#endif #endif
#endif /* ROCKBOX */
/* ----- vu gui-peak- & rms- vu-meter-display ---------- */ /* ----- vu gui-peak- & rms- vu-meter-display ---------- */
@ -31,6 +38,10 @@ static t_class *vu_class;
static void vu_update_rms(t_vu *x, t_glist *glist) static void vu_update_rms(t_vu *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
if(glist_isvisible(glist)) if(glist_isvisible(glist))
{ {
int w4=x->x_gui.x_w/4, off=text_ypix(&x->x_gui.x_obj, glist)-1; int w4=x->x_gui.x_w/4, off=text_ypix(&x->x_gui.x_obj, glist)-1;
@ -40,10 +51,15 @@ static void vu_update_rms(t_vu *x, t_glist *glist)
glist_getcanvas(glist), x, quad1, off, quad3, glist_getcanvas(glist), x, quad1, off, quad3,
off + (x->x_led_size+1)*(IEM_VU_STEPS-x->x_rms)); off + (x->x_led_size+1)*(IEM_VU_STEPS-x->x_rms));
} }
#endif /* ROCKBOX */
} }
static void vu_update_peak(t_vu *x, t_glist *glist) static void vu_update_peak(t_vu *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
if(glist_isvisible(glist)) if(glist_isvisible(glist))
@ -74,10 +90,15 @@ static void vu_update_peak(t_vu *x, t_glist *glist)
mid, ypos+20); mid, ypos+20);
} }
} }
#endif /* ROCKBOX */
} }
static void vu_draw_new(t_vu *x, t_glist *glist) static void vu_draw_new(t_vu *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
@ -151,11 +172,16 @@ static void vu_draw_new(t_vu *x, t_glist *glist)
xpos+x->x_gui.x_w+1, ypos-1, xpos+x->x_gui.x_w+1, ypos-1,
x, 1); x, 1);
} }
#endif /* ROCKBOX */
} }
static void vu_draw_move(t_vu *x, t_glist *glist) static void vu_draw_move(t_vu *x, t_glist *glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
@ -212,10 +238,15 @@ static void vu_draw_move(t_vu *x, t_glist *glist)
xpos+x->x_gui.x_w+1-IOWIDTH, ypos-2, xpos+x->x_gui.x_w+1-IOWIDTH, ypos-2,
xpos+x->x_gui.x_w+1, ypos-1); xpos+x->x_gui.x_w+1, ypos-1);
} }
#endif /* ROCKBOX */
} }
static void vu_draw_erase(t_vu* x,t_glist* glist) static void vu_draw_erase(t_vu* x,t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
int i; int i;
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
@ -244,10 +275,15 @@ static void vu_draw_erase(t_vu* x,t_glist* glist)
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 1); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 1);
} }
#endif /* ROCKBOX */
} }
static void vu_draw_config(t_vu* x, t_glist* glist) static void vu_draw_config(t_vu* x, t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
int i; int i;
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
@ -277,10 +313,16 @@ static void vu_draw_config(t_vu* x, t_glist* glist)
x, x->x_gui.x_bcol, x->x_gui.x_bcol); x, x->x_gui.x_bcol, x->x_gui.x_bcol);
sys_vgui(".x%x.c itemconfigure %xPLED -width %d\n", canvas, x, sys_vgui(".x%x.c itemconfigure %xPLED -width %d\n", canvas, x,
x->x_led_size); x->x_led_size);
#endif /* ROCKBOX */
} }
static void vu_draw_io(t_vu* x, t_glist* glist, int old_snd_rcv_flags) static void vu_draw_io(t_vu* x, t_glist* glist, int old_snd_rcv_flags)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
(void) old_snd_rcv_flags;
#else /* ROCKBOX */
int xpos=text_xpix(&x->x_gui.x_obj, glist); int xpos=text_xpix(&x->x_gui.x_obj, glist);
int ypos=text_ypix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist);
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
@ -321,10 +363,15 @@ static void vu_draw_io(t_vu* x, t_glist* glist, int old_snd_rcv_flags)
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 1); sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 1);
} }
#endif /* ROCKBOX */
} }
static void vu_draw_select(t_vu* x,t_glist* glist) static void vu_draw_select(t_vu* x,t_glist* glist)
{ {
#ifdef ROCKBOX
(void) x;
(void) glist;
#else /* ROCKBOX */
int i; int i;
t_canvas *canvas=glist_getcanvas(glist); t_canvas *canvas=glist_getcanvas(glist);
@ -362,6 +409,7 @@ static void vu_draw_select(t_vu* x,t_glist* glist)
} }
sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
} }
#endif /* ROCKBOX */
} }
void vu_draw(t_vu *x, t_glist *glist, int mode) void vu_draw(t_vu *x, t_glist *glist, int mode)
@ -425,6 +473,10 @@ void vu_check_height(t_vu *x, int h)
static void vu_scale(t_vu *x, t_floatarg fscale) static void vu_scale(t_vu *x, t_floatarg fscale)
{ {
#ifdef ROCKBOX
(void) x;
(void) fscale;
#else /* ROCKBOX */
int i, scale = (int)fscale; int i, scale = (int)fscale;
if(scale != 0) scale = 1; if(scale != 0) scale = 1;
@ -446,7 +498,11 @@ static void vu_scale(t_vu *x, t_floatarg fscale)
} }
if(!x->x_scale && scale) if(!x->x_scale && scale)
{ {
#ifdef ROCKBOX
int end=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist)+x->x_gui.x_w+4;
#else /* ROCKBOX */
int w4=x->x_gui.x_w/4, end=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist)+x->x_gui.x_w+4; int w4=x->x_gui.x_w/4, end=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist)+x->x_gui.x_w+4;
#endif /* ROCKBOX */
int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2; int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2;
int yyy, k4=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist)-k3; int yyy, k4=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist)-k3;
t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist); t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
@ -471,10 +527,15 @@ static void vu_scale(t_vu *x, t_floatarg fscale)
x->x_gui.x_lcol, x, i); x->x_gui.x_lcol, x, i);
} }
} }
#endif /* ROCKBOX */
} }
static void vu_properties(t_gobj *z, t_glist *owner) static void vu_properties(t_gobj *z, t_glist *owner)
{ {
#ifdef ROCKBOX
(void) z;
(void) owner;
#else /* ROCKBOX */
t_vu *x = (t_vu *)z; t_vu *x = (t_vu *)z;
char buf[800]; char buf[800];
t_symbol *srl[3]; t_symbol *srl[3];
@ -496,6 +557,7 @@ static void vu_properties(t_gobj *z, t_glist *owner)
x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
0xffffff & x->x_gui.x_bcol, -1/*no front-color*/, 0xffffff & x->x_gui.x_lcol); 0xffffff & x->x_gui.x_bcol, -1/*no front-color*/, 0xffffff & x->x_gui.x_lcol);
gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
#endif /* ROCKBOX */
} }
static void vu_dialog(t_vu *x, t_symbol *s, int argc, t_atom *argv) static void vu_dialog(t_vu *x, t_symbol *s, int argc, t_atom *argv)
@ -506,6 +568,10 @@ static void vu_dialog(t_vu *x, t_symbol *s, int argc, t_atom *argv)
int scale = (int)atom_getintarg(4, argc, argv); int scale = (int)atom_getintarg(4, argc, argv);
int sr_flags; int sr_flags;
#ifdef ROCKBOX
(void) s;
#endif
srl[0] = gensym("empty"); srl[0] = gensym("empty");
sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv); sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
x->x_gui.x_fsf.x_snd_able = 0; x->x_gui.x_fsf.x_snd_able = 0;
@ -523,6 +589,9 @@ static void vu_dialog(t_vu *x, t_symbol *s, int argc, t_atom *argv)
static void vu_size(t_vu *x, t_symbol *s, int ac, t_atom *av) static void vu_size(t_vu *x, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
#endif
x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
if(ac > 1) if(ac > 1)
vu_check_height(x, (int)atom_getintarg(1, ac, av)); vu_check_height(x, (int)atom_getintarg(1, ac, av));
@ -608,9 +677,14 @@ static void *vu_new(t_symbol *s, int argc, t_atom *argv)
t_vu *x = (t_vu *)pd_new(vu_class); t_vu *x = (t_vu *)pd_new(vu_class);
int bflcol[]={-66577, -1, -1}; int bflcol[]={-66577, -1, -1};
int w=IEM_GUI_DEFAULTSIZE, h=IEM_VU_STEPS*IEM_VU_DEFAULTSIZE; int w=IEM_GUI_DEFAULTSIZE, h=IEM_VU_STEPS*IEM_VU_DEFAULTSIZE;
#ifdef ROCKBOX
int ldx=-1, ldy=-8, fs=8, scale=1;
(void) s;
#else /* ROCKBOX */
int ldx=-1, ldy=-8, f=0, fs=8, scale=1; int ldx=-1, ldy=-8, f=0, fs=8, scale=1;
int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME; int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
char str[144]; char str[144];
#endif /* ROCKBOX */
iem_inttosymargs(&x->x_gui.x_isa, 0); iem_inttosymargs(&x->x_gui.x_isa, 0);
iem_inttofstyle(&x->x_gui.x_fsf, 0); iem_inttofstyle(&x->x_gui.x_fsf, 0);
@ -678,7 +752,9 @@ static void vu_free(t_vu *x)
{ {
if(x->x_gui.x_fsf.x_rcv_able) if(x->x_gui.x_fsf.x_rcv_able)
pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
#ifndef ROCKBOX
gfxstub_deleteforkey(x); gfxstub_deleteforkey(x);
#endif
} }
void g_vumeter_setup(void) void g_vumeter_setup(void)

View file

@ -3,8 +3,14 @@
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
#include "m_pd.h" #include "m_pd.h"
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#else /* ROCKBOX */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#endif /* ROCKBOX */
/* convenience routines for checking and getting values of /* convenience routines for checking and getting values of
atoms. There's no "pointer" version since there's nothing atoms. There's no "pointer" version since there's nothing
@ -23,7 +29,9 @@ t_int atom_getint(t_atom *a)
t_symbol *atom_getsymbol(t_atom *a) /* LATER think about this more carefully */ t_symbol *atom_getsymbol(t_atom *a) /* LATER think about this more carefully */
{ {
#ifndef ROCKBOX
char buf[30]; char buf[30];
#endif
if (a->a_type == A_SYMBOL) return (a->a_w.w_symbol); if (a->a_type == A_SYMBOL) return (a->a_w.w_symbol);
else return (&s_float); else return (&s_float);
} }
@ -33,7 +41,11 @@ t_symbol *atom_gensym(t_atom *a) /* this works better for graph labels */
char buf[30]; char buf[30];
if (a->a_type == A_SYMBOL) return (a->a_w.w_symbol); if (a->a_type == A_SYMBOL) return (a->a_w.w_symbol);
else if (a->a_type == A_FLOAT) else if (a->a_type == A_FLOAT)
#ifdef ROCKBOX
ftoan(a->a_w.w_float, buf, sizeof(buf)-1);
#else
sprintf(buf, "%g", a->a_w.w_float); sprintf(buf, "%g", a->a_w.w_float);
#endif
else strcpy(buf, "???"); else strcpy(buf, "???");
return (gensym(buf)); return (gensym(buf));
} }
@ -76,7 +88,11 @@ void atom_string(t_atom *a, char *buf, unsigned int bufsize)
strcpy(buf, "(pointer)"); strcpy(buf, "(pointer)");
break; break;
case A_FLOAT: case A_FLOAT:
#ifdef ROCKBOX
ftoan(a->a_w.w_float, tbuf, sizeof(tbuf)-1);
#else
sprintf(tbuf, "%g", a->a_w.w_float); sprintf(tbuf, "%g", a->a_w.w_float);
#endif
if (strlen(tbuf) < bufsize-1) strcpy(buf, tbuf); if (strlen(tbuf) < bufsize-1) strcpy(buf, tbuf);
else if (a->a_w.w_float < 0) strcpy(buf, "-"); else if (a->a_w.w_float < 0) strcpy(buf, "-");
else strcat(buf, "+"); else strcat(buf, "+");
@ -118,10 +134,10 @@ void atom_string(t_atom *a, char *buf, unsigned int bufsize)
} }
break; break;
case A_DOLLAR: case A_DOLLAR:
sprintf(buf, "$%d", a->a_w.w_index); snprintf(buf, bufsize-1, "$%d", a->a_w.w_index);
break; break;
case A_DOLLSYM: case A_DOLLSYM:
sprintf(buf, "$%s", a->a_w.w_symbol->s_name); snprintf(buf, bufsize-1, "$%s", a->a_w.w_symbol->s_name);
break; break;
default: default:
bug("atom_string"); bug("atom_string");

View file

@ -10,9 +10,15 @@
* change marked with IOhannes * change marked with IOhannes
*/ */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#ifdef SIMULATOR
int printf(const char *fmt, ...);
void perror(const char*);
#endif
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include "m_pd.h"
#include "s_stuff.h"
#include <stdio.h> #include <stdio.h>
#ifdef UNIX #ifdef UNIX
#include <unistd.h> #include <unistd.h>
@ -21,8 +27,13 @@
#include <io.h> #include <io.h>
#endif #endif
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#endif /* ROCKBOX */
#include "m_pd.h"
#include "s_stuff.h"
struct _binbuf struct _binbuf
{ {
@ -72,7 +83,9 @@ void binbuf_text(t_binbuf *x, char *text, size_t size)
x->b_n = 0; x->b_n = 0;
while (1) while (1)
{ {
#ifndef ROCKBOX
int type; int type;
#endif
/* skip leading space */ /* skip leading space */
while ((textp != etext) && (*textp == ' ' || *textp == '\n' while ((textp != etext) && (*textp == ' ' || *textp == '\n'
|| *textp == '\r' || *textp == '\t')) textp++; || *textp == '\r' || *textp == '\t')) textp++;
@ -158,6 +171,7 @@ void binbuf_text(t_binbuf *x, char *text, size_t size)
#if 0 #if 0
post("buf %s", buf); post("buf %s", buf);
#endif #endif
if (*buf == '$' && buf[1] >= '0' && buf[1] <= '9' && !firstslash) if (*buf == '$' && buf[1] >= '0' && buf[1] <= '9' && !firstslash)
{ {
for (bufp = buf+2; *bufp; bufp++) for (bufp = buf+2; *bufp; bufp++)
@ -219,7 +233,7 @@ void binbuf_gettext(t_binbuf *x, char **bufp, int *lengthp)
} }
if (length && buf[length-1] == ' ') if (length && buf[length-1] == ' ')
{ {
if (newbuf = t_resizebytes(buf, length, length-1)) if((newbuf = t_resizebytes(buf, length, length-1)))
{ {
buf = newbuf; buf = newbuf;
length--; length--;
@ -236,8 +250,8 @@ void binbuf_add(t_binbuf *x, int argc, t_atom *argv)
{ {
int newsize = x->b_n + argc, i; int newsize = x->b_n + argc, i;
t_atom *ap; t_atom *ap;
if (ap = t_resizebytes(x->b_vec, x->b_n * sizeof(*x->b_vec), if((ap = t_resizebytes(x->b_vec, x->b_n * sizeof(*x->b_vec),
newsize * sizeof(*x->b_vec))) newsize * sizeof(*x->b_vec))))
x->b_vec = ap; x->b_vec = ap;
else else
{ {
@ -310,11 +324,19 @@ void binbuf_addbinbuf(t_binbuf *x, t_binbuf *y)
SETSYMBOL(ap, gensym(",")); SETSYMBOL(ap, gensym(","));
break; break;
case A_DOLLAR: case A_DOLLAR:
#ifdef ROCKBOX
snprintf(tbuf, sizeof(tbuf)-1, "$%d", ap->a_w.w_index);
#else /* ROCKBOX */
sprintf(tbuf, "$%d", ap->a_w.w_index); sprintf(tbuf, "$%d", ap->a_w.w_index);
#endif /* ROCKBOX */
SETSYMBOL(ap, gensym(tbuf)); SETSYMBOL(ap, gensym(tbuf));
break; break;
case A_DOLLSYM: case A_DOLLSYM:
#ifdef ROCKBOX
snprintf(tbuf, sizeof(tbuf)-1, "$%s", ap->a_w.w_symbol->s_name);
#else /* ROCKBOX */
sprintf(tbuf, "$%s", ap->a_w.w_symbol->s_name); sprintf(tbuf, "$%s", ap->a_w.w_symbol->s_name);
#endif /* ROCKBOX */
SETSYMBOL(ap, gensym(tbuf)); SETSYMBOL(ap, gensym(tbuf));
break; break;
case A_SYMBOL: case A_SYMBOL:
@ -346,8 +368,8 @@ void binbuf_restore(t_binbuf *x, int argc, t_atom *argv)
{ {
int newsize = x->b_n + argc, i; int newsize = x->b_n + argc, i;
t_atom *ap; t_atom *ap;
if (ap = t_resizebytes(x->b_vec, x->b_n * sizeof(*x->b_vec), if((ap = t_resizebytes(x->b_vec, x->b_n * sizeof(*x->b_vec),
newsize * sizeof(*x->b_vec))) newsize * sizeof(*x->b_vec))))
x->b_vec = ap; x->b_vec = ap;
else else
{ {
@ -374,7 +396,11 @@ void binbuf_restore(t_binbuf *x, int argc, t_atom *argv)
else else
{ {
int dollar = 0; int dollar = 0;
#ifdef ROCKBOX
dollar = atoi(argv->a_w.w_symbol->s_name + 1);
#else
sscanf(argv->a_w.w_symbol->s_name + 1, "%d", &dollar); sscanf(argv->a_w.w_symbol->s_name + 1, "%d", &dollar);
#endif
SETDOLLAR(ap, dollar); SETDOLLAR(ap, dollar);
} }
} }
@ -430,10 +456,18 @@ t_symbol *binbuf_realizedollsym(t_symbol *s, int ac, t_atom *av, int tonew)
{ {
if (!tonew) if (!tonew)
return (0); return (0);
#ifdef ROCKBOX
else snprintf(buf, sizeof(buf)-1, "$%d", argno);
#else /* ROCKBOX */
else sprintf(buf, "$%d", argno); else sprintf(buf, "$%d", argno);
#endif /* ROCKBOX */
} }
else if (argno == 0) else if (argno == 0)
#ifdef ROCKBOX
snprintf(buf, sizeof(buf)-1, "%d", canvas_getdollarzero());
#else /* ROCKBOX */
sprintf(buf, "%d", canvas_getdollarzero()); sprintf(buf, "%d", canvas_getdollarzero());
#endif /* ROCKBOX */
else else
atom_string(av+(argno-1), buf, MAXPDSTRING/2-1); atom_string(av+(argno-1), buf, MAXPDSTRING/2-1);
strncat(buf, sp, MAXPDSTRING/2-1); strncat(buf, sp, MAXPDSTRING/2-1);
@ -582,6 +616,10 @@ void binbuf_eval(t_binbuf *x, t_pd *target, int argc, t_atom *argv)
if (nargs == 1) pd_float(target, stackwas->a_w.w_float); if (nargs == 1) pd_float(target, stackwas->a_w.w_float);
else pd_list(target, 0, nargs, stackwas); else pd_list(target, 0, nargs, stackwas);
break; break;
#ifdef ROCKBOX
default:
break;
#endif
} }
} }
msp = stackwas; msp = stackwas;
@ -606,12 +644,14 @@ static int binbuf_doopen(char *s, int mode)
return (open(namebuf, mode)); return (open(namebuf, mode));
} }
#ifndef ROCKBOX
static FILE *binbuf_dofopen(char *s, char *mode) static FILE *binbuf_dofopen(char *s, char *mode)
{ {
char namebuf[MAXPDSTRING]; char namebuf[MAXPDSTRING];
sys_bashfilename(s, namebuf); sys_bashfilename(s, namebuf);
return (fopen(namebuf, mode)); return (fopen(namebuf, mode));
} }
#endif
int binbuf_read(t_binbuf *b, char *filename, char *dirname, int crflag) int binbuf_read(t_binbuf *b, char *filename, char *dirname, int crflag)
{ {
@ -620,30 +660,51 @@ int binbuf_read(t_binbuf *b, char *filename, char *dirname, int crflag)
int readret; int readret;
char *buf; char *buf;
char namebuf[MAXPDSTRING]; char namebuf[MAXPDSTRING];
namebuf[0] = 0; namebuf[0] = 0;
if (*dirname) if (*dirname)
strcat(namebuf, dirname), strcat(namebuf, "/"); strcat(namebuf, dirname), strcat(namebuf, "/");
strcat(namebuf, filename); strcat(namebuf, filename);
if ((fd = binbuf_doopen(namebuf, 0)) < 0) if ((fd = binbuf_doopen(namebuf, 0)) < 0)
{ {
#ifdef ROCKBOX
#ifdef SIMULATOR
printf("open: ");
perror(namebuf);
#endif /* SIMULATOR */
#else /* ROCKBOX */
fprintf(stderr, "open: "); fprintf(stderr, "open: ");
perror(namebuf); perror(namebuf);
#endif /* ROCKBOX */
return (1); return (1);
} }
if ((length = lseek(fd, 0, SEEK_END)) < 0 || lseek(fd, 0, SEEK_SET) < 0 if ((length = lseek(fd, 0, SEEK_END)) < 0 || lseek(fd, 0, SEEK_SET) < 0
|| !(buf = t_getbytes(length))) || !(buf = t_getbytes(length)))
{ {
#ifdef ROCKBOX
#ifdef SIMULATOR
printf("lseek: ");
perror(namebuf);
#endif /* SIMULATOR */
#else /* ROCKBOX */
fprintf(stderr, "lseek: "); fprintf(stderr, "lseek: ");
perror(namebuf); perror(namebuf);
#endif /* ROCKBOX */
close(fd); close(fd);
return(1); return(1);
} }
if ((readret = read(fd, buf, length)) < length) if ((readret = read(fd, buf, length)) < length)
{ {
#ifdef ROCKBOX
#ifdef SIMULATOR
printf("read (%d %ld) -> %d\n", fd, length, readret);
perror(namebuf);
#endif /* SIMULATOR */
#else /* ROCKBOX */
fprintf(stderr, "read (%d %ld) -> %d\n", fd, length, readret); fprintf(stderr, "read (%d %ld) -> %d\n", fd, length, readret);
perror(namebuf); perror(namebuf);
#endif /* ROCKBOX */
close(fd); close(fd);
t_freebytes(buf, length); t_freebytes(buf, length);
return(1); return(1);
@ -691,7 +752,11 @@ static t_binbuf *binbuf_convert(t_binbuf *oldb, int maxtopd);
semicolons. */ semicolons. */
int binbuf_write(t_binbuf *x, char *filename, char *dir, int crflag) int binbuf_write(t_binbuf *x, char *filename, char *dir, int crflag)
{ {
#ifdef ROCKBOX
int f = 0;
#else /* ROCKBOX */
FILE *f = 0; FILE *f = 0;
#endif /* ROCKBOX */
char sbuf[WBUFSIZE], fbuf[MAXPDSTRING], *bp = sbuf, *ep = sbuf + WBUFSIZE; char sbuf[WBUFSIZE], fbuf[MAXPDSTRING], *bp = sbuf, *ep = sbuf + WBUFSIZE;
t_atom *ap; t_atom *ap;
int indx, deleteit = 0; int indx, deleteit = 0;
@ -707,9 +772,19 @@ int binbuf_write(t_binbuf *x, char *filename, char *dir, int crflag)
deleteit = 1; deleteit = 1;
} }
#ifdef ROCKBOX
if(!(f = binbuf_doopen(fbuf, O_WRONLY|O_CREAT|O_TRUNC)))
#else /* ROCKBOX */
if (!(f = binbuf_dofopen(fbuf, "w"))) if (!(f = binbuf_dofopen(fbuf, "w")))
#endif /* ROCKBOX */
{ {
#ifdef ROCKBOX
#ifdef SIMULATOR
printf("open: ");
#endif /* SIMULATOR */
#else /* ROCKBOX */
fprintf(stderr, "open: "); fprintf(stderr, "open: ");
#endif /* ROCKBOX */
sys_unixerror(fbuf); sys_unixerror(fbuf);
goto fail; goto fail;
} }
@ -723,7 +798,11 @@ int binbuf_write(t_binbuf *x, char *filename, char *dir, int crflag)
else length = 40; else length = 40;
if (ep - bp < length) if (ep - bp < length)
{ {
#ifdef ROCKBOX
if(write(f, sbuf, bp-sbuf) < 1)
#else /* ROCKBOX */
if (fwrite(sbuf, bp-sbuf, 1, f) < 1) if (fwrite(sbuf, bp-sbuf, 1, f) < 1)
#endif /* ROCKBOX */
{ {
sys_unixerror(fbuf); sys_unixerror(fbuf);
goto fail; goto fail;
@ -750,20 +829,32 @@ int binbuf_write(t_binbuf *x, char *filename, char *dir, int crflag)
ncolumn++; ncolumn++;
} }
} }
#ifdef ROCKBOX
if(write(f, sbuf, bp-sbuf) < 1)
#else /* ROCKBOX */
if (fwrite(sbuf, bp-sbuf, 1, f) < 1) if (fwrite(sbuf, bp-sbuf, 1, f) < 1)
#endif /* ROCKBOX */
{ {
sys_unixerror(fbuf); sys_unixerror(fbuf);
goto fail; goto fail;
} }
if (deleteit) if (deleteit)
binbuf_free(x); binbuf_free(x);
#ifdef ROCKBOX
close(f);
#else /* ROCKBOX */
fclose(f); fclose(f);
#endif /* ROCKBOX */
return (0); return (0);
fail: fail:
if (deleteit) if (deleteit)
binbuf_free(x); binbuf_free(x);
if (f) if (f)
fclose(f); #ifdef ROCKBOX
close(f);
#else /* ROCKBOX */
fclose(f);
#endif /* ROCKBOX */
return (1); return (1);
} }
@ -816,13 +907,21 @@ static t_binbuf *binbuf_convert(t_binbuf *oldb, int maxtopd)
if (nextmess[i].a_type == A_DOLLAR) if (nextmess[i].a_type == A_DOLLAR)
{ {
char buf[100]; char buf[100];
#ifdef ROCKBOX
snprintf(buf, sizeof(buf)-1, "$%d", nextmess[i].a_w.w_index);
#else /* ROCKBOX */
sprintf(buf, "$%d", nextmess[i].a_w.w_index); sprintf(buf, "$%d", nextmess[i].a_w.w_index);
#endif /* ROCKBOX */
SETSYMBOL(nextmess+i, gensym(buf)); SETSYMBOL(nextmess+i, gensym(buf));
} }
else if (nextmess[i].a_type == A_DOLLSYM) else if (nextmess[i].a_type == A_DOLLSYM)
{ {
char buf[100]; char buf[100];
#ifdef ROCKBOX
snprintf(buf, sizeof(buf)-1, "$%s", nextmess[i].a_w.w_symbol->s_name);
#else /* ROCKBOX */
sprintf(buf, "$%s", nextmess[i].a_w.w_symbol->s_name); sprintf(buf, "$%s", nextmess[i].a_w.w_symbol->s_name);
#endif /* ROCKBOX */
SETSYMBOL(nextmess+i, gensym(buf)); SETSYMBOL(nextmess+i, gensym(buf));
} }
} }
@ -846,7 +945,11 @@ static t_binbuf *binbuf_convert(t_binbuf *oldb, int maxtopd)
atom_getfloatarg(2, natom, nextmess), atom_getfloatarg(2, natom, nextmess),
atom_getfloatarg(5, natom, nextmess) - atom_getfloatarg(5, natom, nextmess) -
atom_getfloatarg(3, natom, nextmess), atom_getfloatarg(3, natom, nextmess),
#ifdef ROCKBOX
10.0);
#else
(float)sys_defaultfont); (float)sys_defaultfont);
#endif
} }
} }
if (!strcmp(first, "#P")) if (!strcmp(first, "#P"))
@ -1157,13 +1260,13 @@ int binbuf_match(t_binbuf *inbuf, t_binbuf *searchbuf)
t_atom *a1 = &inbuf->b_vec[indexin + nmatched], t_atom *a1 = &inbuf->b_vec[indexin + nmatched],
*a2 = &searchbuf->b_vec[nmatched]; *a2 = &searchbuf->b_vec[nmatched];
if (a1->a_type != a2->a_type || if (a1->a_type != a2->a_type ||
a1->a_type == A_SYMBOL && a1->a_w.w_symbol != a2->a_w.w_symbol (a1->a_type == A_SYMBOL && a1->a_w.w_symbol != a2->a_w.w_symbol)
|| ||
a1->a_type == A_FLOAT && a1->a_w.w_float != a2->a_w.w_float (a1->a_type == A_FLOAT && a1->a_w.w_float != a2->a_w.w_float)
|| ||
a1->a_type == A_DOLLAR && a1->a_w.w_index != a2->a_w.w_index (a1->a_type == A_DOLLAR && a1->a_w.w_index != a2->a_w.w_index)
|| ||
a1->a_type == A_DOLLSYM && a1->a_w.w_symbol != a2->a_w.w_symbol) (a1->a_type == A_DOLLSYM && a1->a_w.w_symbol != a2->a_w.w_symbol))
goto nomatch; goto nomatch;
} }
return (1); return (1);
@ -1183,9 +1286,12 @@ void binbuf_evalfile(t_symbol *name, t_symbol *dir)
/* set filename so that new canvases can pick them up */ /* set filename so that new canvases can pick them up */
int dspstate = canvas_suspend_dsp(); int dspstate = canvas_suspend_dsp();
glob_setfilename(0, name, dir); glob_setfilename(0, name, dir);
if (binbuf_read(b, name->s_name, dir->s_name, 0)) if (binbuf_read(b, name->s_name, dir->s_name, 0))
{ {
#if !defined(ROCKBOX) || (defined(ROCKBOX) && defined(SIMULATOR))
perror(name->s_name); perror(name->s_name);
#endif
} }
else else
{ {
@ -1205,6 +1311,10 @@ void binbuf_evalfile(t_symbol *name, t_symbol *dir)
void glob_evalfile(t_pd *ignore, t_symbol *name, t_symbol *dir) void glob_evalfile(t_pd *ignore, t_symbol *name, t_symbol *dir)
{ {
t_pd *x = 0; t_pd *x = 0;
#ifdef ROCKBOX
(void) ignore;
#endif
/* even though binbuf_evalfile appears to take care of dspstate, /* even though binbuf_evalfile appears to take care of dspstate,
we have to do it again here, because canvas_startdsp() assumes we have to do it again here, because canvas_startdsp() assumes
that all toplevel canvases are visible. LATER check if this that all toplevel canvases are visible. LATER check if this

View file

@ -2,10 +2,23 @@
* For information on usage and redistribution, and for a DISCLAIMER OF ALL * For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
#if 0
//#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#endif
#define PD_CLASS_DEF #define PD_CLASS_DEF
#include "m_pd.h" #include "m_pd.h"
#include "m_imp.h" #include "m_imp.h"
#include "s_stuff.h" #include "s_stuff.h"
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#ifdef UNIX #ifdef UNIX
#include <unistd.h> #include <unistd.h>
@ -16,6 +29,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#endif /* ROCKBOX */
static t_symbol *class_loadsym; /* name under which an extern is invoked */ static t_symbol *class_loadsym; /* name under which an extern is invoked */
static void pd_defaultfloat(t_pd *x, t_float f); static void pd_defaultfloat(t_pd *x, t_float f);
@ -27,6 +41,10 @@ static t_symbol *class_extern_dir = &s_;
static void pd_defaultanything(t_pd *x, t_symbol *s, int argc, t_atom *argv) static void pd_defaultanything(t_pd *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) argc;
(void) argv;
#endif
pd_error(x, "%s: no method for '%s'", (*x)->c_name->s_name, s->s_name); pd_error(x, "%s: no method for '%s'", (*x)->c_name->s_name, s->s_name);
} }
@ -422,6 +440,10 @@ char *class_gethelpdir(t_class *c)
static void class_nosavefn(t_gobj *z, t_binbuf *b) static void class_nosavefn(t_gobj *z, t_binbuf *b)
{ {
#ifdef ROCKBOX
(void) z;
(void) b;
#endif
bug("save function called but not defined"); bug("save function called but not defined");
} }
@ -465,7 +487,7 @@ t_symbol *dogensym(char *s, t_symbol *oldsym)
s2++; s2++;
} }
sym1 = symhash + (hash2 & (HASHSIZE-1)); sym1 = symhash + (hash2 & (HASHSIZE-1));
while (sym2 = *sym1) while ((sym2 = *sym1))
{ {
if (!strcmp(sym2->s_name, s)) return(sym2); if (!strcmp(sym2->s_name, s)) return(sym2);
sym1 = &sym2->s_next; sym1 = &sym2->s_next;
@ -485,10 +507,14 @@ t_symbol *dogensym(char *s, t_symbol *oldsym)
t_symbol *gensym(char *s) t_symbol *gensym(char *s)
{ {
printf("gensym: %s\n", s);
return(dogensym(s, 0)); return(dogensym(s, 0));
} }
static t_symbol *addfileextent(t_symbol *s) #ifndef ROCKBOX
static
#endif
t_symbol *addfileextent(t_symbol *s)
{ {
char namebuf[MAXPDSTRING], *str = s->s_name; char namebuf[MAXPDSTRING], *str = s->s_name;
int ln = strlen(str); int ln = strlen(str);
@ -608,7 +634,9 @@ typedef t_pd *(*t_fun6)(t_int i1, t_int i2, t_int i3, t_int i4, t_int i5, t_int
void pd_typedmess(t_pd *x, t_symbol *s, int argc, t_atom *argv) void pd_typedmess(t_pd *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifndef ROCKBOX
t_method *f; t_method *f;
#endif
t_class *c = *x; t_class *c = *x;
t_methodentry *m; t_methodentry *m;
t_atomtype *wp, wanttype; t_atomtype *wp, wanttype;
@ -617,7 +645,7 @@ void pd_typedmess(t_pd *x, t_symbol *s, int argc, t_atom *argv)
t_floatarg ad[MAXPDARG+1], *dp = ad; t_floatarg ad[MAXPDARG+1], *dp = ad;
int narg = 0; int narg = 0;
t_pd *bonzo; t_pd *bonzo;
/* check for messages that are handled by fixed slots in the class /* check for messages that are handled by fixed slots in the class
structure. We don't catch "pointer" though so that sending "pointer" structure. We don't catch "pointer" though so that sending "pointer"
to pd_objectmaker doesn't require that we supply a pointer value. */ to pd_objectmaker doesn't require that we supply a pointer value. */
@ -658,9 +686,10 @@ void pd_typedmess(t_pd *x, t_symbol *s, int argc, t_atom *argv)
else (*((t_messgimme)(m->me_fun)))(x, s, argc, argv); else (*((t_messgimme)(m->me_fun)))(x, s, argc, argv);
return; return;
} }
if (argc > MAXPDARG) argc = MAXPDARG; if (argc > MAXPDARG) argc = MAXPDARG;
if (x != &pd_objectmaker) *(ap++) = (t_int)x, narg++; if (x != &pd_objectmaker) *(ap++) = (t_int)x, narg++;
while (wanttype = *wp++) while((wanttype = *wp++))
{ {
switch (wanttype) switch (wanttype)
{ {
@ -712,6 +741,11 @@ void pd_typedmess(t_pd *x, t_symbol *s, int argc, t_atom *argv)
} }
narg++; narg++;
ap++; ap++;
#ifdef ROCKBOX
break;
default:
break;
#endif
} }
} }
switch (narg) switch (narg)

View file

@ -51,6 +51,9 @@ void d_osc_setup(void);
void d_soundfile_setup(void); void d_soundfile_setup(void);
void d_ugen_setup(void); void d_ugen_setup(void);
/* PD anywhere specific. -- W.B. */
void d_intern_setup(void);
void conf_init(void) void conf_init(void)
{ {
g_array_setup(); g_array_setup();
@ -81,11 +84,15 @@ void conf_init(void)
x_time_setup(); x_time_setup();
x_arithmetic_setup(); x_arithmetic_setup();
#ifndef ROCKBOX
x_midi_setup(); x_midi_setup();
#endif
x_misc_setup(); x_misc_setup();
x_net_setup(); x_net_setup();
x_qlist_setup(); x_qlist_setup();
#ifndef ROCKBOX
x_gui_setup(); x_gui_setup();
#endif
d_arithmetic_setup(); d_arithmetic_setup();
d_dac_setup(); d_dac_setup();
d_fft_setup(); d_fft_setup();

View file

@ -1,9 +1,14 @@
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#else /* ROCKBOX */
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <netdb.h> #include <netdb.h>
#include <stdio.h> #include <stdio.h>
#endif /* ROCKBOX */
#include "m_pd.h" #include "m_pd.h"
#include "m_imp.h" #include "m_imp.h"
@ -21,8 +26,19 @@ static t_int x_fd = -1;
static void ipod_connect() static void ipod_connect(void)
{ {
#ifdef ROCKBOX
if (x_fd >= 0)
{
error("ipod_connect: already connected");
return;
}
else
{
x_fd++;
}
#else /* ROCKBOX */
struct sockaddr_in server; struct sockaddr_in server;
struct hostent *hp; struct hostent *hp;
int sockfd; int sockfd;
@ -65,6 +81,7 @@ static void ipod_connect()
} }
post("connected %s %d",hostname,portno); post("connected %s %d",hostname,portno);
x_fd = sockfd; x_fd = sockfd;
#endif /* ROCKBOX */
} }
@ -72,8 +89,13 @@ static void ipod_connect()
static void ipod_bang(t_ipod *x) static void ipod_bang(t_ipod *x)
{ {
static char sendme[200]; static char sendme[200];
#ifdef ROCKBOX
snprintf(sendme, sizeof(sendme)-1, "%s bang;\n", x->x_what->s_name);
SEND_FROM_CORE(sendme);
#else /* ROCKBOX */
sprintf(sendme,"%s bang;\n",x->x_what->s_name); sprintf(sendme,"%s bang;\n",x->x_what->s_name);
send(x_fd,sendme,strlen(sendme),0); send(x_fd,sendme,strlen(sendme),0);
#endif /*ROCKBOX */
// if (x->x_sym->s_thing) pd_bang(x->x_sym->s_thing); // if (x->x_sym->s_thing) pd_bang(x->x_sym->s_thing);
} }
@ -81,9 +103,19 @@ static void ipod_bang(t_ipod *x)
static void ipod_float(t_ipod *x, t_float f) static void ipod_float(t_ipod *x, t_float f)
{ {
static char sendme[200]; static char sendme[200];
#ifdef ROCKBOX
char f_buf[32];
ftoan(f, f_buf, sizeof(f_buf)-1);
strcpy(sendme, x->x_what->s_name);
strcat(sendme, " ");
strcat(sendme, f_buf);
SEND_FROM_CORE(sendme);
#else /* ROCKBOX */
sprintf(sendme,"%s %f;\n",x->x_what->s_name,f); sprintf(sendme,"%s %f;\n",x->x_what->s_name,f);
send(x_fd,sendme,strlen(sendme),0); send(x_fd,sendme,strlen(sendme),0);
#endif /* ROCKBOX */
// post("forwarding float %s",x->x_what->s_name); // post("forwarding float %s",x->x_what->s_name);
// if (x->x_sym->s_thing) pd_float(x->x_sym->s_thing, f); // if (x->x_sym->s_thing) pd_float(x->x_sym->s_thing, f);

View file

@ -83,6 +83,7 @@ void glob_init(void)
gensym("audiostatus"), 0); gensym("audiostatus"), 0);
class_addmethod(glob_pdobject, (t_method)glob_finderror, class_addmethod(glob_pdobject, (t_method)glob_finderror,
gensym("finderror"), 0); gensym("finderror"), 0);
#ifndef ROCKBOX
class_addmethod(glob_pdobject, (t_method)glob_audio_properties, class_addmethod(glob_pdobject, (t_method)glob_audio_properties,
gensym("audio-properties"), A_DEFFLOAT, 0); gensym("audio-properties"), A_DEFFLOAT, 0);
class_addmethod(glob_pdobject, (t_method)glob_audio_dialog, class_addmethod(glob_pdobject, (t_method)glob_audio_dialog,
@ -93,6 +94,7 @@ void glob_init(void)
gensym("midi-properties"), A_DEFFLOAT, 0); gensym("midi-properties"), A_DEFFLOAT, 0);
class_addmethod(glob_pdobject, (t_method)glob_midi_dialog, class_addmethod(glob_pdobject, (t_method)glob_midi_dialog,
gensym("midi-dialog"), A_GIMME, 0); gensym("midi-dialog"), A_GIMME, 0);
#endif /* ROCKBOX */
class_addmethod(glob_pdobject, (t_method)glob_start_path_dialog, class_addmethod(glob_pdobject, (t_method)glob_start_path_dialog,
gensym("start-path-dialog"), A_DEFFLOAT, 0); gensym("start-path-dialog"), A_DEFFLOAT, 0);
class_addmethod(glob_pdobject, (t_method)glob_path_dialog, class_addmethod(glob_pdobject, (t_method)glob_path_dialog,

View file

@ -4,7 +4,7 @@
#ifdef ROCKBOX #ifdef ROCKBOX
#include "plugin.h" #include "plugin.h"
#define memset rb->memset #include "pdbox.h"
#else /* ROCKBOX */ #else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View file

@ -53,9 +53,9 @@ t_inlet *inlet_new(t_object *owner, t_pd *dest, t_symbol *s1, t_symbol *s2)
else x->i_symto = s2; else x->i_symto = s2;
x->i_symfrom = s1; x->i_symfrom = s1;
x->i_next = 0; x->i_next = 0;
if (y = owner->ob_inlet) if((y = owner->ob_inlet))
{ {
while (y2 = y->i_next) y = y2; while((y2 = y->i_next)) y = y2;
y->i_next = x; y->i_next = x;
} }
else owner->ob_inlet = x; else owner->ob_inlet = x;
@ -106,7 +106,9 @@ static void inlet_symbol(t_inlet *x, t_symbol *s)
static void inlet_list(t_inlet *x, t_symbol *s, int argc, t_atom *argv) static void inlet_list(t_inlet *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifndef ROCKBOX
t_atom at; t_atom at;
#endif
if (x->i_symfrom == &s_list || x->i_symfrom == &s_float if (x->i_symfrom == &s_list || x->i_symfrom == &s_float
|| x->i_symfrom == &s_symbol || x->i_symfrom == &s_pointer) || x->i_symfrom == &s_symbol || x->i_symfrom == &s_pointer)
typedmess(x->i_dest, x->i_symto, argc, argv); typedmess(x->i_dest, x->i_symto, argc, argv);
@ -154,9 +156,9 @@ t_inlet *pointerinlet_new(t_object *owner, t_gpointer *gp)
x->i_symfrom = &s_pointer; x->i_symfrom = &s_pointer;
x->i_pointerslot = gp; x->i_pointerslot = gp;
x->i_next = 0; x->i_next = 0;
if (y = owner->ob_inlet) if((y = owner->ob_inlet))
{ {
while (y2 = y->i_next) y = y2; while((y2 = y->i_next)) y = y2;
y->i_next = x; y->i_next = x;
} }
else owner->ob_inlet = x; else owner->ob_inlet = x;
@ -176,9 +178,9 @@ t_inlet *floatinlet_new(t_object *owner, t_float *fp)
x->i_symfrom = &s_float; x->i_symfrom = &s_float;
x->i_floatslot = fp; x->i_floatslot = fp;
x->i_next = 0; x->i_next = 0;
if (y = owner->ob_inlet) if((y = owner->ob_inlet))
{ {
while (y2 = y->i_next) y = y2; while((y2 = y->i_next)) y = y2;
y->i_next = x; y->i_next = x;
} }
else owner->ob_inlet = x; else owner->ob_inlet = x;
@ -198,9 +200,9 @@ t_inlet *symbolinlet_new(t_object *owner, t_symbol **sp)
x->i_symfrom = &s_symbol; x->i_symfrom = &s_symbol;
x->i_symslot = sp; x->i_symslot = sp;
x->i_next = 0; x->i_next = 0;
if (y = owner->ob_inlet) if((y = owner->ob_inlet))
{ {
while (y2 = y->i_next) y = y2; while((y2 = y->i_next)) y = y2;
y->i_next = x; y->i_next = x;
} }
else owner->ob_inlet = x; else owner->ob_inlet = x;
@ -217,6 +219,11 @@ void obj_list(t_object *x, t_symbol *s, int argc, t_atom *argv)
t_atom *ap; t_atom *ap;
int count; int count;
t_inlet *ip = ((t_object *)x)->ob_inlet; t_inlet *ip = ((t_object *)x)->ob_inlet;
#ifdef ROCKBOX
(void) s;
#endif
if (!argc) return; if (!argc) return;
for (count = argc-1, ap = argv+1; ip && count--; ap++, ip = ip->i_next) for (count = argc-1, ap = argv+1; ip && count--; ap++, ip = ip->i_next)
{ {
@ -296,9 +303,9 @@ t_outlet *outlet_new(t_object *owner, t_symbol *s)
t_outlet *x = (t_outlet *)getbytes(sizeof(*x)), *y, *y2; t_outlet *x = (t_outlet *)getbytes(sizeof(*x)), *y, *y2;
x->o_owner = owner; x->o_owner = owner;
x->o_next = 0; x->o_next = 0;
if (y = owner->ob_outlet) if((y = owner->ob_outlet))
{ {
while (y2 = y->o_next) y = y2; while((y2 = y->o_next)) y = y2;
y->o_next = x; y->o_next = x;
} }
else owner->ob_outlet = x; else owner->ob_outlet = x;
@ -474,7 +481,7 @@ doit:
freebytes(oc, sizeof(*oc)); freebytes(oc, sizeof(*oc));
goto done; goto done;
} }
while (oc2 = oc->oc_next) while((oc2 = oc->oc_next))
{ {
if (oc2->oc_to == to) if (oc2->oc_to == to)
{ {

View file

@ -2,10 +2,15 @@
* For information on usage and redistribution, and for a DISCLAIMER OF ALL * For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
#include <stdlib.h>
#include "m_pd.h" #include "m_pd.h"
#include "m_imp.h" #include "m_imp.h"
#ifdef ROCKBOX
void pd_checkgui(t_pd *x, t_symbol *s);
#else /* ROCKBOX */
#include <stdlib.h>
#endif /* ROCKBOX */
/* FIXME no out-of-memory testing yet! */ /* FIXME no out-of-memory testing yet! */
t_pd *pd_new(t_class *c) t_pd *pd_new(t_class *c)
@ -166,7 +171,7 @@ void pd_unbind(t_pd *x, t_symbol *s)
b->b_list = e->e_next; b->b_list = e->e_next;
freebytes(e, sizeof(t_bindelem)); freebytes(e, sizeof(t_bindelem));
} }
else for (e = b->b_list; e2 = e->e_next; e = e2) else for (e = b->b_list; (e2 = e->e_next); e = e2)
if (e2->e_who == x) if (e2->e_who == x)
{ {
e->e_next = e2->e_next; e->e_next = e2->e_next;
@ -194,8 +199,13 @@ t_pd *pd_findbyclass(t_symbol *s, t_class *c)
if (*s->s_thing == bindlist_class) if (*s->s_thing == bindlist_class)
{ {
t_bindlist *b = (t_bindlist *)s->s_thing; t_bindlist *b = (t_bindlist *)s->s_thing;
#ifdef ROCKBOX
t_bindelem *e;
#else /* ROCKBOX */
t_bindelem *e, *e2; t_bindelem *e, *e2;
#endif /* ROCKBOX */
int warned = 0; int warned = 0;
for (e = b->b_list; e; e = e->e_next) for (e = b->b_list; e; e = e->e_next)
if (*e->e_who == c) if (*e->e_who == c)
{ {
@ -288,6 +298,9 @@ void pd_symbol(t_pd *x, t_symbol *s)
void pd_list(t_pd *x, t_symbol *s, int argc, t_atom *argv) void pd_list(t_pd *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
(*(*x)->c_listmethod)(x, &s_list, argc, argv); (*(*x)->c_listmethod)(x, &s_list, argc, argv);
} }

View file

@ -2,6 +2,11 @@
* For information on usage and redistribution, and for a DISCLAIMER OF ALL * For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#endif
/* scheduling stuff */ /* scheduling stuff */
#include "m_pd.h" #include "m_pd.h"
@ -14,13 +19,21 @@
/* T.Grill - enable PD global thread locking - sys_lock, sys_unlock, sys_trylock functions */ /* T.Grill - enable PD global thread locking - sys_lock, sys_unlock, sys_trylock functions */
#define THREAD_LOCKING #ifndef ROCKBOX
#define THREAD_LOCKING
#include "pthread.h" #include "pthread.h"
#endif
static int sys_quit; static int sys_quit;
static t_time sys_time; #ifndef ROCKBOX
static t_time sys_time_per_msec = TIMEUNITPERSEC / 1000.; static
#endif
t_time sys_time;
#ifndef ROCKBOX
static
#endif
t_time sys_time_per_msec = TIMEUNITPERSEC / 1000.;
int sys_schedblocksize = DEFDACBLKSIZE; int sys_schedblocksize = DEFDACBLKSIZE;
int sys_usecsincelastsleep(void); int sys_usecsincelastsleep(void);
@ -133,9 +146,12 @@ static int sys_bin[] = {0, 2, 5, 10, 20, 30, 50, 100, 1000};
#define NBIN (sizeof(sys_bin)/sizeof(*sys_bin)) #define NBIN (sizeof(sys_bin)/sizeof(*sys_bin))
#define NHIST 10 #define NHIST 10
static int sys_histogram[NHIST][NBIN]; static int sys_histogram[NHIST][NBIN];
#ifndef ROCKBOX
static t_time sys_histtime; static t_time sys_histtime;
#endif
static int sched_diddsp, sched_didpoll, sched_didnothing; static int sched_diddsp, sched_didpoll, sched_didnothing;
#ifndef ROCKBOX
static void sys_clearhist( void) static void sys_clearhist( void)
{ {
unsigned int i, j; unsigned int i, j;
@ -144,6 +160,7 @@ static void sys_clearhist( void)
sys_histtime = sys_getrealtime(); sys_histtime = sys_getrealtime();
sched_diddsp = sched_didpoll = sched_didnothing = 0; sched_diddsp = sched_didpoll = sched_didnothing = 0;
} }
#endif
void sys_printhist( void) void sys_printhist( void)
{ {
@ -169,10 +186,15 @@ void sys_printhist( void)
sched_diddsp, sched_didpoll, sched_didnothing); sched_diddsp, sched_didpoll, sched_didnothing);
} }
#ifndef ROCKBOX
static int sys_histphase; static int sys_histphase;
#endif
int sys_addhist(int phase) int sys_addhist(int phase)
{ {
#ifdef ROCKBOX
(void) phase;
#endif
#ifndef FIXEDPOINT #ifndef FIXEDPOINT
int i, j, phasewas = sys_histphase; int i, j, phasewas = sys_histphase;
t_time newtime = sys_getrealtime(); t_time newtime = sys_getrealtime();
@ -216,7 +238,11 @@ static char *(oss_errornames[]) = {
void glob_audiostatus(void) void glob_audiostatus(void)
{ {
#ifdef ROCKBOX
int nresync, nresyncphase, i;
#else
int dev, nresync, nresyncphase, i; int dev, nresync, nresyncphase, i;
#endif
nresync = (oss_nresync >= NRESYNC ? NRESYNC : oss_nresync); nresync = (oss_nresync >= NRESYNC ? NRESYNC : oss_nresync);
nresyncphase = oss_resyncphase - 1; nresyncphase = oss_resyncphase - 1;
post("audio I/O error history:"); post("audio I/O error history:");
@ -251,7 +277,9 @@ void sys_log_error(int type)
if (type != ERR_NOTHING && !sched_diored && if (type != ERR_NOTHING && !sched_diored &&
(sched_diddsp >= sched_dioredtime)) (sched_diddsp >= sched_dioredtime))
{ {
#ifndef ROCKBOX
sys_vgui("pdtk_pd_dio 1\n"); sys_vgui("pdtk_pd_dio 1\n");
#endif
sched_diored = 1; sched_diored = 1;
} }
sched_dioredtime = sched_dioredtime =
@ -263,6 +291,7 @@ static int sched_lastinclip, sched_lastoutclip,
void glob_ping(t_pd *dummy); void glob_ping(t_pd *dummy);
#ifndef ROCKBOX
static void sched_pollformeters( void) static void sched_pollformeters( void)
{ {
int inclip, outclip, indb, outdb; int inclip, outclip, indb, outdb;
@ -313,9 +342,13 @@ static void sched_pollformeters( void)
sched_nextmeterpolltime = sched_nextmeterpolltime =
sched_diddsp + (int)(sys_dacsr /(double)sys_schedblocksize); sched_diddsp + (int)(sys_dacsr /(double)sys_schedblocksize);
} }
#endif /* ROCKBOX */
void glob_meters(void *dummy, float f) void glob_meters(void *dummy, float f)
{ {
#ifdef ROCKBOX
(void) dummy;
#endif
if (f == 0) if (f == 0)
sys_getmeters(0, 0); sys_getmeters(0, 0);
sched_meterson = (f != 0); sched_meterson = (f != 0);
@ -335,7 +368,10 @@ void dsp_tick(void);
static int sched_usedacs = 1; static int sched_usedacs = 1;
static t_time sched_referencerealtime, sched_referencelogicaltime; static t_time sched_referencerealtime, sched_referencelogicaltime;
static t_time sys_time_per_dsp_tick; #ifndef ROCKBOX
static
#endif
t_time sys_time_per_dsp_tick;
void sched_set_using_dacs(int flag) void sched_set_using_dacs(int flag)
{ {
@ -344,14 +380,24 @@ void sched_set_using_dacs(int flag)
{ {
sched_referencerealtime = sys_getrealtime(); sched_referencerealtime = sys_getrealtime();
sched_referencelogicaltime = clock_getlogicaltime(); sched_referencelogicaltime = clock_getlogicaltime();
#ifndef ROCKBOX
post("schedsetuding"); post("schedsetuding");
#endif
} }
sys_time_per_dsp_tick = (TIMEUNITPERSEC) * sys_time_per_dsp_tick = (TIMEUNITPERSEC) *
((double)sys_schedblocksize) / sys_dacsr; ((double)sys_schedblocksize) / sys_dacsr;
/*
#ifdef SIMULATOR
printf("%f\n%f\n%f\n%f\n", (double)sys_time_per_dsp_tick, (double)TIMEUNITPERSEC, (double) sys_schedblocksize, (double)sys_dacsr);
#endif
*/
} }
/* take the scheduler forward one DSP tick, also handling clock timeouts */ /* take the scheduler forward one DSP tick, also handling clock timeouts */
static void sched_tick(t_time next_sys_time) #ifndef ROCKBOX
static
#endif
void sched_tick(t_time next_sys_time)
{ {
int countdown = 5000; int countdown = 5000;
while (clock_setlist && clock_setlist->c_settime < next_sys_time) while (clock_setlist && clock_setlist->c_settime < next_sys_time)
@ -364,7 +410,9 @@ static void sched_tick(t_time next_sys_time)
if (!countdown--) if (!countdown--)
{ {
countdown = 5000; countdown = 5000;
#ifndef ROCKBOX
sys_pollgui(); sys_pollgui();
#endif
} }
if (sys_quit) if (sys_quit)
return; return;
@ -388,9 +436,11 @@ the audio I/O system is still busy with previous transfers.
void sys_pollmidiqueue( void); void sys_pollmidiqueue( void);
void sys_initmidiqueue( void); void sys_initmidiqueue( void);
#ifndef ROCKBOX
int m_scheduler_pda( void) int m_scheduler_pda( void)
{ {
int idlecount = 0; int idlecount = 0;
sys_time_per_dsp_tick = (TIMEUNITPERSEC) * sys_time_per_dsp_tick = (TIMEUNITPERSEC) *
((double)sys_schedblocksize) / sys_dacsr; ((double)sys_schedblocksize) / sys_dacsr;
@ -402,13 +452,18 @@ int m_scheduler_pda( void)
sys_sleepgrain = 100; sys_sleepgrain = 100;
else if (sys_sleepgrain > 5000) else if (sys_sleepgrain > 5000)
sys_sleepgrain = 5000; sys_sleepgrain = 5000;
sys_initmidiqueue(); sys_initmidiqueue();
while (!sys_quit) while (!sys_quit)
{ {
int didsomething = 0; int didsomething = 0;
int timeforward; int timeforward;
sys_addhist(0); sys_addhist(0);
waitfortick: waitfortick:
if (sched_usedacs) if (sched_usedacs)
{ {
@ -564,7 +619,7 @@ int sys_trylock(void)
void sys_lock(void) {} void sys_lock(void) {}
void sys_unlock(void) {} void sys_unlock(void) {}
int sys_trylock(void) {} int sys_trylock(void) { return 0; }
#endif #endif
@ -580,3 +635,4 @@ void sys_exit(void)
sys_quit = 1; sys_quit = 1;
} }
#endif /* ROCKBOX */

View file

@ -6,6 +6,13 @@
audio settings from argparse routine and from dialog window. audio settings from argparse routine and from dialog window.
*/ */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "s_stuff.h"
#define snprintf rb->snprintf
#else /* ROCKBOX */
#include "m_pd.h" #include "m_pd.h"
#include "s_stuff.h" #include "s_stuff.h"
#include <stdio.h> #include <stdio.h>
@ -17,6 +24,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#endif /* ROCKBOX */
#define SYS_DEFAULTCH 2 #define SYS_DEFAULTCH 2
#define SYS_MAXCH 100 #define SYS_MAXCH 100
@ -116,7 +124,11 @@ static void sys_save_audio_params(
void oss_init(void); void oss_init(void);
#endif #endif
#ifdef ROCKBOX
static void pd_audio_init(void)
#else
static void audio_init( void) static void audio_init( void)
#endif
{ {
static int initted = 0; static int initted = 0;
if (initted) if (initted)
@ -131,7 +143,9 @@ static void audio_init( void)
static void sys_setchsr(int chin, int chout, int sr) static void sys_setchsr(int chin, int chout, int sr)
{ {
#ifndef ROCKBOX
int nblk; int nblk;
#endif
int inbytes = (chin ? chin : 2) * (DEFDACBLKSIZE*sizeof(float)); int inbytes = (chin ? chin : 2) * (DEFDACBLKSIZE*sizeof(float));
int outbytes = (chout ? chout : 2) * (DEFDACBLKSIZE*sizeof(float)); int outbytes = (chout ? chout : 2) * (DEFDACBLKSIZE*sizeof(float));
@ -144,12 +158,20 @@ static void sys_setchsr(int chin, int chout, int sr)
if (sys_soundin) if (sys_soundin)
free(sys_soundin); free(sys_soundin);
#ifdef ROCKBOX
sys_soundin = (t_sample*) malloc(inbytes);
#else
sys_soundin = (t_float *)malloc(inbytes); sys_soundin = (t_float *)malloc(inbytes);
#endif
memset(sys_soundin, 0, inbytes); memset(sys_soundin, 0, inbytes);
if (sys_soundout) if (sys_soundout)
free(sys_soundout); free(sys_soundout);
#ifdef ROCKBOX
sys_soundout = (t_sample*) malloc(outbytes);
#else
sys_soundout = (t_float *)malloc(outbytes); sys_soundout = (t_float *)malloc(outbytes);
#endif
memset(sys_soundout, 0, outbytes); memset(sys_soundout, 0, outbytes);
if (sys_verbose) if (sys_verbose)
@ -169,12 +191,20 @@ void sys_open_audio(int naudioindev, int *audioindev, int nchindev,
int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev, int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev,
int *choutdev, int rate, int advance, int enable) int *choutdev, int rate, int advance, int enable)
{ {
#ifdef ROCKBOX
int i;
#else
int i, *ip; int i, *ip;
#endif
int defaultchannels = SYS_DEFAULTCH; int defaultchannels = SYS_DEFAULTCH;
int inchans, outchans; int inchans, outchans;
if (rate < 1) if (rate < 1)
rate = SYS_DEFAULTSRATE; rate = SYS_DEFAULTSRATE;
#ifdef ROCKBOX
pd_audio_init();
#else
audio_init(); audio_init();
#endif
/* Since the channel vector might be longer than the /* Since the channel vector might be longer than the
audio device vector, or vice versa, we fill the shorter one audio device vector, or vice versa, we fill the shorter one
in to match the longer one. Also, if both are empty, we fill in in to match the longer one. Also, if both are empty, we fill in
@ -329,6 +359,11 @@ else
mmio_open_audio(naudioindev, audioindev, nchindev, chindev, mmio_open_audio(naudioindev, audioindev, nchindev, chindev,
naudiooutdev, audiooutdev, nchoutdev, choutdev, rate); naudiooutdev, audiooutdev, nchoutdev, choutdev, rate);
else else
#endif
#ifdef USEAPI_ROCKBOX
if (sys_audioapi == API_ROCKBOX)
rockbox_open_audio(rate);
else
#endif #endif
post("unknown audio API specified"); post("unknown audio API specified");
} }
@ -337,7 +372,9 @@ else
if (sys_inchannels == 0 && sys_outchannels == 0) if (sys_inchannels == 0 && sys_outchannels == 0)
enable = 0; enable = 0;
audio_state = enable; audio_state = enable;
#ifndef ROCKBOX
sys_vgui("set pd_whichapi %d\n", (audio_isopen() ? sys_audioapi : 0)); sys_vgui("set pd_whichapi %d\n", (audio_isopen() ? sys_audioapi : 0));
#endif
sched_set_using_dacs(enable); sched_set_using_dacs(enable);
} }
@ -369,6 +406,11 @@ void sys_close_audio(void)
if (sys_audioapi == API_MMIO) if (sys_audioapi == API_MMIO)
mmio_close_audio(); mmio_close_audio();
else else
#endif
#ifdef USEAPI_ROCKBOX
if (sys_audioapi == API_ROCKBOX)
rockbox_close_audio();
else
#endif #endif
post("sys_close_audio: unknown API %d", sys_audioapi); post("sys_close_audio: unknown API %d", sys_audioapi);
sys_inchannels = sys_outchannels = 0; sys_inchannels = sys_outchannels = 0;
@ -434,6 +476,11 @@ int sys_send_dacs(void)
if (sys_audioapi == API_MMIO) if (sys_audioapi == API_MMIO)
return (mmio_send_dacs()); return (mmio_send_dacs());
else else
#endif
#ifdef USEAPI_ROCKBOX
if (sys_audioapi == API_ROCKBOX)
return (rockbox_send_dacs());
else
#endif #endif
post("unknown API"); post("unknown API");
return (0); return (0);
@ -482,11 +529,17 @@ void sys_reportidle(void)
#define MAXNDEV 20 #define MAXNDEV 20
#define DEVDESCSIZE 80 #define DEVDESCSIZE 80
#ifndef ROCKBOX
static void audio_getdevs(char *indevlist, int *nindevs, static void audio_getdevs(char *indevlist, int *nindevs,
char *outdevlist, int *noutdevs, int *canmulti, char *outdevlist, int *noutdevs, int *canmulti,
int maxndev, int devdescsize) int maxndev, int devdescsize)
{ {
#ifdef ROCKBOX
(void) maxndev;
pd_audio_init();
#else
audio_init(); audio_init();
#endif /* ROCKBOX */
#ifdef USEAPI_OSS #ifdef USEAPI_OSS
if (sys_audioapi == API_OSS) if (sys_audioapi == API_OSS)
{ {
@ -518,6 +571,13 @@ static void audio_getdevs(char *indevlist, int *nindevs,
maxndev, devdescsize); maxndev, devdescsize);
} }
else else
#endif
#ifdef USEAPI_ROCKBOX
if (sys_audioapi == API_ROCKBOX)
{
/* Rockbox devices are known in advance. (?) */
}
else
#endif #endif
{ {
/* this shouldn't happen once all the above get filled in. */ /* this shouldn't happen once all the above get filled in. */
@ -531,6 +591,7 @@ static void audio_getdevs(char *indevlist, int *nindevs,
*canmulti = 0; *canmulti = 0;
} }
} }
#endif
#ifdef MSW #ifdef MSW
#define DEVONSET 0 /* microsoft device list starts at 0 (the "mapper"). */ #define DEVONSET 0 /* microsoft device list starts at 0 (the "mapper"). */
@ -538,6 +599,7 @@ static void audio_getdevs(char *indevlist, int *nindevs,
#define DEVONSET 1 /* To agree with command line flags, normally start at 1 */ #define DEVONSET 1 /* To agree with command line flags, normally start at 1 */
#endif #endif
#ifndef ROCKBOX
static void sys_listaudiodevs(void ) static void sys_listaudiodevs(void )
{ {
char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE]; char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE];
@ -564,8 +626,10 @@ static void sys_listaudiodevs(void )
} }
post("API number %d\n", sys_audioapi); post("API number %d\n", sys_audioapi);
} }
#endif
/* start an audio settings dialog window */ /* start an audio settings dialog window */
#ifndef ROCKBOX
void glob_audio_properties(t_pd *dummy, t_floatarg flongform) void glob_audio_properties(t_pd *dummy, t_floatarg flongform)
{ {
char buf[1024 + 2 * MAXNDEV*(DEVDESCSIZE+4)]; char buf[1024 + 2 * MAXNDEV*(DEVDESCSIZE+4)];
@ -645,8 +709,10 @@ void glob_audio_properties(t_pd *dummy, t_floatarg flongform)
gfxstub_deleteforkey(0); gfxstub_deleteforkey(0);
gfxstub_new(&glob_pdobject, glob_audio_properties, buf); gfxstub_new(&glob_pdobject, glob_audio_properties, buf);
} }
#endif
/* new values from dialog window */ /* new values from dialog window */
#ifndef ROCKBOX
void glob_audio_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv) void glob_audio_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
{ {
int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV]; int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];
@ -696,6 +762,7 @@ void glob_audio_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
noutdev, newaudiooutdev, noutdev, newaudiooutchan, noutdev, newaudiooutdev, noutdev, newaudiooutchan,
newrate, newadvance, 1); newrate, newadvance, 1);
} }
#endif
void sys_listdevs(void ) void sys_listdevs(void )
{ {
@ -723,6 +790,13 @@ void sys_listdevs(void )
if (sys_audioapi == API_ALSA) if (sys_audioapi == API_ALSA)
sys_listaudiodevs(); sys_listaudiodevs();
else else
#endif
#ifdef USEAPI_ROCKBOX
if (sys_audioapi == API_ROCKBOX)
{
/* Nothing to list, IMO. */
}
else
#endif #endif
post("unknown API"); post("unknown API");
@ -746,9 +820,11 @@ void sys_set_audio_api(int which)
post("sys_audioapi %d", sys_audioapi); post("sys_audioapi %d", sys_audioapi);
} }
#ifndef ROCKBOX
void glob_audio_setapi(void *dummy, t_floatarg f) void glob_audio_setapi(void *dummy, t_floatarg f)
{ {
int newapi = f; int newapi = f;
if (newapi) if (newapi)
{ {
if (newapi == sys_audioapi) if (newapi == sys_audioapi)
@ -775,6 +851,7 @@ void glob_audio_setapi(void *dummy, t_floatarg f)
sched_set_using_dacs(0); sched_set_using_dacs(0);
} }
} }
#endif
/* start or stop the audio hardware */ /* start or stop the audio hardware */
void sys_set_audio_state(int onoff) void sys_set_audio_state(int onoff)
@ -842,6 +919,10 @@ void alsa_printstate( void);
void glob_foo(void *dummy, t_symbol *s, int argc, t_atom *argv) void glob_foo(void *dummy, t_symbol *s, int argc, t_atom *argv)
{ {
t_symbol *arg = atom_getsymbolarg(0, argc, argv); t_symbol *arg = atom_getsymbolarg(0, argc, argv);
#ifdef ROCKBOX
(void) dummy;
(void) s;
#endif
if (arg == gensym("restart")) if (arg == gensym("restart"))
{ {
int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV]; int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];

View file

@ -0,0 +1,144 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2009 Wincent Balin
*
* 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "s_stuff.h"
/* Sound output buffer. */
#define AUDIO_OUTPUT_BLOCKS 3
static struct pdbox_audio_block audio_output[AUDIO_OUTPUT_BLOCKS];
static unsigned int output_head;
static unsigned int output_tail;
static unsigned int output_fill;
/* Open audio. */
void rockbox_open_audio(int rate)
{
unsigned int i;
/* Initialize output buffer. */
for(i = 0; i < AUDIO_OUTPUT_BLOCKS; i++)
audio_output[i].fill = 0;
output_head = 0;
output_tail = 0;
output_fill = 0;
#if INPUT_SRC_CAPS != 0
/* Select playback */
rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
rb->audio_set_output_source(AUDIO_SRC_PLAYBACK);
#endif
/* Set sample rate of the audio buffer. */
rb->pcm_set_frequency(rate);
}
/* Close audio. */
void rockbox_close_audio(void)
{
/* Stop playback. */
rb->pcm_play_stop();
/* Restore default sampling rate. */
rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
}
/* Rockbox audio callback. */
void pdbox_get_more(unsigned char** start, size_t* size)
{
if(output_fill > 0)
{
/* Store output data address and size. */
*start = (unsigned char*) audio_output[output_tail].data;
*size = audio_output[output_tail].fill;
/* Advance tail index. */
audio_output[output_tail].fill = 0;
output_fill--;
if(output_tail == AUDIO_OUTPUT_BLOCKS-1)
output_tail = 0;
else
output_tail++;
}
else
{
/* Nothing to play. */
*start = NULL;
*size = 0;
return;
}
}
/* Audio I/O. */
int rockbox_send_dacs(void)
{
/* Start playback if needed and possible. */
if(output_fill > 1 &&
audio_output[output_tail].fill == PD_AUDIO_BLOCK_SIZE)
{
/* Start playback. */
rb->pcm_play_data(pdbox_get_more,
(unsigned char*) audio_output[output_tail].data,
PD_AUDIO_BLOCK_SIZE);
/* Advance tail index. */
audio_output[output_tail].fill = PD_AUDIO_BLOCK_SIZE;
output_fill--;
if(output_tail == AUDIO_OUTPUT_BLOCKS-1)
output_tail = 0;
else
output_tail++;
}
#if 0
if (sys_getrealtime() > timebefore + 0.002)
{
/* post("slept"); */
return (SENDDACS_SLEPT);
}
else
#endif
return (SENDDACS_YES);
}
/* Placeholder. */
void rockbox_listdevs(void)
{
}
#if 0
/* Scanning for devices */
void rockbox_getdevs(char *indevlist, int *nindevs,
char *outdevlist, int *noutdevs, int *canmulti,
int maxndev, int devdescsize)
{
}
#endif

View file

@ -6,14 +6,32 @@
* this file contains file-handling routines. * this file contains file-handling routines.
*/ */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "s_stuff.h"
#else /* ROCKBOX */
#include "m_pd.h" #include "m_pd.h"
#include "s_stuff.h" #include "s_stuff.h"
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#endif /* ROCKBOX */
/* LATER delete this? -- replaced by find_via_path() in s_path.c */ /* LATER delete this? -- replaced by find_via_path() in s_path.c */
int sys_isreadablefile(const char *s) int sys_isreadablefile(const char *s)
{ {
#ifdef ROCKBOX
int fd;
if((fd = open(s, O_RDONLY)))
{
close(fd);
return 1;
}
else
return 0;
#else /* ROCKBOX */
struct stat statbuf; struct stat statbuf;
int mode; int mode;
if (stat(s, &statbuf) < 0) return (0); if (stat(s, &statbuf) < 0) return (0);
@ -22,13 +40,14 @@ int sys_isreadablefile(const char *s)
if (S_ISDIR(mode)) return (0); if (S_ISDIR(mode)) return (0);
#endif #endif
return (1); return (1);
#endif /* ROCKBOX */
} }
/* change '/' characters to the system's native file separator */ /* change '/' characters to the system's native file separator */
void sys_bashfilename(const char *from, char *to) void sys_bashfilename(const char *from, char *to)
{ {
char c; char c;
while (c = *from++) while((c = *from++))
{ {
#ifdef MSW #ifdef MSW
if (c == '/') c = '\\'; if (c == '/') c = '\\';
@ -43,7 +62,7 @@ void sys_bashfilename(const char *from, char *to)
void sys_unbashfilename(const char *from, char *to) void sys_unbashfilename(const char *from, char *to)
{ {
char c; char c;
while (c = *from++) while((c = *from++))
{ {
#ifdef MSW #ifdef MSW
if (c == '\\') c = '/'; if (c == '\\') c = '/';

View file

@ -2,6 +2,10 @@
* For information on usage and redistribution, and for a DISCLAIMER OF ALL * For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#else /* ROCKBOX */
#ifdef DL_OPEN #ifdef DL_OPEN
#include <dlfcn.h> #include <dlfcn.h>
#endif #endif
@ -17,12 +21,14 @@
#include <mach-o/dyld.h> #include <mach-o/dyld.h>
#endif #endif
#include <string.h> #include <string.h>
#include <stdio.h>
#endif /* ROCKBOX */
#include "m_pd.h" #include "m_pd.h"
#include "s_stuff.h" #include "s_stuff.h"
#include <stdio.h>
typedef void (*t_xxx)(void); typedef void (*t_xxx)(void);
#ifndef ROCKBOX
static char sys_dllextent[] = static char sys_dllextent[] =
#ifdef __FreeBSD__ #ifdef __FreeBSD__
".pd_freebsd"; ".pd_freebsd";
@ -43,12 +49,22 @@ static char sys_dllextent[] =
#ifdef MSW #ifdef MSW
".dll"; ".dll";
#endif #endif
#endif /* ROCKBOX */
void class_set_extern_dir(t_symbol *s); void class_set_extern_dir(t_symbol *s);
#ifdef STATIC #ifdef STATIC
int sys_load_lib(char *dirname, char *classname) int sys_load_lib(char *dirname, char *classname)
#ifdef ROCKBOX
{
(void) dirname;
(void) classname;
return 0;
}
#else /* ROCKBOX */
{ return 0;} { return 0;}
#endif /* ROCKBOX */
#else #else
int sys_load_lib(char *dirname, char *classname) int sys_load_lib(char *dirname, char *classname)
{ {

View file

@ -14,6 +14,26 @@
#define DEBUG(x) #define DEBUG(x)
void readsf_banana( void); /* debugging */ void readsf_banana( void); /* debugging */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#include "m_pd.h"
#include "m_imp.h"
#include "s_stuff.h"
#define open rb->open
#define close rb->close
#define strcpy rb->strcpy
#define strcat rb->strcat
#define strlen rb->strlen
#define strcmp rb->strcmp
#define strncpy rb->strncpy
#define strrchr rb->strrchr
#define strncat rb_strncat
#else /* ROCKBOX */
#include <stdlib.h> #include <stdlib.h>
#ifdef UNIX #ifdef UNIX
#include <unistd.h> #include <unistd.h>
@ -29,6 +49,7 @@ void readsf_banana( void); /* debugging */
#include "s_stuff.h" #include "s_stuff.h"
#include <stdio.h> #include <stdio.h>
#include <fcntl.h> #include <fcntl.h>
#endif /* ROCKBOX */
static t_namelist *pd_path, *pd_helppath; static t_namelist *pd_path, *pd_helppath;
@ -85,6 +106,10 @@ t_namelist *namelist_append(t_namelist *listwas, const char *s)
char temp[MAXPDSTRING]; char temp[MAXPDSTRING];
t_namelist *nl = listwas, *rtn = listwas; t_namelist *nl = listwas, *rtn = listwas;
#ifdef ROCKBOX
(void) rtn;
#endif
npos = s; npos = s;
do do
{ {
@ -138,6 +163,10 @@ int open_via_path(const char *dir, const char *name, const char* ext,
int fd = -1; int fd = -1;
char listbuf[MAXPDSTRING]; char listbuf[MAXPDSTRING];
#ifdef ROCKBOX
(void) bin;
#endif
if (name[0] == '/' if (name[0] == '/'
#ifdef MSW #ifdef MSW
|| (name[1] == ':' && name[2] == '/') || (name[1] == ':' && name[2] == '/')
@ -191,6 +220,7 @@ int open_via_path(const char *dir, const char *name, const char* ext,
char *slash; char *slash;
if (sys_verbose) post("tried %s and succeeded", dirresult); if (sys_verbose) post("tried %s and succeeded", dirresult);
sys_unbashfilename(dirresult, dirresult); sys_unbashfilename(dirresult, dirresult);
slash = strrchr(dirresult, '/'); slash = strrchr(dirresult, '/');
if (slash) if (slash)
{ {
@ -199,7 +229,7 @@ int open_via_path(const char *dir, const char *name, const char* ext,
} }
else *nameresult = dirresult; else *nameresult = dirresult;
return (fd); return (fd);
} }
} }
else else
@ -245,7 +275,9 @@ static int do_open_via_helppath(const char *realname, t_namelist *listp)
else else
#endif #endif
{ {
#ifndef ROCKBOX
char *slash; char *slash;
#endif
if (sys_verbose) post("tried %s and succeeded", dirresult); if (sys_verbose) post("tried %s and succeeded", dirresult);
sys_unbashfilename(dirresult, dirresult); sys_unbashfilename(dirresult, dirresult);
close (fd); close (fd);
@ -266,8 +298,12 @@ static int do_open_via_helppath(const char *realname, t_namelist *listp)
search attempts. */ search attempts. */
void open_via_helppath(const char *name, const char *dir) void open_via_helppath(const char *name, const char *dir)
{ {
#ifdef ROCKBOX
t_namelist thislist, *listp;
#else /*ROCKBOX */
t_namelist *nl, thislist, *listp; t_namelist *nl, thislist, *listp;
int fd = -1; int fd = -1;
#endif /* ROCKBOX */
char dirbuf2[MAXPDSTRING], realname[MAXPDSTRING]; char dirbuf2[MAXPDSTRING], realname[MAXPDSTRING];
/* if directory is supplied, put it at head of search list. */ /* if directory is supplied, put it at head of search list. */
@ -380,6 +416,10 @@ int sys_rcfile(void)
/* start an audio settings dialog window */ /* start an audio settings dialog window */
void glob_start_path_dialog(t_pd *dummy, t_floatarg flongform) void glob_start_path_dialog(t_pd *dummy, t_floatarg flongform)
{ {
#ifdef ROCKBOX
(void) dummy;
(void) flongform;
#else /* ROCKBOX */
char buf[MAXPDSTRING]; char buf[MAXPDSTRING];
int i; int i;
t_namelist *nl; t_namelist *nl;
@ -391,12 +431,19 @@ void glob_start_path_dialog(t_pd *dummy, t_floatarg flongform)
sprintf(buf, "pdtk_path_dialog %%s\n"); sprintf(buf, "pdtk_path_dialog %%s\n");
gfxstub_new(&glob_pdobject, glob_start_path_dialog, buf); gfxstub_new(&glob_pdobject, glob_start_path_dialog, buf);
#endif /* ROCKBOX */
} }
/* new values from dialog window */ /* new values from dialog window */
void glob_path_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv) void glob_path_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
{ {
int i; int i;
#ifdef ROCKBOX
(void) dummy;
(void) s;
#endif /* ROCKBOX */
namelist_free(pd_path); namelist_free(pd_path);
pd_path = 0; pd_path = 0;
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)

View file

@ -79,7 +79,7 @@ void poststring(char *s)
#ifdef SIMULATOR #ifdef SIMULATOR
printf(" %s", s); printf(" %s", s);
#else /* SIMULATOR */ #else /* SIMULATOR */
(void)s; (void) s;
#endif /* SIMULATOR */ #endif /* SIMULATOR */
#else /* ROCKBOX */ #else /* ROCKBOX */
fprintf(stderr, " %s", s); fprintf(stderr, " %s", s);
@ -167,7 +167,7 @@ void pd_error(void *object, char *fmt, ...)
saidit = 1; saidit = 1;
} }
#else /* SIMULATOR */ #else /* SIMULATOR */
(void)object; (void) object;
(void) fmt; (void) fmt;
#endif /* SIMULATOR */ #endif /* SIMULATOR */
#else /* ROCKBOX */ #else /* ROCKBOX */
@ -191,7 +191,7 @@ void pd_error(void *object, char *fmt, ...)
void glob_finderror(t_pd *dummy) void glob_finderror(t_pd *dummy)
{ {
#ifdef ROCKBOX #ifdef ROCKBOX
(void)dummy; (void) dummy;
#endif /* ROCKBOX */ #endif /* ROCKBOX */
if (!error_object) if (!error_object)
post("no findable error yet."); post("no findable error yet.");
@ -250,8 +250,12 @@ void sys_logerror(char *object, char *s)
void sys_unixerror(char *object) void sys_unixerror(char *object)
{ {
#ifdef ROCKBOX
(void) object;
#else
errobject = object; errobject = object;
errstring = strerror(errno); errstring = strerror(errno);
#endif /* ROCKBOX */
} }
void sys_ouch(void) void sys_ouch(void)

View file

@ -130,8 +130,9 @@ void sys_setvirtualalarm( void);
#define API_MMIO 3 #define API_MMIO 3
#define API_PORTAUDIO 4 #define API_PORTAUDIO 4
#define API_JACK 5 #define API_JACK 5
#define API_ROCKBOX 6
#ifdef __linux__ #if defined(__linux__) && !defined(ROCKBOX)
#define API_DEFAULT API_OSS #define API_DEFAULT API_OSS
#define API_DEFSTRING "OSS" #define API_DEFSTRING "OSS"
#endif #endif
@ -143,6 +144,10 @@ void sys_setvirtualalarm( void);
#define API_DEFAULT API_PORTAUDIO #define API_DEFAULT API_PORTAUDIO
#define API_DEFSTRING "portaudio" #define API_DEFSTRING "portaudio"
#endif #endif
#ifdef ROCKBOX
#define API_DEFAULT API_ROCKBOX
#define API_DEFSTRING "Rockbox"
#endif
#define DEFAULTAUDIODEV 0 #define DEFAULTAUDIODEV 0
#define MAXAUDIOINDEV 4 #define MAXAUDIOINDEV 4
@ -204,6 +209,11 @@ void mmio_getdevs(char *indevlist, int *nindevs,
char *outdevlist, int *noutdevs, int *canmulti, char *outdevlist, int *noutdevs, int *canmulti,
int maxndev, int devdescsize); int maxndev, int devdescsize);
void rockbox_open_audio(int rate);
void rockbox_close_audio(void);
int rockbox_send_dacs(void);
void rockbox_getdevs(void);
void sys_listmididevs(void); void sys_listmididevs(void);
void sys_set_audio_api(int whichapi); void sys_set_audio_api(int whichapi);
void sys_get_audio_apis(char *buf); void sys_get_audio_apis(char *buf);

View file

@ -5,6 +5,11 @@
/* utility functions for signals /* utility functions for signals
*/ */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#endif
#include "m_pd.h" #include "m_pd.h"
#include <math.h> #include <math.h>
#define LOGTEN 2.302585092994 #define LOGTEN 2.302585092994

View file

@ -6,6 +6,11 @@
done on floats; the logical and bitwise binops convert their done on floats; the logical and bitwise binops convert their
inputs to int and their outputs back to float. */ inputs to int and their outputs back to float. */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#endif
#include "m_pd.h" #include "m_pd.h"
#include <math.h> #include <math.h>

View file

@ -4,10 +4,18 @@
/* connective objects */ /* connective objects */
#ifdef ROCKBOX
#include "plugin.h"
#include "pdbox.h"
#endif
#include "m_pd.h" #include "m_pd.h"
#ifndef ROCKBOX
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#endif
extern t_pd *newest; extern t_pd *newest;
/* -------------------------- int ------------------------------ */ /* -------------------------- int ------------------------------ */
@ -62,6 +70,9 @@ typedef struct _pdfloat
static void *pdfloat_new(t_pd *dummy, t_float f) static void *pdfloat_new(t_pd *dummy, t_float f)
{ {
#ifdef ROCKBOX
(void) dummy;
#endif
t_pdfloat *x = (t_pdfloat *)pd_new(pdfloat_class); t_pdfloat *x = (t_pdfloat *)pd_new(pdfloat_class);
x->x_f = f; x->x_f = f;
outlet_new(&x->x_obj, &s_float); outlet_new(&x->x_obj, &s_float);
@ -105,6 +116,9 @@ typedef struct _pdsymbol
static void *pdsymbol_new(t_pd *dummy, t_symbol *s) static void *pdsymbol_new(t_pd *dummy, t_symbol *s)
{ {
#ifdef ROCKBOX
(void) dummy;
#endif
t_pdsymbol *x = (t_pdsymbol *)pd_new(pdsymbol_class); t_pdsymbol *x = (t_pdsymbol *)pd_new(pdsymbol_class);
x->x_s = s; x->x_s = s;
outlet_new(&x->x_obj, &s_symbol); outlet_new(&x->x_obj, &s_symbol);
@ -125,6 +139,10 @@ static void pdsymbol_symbol(t_pdsymbol *x, t_symbol *s)
static void pdsymbol_anything(t_pdsymbol *x, t_symbol *s, int ac, t_atom *av) static void pdsymbol_anything(t_pdsymbol *x, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) ac;
(void) av;
#endif
outlet_symbol(x->x_obj.ob_outlet, x->x_s = s); outlet_symbol(x->x_obj.ob_outlet, x->x_s = s);
} }
@ -147,6 +165,9 @@ typedef struct _bang
static void *bang_new(t_pd *dummy) static void *bang_new(t_pd *dummy)
{ {
#ifdef ROCKBOX
(void) dummy;
#endif
t_bang *x = (t_bang *)pd_new(bang_class); t_bang *x = (t_bang *)pd_new(bang_class);
outlet_new(&x->x_obj, &s_bang); outlet_new(&x->x_obj, &s_bang);
newest = &x->x_obj.ob_pd; newest = &x->x_obj.ob_pd;
@ -155,6 +176,9 @@ static void *bang_new(t_pd *dummy)
static void *bang_new2(t_bang f) static void *bang_new2(t_bang f)
{ {
#ifdef ROCKBOX
(void) f;
#endif
return (bang_new(0)); return (bang_new(0));
} }
@ -383,6 +407,9 @@ static void sel2_free(t_sel2 *x)
static void *select_new(t_symbol *s, int argc, t_atom *argv) static void *select_new(t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
t_atom a; t_atom a;
if (argc == 0) if (argc == 0)
{ {
@ -484,6 +511,9 @@ static void route_anything(t_route *x, t_symbol *sel, int argc, t_atom *argv)
static void route_list(t_route *x, t_symbol *sel, int argc, t_atom *argv) static void route_list(t_route *x, t_symbol *sel, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) sel;
#endif
t_routeelement *e; t_routeelement *e;
int nelement; int nelement;
if (x->x_type == A_FLOAT) if (x->x_type == A_FLOAT)
@ -562,6 +592,9 @@ static void route_free(t_route *x)
static void *route_new(t_symbol *s, int argc, t_atom *argv) static void *route_new(t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
int n; int n;
t_routeelement *e; t_routeelement *e;
t_route *x = (t_route *)pd_new(route_class); t_route *x = (t_route *)pd_new(route_class);
@ -610,6 +643,9 @@ typedef struct _pack
static void *pack_new(t_symbol *s, int argc, t_atom *argv) static void *pack_new(t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
t_pack *x = (t_pack *)pd_new(pack_class); t_pack *x = (t_pack *)pd_new(pack_class);
t_atom defarg[2], *ap, *vec, *vp; t_atom defarg[2], *ap, *vec, *vp;
t_gpointer *gp; t_gpointer *gp;
@ -737,6 +773,9 @@ static void pack_symbol(t_pack *x, t_symbol *s)
static void pack_list(t_pack *x, t_symbol *s, int ac, t_atom *av) static void pack_list(t_pack *x, t_symbol *s, int ac, t_atom *av)
{ {
#ifdef ROCKBOX
(void) s;
#endif
obj_list(&x->x_obj, 0, ac, av); obj_list(&x->x_obj, 0, ac, av);
} }
@ -793,6 +832,9 @@ typedef struct _unpack
static void *unpack_new(t_symbol *s, int argc, t_atom *argv) static void *unpack_new(t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
t_unpack *x = (t_unpack *)pd_new(unpack_class); t_unpack *x = (t_unpack *)pd_new(unpack_class);
t_atom defarg[2], *ap; t_atom defarg[2], *ap;
t_unpackout *u; t_unpackout *u;
@ -841,6 +883,9 @@ static void *unpack_new(t_symbol *s, int argc, t_atom *argv)
static void unpack_list(t_unpack *x, t_symbol *s, int argc, t_atom *argv) static void unpack_list(t_unpack *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
t_atom *ap; t_atom *ap;
t_unpackout *u; t_unpackout *u;
int i; int i;
@ -907,6 +952,9 @@ typedef struct _trigger
static void *trigger_new(t_symbol *s, int argc, t_atom *argv) static void *trigger_new(t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
t_trigger *x = (t_trigger *)pd_new(trigger_class); t_trigger *x = (t_trigger *)pd_new(trigger_class);
t_atom defarg[2], *ap; t_atom defarg[2], *ap;
t_triggerout *u; t_triggerout *u;
@ -953,6 +1001,9 @@ static void *trigger_new(t_symbol *s, int argc, t_atom *argv)
static void trigger_list(t_trigger *x, t_symbol *s, int argc, t_atom *argv) static void trigger_list(t_trigger *x, t_symbol *s, int argc, t_atom *argv)
{ {
#ifdef ROCKBOX
(void) s;
#endif
t_triggerout *u; t_triggerout *u;
int i; int i;
t_atom at; t_atom at;
@ -1204,14 +1255,22 @@ static void *makefilename_new(t_symbol *s)
static void makefilename_float(t_makefilename *x, t_floatarg f) static void makefilename_float(t_makefilename *x, t_floatarg f)
{ {
char buf[MAXPDSTRING]; char buf[MAXPDSTRING];
#ifdef ROCKBOX
snprintf(buf, sizeof(buf), x->x_format->s_name, (int)f);
#else
sprintf(buf, x->x_format->s_name, (int)f); sprintf(buf, x->x_format->s_name, (int)f);
#endif
outlet_symbol(x->x_obj.ob_outlet, gensym(buf)); outlet_symbol(x->x_obj.ob_outlet, gensym(buf));
} }
static void makefilename_symbol(t_makefilename *x, t_symbol *s) static void makefilename_symbol(t_makefilename *x, t_symbol *s)
{ {
char buf[MAXPDSTRING]; char buf[MAXPDSTRING];
#ifdef ROCKBOX
snprintf(buf, sizeof(buf), x->x_format->s_name, s->s_name);
#else
sprintf(buf, x->x_format->s_name, s->s_name); sprintf(buf, x->x_format->s_name, s->s_name);
#endif
outlet_symbol(x->x_obj.ob_outlet, gensym(buf)); outlet_symbol(x->x_obj.ob_outlet, gensym(buf));
} }

Some files were not shown because too many files have changed in this diff Show more