aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2004-10-12 07:19:23 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2004-10-12 07:19:23 +0000
commit7b4450284343e6ad3494f7639cb68e317c9fc1a4 (patch)
tree026de80c9243168ee252a93682229c3e1298b742 /src
parent64ac1b68a9e657bb78cf3405c6665faf41bc5a61 (diff)
fixed a bug with sharing signal pointers (thanks tim)
svn path=/trunk/externals/zexy/; revision=2103
Diffstat (limited to 'src')
-rw-r--r--src/z_sigmatrix.c74
1 files changed, 21 insertions, 53 deletions
diff --git a/src/z_sigmatrix.c b/src/z_sigmatrix.c
index 5708c6f..f801950 100644
--- a/src/z_sigmatrix.c
+++ b/src/z_sigmatrix.c
@@ -313,17 +313,14 @@ typedef struct _demux {
int n_out;
t_float **out;
- int changed;
- int oldout;
} t_demux;
static void demux_output(t_demux *x, t_floatarg f)
{
- if ((f>=0)&&(f<x->n_out)&&((int)f!=x->output)){
- x->oldout=x->output;
+ if ((f>=0)&&(f<x->n_out)){
x->output=f;
- x->changed=1;
- }
+ } else
+ error("demultiplex: %d is channel out of range (0..%d)", (int)f, x->n_out);
}
@@ -333,29 +330,19 @@ static t_int *demux_perform(t_int *w)
t_float *in = (t_float *)(w[2]);
int N = (int)(w[3]);
int n = N;
-
- t_float *out = x->out[x->output];
- if(x->changed){
- t_float *oldout=x->out[x->oldout];
- x->changed=0;
- if (out!=in)
- while(n--){
- *out++=*in;
- *in++=*oldout++=0;
- }
- else
- while(n--)*oldout++=0;
-
- } else { /* !changed */
- if (out!=in)
- while(n--){
- *out++=*in;
- *in++=0;
- }
- }
+ int channel=x->n_out;
+
+ while(channel--){
+ t_float*out=x->out[channel];
+ n=N;
+ if(x->output==channel){
+ while(n--)*out++=*in++;
+ } else
+ while(n--)*out++=0.f;
+ }
return (w+4);
}
@@ -426,18 +413,15 @@ typedef struct _mux {
int n_in;
t_float **in;
-
- int changed;
- int oldin;
} t_mux;
static void mux_input(t_mux *x, t_floatarg f)
{
- if ((f>=0)&&(f<x->n_in)&&((int)f!=x->input)){
- x->oldin=x->input;
+ if ((f>=0)&&(f<x->n_in)){
x->input=f;
- x->changed=1;
- }
+ } else
+ error("multiplex: %d is channel out of range (0..%d)", (int)f, x->n_in);
+
}
static t_int *mux_perform(t_int *w)
@@ -446,26 +430,10 @@ static t_int *mux_perform(t_int *w)
t_float *out = (t_float *)(w[2]);
int n = (int)(w[3]);
- t_float *in;
-
- in = x->in[x->input];
-
- if(x->changed){
- t_float *oldin=x->in[x->oldin];
- x->changed=0;
- if (in!=out)
- while(n--){
- *out++=*in;
- *in++=*oldin++=0;
- }
- else while(n--)*oldin++=0;
- } else {
- if (in!=out)
- while(n--){
- *out++=*in;
- *in++=0;
- }
- }
+ t_float *in = x->in[x->input];
+
+ while(n--)*out++=*in++;
+
return (w+4);
}