diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/breakpoints.c | 80 | ||||
-rw-r--r-- | src/breakpoints~.c | 137 | ||||
-rw-r--r-- | src/breakpoints~.h | 8 | ||||
-rw-r--r-- | src/param.c | 10 | ||||
-rw-r--r-- | src/paramCustom.h | 2 | ||||
-rw-r--r-- | src/paramId.h | 54 | ||||
-rw-r--r-- | src/paramPath.h | 54 | ||||
-rw-r--r-- | src/w_breakpoints.h | 8 |
8 files changed, 146 insertions, 207 deletions
diff --git a/src/breakpoints.c b/src/breakpoints.c index 8d7bbbe..1d37149 100644 --- a/src/breakpoints.c +++ b/src/breakpoints.c @@ -38,7 +38,7 @@ char dumpy[2000]; cause the problem. for the moment we prevent from reallocating
by setting the STATES variable to 100 */
-void breakpoints_resize(t_breakpoints* x,int ns)
+static void breakpoints_resize(t_breakpoints* x,int ns)
{
if (ns > x->args) {
int newargs = ns*sizeof(t_float);
@@ -51,7 +51,7 @@ void breakpoints_resize(t_breakpoints* x,int ns) -void breakpoints_totaldur(t_breakpoints* x,t_float dur)
+static void breakpoints_totaldur(t_breakpoints* x,t_float dur)
{
int i;
float f = dur/x->duration[x->last_state];
@@ -89,7 +89,7 @@ static void breakpoints_dump(t_breakpoints* e) /////////////////////////////////////////////////////
}
-void breakpoints_init(t_breakpoints *x,int argc,t_atom* argv)
+static void breakpoints_init(t_breakpoints *x,int argc,t_atom* argv)
{
t_float* dur;
t_float* val;
@@ -159,15 +159,16 @@ void breakpoints_init(t_breakpoints *x,int argc,t_atom* argv) -void breakpoints_list(t_breakpoints *x,t_symbol* s, int argc,t_atom* argv)
+static void breakpoints_list(t_breakpoints *x,t_symbol* s, int argc,t_atom* argv)
{
+
breakpoints_init(x,argc,argv);
if (glist_isvisible(x->w.glist)) {
breakpoints_drawme(x, x->w.glist, 0);
}
}
-void breakpoints_setresize(t_breakpoints *x, t_floatarg f)
+static void breakpoints_setresize(t_breakpoints *x, t_floatarg f)
{
x->resizeable = f;
}
@@ -175,36 +176,47 @@ void breakpoints_setresize(t_breakpoints *x, t_floatarg f) -
-void breakpoints_float(t_breakpoints *x, t_floatarg f)
+static void breakpoints_float(t_breakpoints *x, t_floatarg f)
{
- int state = 0;
- float val;
+
+ // int state = x->state;
+ t_float val;
+
+ if (x->state > x->last_state) x->state = x->last_state;
+
+ while ( (x->state > 0) && (f < x->duration[x->state-1]) ) x->state--;
+ while ( (x->state < x->last_state) && (x->duration[x->state] < f) ) x->state++;
- while (x->duration[state] < f && state < x->last_state) state++;
+
+ //x->state = state;
- if (state == 0 || f >= x->duration[x->last_state]) {
- val = x->finalvalues[state];
+ if (x->state == 0 || f >= x->duration[x->last_state]) {
+ post("out of bounds");
+ val = x->finalvalues[x->state];
outlet_float(x->x_obj.ob_outlet,val);
if (x->s_sym != &s_) pd_float(x->s_sym->s_thing, f);
return;
}
+
+
- val = x->finalvalues[state-1] +
- (f - x->duration[state-1])*
- (x->finalvalues[state] - x->finalvalues[state-1])/
- (x->duration[state] - x->duration[state-1]);
+ val = x->finalvalues[x->state-1] +
+ (f - x->duration[x->state-1])*
+ (x->finalvalues[x->state] - x->finalvalues[x->state-1])/
+ (x->duration[x->state] - x->duration[x->state-1]);
//val *= (x->max - x->min);
outlet_float(x->x_obj.ob_outlet,val);
if (x->s_sym != &s_) pd_float(x->s_sym->s_thing, val);
+
}
-void breakpoints_bang(t_breakpoints *x)
+
+static void breakpoints_bang(t_breakpoints *x)
{
t_atom a[2];
@@ -227,29 +239,6 @@ void breakpoints_bang(t_breakpoints *x) clock_delay(x->x_clock,x->duration[x->x_state]);
}
-/*
-
-void breakpoints_release(t_breakpoints* x) {
- t_atom a[2];
- float del = x->duration[x->x_state] - x->duration[x->x_state-1];
- if (x->x_state <= x->sustain_state) {
- x->x_state = x->sustain_state+1; // skip sustain state
- clock_delay(x->x_clock,del);
- SETFLOAT(a,x->finalvalues[x->x_state]*(x->max-x->min));
- SETFLOAT(a+1,del);
- OUT_LIST(x,2,a);
- }
-}
-
-static void breakpoints_sustain(t_breakpoints *x, t_floatarg f)
-{
- if (f > 0 && f < x->last_state)
- x->sustain_state = f;
- else
- pd_error(x,"sustain value not betweem 0 and %f, ignoring message", x->last_state);
-}
-
-*/
static void breakpoints_tick(t_breakpoints* x)
@@ -293,10 +282,13 @@ static void bindsym(t_pd* x,t_symbol* o,t_symbol* s) static void *breakpoints_new(t_symbol *s,int argc,t_atom* argv)
{
+
+ post("BITHCE");
+
t_breakpoints *x = (t_breakpoints *)pd_new(breakpoints_class);
x->borderwidth = 1;
-
+ x->state = 0;
x->x_f = 0;
x->args = STATES;
x->finalvalues = getbytes( x->args*sizeof(t_float));
@@ -379,11 +371,11 @@ static void *breakpoints_new(t_symbol *s,int argc,t_atom* argv) }
-void breakpoints_motion(t_breakpoints *x, t_floatarg dx, t_floatarg dy);
-void breakpoints_click(t_breakpoints *x,
+static void breakpoints_motion(t_breakpoints *x, t_floatarg dx, t_floatarg dy);
+static void breakpoints_click(t_breakpoints *x,
t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl,
t_floatarg alt);
-void breakpoints_key(t_breakpoints *x, t_floatarg f);
+static void breakpoints_key(t_breakpoints *x, t_floatarg f);
t_widgetbehavior breakpoints_widgetbehavior;
diff --git a/src/breakpoints~.c b/src/breakpoints~.c index 8e3b903..2f7e4a0 100644 --- a/src/breakpoints~.c +++ b/src/breakpoints~.c @@ -38,7 +38,7 @@ char dumpy[2000]; cause the problem. for the moment we prevent from reallocating
by setting the STATES variable to 100 */
-void breakpoints_resize(t_breakpoints* x,int ns)
+static void breakpoints_resize(t_breakpoints* x,int ns)
{
if (ns > x->args) {
int newargs = ns*sizeof(t_float);
@@ -59,39 +59,40 @@ static t_int *breakpointssig_perform(t_int *w) {
t_breakpoints *x = (t_breakpoints *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- t_float *out = (t_float *)(w[3]);
+ t_sample *in = (t_float *)(w[2]);
+ t_sample *out = (t_float *)(w[3]);
int n = (int)(w[4]);
- int state;
- float f;
- float val;
+ //int state = x->state;
+ t_sample f;
+ t_sample val;
- while (n--)
- {
-
- // STUFF
- state = 0;
- f = *(in++);
+ if (x->state > x->last_state) x->state = x->last_state;
+ while (n--) {
+ f = *in;
+
+
+
- while (x->duration[state] < f && state < x->last_state) state++;
-
- if (state == 0 || f >= x->duration[x->last_state]) {
- val = x->finalvalues[state];
-
- } else {
- val = x->finalvalues[state-1] + (f - x->duration[state-1]) *
- (x->finalvalues[state] - x->finalvalues[state-1]) /
- (x->duration[state] - x->duration[state-1]);
-
-
-
- }
- // STUFF END
-
-
- *out++ = val;
+ while ( (x->state > 0) && (f < x->duration[x->state-1]) ) x->state--;
+ while ( (x->state < x->last_state) && (x->duration[x->state] < f) ) x->state++;
+ // Interpolate
+ if (x->state == 0 || f >= x->duration[x->last_state]) {
+ val = x->finalvalues[x->state];
+ } else {
+ val = x->finalvalues[x->state-1] +
+ (f - x->duration[x->state-1])*
+ (x->finalvalues[x->state] - x->finalvalues[x->state-1])/
+ (x->duration[x->state] - x->duration[x->state-1]);
+ }
+
+ // Output
+ *out= val;
+ out++;
+ in++;
+ //*out++=x->state;
}
+ //x->state = state;
return (w+5);
}
@@ -105,7 +106,7 @@ static void breakpointssig_dsp(t_breakpoints *x, t_signal **sp) dsp_add(breakpointssig_perform, 4, x,sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
}
-void breakpoints_totaldur(t_breakpoints* x,t_float dur)
+static void breakpoints_totaldur(t_breakpoints* x,t_float dur)
{
int i;
float f = dur/x->duration[x->last_state];
@@ -143,7 +144,7 @@ static void breakpoints_dump(t_breakpoints* e) /////////////////////////////////////////////////////
}
-void breakpoints_init(t_breakpoints *x,int argc,t_atom* argv)
+static void breakpoints_init(t_breakpoints *x,int argc,t_atom* argv)
{
t_float* dur;
t_float* val;
@@ -211,7 +212,7 @@ void breakpoints_init(t_breakpoints *x,int argc,t_atom* argv) -void breakpoints_list(t_breakpoints *x,t_symbol* s, int argc,t_atom* argv)
+static void breakpoints_list(t_breakpoints *x,t_symbol* s, int argc,t_atom* argv)
{
breakpoints_init(x,argc,argv);
if (glist_isvisible(x->w.glist)) {
@@ -219,7 +220,7 @@ void breakpoints_list(t_breakpoints *x,t_symbol* s, int argc,t_atom* argv) }
}
-void breakpoints_setresize(t_breakpoints *x, t_floatarg f)
+static void breakpoints_setresize(t_breakpoints *x, t_floatarg f)
{
x->resizeable = f;
}
@@ -227,7 +228,7 @@ void breakpoints_setresize(t_breakpoints *x, t_floatarg f) -
+/*
void breakpoints_float(t_breakpoints *x, t_floatarg f)
{
int state = 0;
@@ -253,59 +254,6 @@ void breakpoints_float(t_breakpoints *x, t_floatarg f) outlet_float(x->x_obj.ob_outlet,val);
if (x->s_sym != &s_) pd_float(x->s_sym->s_thing, val);
}
-
-
-
-
-
-
-/*
-
-void breakpoints_release(t_breakpoints* x) {
- t_atom a[2];
- float del = x->duration[x->x_state] - x->duration[x->x_state-1];
- if (x->x_state <= x->sustain_state) {
- x->x_state = x->sustain_state+1; // skip sustain state
- clock_delay(x->x_clock,del);
- SETFLOAT(a,x->finalvalues[x->x_state]*(x->max-x->min));
- SETFLOAT(a+1,del);
- OUT_LIST(x,2,a);
- }
-}
-
-static void breakpoints_sustain(t_breakpoints *x, t_floatarg f)
-{
- if (f > 0 && f < x->last_state)
- x->sustain_state = f;
- else
- pd_error(x,"sustain value not betweem 0 and %f, ignoring message", x->last_state);
-}
-
-*/
-
-/*
-static void breakpoints_tick(t_breakpoints* x)
-{
- t_atom a[2];
- x->x_state++;
- if (x->x_state <= x->last_state && x->x_state != x->sustain_state) {
- float del = x->duration[x->x_state] - x->duration[x->x_state-1];
- clock_delay(x->x_clock,del);
- SETFLOAT(a,x->finalvalues[x->x_state]*(x->max-x->min));
- SETFLOAT(a+1,del);
- OUT_LIST(x,2,a);
- }
-// else
-// clock_unset(x->x_clock);
-}
-
-*/
-
-/*
-static void breakpoints_freeze(t_breakpoints* x, t_floatarg f)
-{
- x->x_freeze = f;
-}
*/
static void bindsym(t_pd* x,t_symbol* o,t_symbol* s)
@@ -316,16 +264,13 @@ static void bindsym(t_pd* x,t_symbol* o,t_symbol* s) }
-
-
-
-
-
-
static void *breakpoints_new(t_symbol *s,int argc,t_atom* argv)
{
t_breakpoints *x = (t_breakpoints *)pd_new(breakpoints_class);
+
+ x->state = 0;
+
x->borderwidth = 2;
x->x_f = 0;
@@ -409,11 +354,11 @@ static void *breakpoints_new(t_symbol *s,int argc,t_atom* argv) -void breakpoints_motion(t_breakpoints *x, t_floatarg dx, t_floatarg dy);
-void breakpoints_click(t_breakpoints *x,
+static void breakpoints_motion(t_breakpoints *x, t_floatarg dx, t_floatarg dy);
+static void breakpoints_click(t_breakpoints *x,
t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl,
t_floatarg alt);
-void breakpoints_key(t_breakpoints *x, t_floatarg f);
+static void breakpoints_key(t_breakpoints *x, t_floatarg f);
t_widgetbehavior breakpoints_widgetbehavior;
diff --git a/src/breakpoints~.h b/src/breakpoints~.h index f973dac..b000f53 100644 --- a/src/breakpoints~.h +++ b/src/breakpoints~.h @@ -48,6 +48,8 @@ typedef struct _breakpoints t_float x_f; /* place to hold inlet's value if it's set by message */
+ int state;
+
t_outlet* out2;
t_outlet* out3;
@@ -57,8 +59,8 @@ typedef struct _breakpoints t_widgetbehavior breakpoints_widgetbehavior;
-void breakpoints_drawme(t_breakpoints *x, t_glist *glist, int firsttime);
-int breakpoints_set_values(t_breakpoints * x);
-void breakpoints_resize(t_breakpoints* x,int ns);
+static void breakpoints_drawme(t_breakpoints *x, t_glist *glist, int firsttime);
+static int breakpoints_set_values(t_breakpoints * x);
+static void breakpoints_resize(t_breakpoints* x,int ns);
#endif
diff --git a/src/param.c b/src/param.c index 104cb4a..ae1f0c2 100644 --- a/src/param.c +++ b/src/param.c @@ -23,7 +23,7 @@ #include "paramCustom.h" #include "paramDump.h" #include "paramFile.h" -#include "paramId.h" +#include "paramPath.h" #include "paramRoute.h" #include "paramGui.h" @@ -326,8 +326,8 @@ static void* param_new(t_symbol *s, int argc, t_atom *argv) { x = paramDump_new(s, argc-1, argv+1); else if (s2 == gensym("file")) x = paramFile_new(s, argc-1, argv+1); - else if (s2 == gensym("id")) - x = paramId_new(s, argc-1, argv+1); + else if (s2 == gensym("id") || s2 == gensym("path")) + x = paramPath_new(s, argc-1, argv+1); else if (s2 == gensym("route")) x = paramRoute_new(s, argc-1, argv+1); else if (s2 == gensym("gui")) @@ -336,7 +336,7 @@ static void* param_new(t_symbol *s, int argc, t_atom *argv) { x = paramClass_new(s, argc, argv); } if ( x == NULL) { - post("Param is missing a symbolic argument. Possible values: custom, dump, file, id, route, gui or a /name."); + post("Param is missing a symbolic argument. Possible values: custom, dump, file, path, route, gui or a /name."); //post(" custom"); //dump file id route gui or a /\"name\" //post("- dump"); @@ -378,7 +378,7 @@ void param_setup(void) paramCustom_setup(); paramDump_setup(); paramFile_setup(); - paramId_setup(); + paramPath_setup(); paramRoute_setup(); paramGui_setup(); diff --git a/src/paramCustom.h b/src/paramCustom.h index 134782a..3d3f979 100644 --- a/src/paramCustom.h +++ b/src/paramCustom.h @@ -192,7 +192,7 @@ void paramCustom_setup(void) //class_addmethod(param_class, (t_method)paramClass_loadbang, gensym("loadbang"), 0); - paramCustom_receive_class = class_new(gensym("_paramCustom_receive"), + paramCustom_receive_class = class_new(gensym("paramCustom_receive"), 0, 0, sizeof(t_paramCustom_receive), CLASS_PD | CLASS_NOINLET, 0); class_addanything(paramCustom_receive_class, paramCustom_receive_anything); diff --git a/src/paramId.h b/src/paramId.h deleted file mode 100644 index c11ec22..0000000 --- a/src/paramId.h +++ /dev/null @@ -1,54 +0,0 @@ - - -static t_class *paramId_class; - - -typedef struct _paramId -{ - t_object x_obj; - t_outlet* outlet; - t_symbol* path; - //t_symbol* root; -} t_paramId; - - - -// Dump out everything (OR THE ID'S OR JUST THE NAMES?) -static void paramId_bang(t_paramId *x) { - - outlet_symbol(x->outlet,x->path); - - -} - - - -static void paramId_free(t_paramId *x) -{ - - -} - - -static void *paramId_new(t_symbol *s, int ac, t_atom *av) { - t_paramId *x = (t_paramId *)pd_new(paramId_class); - - //x->root = tof_get_dollarzero(tof_get_root_canvas(tof_get_canvas())); - t_canvas* canvas = tof_get_canvas(); - x->path = param_get_path(canvas,NULL); - - x->outlet = outlet_new(&x->x_obj, &s_list); - - return (x); -} - -void paramId_setup(void) { - paramId_class = class_new(gensym("param id"), - (t_newmethod)paramId_new, (t_method)paramId_free, - sizeof(t_paramId), 0, A_GIMME, 0); - - class_addbang(paramId_class, paramId_bang); - - class_sethelpsymbol(paramId_class, gensym("param")); - -} diff --git a/src/paramPath.h b/src/paramPath.h new file mode 100644 index 0000000..5efd54b --- /dev/null +++ b/src/paramPath.h @@ -0,0 +1,54 @@ + + +static t_class *paramPath_class; + + +typedef struct _paramPath +{ + t_object x_obj; + t_outlet* outlet; + t_symbol* path; + //t_symbol* root; +} t_paramPath; + + + +// Dump out everything (OR THE ID'S OR JUST THE NAMES?) +static void paramPath_bang(t_paramPath *x) { + + outlet_symbol(x->outlet,x->path); + + +} + + + +static void paramPath_free(t_paramPath *x) +{ + + +} + + +static void *paramPath_new(t_symbol *s, int ac, t_atom *av) { + t_paramPath *x = (t_paramPath *)pd_new(paramPath_class); + + //x->root = tof_get_dollarzero(tof_get_root_canvas(tof_get_canvas())); + t_canvas* canvas = tof_get_canvas(); + x->path = param_get_path(canvas,NULL); + + x->outlet = outlet_new(&x->x_obj, &s_list); + + return (x); +} + +void paramPath_setup(void) { + paramPath_class = class_new(gensym("param path"), + (t_newmethod)paramPath_new, (t_method)paramPath_free, + sizeof(t_paramPath), 0, A_GIMME, 0); + + class_addbang(paramPath_class, paramPath_bang); + + class_sethelpsymbol(paramPath_class, gensym("param")); + +} diff --git a/src/w_breakpoints.h b/src/w_breakpoints.h index 14c326b..2b980d7 100644 --- a/src/w_breakpoints.h +++ b/src/w_breakpoints.h @@ -295,7 +295,7 @@ int i; -void breakpoints_drawme(t_breakpoints *x, t_glist *glist, int firsttime)
+static void breakpoints_drawme(t_breakpoints *x, t_glist *glist, int firsttime)
{
if (firsttime) breakpoints_create(x,glist);
@@ -307,7 +307,7 @@ void breakpoints_drawme(t_breakpoints *x, t_glist *glist, int firsttime) -void breakpoints_erase(t_breakpoints* x,t_glist* glist)
+static void breakpoints_erase(t_breakpoints* x,t_glist* glist)
{
//int n;
sys_vgui(".x%x.c delete %xS\n",
@@ -438,7 +438,7 @@ static void breakpoints_followpointer(t_breakpoints* x,t_glist* glist) }
-void breakpoints_motion(t_breakpoints *x, t_floatarg dx, t_floatarg dy)
+static void breakpoints_motion(t_breakpoints *x, t_floatarg dx, t_floatarg dy)
{
if (x->w.shift) {
x->w.pointerx+=dx/1000.f;
@@ -459,7 +459,7 @@ void breakpoints_motion(t_breakpoints *x, t_floatarg dx, t_floatarg dy) breakpoints_update(x,x->w.glist);
}
-void breakpoints_key(t_breakpoints *x, t_floatarg f)
+static void breakpoints_key(t_breakpoints *x, t_floatarg f)
{
if (f == 8.0 && x->w.grabbed < x->last_state && x->w.grabbed > 0) {
int i;
|