diff options
Diffstat (limited to 'src/demultiplex~.c')
-rw-r--r-- | src/demultiplex~.c | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/src/demultiplex~.c b/src/demultiplex~.c index 7d5f0b3..111e123 100644 --- a/src/demultiplex~.c +++ b/src/demultiplex~.c @@ -1,4 +1,4 @@ -/* +/* * demux~ : demultiplex a signal to a specified output * * (c) 1999-2011 IOhannes m zmölnig, forum::für::umläute, institute of electronic music and acoustics (iem) @@ -7,12 +7,12 @@ * 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 program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License along * with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -33,10 +33,12 @@ typedef struct _demux { static void demux_output(t_demux *x, t_floatarg f) { - if ((f>=0)&&(f<x->n_out)){ + if ((f>=0)&&(f<x->n_out)) { x->output=f; - } else - error("demultiplex: %d is channel out of range (0..%d)", (int)f, x->n_out); + } else { + error("demultiplex: %d is channel out of range (0..%d)", (int)f, + x->n_out); + } } @@ -49,13 +51,17 @@ static t_int *demux_perform(t_int *w) int channel=x->n_out; - while(channel--){ + while(channel--) { t_sample*out=x->out[channel]; n=N; - if(x->output==channel){ - while(n--)*out++=*in++; + if(x->output==channel) { + while(n--) { + *out++=*in++; + } } else - while(n--)*out++=0.f; + while(n--) { + *out++=0.f; + } } return (w+4); } @@ -64,7 +70,9 @@ static void demux_dsp(t_demux *x, t_signal **sp) { int n = x->n_out; t_sample **dummy=x->out; - while(n--)*dummy++=sp[x->n_out-n]->s_vec; + while(n--) { + *dummy++=sp[x->n_out-n]->s_vec; + } dsp_add(demux_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); } @@ -87,22 +95,29 @@ static void *demux_new(t_symbol* UNUSED(s), int argc, t_atom* UNUSED(argv)) t_demux *x = (t_demux *)pd_new(demux_class); int i; - if (!argc)argc=2; + if (!argc) { + argc=2; + } x->n_out=argc; x->output=0; - while(argc--)outlet_new(&x->x_obj, gensym("signal")); + while(argc--) { + outlet_new(&x->x_obj, gensym("signal")); + } x->out = (t_sample **)getbytes(x->n_out * sizeof(t_sample *)); i=x->n_out; - while(i--)x->out[i]=0; + while(i--) { + x->out[i]=0; + } return (x); } void demultiplex_tilde_setup(void) { - demux_class = class_new(gensym("demultiplex~"), (t_newmethod)demux_new, (t_method)demux_free, sizeof(t_demux), 0, A_GIMME, 0); + demux_class = class_new(gensym("demultiplex~"), (t_newmethod)demux_new, + (t_method)demux_free, sizeof(t_demux), 0, A_GIMME, 0); class_addcreator((t_newmethod)demux_new, gensym("demux~"), A_GIMME, 0); class_addfloat(demux_class, demux_output); |