Skip to content

Commit

Permalink
shakers~ Fix CC updates and clean up help patcher (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelgk committed Dec 23, 2020
1 parent 80e1126 commit 5fff169
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 40 deletions.
50 changes: 35 additions & 15 deletions help/shakers~.maxhelp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
,
"classnamespace" : "box",
"rect" : [ 434.0, 164.0, 624.0, 618.0 ],
"rect" : [ 100.0, 100.0, 624.0, 618.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
Expand Down Expand Up @@ -40,36 +40,56 @@
"assistshowspatchername" : 0,
"boxes" : [ {
"box" : {
"id" : "obj-25",
"id" : "obj-12",
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 115.0, 227.0, 275.0, 20.0 ],
"text" : "noteon has an optional amplitude argument"
"patching_rect" : [ 230.5, 337.5, 55.0, 20.0 ],
"text" : "[0, 128]"
}

}
, {
"box" : {
"id" : "obj-11",
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 230.5, 366.25, 55.0, 20.0 ],
"text" : "[0., 128.]"
}

}
, {
"box" : {
"id" : "obj-21",
"linecount" : 2,
"id" : "obj-10",
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 237.0, 274.5, 206.0, 33.0 ],
"text" : "\"Shaking\" the value of energy can simulate shaking the instrument"
"patching_rect" : [ 230.5, 308.75, 55.0, 20.0 ],
"text" : "[0., 128.]"
}

}
, {
"box" : {
"id" : "obj-19",
"linecount" : 3,
"id" : "obj-3",
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 237.0, 325.5, 161.0, 47.0 ],
"text" : "Energy, decay, num_objects, and res_freq should be in the range 0-128"
"patching_rect" : [ 230.5, 281.0, 55.0, 20.0 ],
"text" : "[0., 128.]"
}

}
, {
"box" : {
"id" : "obj-25",
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 115.0, 227.0, 275.0, 20.0 ],
"text" : "noteon has an optional amplitude argument"
}

}
Expand Down Expand Up @@ -217,7 +237,7 @@
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 75.5, 308.0, 150.0, 22.0 ]
"patching_rect" : [ 75.5, 308.75, 150.0, 22.0 ]
}

}
Expand All @@ -241,7 +261,7 @@
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 75.5, 338.0, 150.0, 22.0 ]
"patching_rect" : [ 75.5, 337.5, 150.0, 22.0 ]
}

}
Expand All @@ -253,7 +273,7 @@
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 75.5, 367.0, 150.0, 22.0 ]
"patching_rect" : [ 75.5, 366.25, 150.0, 22.0 ]
}

}
Expand Down
31 changes: 6 additions & 25 deletions source/projects/shakers~/shakers~.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,9 @@ typedef struct _shakers
//"power" messages so that you can bypass them individually

long f_num_objects;
long f_old_num_objects; // Keep copies of old values so that we know when to change them
double f_energy;
double f_old_energy;
double f_res_freq;
double f_old_res_freq;
double f_decay;
double f_old_decay;
t_symbol *f_shaker_type; // Instrument selection

} t_shakers;
Expand Down Expand Up @@ -187,7 +183,12 @@ void shakers_noteon(t_shakers *x, t_symbol *s, long argc, t_atom *argv)
{
long instrument = 0;
float amp = 1.;


x->myshakers->controlChange(1, CLAMP(x->f_res_freq, 0., 128.));
x->myshakers->controlChange(2, CLAMP(x->f_energy, 0., 128.));
x->myshakers->controlChange(4, CLAMP(x->f_num_objects, 0, 128));
x->myshakers->controlChange(11, CLAMP(x->f_decay, 0., 128.));

if (x->f_shaker_type == gensym("Maraca")) {
instrument = 0;
} else if (x->f_shaker_type == gensym("Cabasa")) {
Expand Down Expand Up @@ -294,26 +295,6 @@ void shakers_perform64(t_shakers *x, t_object *dsp64, double **ins, long numins,
t_double *in[MAX_INPUTS]; //pointers to the input vectors
t_double *out[MAX_OUTPUTS]; //pointers to the output vectors
long n = sampleframes; //number of samples per vector

if (x->f_res_freq != x->f_old_res_freq) {
x->f_old_res_freq = x->f_res_freq;
x->myshakers->controlChange(1, x->f_res_freq);
}

if (x->f_energy != x->f_old_energy) {
x->f_old_energy = x->f_energy;
x->myshakers->controlChange(2, x->f_energy);
}

if (x->f_num_objects != x->f_old_num_objects) {
x->f_old_num_objects = x->f_num_objects;
x->myshakers->controlChange(4, x->f_num_objects);
}

if (x->f_decay != x->f_old_decay) {
x->f_old_decay = x->f_decay;
x->myshakers->controlChange(11, x->f_decay);
}

//check to see if we should skip this routine if the patcher is "muted"
//i also setup of "power" messages for expensive objects, so that the
Expand Down

0 comments on commit 5fff169

Please sign in to comment.