Skip to content

Commit

Permalink
pd: make first inlet a pure message inlet
Browse files Browse the repository at this point in the history
the first inlet only takes messages, there is no reason why it should be a signal inlet.
this makes sure that users get an error when they wrongly try to connect it to a signal chord.
  • Loading branch information
Spacechild1 committed Jul 12, 2024
1 parent 076835a commit 8120569
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions architecture/puredata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
Please note that this is to be compiled as a shared library, which is
then loaded dynamically by Pd as an external. */

#include <assert.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
Expand Down Expand Up @@ -495,30 +496,30 @@ static void faust_dsp(t_faust *x, t_signal **sp)
* class, we need to call signal_setmultiout() on all outputs
* - even in single-channel mode! */
if (x->multi) {
g_signal_setmultiout(&sp[2], x->n_out);
g_signal_setmultiout(&sp[1], x->n_out);
} else {
for (int i = 0; i < x->n_out; ++i) {
g_signal_setmultiout(&sp[x->n_in+i+1], 1);
g_signal_setmultiout(&sp[x->n_in+i], 1);
}
}
}
/* now we can store the input and output signals */
if (x->multi) {
for (int i = 0; i < x->n_in; i++) {
if (i < sp[1]->s_nchans)
x->inputs[i] = sp[1]->s_vec + (i*n);
if (i < sp[0]->s_nchans)
x->inputs[i] = sp[0]->s_vec + (i*n);
else
x->inputs[i] = x->dummy;
}
for (int i = 0; i < x->n_out; i++)
x->outputs[i] = sp[2]->s_vec + (i*n);
x->outputs[i] = sp[1]->s_vec + (i*n);
} else
#endif
{
for (int i = 0; i < x->n_in; i++)
x->inputs[i] = sp[i+1]->s_vec;
x->inputs[i] = sp[i]->s_vec;
for (int i = 0; i < x->n_out; i++)
x->outputs[i] = sp[x->n_in+i+1]->s_vec;
x->outputs[i] = sp[x->n_in+i]->s_vec;
}

dsp_add(faust_perform, 2, x, (t_int)n);
Expand Down Expand Up @@ -678,6 +679,7 @@ static void *faust_new(t_symbol *s, int argc, t_atom *argv)
}
x->n_in = x->dsp->getNumInputs();
x->n_out = x->dsp->getNumOutputs();
assert((x->n_in + x->n_out) > 0); /* there must be at least one signal */
if (x->n_in > 0)
x->inputs = (t_sample**)malloc(x->n_in*sizeof(t_sample*));
if (x->n_out > 0) {
Expand Down Expand Up @@ -729,7 +731,6 @@ extern "C" void faust_setup(mydsp)
sizeof(t_faust), classflags, A_GIMME, A_NULL);
class_addmethod(faust_class, (t_method)faust_dsp, gensym((char*)"dsp"), A_NULL);
class_addanything(faust_class, faust_any);
class_addmethod(faust_class, nullfn, &s_signal, A_NULL);
s_button = gensym((char*)"button");
s_checkbox = gensym((char*)"checkbox");
s_vslider = gensym((char*)"vslider");
Expand Down

0 comments on commit 8120569

Please sign in to comment.