diff options
Diffstat (limited to 'src/iem_t3_lib')
-rw-r--r-- | src/iem_t3_lib/iem_t3_lib.c | 132 | ||||
-rw-r--r-- | src/iem_t3_lib/sigt3_line.c | 558 | ||||
-rw-r--r-- | src/iem_t3_lib/sigt3_sig.c | 400 | ||||
-rw-r--r-- | src/iem_t3_lib/t3_bpe.c | 282 | ||||
-rw-r--r-- | src/iem_t3_lib/t3_delay.c | 192 | ||||
-rw-r--r-- | src/iem_t3_lib/t3_metro.c | 240 | ||||
-rw-r--r-- | src/iem_t3_lib/t3_timer.c | 110 |
7 files changed, 957 insertions, 957 deletions
diff --git a/src/iem_t3_lib/iem_t3_lib.c b/src/iem_t3_lib/iem_t3_lib.c index 65365ae..91b3725 100644 --- a/src/iem_t3_lib/iem_t3_lib.c +++ b/src/iem_t3_lib/iem_t3_lib.c @@ -1,66 +1,66 @@ -/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
-
-iem_t3_lib written by Gerhard Eckel, Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
-
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-#include "m_pd.h"
-#include "iemlib.h"
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <math.h>
-/*
-#include <ctype.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#ifndef NT
-#include <sys/signal.h>
-#include <unistd.h>
-#endif
-
-#ifdef NT
-#include <io.h>
-#endif
-*/
-
-static t_class *iem_t3_lib_class;
-
-static void *iem_t3_lib_new(void)
-{
- t_object *x = (t_object *)pd_new(iem_t3_lib_class);
-
- return (x);
-}
-
-void sigt3_line_setup(void);
-void sigt3_sig_setup(void);
-void t3_bpe_setup(void);
-void t3_delay_setup(void);
-void t3_metro_setup(void);
-void t3_timer_setup(void);
-
-/* ------------------------ setup routine ------------------------- */
-
-void iem_t3_lib_setup(void)
-{
- iem_t3_lib_class = class_new(gensym("iem_t3_lib"), iem_t3_lib_new, 0,
- sizeof(t_object), CLASS_NOINLET, 0);
-
- sigt3_line_setup();
- sigt3_sig_setup();
- t3_bpe_setup();
- t3_delay_setup();
- t3_metro_setup();
- t3_timer_setup();
-
- post("iem_t3_lib (R-1.16) library loaded! (c) Gerhard Eckel, Thomas Musil 05.2005");
- post(" musil%ciem.at iem KUG Graz Austria", '@');
-}
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iem_t3_lib written by Gerhard Eckel, Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */ + +#ifdef NT +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +#include "m_pd.h" +#include "iemlib.h" +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <math.h> +/* +#include <ctype.h> +#include <signal.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#ifndef NT +#include <sys/signal.h> +#include <unistd.h> +#endif + +#ifdef NT +#include <io.h> +#endif +*/ + +static t_class *iem_t3_lib_class; + +static void *iem_t3_lib_new(void) +{ + t_object *x = (t_object *)pd_new(iem_t3_lib_class); + + return (x); +} + +void sigt3_line_setup(void); +void sigt3_sig_setup(void); +void t3_bpe_setup(void); +void t3_delay_setup(void); +void t3_metro_setup(void); +void t3_timer_setup(void); + +/* ------------------------ setup routine ------------------------- */ + +void iem_t3_lib_setup(void) +{ + iem_t3_lib_class = class_new(gensym("iem_t3_lib"), iem_t3_lib_new, 0, + sizeof(t_object), CLASS_NOINLET, 0); + + sigt3_line_setup(); + sigt3_sig_setup(); + t3_bpe_setup(); + t3_delay_setup(); + t3_metro_setup(); + t3_timer_setup(); + + post("iem_t3_lib (R-1.16) library loaded! (c) Gerhard Eckel, Thomas Musil 05.2005"); + post(" musil%ciem.at iem KUG Graz Austria", '@'); +} diff --git a/src/iem_t3_lib/sigt3_line.c b/src/iem_t3_lib/sigt3_line.c index e58552f..3666098 100644 --- a/src/iem_t3_lib/sigt3_line.c +++ b/src/iem_t3_lib/sigt3_line.c @@ -1,279 +1,279 @@ -/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
-
-iem_t3_lib written by Gerhard Eckel, Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
-
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-#include "m_pd.h"
-#include "iemlib.h"
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-
-/* -------------------------- t3_line~ ------------------------------ */
-static t_class *sigt3_line_class;
-
-typedef struct _sigt3_line
-{
- t_object x_obj;
- t_clock *x_clock;
- float *x_beg;
- double x_cur_val;
- double x_dst_val;
- double x_inlet_val;
- double x_inc64;
- double x_inc;
- double x_ms2samps;
- double x_ticks2ms;
- double x_inlet_time;
- double x_dst_time;
- int x_cur_samps;
- int x_dur_samps;
- int x_n;
- int x_t3_bang_samps;
- int x_transient;
-} t_sigt3_line;
-
-static void sigt3_line_nontransient(float *vec, t_sigt3_line *x, int n)
-{
- int cur_samps = x->x_cur_samps, i;
- double inc = x->x_inc;
- double cur_val = x->x_cur_val;
-
- if(cur_samps)
- {
- if(cur_samps > n)
- {
- x->x_cur_samps -= n;
- while(n--)
- {
- cur_val += inc;
- *vec++ = (float)cur_val;
- }
- x->x_cur_val += x->x_inc64;
- }
- else if(cur_samps == n)
- {
- x->x_cur_samps = 0;
- while(n--)
- {
- cur_val += inc;
- *vec++ = (float)cur_val;
- }
- x->x_cur_val = x->x_dst_val;
- }
- else
- {
- for(i=0; i<cur_samps; i++)
- {
- cur_val += inc;
- *vec++ = (float)cur_val;
- }
- x->x_cur_val = cur_val = x->x_dst_val;
- for(i=cur_samps; i<n; i++)
- *vec++ = (float)cur_val;
- x->x_cur_samps = 0;
- }
- }
- else
- {
- while(n--)
- *vec++ = (float)cur_val;
- }
-}
-
-static t_int *sigt3_line_perform(t_int *w)
-{
- t_float *out = (t_float *)(w[1]);
- t_sigt3_line *x = (t_sigt3_line *)(w[2]);
- int n = (int)(w[3]);
-
- if(x->x_transient)
- {
- float *trans = x->x_beg;
-
- while(n--)
- *out++ = *trans++;
- x->x_transient = 0;
- }
- else
- sigt3_line_nontransient(out, x, n);
- return(w+4);
-}
-
-static void sigt3_line_tick(t_sigt3_line *x)
-{
- float *trans = x->x_beg;
- int n = x->x_n, t3_bang_samps, cur_samps, i;
- double inc, cur_val;
-
- if(!x->x_transient)
- sigt3_line_nontransient(trans, x, n);
- t3_bang_samps = x->x_t3_bang_samps;
- x->x_dst_val = x->x_inlet_val;
- if(x->x_inlet_time <= 0.0)
- {
- x->x_inlet_time = 0.0;
- x->x_dst_time = 0.0;
- x->x_dur_samps = 0;
- x->x_cur_samps = 0;
- cur_val = x->x_cur_val = x->x_dst_val;
- for(i=t3_bang_samps; i<n; i++)
- trans[i] = (float)cur_val;
- }
- else
- {
- int diff, end;
-
- x->x_dst_time = x->x_inlet_time;
- x->x_inlet_time = 0.0;
- cur_samps = (int)(x->x_dst_time * x->x_ms2samps);
- if(!cur_samps)
- cur_samps = 1;
- x->x_dur_samps = cur_samps;
- x->x_cur_samps = cur_samps;
- cur_val = x->x_cur_val = (double)trans[t3_bang_samps];
- inc = x->x_inc = (x->x_dst_val - cur_val)/(double)cur_samps;
- x->x_inc64 = (double)x->x_n * inc;
- diff = n - t3_bang_samps;
- if(cur_samps > diff)
- {
- for(i=t3_bang_samps; i<n; i++)
- {
- cur_val += inc;
- trans[i] = (float)cur_val;
- }
- x->x_cur_val += (double)diff * inc;
- x->x_cur_samps -= diff;
- }
- else if(cur_samps == diff)
- {
- for(i=t3_bang_samps; i<n; i++)
- {
- cur_val += inc;
- trans[i] = (float)cur_val;
- }
- x->x_cur_val = x->x_dst_val;
- x->x_cur_samps = 0;
- }
- else
- {
- end = t3_bang_samps + cur_samps;
- for(i=t3_bang_samps; i<end; i++)
- {
- cur_val += inc;
- trans[i] = (float)cur_val;
- }
- cur_val = x->x_cur_val = x->x_dst_val;
- x->x_cur_samps = 0;
- for(i=end; i<n; i++)
- trans[i] = (float)cur_val;
- }
- }
- x->x_transient = 1;
-}
-
-static void sigt3_line_list(t_sigt3_line *x, t_symbol *s, int ac, t_atom *av)
-{
- if((ac >= 2)&&IS_A_FLOAT(av,0)&&IS_A_FLOAT(av,1))
- {
- int t3_bang_samps, ticks;
- double time;
-
- x->x_inlet_val = (double)atom_getfloatarg(1, ac, av);
- t3_bang_samps = (int)((float)atom_getfloatarg(0, ac, av)*x->x_ms2samps);
- if(t3_bang_samps < 0)
- t3_bang_samps = 0;
- ticks = t3_bang_samps / x->x_n;
- x->x_t3_bang_samps = t3_bang_samps - x->x_n * ticks;
- if((ac >= 3)&&IS_A_FLOAT(av,2))
- {
- time = (double)atom_getfloatarg(2, ac, av);
- if(time < 0.0)
- time = 0.0;
- x->x_inlet_time = time;
- }
- if(ticks < 1)
- sigt3_line_tick(x);
- else
- clock_delay(x->x_clock, (double)ticks * x->x_ticks2ms);
- }
-}
-
-static void sigt3_line_ft1(t_sigt3_line *x, t_float time)
-{
- if(time < 0.0)
- time = 0.0;
- x->x_inlet_time = (double)time;
-}
-
-static void sigt3_line_stop(t_sigt3_line *x)
-{
- clock_unset(x->x_clock);
- x->x_cur_samps = x->x_dur_samps = x->x_transient = 0;
- x->x_inc = x->x_inc64 = x->x_inlet_time = x->x_dst_time = 0.0;
-}
-
-static void sigt3_line_dsp(t_sigt3_line *x, t_signal **sp)
-{
- int i;
- float val, *trans;
-
- if(sp[0]->s_n > x->x_n)
- {
- freebytes(x->x_beg, x->x_n*sizeof(float));
- x->x_n = (int)sp[0]->s_n;
- x->x_beg = (float *)getbytes(x->x_n*sizeof(float));
- }
- else
- x->x_n = (int)sp[0]->s_n;
- i = x->x_n;
- val = x->x_cur_val;
- trans = x->x_beg;
- while(i--)
- *trans++ = val;
- x->x_ms2samps = 0.001*(double)sp[0]->s_sr;
- x->x_ticks2ms = (double)x->x_n / x->x_ms2samps;
- dsp_add(sigt3_line_perform, 3, sp[0]->s_vec, x, sp[0]->s_n);
-}
-
-static void sigt3_line_free(t_sigt3_line *x)
-{
- if(x->x_beg)
- freebytes(x->x_beg, x->x_n*sizeof(float));
- clock_free(x->x_clock);
-}
-
-static void *sigt3_line_new(t_floatarg init_val)
-{
- t_sigt3_line *x = (t_sigt3_line *)pd_new(sigt3_line_class);
- int i;
-
- x->x_n = (int)sys_getblksize();
- x->x_beg = (float *)getbytes(x->x_n*sizeof(float));
- x->x_inlet_val = x->x_cur_val = x->x_dst_val = init_val;
- x->x_t3_bang_samps = x->x_cur_samps = x->x_dur_samps = x->x_transient = 0;
- x->x_inlet_time = x->x_dst_time = 0.0;
- x->x_inc64 = x->x_inc = 0.0;
- x->x_ms2samps = 0.001 * (double)sys_getsr();
- x->x_ticks2ms = (double)x->x_n / x->x_ms2samps;
- x->x_clock = clock_new(x, (t_method)sigt3_line_tick);
- outlet_new(&x->x_obj, &s_signal);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
- return (x);
-}
-
-void sigt3_line_setup(void)
-{
- sigt3_line_class = class_new(gensym("t3_line~"), (t_newmethod)sigt3_line_new,
- (t_method)sigt3_line_free, sizeof(t_sigt3_line), 0, A_DEFFLOAT, 0);
- class_addmethod(sigt3_line_class, (t_method)sigt3_line_dsp, gensym("dsp"), 0);
- class_addmethod(sigt3_line_class, (t_method)sigt3_line_stop, gensym("stop"), 0);
- class_addmethod(sigt3_line_class, (t_method)sigt3_line_ft1, gensym("ft1"), A_FLOAT, 0);
- class_addlist(sigt3_line_class, (t_method)sigt3_line_list);
- class_sethelpsymbol(sigt3_line_class, gensym("iemhelp/help-t3_line~"));
-}
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iem_t3_lib written by Gerhard Eckel, Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */ + +#ifdef NT +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +#include "m_pd.h" +#include "iemlib.h" +#include <math.h> +#include <stdio.h> +#include <string.h> + +/* -------------------------- t3_line~ ------------------------------ */ +static t_class *sigt3_line_class; + +typedef struct _sigt3_line +{ + t_object x_obj; + t_clock *x_clock; + float *x_beg; + double x_cur_val; + double x_dst_val; + double x_inlet_val; + double x_inc64; + double x_inc; + double x_ms2samps; + double x_ticks2ms; + double x_inlet_time; + double x_dst_time; + int x_cur_samps; + int x_dur_samps; + int x_n; + int x_t3_bang_samps; + int x_transient; +} t_sigt3_line; + +static void sigt3_line_nontransient(float *vec, t_sigt3_line *x, int n) +{ + int cur_samps = x->x_cur_samps, i; + double inc = x->x_inc; + double cur_val = x->x_cur_val; + + if(cur_samps) + { + if(cur_samps > n) + { + x->x_cur_samps -= n; + while(n--) + { + cur_val += inc; + *vec++ = (float)cur_val; + } + x->x_cur_val += x->x_inc64; + } + else if(cur_samps == n) + { + x->x_cur_samps = 0; + while(n--) + { + cur_val += inc; + *vec++ = (float)cur_val; + } + x->x_cur_val = x->x_dst_val; + } + else + { + for(i=0; i<cur_samps; i++) + { + cur_val += inc; + *vec++ = (float)cur_val; + } + x->x_cur_val = cur_val = x->x_dst_val; + for(i=cur_samps; i<n; i++) + *vec++ = (float)cur_val; + x->x_cur_samps = 0; + } + } + else + { + while(n--) + *vec++ = (float)cur_val; + } +} + +static t_int *sigt3_line_perform(t_int *w) +{ + t_float *out = (t_float *)(w[1]); + t_sigt3_line *x = (t_sigt3_line *)(w[2]); + int n = (int)(w[3]); + + if(x->x_transient) + { + float *trans = x->x_beg; + + while(n--) + *out++ = *trans++; + x->x_transient = 0; + } + else + sigt3_line_nontransient(out, x, n); + return(w+4); +} + +static void sigt3_line_tick(t_sigt3_line *x) +{ + float *trans = x->x_beg; + int n = x->x_n, t3_bang_samps, cur_samps, i; + double inc, cur_val; + + if(!x->x_transient) + sigt3_line_nontransient(trans, x, n); + t3_bang_samps = x->x_t3_bang_samps; + x->x_dst_val = x->x_inlet_val; + if(x->x_inlet_time <= 0.0) + { + x->x_inlet_time = 0.0; + x->x_dst_time = 0.0; + x->x_dur_samps = 0; + x->x_cur_samps = 0; + cur_val = x->x_cur_val = x->x_dst_val; + for(i=t3_bang_samps; i<n; i++) + trans[i] = (float)cur_val; + } + else + { + int diff, end; + + x->x_dst_time = x->x_inlet_time; + x->x_inlet_time = 0.0; + cur_samps = (int)(x->x_dst_time * x->x_ms2samps); + if(!cur_samps) + cur_samps = 1; + x->x_dur_samps = cur_samps; + x->x_cur_samps = cur_samps; + cur_val = x->x_cur_val = (double)trans[t3_bang_samps]; + inc = x->x_inc = (x->x_dst_val - cur_val)/(double)cur_samps; + x->x_inc64 = (double)x->x_n * inc; + diff = n - t3_bang_samps; + if(cur_samps > diff) + { + for(i=t3_bang_samps; i<n; i++) + { + cur_val += inc; + trans[i] = (float)cur_val; + } + x->x_cur_val += (double)diff * inc; + x->x_cur_samps -= diff; + } + else if(cur_samps == diff) + { + for(i=t3_bang_samps; i<n; i++) + { + cur_val += inc; + trans[i] = (float)cur_val; + } + x->x_cur_val = x->x_dst_val; + x->x_cur_samps = 0; + } + else + { + end = t3_bang_samps + cur_samps; + for(i=t3_bang_samps; i<end; i++) + { + cur_val += inc; + trans[i] = (float)cur_val; + } + cur_val = x->x_cur_val = x->x_dst_val; + x->x_cur_samps = 0; + for(i=end; i<n; i++) + trans[i] = (float)cur_val; + } + } + x->x_transient = 1; +} + +static void sigt3_line_list(t_sigt3_line *x, t_symbol *s, int ac, t_atom *av) +{ + if((ac >= 2)&&IS_A_FLOAT(av,0)&&IS_A_FLOAT(av,1)) + { + int t3_bang_samps, ticks; + double time; + + x->x_inlet_val = (double)atom_getfloatarg(1, ac, av); + t3_bang_samps = (int)((float)atom_getfloatarg(0, ac, av)*x->x_ms2samps); + if(t3_bang_samps < 0) + t3_bang_samps = 0; + ticks = t3_bang_samps / x->x_n; + x->x_t3_bang_samps = t3_bang_samps - x->x_n * ticks; + if((ac >= 3)&&IS_A_FLOAT(av,2)) + { + time = (double)atom_getfloatarg(2, ac, av); + if(time < 0.0) + time = 0.0; + x->x_inlet_time = time; + } + if(ticks < 1) + sigt3_line_tick(x); + else + clock_delay(x->x_clock, (double)ticks * x->x_ticks2ms); + } +} + +static void sigt3_line_ft1(t_sigt3_line *x, t_float time) +{ + if(time < 0.0) + time = 0.0; + x->x_inlet_time = (double)time; +} + +static void sigt3_line_stop(t_sigt3_line *x) +{ + clock_unset(x->x_clock); + x->x_cur_samps = x->x_dur_samps = x->x_transient = 0; + x->x_inc = x->x_inc64 = x->x_inlet_time = x->x_dst_time = 0.0; +} + +static void sigt3_line_dsp(t_sigt3_line *x, t_signal **sp) +{ + int i; + float val, *trans; + + if(sp[0]->s_n > x->x_n) + { + freebytes(x->x_beg, x->x_n*sizeof(float)); + x->x_n = (int)sp[0]->s_n; + x->x_beg = (float *)getbytes(x->x_n*sizeof(float)); + } + else + x->x_n = (int)sp[0]->s_n; + i = x->x_n; + val = x->x_cur_val; + trans = x->x_beg; + while(i--) + *trans++ = val; + x->x_ms2samps = 0.001*(double)sp[0]->s_sr; + x->x_ticks2ms = (double)x->x_n / x->x_ms2samps; + dsp_add(sigt3_line_perform, 3, sp[0]->s_vec, x, sp[0]->s_n); +} + +static void sigt3_line_free(t_sigt3_line *x) +{ + if(x->x_beg) + freebytes(x->x_beg, x->x_n*sizeof(float)); + clock_free(x->x_clock); +} + +static void *sigt3_line_new(t_floatarg init_val) +{ + t_sigt3_line *x = (t_sigt3_line *)pd_new(sigt3_line_class); + int i; + + x->x_n = (int)sys_getblksize(); + x->x_beg = (float *)getbytes(x->x_n*sizeof(float)); + x->x_inlet_val = x->x_cur_val = x->x_dst_val = init_val; + x->x_t3_bang_samps = x->x_cur_samps = x->x_dur_samps = x->x_transient = 0; + x->x_inlet_time = x->x_dst_time = 0.0; + x->x_inc64 = x->x_inc = 0.0; + x->x_ms2samps = 0.001 * (double)sys_getsr(); + x->x_ticks2ms = (double)x->x_n / x->x_ms2samps; + x->x_clock = clock_new(x, (t_method)sigt3_line_tick); + outlet_new(&x->x_obj, &s_signal); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1")); + return (x); +} + +void sigt3_line_setup(void) +{ + sigt3_line_class = class_new(gensym("t3_line~"), (t_newmethod)sigt3_line_new, + (t_method)sigt3_line_free, sizeof(t_sigt3_line), 0, A_DEFFLOAT, 0); + class_addmethod(sigt3_line_class, (t_method)sigt3_line_dsp, gensym("dsp"), 0); + class_addmethod(sigt3_line_class, (t_method)sigt3_line_stop, gensym("stop"), 0); + class_addmethod(sigt3_line_class, (t_method)sigt3_line_ft1, gensym("ft1"), A_FLOAT, 0); + class_addlist(sigt3_line_class, (t_method)sigt3_line_list); + class_sethelpsymbol(sigt3_line_class, gensym("iemhelp/help-t3_line~")); +} diff --git a/src/iem_t3_lib/sigt3_sig.c b/src/iem_t3_lib/sigt3_sig.c index fcfedee..27dc01d 100644 --- a/src/iem_t3_lib/sigt3_sig.c +++ b/src/iem_t3_lib/sigt3_sig.c @@ -1,200 +1,200 @@ -/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
-
-iem_t3_lib written by Gerhard Eckel, Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
-
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-#include "m_pd.h"
-#include "iemlib.h"
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-
-/* -------------------------- sigt3_sig~ ------------------------------ */
-static t_class *sigt3_sig_class;
-
-typedef struct _sigt3_sig
-{
- t_object x_obj;
- t_clock *x_clock;
- float x_old_val;
- float x_new_val;
- float *x_beg;
- int x_n;
- int x_t3_bang_samps;
- int x_transient;
- float x_ms2samps;
- float x_ticks2ms;
-} t_sigt3_sig;
-
-static void sigt3_sig_tick(t_sigt3_sig *x)
-{
- float *trans = x->x_beg, val;
- int n = x->x_n, t3_bang_samps, i;
-
- t3_bang_samps = x->x_t3_bang_samps;
- if(!x->x_transient)
- {
- val = x->x_old_val;
- for(i=0; i<t3_bang_samps; i++)
- trans[i] = val;
- x->x_transient = 1;
- }
- val = x->x_old_val = x->x_new_val;
- for(i=t3_bang_samps; i<n; i++)
- trans[i] = val;
-}
-
-static void sigt3_sig_stop(t_sigt3_sig *x)
-{
- clock_unset(x->x_clock);
- x->x_new_val = x->x_old_val;
-}
-
-static void sigt3_sig_list(t_sigt3_sig *x, t_symbol *s, int ac, t_atom *av)
-{
- if((ac == 2)&&IS_A_FLOAT(av,0)&&IS_A_FLOAT(av,1))
- {
- int n = x->x_n, t3_bang_samps, ticks;
-
- t3_bang_samps = (int)((float)atom_getfloatarg(0, ac, av)*x->x_ms2samps);
- x->x_new_val = (float)atom_getfloatarg(1, ac, av);
- if(t3_bang_samps < 0)
- t3_bang_samps = 0;
- ticks = t3_bang_samps / n;
- x->x_t3_bang_samps = t3_bang_samps - n*ticks;
- if(ticks < 1)
- sigt3_sig_tick(x);
- else
- clock_delay(x->x_clock, (double)ticks * (double)x->x_ticks2ms);
- }
-}
-
-static t_int *sigt3_sig_perform(t_int *w)
-{
- t_float *out = (t_float *)(w[1]);
- t_sigt3_sig *x = (t_sigt3_sig *)(w[2]);
- int n = (int)(w[3]);
-
- if(x->x_transient)
- {
- float *trans = x->x_beg;
-
- while(n--)
- *out++ = *trans++;
- x->x_transient = 0;
- }
- else
- {
- float val = x->x_new_val;
-
- while(n--)
- *out++ = val;
- }
- return (w+4);
-}
-
-static t_int *sigt3_sig_perf8(t_int *w)
-{
- t_float *out = (t_float *)(w[1]);
- t_sigt3_sig *x = (t_sigt3_sig *)(w[2]);
- int n = (int)(w[3]), i;
-
- if(x->x_transient)
- {
- float *trans = x->x_beg;
-
- for(i=0; i<n; i+=8, out+=8, trans+=8)
- {
- out[0] = trans[0];
- out[1] = trans[1];
- out[2] = trans[2];
- out[3] = trans[3];
- out[4] = trans[4];
- out[5] = trans[5];
- out[6] = trans[6];
- out[7] = trans[7];
- }
- x->x_transient = 0;
- }
- else
- {
- float val = x->x_new_val;
-
- for(i=0; i<n; i+=8, out+=8)
- {
- out[0] = val;
- out[1] = val;
- out[2] = val;
- out[3] = val;
- out[4] = val;
- out[5] = val;
- out[6] = val;
- out[7] = val;
- }
- }
- return (w+4);
-}
-
-static void sigt3_sig_dsp(t_sigt3_sig *x, t_signal **sp)
-{
- int i;
- float *trans, val;
-
- if(sp[0]->s_n > x->x_n)
- {
- freebytes(x->x_beg, x->x_n*sizeof(float));
- x->x_n = sp[0]->s_n;
- x->x_beg = (float *)getbytes(x->x_n*sizeof(float));
- }
- else
- x->x_n = sp[0]->s_n;
- x->x_ms2samps = 0.001*(float)sp[0]->s_sr;
- x->x_ticks2ms = (float)x->x_n / x->x_ms2samps;
- i = x->x_n;
- val = x->x_new_val;
- trans = x->x_beg;
- while(i--)
- *trans++ = val;
-
- if((sp[0]->s_n)&7)
- dsp_add(sigt3_sig_perform, 3, sp[0]->s_vec, x, sp[0]->s_n);
- else
- dsp_add(sigt3_sig_perf8, 3, sp[0]->s_vec, x, sp[0]->s_n);
-}
-
-static void sigt3_sig_free(t_sigt3_sig *x)
-{
- if(x->x_beg)
- freebytes(x->x_beg, x->x_n*sizeof(float));
- clock_free(x->x_clock);
-}
-
-static void *sigt3_sig_new(t_floatarg init_val)
-{
- t_sigt3_sig *x = (t_sigt3_sig *)pd_new(sigt3_sig_class);
-
- x->x_new_val = x->x_old_val = init_val;
- x->x_n = (int)sys_getblksize();
- x->x_beg = (float *)getbytes(x->x_n*sizeof(float));
- x->x_t3_bang_samps = x->x_transient = 0;
- x->x_ms2samps = 0.001 * (float)sys_getsr();
- x->x_ticks2ms = (float)x->x_n / x->x_ms2samps;
- x->x_clock = clock_new(x, (t_method)sigt3_sig_tick);
- outlet_new(&x->x_obj, &s_signal);
- return (x);
-}
-
-void sigt3_sig_setup(void)
-{
- sigt3_sig_class = class_new(gensym("t3_sig~"), (t_newmethod)sigt3_sig_new,
- (t_method)sigt3_sig_free, sizeof(t_sigt3_sig), 0, A_DEFFLOAT, 0);
- class_addmethod(sigt3_sig_class, (t_method)sigt3_sig_dsp, gensym("dsp"), 0);
- class_addmethod(sigt3_sig_class, (t_method)sigt3_sig_stop, gensym("stop"), 0);
- class_addlist(sigt3_sig_class, (t_method)sigt3_sig_list);
- class_sethelpsymbol(sigt3_sig_class, gensym("iemhelp/help-t3_sig~"));
-}
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iem_t3_lib written by Gerhard Eckel, Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */ + +#ifdef NT +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +#include "m_pd.h" +#include "iemlib.h" +#include <math.h> +#include <stdio.h> +#include <string.h> + +/* -------------------------- sigt3_sig~ ------------------------------ */ +static t_class *sigt3_sig_class; + +typedef struct _sigt3_sig +{ + t_object x_obj; + t_clock *x_clock; + float x_old_val; + float x_new_val; + float *x_beg; + int x_n; + int x_t3_bang_samps; + int x_transient; + float x_ms2samps; + float x_ticks2ms; +} t_sigt3_sig; + +static void sigt3_sig_tick(t_sigt3_sig *x) +{ + float *trans = x->x_beg, val; + int n = x->x_n, t3_bang_samps, i; + + t3_bang_samps = x->x_t3_bang_samps; + if(!x->x_transient) + { + val = x->x_old_val; + for(i=0; i<t3_bang_samps; i++) + trans[i] = val; + x->x_transient = 1; + } + val = x->x_old_val = x->x_new_val; + for(i=t3_bang_samps; i<n; i++) + trans[i] = val; +} + +static void sigt3_sig_stop(t_sigt3_sig *x) +{ + clock_unset(x->x_clock); + x->x_new_val = x->x_old_val; +} + +static void sigt3_sig_list(t_sigt3_sig *x, t_symbol *s, int ac, t_atom *av) +{ + if((ac == 2)&&IS_A_FLOAT(av,0)&&IS_A_FLOAT(av,1)) + { + int n = x->x_n, t3_bang_samps, ticks; + + t3_bang_samps = (int)((float)atom_getfloatarg(0, ac, av)*x->x_ms2samps); + x->x_new_val = (float)atom_getfloatarg(1, ac, av); + if(t3_bang_samps < 0) + t3_bang_samps = 0; + ticks = t3_bang_samps / n; + x->x_t3_bang_samps = t3_bang_samps - n*ticks; + if(ticks < 1) + sigt3_sig_tick(x); + else + clock_delay(x->x_clock, (double)ticks * (double)x->x_ticks2ms); + } +} + +static t_int *sigt3_sig_perform(t_int *w) +{ + t_float *out = (t_float *)(w[1]); + t_sigt3_sig *x = (t_sigt3_sig *)(w[2]); + int n = (int)(w[3]); + + if(x->x_transient) + { + float *trans = x->x_beg; + + while(n--) + *out++ = *trans++; + x->x_transient = 0; + } + else + { + float val = x->x_new_val; + + while(n--) + *out++ = val; + } + return (w+4); +} + +static t_int *sigt3_sig_perf8(t_int *w) +{ + t_float *out = (t_float *)(w[1]); + t_sigt3_sig *x = (t_sigt3_sig *)(w[2]); + int n = (int)(w[3]), i; + + if(x->x_transient) + { + float *trans = x->x_beg; + + for(i=0; i<n; i+=8, out+=8, trans+=8) + { + out[0] = trans[0]; + out[1] = trans[1]; + out[2] = trans[2]; + out[3] = trans[3]; + out[4] = trans[4]; + out[5] = trans[5]; + out[6] = trans[6]; + out[7] = trans[7]; + } + x->x_transient = 0; + } + else + { + float val = x->x_new_val; + + for(i=0; i<n; i+=8, out+=8) + { + out[0] = val; + out[1] = val; + out[2] = val; + out[3] = val; + out[4] = val; + out[5] = val; + out[6] = val; + out[7] = val; + } + } + return (w+4); +} + +static void sigt3_sig_dsp(t_sigt3_sig *x, t_signal **sp) +{ + int i; + float *trans, val; + + if(sp[0]->s_n > x->x_n) + { + freebytes(x->x_beg, x->x_n*sizeof(float)); + x->x_n = sp[0]->s_n; + x->x_beg = (float *)getbytes(x->x_n*sizeof(float)); + } + else + x->x_n = sp[0]->s_n; + x->x_ms2samps = 0.001*(float)sp[0]->s_sr; + x->x_ticks2ms = (float)x->x_n / x->x_ms2samps; + i = x->x_n; + val = x->x_new_val; + trans = x->x_beg; + while(i--) + *trans++ = val; + + if((sp[0]->s_n)&7) + dsp_add(sigt3_sig_perform, 3, sp[0]->s_vec, x, sp[0]->s_n); + else + dsp_add(sigt3_sig_perf8, 3, sp[0]->s_vec, x, sp[0]->s_n); +} + +static void sigt3_sig_free(t_sigt3_sig *x) +{ + if(x->x_beg) + freebytes(x->x_beg, x->x_n*sizeof(float)); + clock_free(x->x_clock); +} + +static void *sigt3_sig_new(t_floatarg init_val) +{ + t_sigt3_sig *x = (t_sigt3_sig *)pd_new(sigt3_sig_class); + + x->x_new_val = x->x_old_val = init_val; + x->x_n = (int)sys_getblksize(); + x->x_beg = (float *)getbytes(x->x_n*sizeof(float)); + x->x_t3_bang_samps = x->x_transient = 0; + x->x_ms2samps = 0.001 * (float)sys_getsr(); + x->x_ticks2ms = (float)x->x_n / x->x_ms2samps; + x->x_clock = clock_new(x, (t_method)sigt3_sig_tick); + outlet_new(&x->x_obj, &s_signal); + return (x); +} + +void sigt3_sig_setup(void) +{ + sigt3_sig_class = class_new(gensym("t3_sig~"), (t_newmethod)sigt3_sig_new, + (t_method)sigt3_sig_free, sizeof(t_sigt3_sig), 0, A_DEFFLOAT, 0); + class_addmethod(sigt3_sig_class, (t_method)sigt3_sig_dsp, gensym("dsp"), 0); + class_addmethod(sigt3_sig_class, (t_method)sigt3_sig_stop, gensym("stop"), 0); + class_addlist(sigt3_sig_class, (t_method)sigt3_sig_list); + class_sethelpsymbol(sigt3_sig_class, gensym("iemhelp/help-t3_sig~")); +} diff --git a/src/iem_t3_lib/t3_bpe.c b/src/iem_t3_lib/t3_bpe.c index 24c61f9..2aa7846 100644 --- a/src/iem_t3_lib/t3_bpe.c +++ b/src/iem_t3_lib/t3_bpe.c @@ -1,141 +1,141 @@ -/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
-
-iem_t3_lib written by Gerhard Eckel, Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
-
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-#include "m_pd.h"
-#include "iemlib.h"
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-
-/* ------------------------ t3_bpe ---------------------------- */
-static t_class *t3_bpe_class;
-
-typedef struct _t3_bpe
-{
- t_object x_obj;
- t_atom x_at[2];
- t_clock *x_clock;
- int x_maxnum;
- int x_curnum;
- int x_curindex;
- t_atom *x_beg;
- double x_t3_bang;
- double x_ticks2ms;
- int x_hit;
- void *x_out_val;
- void *x_out_time;
- void *x_out_finished;
-} t_t3_bpe;
-
-static void t3_bpe_stop(t_t3_bpe *x)
-{
- clock_unset(x->x_clock);
-}
-
-static void t3_bpe_tick(t_t3_bpe *x)
-{
- t_atom *vec = x->x_beg;
- float val;
- double dticks, time;
- int iticks;
-
- if(x->x_curindex >= x->x_curnum)
- {
- t3_bpe_stop(x);
- outlet_float(x->x_out_finished, x->x_t3_bang);
- }
- else
- {
- x->x_hit = 0;
- vec += x->x_curindex;
- val = atom_getfloat(vec++);
- time = (double)atom_getfloat(vec);
- outlet_float(x->x_out_time, (float)time);
- x->x_at[1].a_w.w_float = val;
- x->x_at[0].a_w.w_float = x->x_t3_bang;
- outlet_list(x->x_obj.ob_outlet, &s_list, 2, x->x_at);
- dticks = (time + x->x_t3_bang)/x->x_ticks2ms;
- iticks = (int)dticks;
- x->x_t3_bang = (dticks - (double)iticks)*x->x_ticks2ms;
- if(!x->x_hit)
- clock_delay(x->x_clock, (double)iticks*x->x_ticks2ms);
- x->x_curindex += 2;
- }
-}
-
-static void t3_bpe_float(t_t3_bpe *x, t_floatarg f)
-{
- double dticks;
- int iticks;
-
- if(x->x_curnum)
- {
- x->x_curindex = 0;
- dticks = (double)f/x->x_ticks2ms;
- iticks = (int)dticks;
- x->x_t3_bang = (dticks - (double)iticks)*x->x_ticks2ms;
- clock_delay(x->x_clock, (double)iticks*x->x_ticks2ms);
- x->x_hit = 1;
- }
-}
-
-static void t3_bpe_list(t_t3_bpe *x, t_symbol *s, int ac, t_atom *av)
-{
- int n = ac & 0xfffffffe, i;
- t_atom *vec = x->x_beg;
- if(n > x->x_maxnum)
- {
- freebytes(x->x_beg, x->x_maxnum*sizeof(t_atom));
- x->x_maxnum = 2 + n;
- x->x_beg = (t_atom *)getbytes(x->x_maxnum*sizeof(t_atom));
- vec = x->x_beg;
- }
- x->x_curnum = n;
- for(i=0; i<n; i++)
- {
- *vec++ = *av++;
- }
-}
-
-static void t3_bpe_free(t_t3_bpe *x)
-{
- freebytes(x->x_beg, x->x_maxnum*sizeof(t_atom));
- clock_free(x->x_clock);
-}
-
-static void *t3_bpe_new(void)
-{
- t_t3_bpe *x = (t_t3_bpe *)pd_new(t3_bpe_class);
-
- x->x_t3_bang = 0.0;
- x->x_ticks2ms = 1000.0*(double)sys_getblksize()/(double)sys_getsr();
- x->x_curindex = 0;
- x->x_maxnum = 20;
- x->x_curnum = 0;
- x->x_hit = 0;
- x->x_beg = (t_atom *)getbytes(x->x_maxnum*sizeof(t_atom));
- x->x_clock = clock_new(x, (t_method)t3_bpe_tick);
- outlet_new(&x->x_obj, &s_list);
- x->x_out_time = outlet_new(&x->x_obj, &s_float);
- x->x_out_finished = outlet_new(&x->x_obj, &s_float);
- x->x_at[0].a_type = A_FLOAT;
- x->x_at[1].a_type = A_FLOAT;
- return (x);
-}
-
-void t3_bpe_setup(void)
-{
- t3_bpe_class = class_new(gensym("t3_bpe"), (t_newmethod)t3_bpe_new,
- (t_method)t3_bpe_free, sizeof(t_t3_bpe), 0, 0);
- class_addmethod(t3_bpe_class, (t_method)t3_bpe_stop, gensym("stop"), 0);
- class_addfloat(t3_bpe_class, (t_method)t3_bpe_float);
- class_addlist(t3_bpe_class, (t_method)t3_bpe_list);
- class_sethelpsymbol(t3_bpe_class, gensym("iemhelp/help-t3_bpe"));
-}
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iem_t3_lib written by Gerhard Eckel, Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */ + +#ifdef NT +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +#include "m_pd.h" +#include "iemlib.h" +#include <math.h> +#include <stdio.h> +#include <string.h> + +/* ------------------------ t3_bpe ---------------------------- */ +static t_class *t3_bpe_class; + +typedef struct _t3_bpe +{ + t_object x_obj; + t_atom x_at[2]; + t_clock *x_clock; + int x_maxnum; + int x_curnum; + int x_curindex; + t_atom *x_beg; + double x_t3_bang; + double x_ticks2ms; + int x_hit; + void *x_out_val; + void *x_out_time; + void *x_out_finished; +} t_t3_bpe; + +static void t3_bpe_stop(t_t3_bpe *x) +{ + clock_unset(x->x_clock); +} + +static void t3_bpe_tick(t_t3_bpe *x) +{ + t_atom *vec = x->x_beg; + float val; + double dticks, time; + int iticks; + + if(x->x_curindex >= x->x_curnum) + { + t3_bpe_stop(x); + outlet_float(x->x_out_finished, x->x_t3_bang); + } + else + { + x->x_hit = 0; + vec += x->x_curindex; + val = atom_getfloat(vec++); + time = (double)atom_getfloat(vec); + outlet_float(x->x_out_time, (float)time); + x->x_at[1].a_w.w_float = val; + x->x_at[0].a_w.w_float = x->x_t3_bang; + outlet_list(x->x_obj.ob_outlet, &s_list, 2, x->x_at); + dticks = (time + x->x_t3_bang)/x->x_ticks2ms; + iticks = (int)dticks; + x->x_t3_bang = (dticks - (double)iticks)*x->x_ticks2ms; + if(!x->x_hit) + clock_delay(x->x_clock, (double)iticks*x->x_ticks2ms); + x->x_curindex += 2; + } +} + +static void t3_bpe_float(t_t3_bpe *x, t_floatarg f) +{ + double dticks; + int iticks; + + if(x->x_curnum) + { + x->x_curindex = 0; + dticks = (double)f/x->x_ticks2ms; + iticks = (int)dticks; + x->x_t3_bang = (dticks - (double)iticks)*x->x_ticks2ms; + clock_delay(x->x_clock, (double)iticks*x->x_ticks2ms); + x->x_hit = 1; + } +} + +static void t3_bpe_list(t_t3_bpe *x, t_symbol *s, int ac, t_atom *av) +{ + int n = ac & 0xfffffffe, i; + t_atom *vec = x->x_beg; + if(n > x->x_maxnum) + { + freebytes(x->x_beg, x->x_maxnum*sizeof(t_atom)); + x->x_maxnum = 2 + n; + x->x_beg = (t_atom *)getbytes(x->x_maxnum*sizeof(t_atom)); + vec = x->x_beg; + } + x->x_curnum = n; + for(i=0; i<n; i++) + { + *vec++ = *av++; + } +} + +static void t3_bpe_free(t_t3_bpe *x) +{ + freebytes(x->x_beg, x->x_maxnum*sizeof(t_atom)); + clock_free(x->x_clock); +} + +static void *t3_bpe_new(void) +{ + t_t3_bpe *x = (t_t3_bpe *)pd_new(t3_bpe_class); + + x->x_t3_bang = 0.0; + x->x_ticks2ms = 1000.0*(double)sys_getblksize()/(double)sys_getsr(); + x->x_curindex = 0; + x->x_maxnum = 20; + x->x_curnum = 0; + x->x_hit = 0; + x->x_beg = (t_atom *)getbytes(x->x_maxnum*sizeof(t_atom)); + x->x_clock = clock_new(x, (t_method)t3_bpe_tick); + outlet_new(&x->x_obj, &s_list); + x->x_out_time = outlet_new(&x->x_obj, &s_float); + x->x_out_finished = outlet_new(&x->x_obj, &s_float); + x->x_at[0].a_type = A_FLOAT; + x->x_at[1].a_type = A_FLOAT; + return (x); +} + +void t3_bpe_setup(void) +{ + t3_bpe_class = class_new(gensym("t3_bpe"), (t_newmethod)t3_bpe_new, + (t_method)t3_bpe_free, sizeof(t_t3_bpe), 0, 0); + class_addmethod(t3_bpe_class, (t_method)t3_bpe_stop, gensym("stop"), 0); + class_addfloat(t3_bpe_class, (t_method)t3_bpe_float); + class_addlist(t3_bpe_class, (t_method)t3_bpe_list); + class_sethelpsymbol(t3_bpe_class, gensym("iemhelp/help-t3_bpe")); +} diff --git a/src/iem_t3_lib/t3_delay.c b/src/iem_t3_lib/t3_delay.c index da7dd06..0298832 100644 --- a/src/iem_t3_lib/t3_delay.c +++ b/src/iem_t3_lib/t3_delay.c @@ -1,96 +1,96 @@ -/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
-
-iem_t3_lib written by Gerhard Eckel, Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
-
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-#include "m_pd.h"
-#include "iemlib.h"
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-
-/* ------------------------ t3_delay ---------------------------- */
-static t_class *t3_delay_class;
-
-typedef struct _t3_delay
-{
- t_object x_obj;
- t_clock *x_clock;
- double x_deltime;
- double x_ticks2ms;
- double x_t3_bang;
-} t_t3_delay;
-
-static void t3_delay_tick(t_t3_delay *x)
-{
- outlet_float(x->x_obj.ob_outlet, x->x_t3_bang);
-}
-
-static void t3_delay_stop(t_t3_delay *x)
-{
- clock_unset(x->x_clock);
-}
-
-static void t3_delay_float(t_t3_delay *x, t_floatarg t3_bang)
-{
- double dticks;
- int iticks;
-
- if(t3_bang < 0)
- t3_bang = 0;
- dticks = (x->x_deltime + (double)t3_bang)/x->x_ticks2ms;
- iticks = (int)dticks;
- x->x_t3_bang = (dticks - (double)iticks)*x->x_ticks2ms;
- clock_delay(x->x_clock, (double)iticks*x->x_ticks2ms);
-}
-
-static void t3_delay_ft1(t_t3_delay *x, t_floatarg f)
-{
- if(f < 0)
- f = 0;
- x->x_deltime = f;
-}
-
-static void t3_delay_list(t_t3_delay *x, t_symbol *s, int ac, t_atom *av)
-{
- if((ac == 2)&&IS_A_FLOAT(av,0)&&IS_A_FLOAT(av,1))
- {
- t3_delay_ft1(x, atom_getfloatarg(1, ac, av));
- t3_delay_float(x, atom_getfloatarg(0, ac, av));
- }
-}
-
-static void t3_delay_free(t_t3_delay *x)
-{
- clock_free(x->x_clock);
-}
-
-static void *t3_delay_new(t_floatarg f)
-{
- t_t3_delay *x = (t_t3_delay *)pd_new(t3_delay_class);
-
- x->x_ticks2ms = 1000.0*(double)sys_getblksize()/(double)sys_getsr();
- t3_delay_ft1(x, f);
- x->x_clock = clock_new(x, (t_method)t3_delay_tick);
- outlet_new(&x->x_obj, &s_float);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
- return (x);
-}
-
-void t3_delay_setup(void)
-{
- t3_delay_class = class_new(gensym("t3_delay"), (t_newmethod)t3_delay_new,
- (t_method)t3_delay_free, sizeof(t_t3_delay), 0, A_DEFFLOAT, 0);
- class_addcreator((t_newmethod)t3_delay_new, gensym("t3_del"), A_DEFFLOAT, 0);
- class_addmethod(t3_delay_class, (t_method)t3_delay_stop, gensym("stop"), 0);
- class_addmethod(t3_delay_class, (t_method)t3_delay_ft1,
- gensym("ft1"), A_FLOAT, 0);
- class_addfloat(t3_delay_class, (t_method)t3_delay_float);
- class_addlist(t3_delay_class, (t_method)t3_delay_list);
- class_sethelpsymbol(t3_delay_class, gensym("iemhelp/help-t3_delay"));
-}
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iem_t3_lib written by Gerhard Eckel, Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */ + +#ifdef NT +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +#include "m_pd.h" +#include "iemlib.h" +#include <math.h> +#include <stdio.h> +#include <string.h> + +/* ------------------------ t3_delay ---------------------------- */ +static t_class *t3_delay_class; + +typedef struct _t3_delay +{ + t_object x_obj; + t_clock *x_clock; + double x_deltime; + double x_ticks2ms; + double x_t3_bang; +} t_t3_delay; + +static void t3_delay_tick(t_t3_delay *x) +{ + outlet_float(x->x_obj.ob_outlet, x->x_t3_bang); +} + +static void t3_delay_stop(t_t3_delay *x) +{ + clock_unset(x->x_clock); +} + +static void t3_delay_float(t_t3_delay *x, t_floatarg t3_bang) +{ + double dticks; + int iticks; + + if(t3_bang < 0) + t3_bang = 0; + dticks = (x->x_deltime + (double)t3_bang)/x->x_ticks2ms; + iticks = (int)dticks; + x->x_t3_bang = (dticks - (double)iticks)*x->x_ticks2ms; + clock_delay(x->x_clock, (double)iticks*x->x_ticks2ms); +} + +static void t3_delay_ft1(t_t3_delay *x, t_floatarg f) +{ + if(f < 0) + f = 0; + x->x_deltime = f; +} + +static void t3_delay_list(t_t3_delay *x, t_symbol *s, int ac, t_atom *av) +{ + if((ac == 2)&&IS_A_FLOAT(av,0)&&IS_A_FLOAT(av,1)) + { + t3_delay_ft1(x, atom_getfloatarg(1, ac, av)); + t3_delay_float(x, atom_getfloatarg(0, ac, av)); + } +} + +static void t3_delay_free(t_t3_delay *x) +{ + clock_free(x->x_clock); +} + +static void *t3_delay_new(t_floatarg f) +{ + t_t3_delay *x = (t_t3_delay *)pd_new(t3_delay_class); + + x->x_ticks2ms = 1000.0*(double)sys_getblksize()/(double)sys_getsr(); + t3_delay_ft1(x, f); + x->x_clock = clock_new(x, (t_method)t3_delay_tick); + outlet_new(&x->x_obj, &s_float); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1")); + return (x); +} + +void t3_delay_setup(void) +{ + t3_delay_class = class_new(gensym("t3_delay"), (t_newmethod)t3_delay_new, + (t_method)t3_delay_free, sizeof(t_t3_delay), 0, A_DEFFLOAT, 0); + class_addcreator((t_newmethod)t3_delay_new, gensym("t3_del"), A_DEFFLOAT, 0); + class_addmethod(t3_delay_class, (t_method)t3_delay_stop, gensym("stop"), 0); + class_addmethod(t3_delay_class, (t_method)t3_delay_ft1, + gensym("ft1"), A_FLOAT, 0); + class_addfloat(t3_delay_class, (t_method)t3_delay_float); + class_addlist(t3_delay_class, (t_method)t3_delay_list); + class_sethelpsymbol(t3_delay_class, gensym("iemhelp/help-t3_delay")); +} diff --git a/src/iem_t3_lib/t3_metro.c b/src/iem_t3_lib/t3_metro.c index 8dcdb61..d71c54a 100644 --- a/src/iem_t3_lib/t3_metro.c +++ b/src/iem_t3_lib/t3_metro.c @@ -1,120 +1,120 @@ -/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
-
-iem_t3_lib written by Gerhard Eckel, Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
-
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-#include "m_pd.h"
-#include "iemlib.h"
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-
-/* ------------------------ t3_metro ---------------------------- */
-static t_class *t3_metro_class;
-
-typedef struct _t3_metro
-{
- t_object x_obj;
- t_clock *x_clock;
- double x_metrotime;
- double x_ticks2ms;
- double x_t3_bang;
- int x_hit;
- void *x_out_next;
-} t_t3_metro;
-
-static void t3_metro_stop(t_t3_metro *x)
-{
- clock_unset(x->x_clock);
-}
-
-static void t3_metro_tick(t_t3_metro *x)
-{
- double dticks;
- int iticks;
-
- x->x_hit = 0;
- outlet_float(x->x_out_next, x->x_metrotime);
- outlet_float(x->x_obj.ob_outlet, x->x_t3_bang);
- dticks = (x->x_metrotime + x->x_t3_bang)/x->x_ticks2ms;
- iticks = (int)dticks;
- x->x_t3_bang = (dticks - (double)iticks)*x->x_ticks2ms;
- if(!x->x_hit)
- clock_delay(x->x_clock, (double)iticks*x->x_ticks2ms);
-}
-
-static void t3_metro_float(t_t3_metro *x, t_floatarg t3_bang)
-{
- double dticks;
- int iticks;
-
- if(t3_bang < 0)
- t3_bang = 0;
- dticks = (double)t3_bang/x->x_ticks2ms;
- iticks = (int)dticks;
- x->x_t3_bang = (dticks - (double)iticks)*x->x_ticks2ms;
- clock_delay(x->x_clock, (double)iticks*x->x_ticks2ms);
- x->x_hit = 1;
-}
-
-static void t3_metro_start(t_t3_metro *x, t_floatarg f)
-{
- t3_metro_float(x, f);
- x->x_hit = 1;
-}
-
-static void t3_metro_ft1(t_t3_metro *x, t_floatarg f)
-{
- if(f < 0.01) f = 0.01;
- x->x_metrotime = (double)f;
-}
-
-static void t3_metro_list(t_t3_metro *x, t_symbol *s, int ac, t_atom *av)
-{
- if((ac == 2)&&IS_A_FLOAT(av,0)&&IS_A_FLOAT(av,1))
- {
- t3_metro_ft1(x, atom_getfloatarg(1, ac, av));
- t3_metro_float(x, atom_getfloatarg(0, ac, av));
- }
-}
-
-static void t3_metro_free(t_t3_metro *x)
-{
- clock_free(x->x_clock);
-}
-
-static void *t3_metro_new(t_symbol *s, int ac, t_atom *av)
-{
- t_t3_metro *x = (t_t3_metro *)pd_new(t3_metro_class);
-
- x->x_metrotime = 10.0;
- x->x_t3_bang = 0.0;
- x->x_hit = 0;
- if((ac == 1)&&IS_A_FLOAT(av,0))
- {
- t3_metro_ft1(x, atom_getfloatarg(0, ac, av));
- }
- x->x_ticks2ms = 1000.0*(double)sys_getblksize()/(double)sys_getsr();
- x->x_clock = clock_new(x, (t_method)t3_metro_tick);
- outlet_new(&x->x_obj, &s_float);
- x->x_out_next = outlet_new(&x->x_obj, &s_float);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
- return (x);
-}
-
-void t3_metro_setup(void)
-{
- t3_metro_class = class_new(gensym("t3_metro"), (t_newmethod)t3_metro_new,
- (t_method)t3_metro_free, sizeof(t_t3_metro), 0, A_GIMME, 0);
- class_addmethod(t3_metro_class, (t_method)t3_metro_stop, gensym("stop"), 0);
- class_addmethod(t3_metro_class, (t_method)t3_metro_start, gensym("start"), A_FLOAT, 0);
- class_addmethod(t3_metro_class, (t_method)t3_metro_ft1, gensym("ft1"), A_FLOAT, 0);
- class_addfloat(t3_metro_class, (t_method)t3_metro_float);
- class_addlist(t3_metro_class, (t_method)t3_metro_list);
- class_sethelpsymbol(t3_metro_class, gensym("iemhelp/help-t3_metro"));
-}
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iem_t3_lib written by Gerhard Eckel, Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */ + +#ifdef NT +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +#include "m_pd.h" +#include "iemlib.h" +#include <math.h> +#include <stdio.h> +#include <string.h> + +/* ------------------------ t3_metro ---------------------------- */ +static t_class *t3_metro_class; + +typedef struct _t3_metro +{ + t_object x_obj; + t_clock *x_clock; + double x_metrotime; + double x_ticks2ms; + double x_t3_bang; + int x_hit; + void *x_out_next; +} t_t3_metro; + +static void t3_metro_stop(t_t3_metro *x) +{ + clock_unset(x->x_clock); +} + +static void t3_metro_tick(t_t3_metro *x) +{ + double dticks; + int iticks; + + x->x_hit = 0; + outlet_float(x->x_out_next, x->x_metrotime); + outlet_float(x->x_obj.ob_outlet, x->x_t3_bang); + dticks = (x->x_metrotime + x->x_t3_bang)/x->x_ticks2ms; + iticks = (int)dticks; + x->x_t3_bang = (dticks - (double)iticks)*x->x_ticks2ms; + if(!x->x_hit) + clock_delay(x->x_clock, (double)iticks*x->x_ticks2ms); +} + +static void t3_metro_float(t_t3_metro *x, t_floatarg t3_bang) +{ + double dticks; + int iticks; + + if(t3_bang < 0) + t3_bang = 0; + dticks = (double)t3_bang/x->x_ticks2ms; + iticks = (int)dticks; + x->x_t3_bang = (dticks - (double)iticks)*x->x_ticks2ms; + clock_delay(x->x_clock, (double)iticks*x->x_ticks2ms); + x->x_hit = 1; +} + +static void t3_metro_start(t_t3_metro *x, t_floatarg f) +{ + t3_metro_float(x, f); + x->x_hit = 1; +} + +static void t3_metro_ft1(t_t3_metro *x, t_floatarg f) +{ + if(f < 0.01) f = 0.01; + x->x_metrotime = (double)f; +} + +static void t3_metro_list(t_t3_metro *x, t_symbol *s, int ac, t_atom *av) +{ + if((ac == 2)&&IS_A_FLOAT(av,0)&&IS_A_FLOAT(av,1)) + { + t3_metro_ft1(x, atom_getfloatarg(1, ac, av)); + t3_metro_float(x, atom_getfloatarg(0, ac, av)); + } +} + +static void t3_metro_free(t_t3_metro *x) +{ + clock_free(x->x_clock); +} + +static void *t3_metro_new(t_symbol *s, int ac, t_atom *av) +{ + t_t3_metro *x = (t_t3_metro *)pd_new(t3_metro_class); + + x->x_metrotime = 10.0; + x->x_t3_bang = 0.0; + x->x_hit = 0; + if((ac == 1)&&IS_A_FLOAT(av,0)) + { + t3_metro_ft1(x, atom_getfloatarg(0, ac, av)); + } + x->x_ticks2ms = 1000.0*(double)sys_getblksize()/(double)sys_getsr(); + x->x_clock = clock_new(x, (t_method)t3_metro_tick); + outlet_new(&x->x_obj, &s_float); + x->x_out_next = outlet_new(&x->x_obj, &s_float); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1")); + return (x); +} + +void t3_metro_setup(void) +{ + t3_metro_class = class_new(gensym("t3_metro"), (t_newmethod)t3_metro_new, + (t_method)t3_metro_free, sizeof(t_t3_metro), 0, A_GIMME, 0); + class_addmethod(t3_metro_class, (t_method)t3_metro_stop, gensym("stop"), 0); + class_addmethod(t3_metro_class, (t_method)t3_metro_start, gensym("start"), A_FLOAT, 0); + class_addmethod(t3_metro_class, (t_method)t3_metro_ft1, gensym("ft1"), A_FLOAT, 0); + class_addfloat(t3_metro_class, (t_method)t3_metro_float); + class_addlist(t3_metro_class, (t_method)t3_metro_list); + class_sethelpsymbol(t3_metro_class, gensym("iemhelp/help-t3_metro")); +} diff --git a/src/iem_t3_lib/t3_timer.c b/src/iem_t3_lib/t3_timer.c index c6dc392..5f0bc3a 100644 --- a/src/iem_t3_lib/t3_timer.c +++ b/src/iem_t3_lib/t3_timer.c @@ -1,55 +1,55 @@ -/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
-
-iem_t3_lib written by Gerhard Eckel, Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
-
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-#include "m_pd.h"
-#include "iemlib.h"
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-
-/* -------------------------- t3_timer ------------------------------ */
-static t_class *t3_timer_class;
-
-typedef struct _t3_timer
-{
- t_object x_obj;
- double x_settime;
- double x_t3_off;
-} t_t3_timer;
-
-static void t3_timer_float(t_t3_timer *x, t_float t3_bang)
-{
- x->x_settime = (double)clock_getsystime();
- x->x_t3_off = (double)t3_bang;
-}
-
-static void t3_timer_ft1(t_t3_timer *x, t_float t3_bang)
-{
- outlet_float(x->x_obj.ob_outlet, clock_gettimesince(x->x_settime)
- + (double)t3_bang - x->x_t3_off);
-}
-
-static void *t3_timer_new(void)
-{
- t_t3_timer *x = (t_t3_timer *)pd_new(t3_timer_class);
- t3_timer_float(x, 0.0);
- outlet_new(&x->x_obj, &s_float);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
- return (x);
-}
-
-void t3_timer_setup(void)
-{
- t3_timer_class = class_new(gensym("t3_timer"), (t_newmethod)t3_timer_new, 0,
- sizeof(t_t3_timer), 0, 0);
- class_addfloat(t3_timer_class, t3_timer_float);
- class_addmethod(t3_timer_class, (t_method)t3_timer_ft1, gensym("ft1"), A_FLOAT, 0);
- class_sethelpsymbol(t3_timer_class, gensym("iemhelp/help-t3_timer"));
-}
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iem_t3_lib written by Gerhard Eckel, Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */ + +#ifdef NT +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +#include "m_pd.h" +#include "iemlib.h" +#include <math.h> +#include <stdio.h> +#include <string.h> + +/* -------------------------- t3_timer ------------------------------ */ +static t_class *t3_timer_class; + +typedef struct _t3_timer +{ + t_object x_obj; + double x_settime; + double x_t3_off; +} t_t3_timer; + +static void t3_timer_float(t_t3_timer *x, t_float t3_bang) +{ + x->x_settime = (double)clock_getsystime(); + x->x_t3_off = (double)t3_bang; +} + +static void t3_timer_ft1(t_t3_timer *x, t_float t3_bang) +{ + outlet_float(x->x_obj.ob_outlet, clock_gettimesince(x->x_settime) + + (double)t3_bang - x->x_t3_off); +} + +static void *t3_timer_new(void) +{ + t_t3_timer *x = (t_t3_timer *)pd_new(t3_timer_class); + t3_timer_float(x, 0.0); + outlet_new(&x->x_obj, &s_float); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); + return (x); +} + +void t3_timer_setup(void) +{ + t3_timer_class = class_new(gensym("t3_timer"), (t_newmethod)t3_timer_new, 0, + sizeof(t_t3_timer), 0, 0); + class_addfloat(t3_timer_class, t3_timer_float); + class_addmethod(t3_timer_class, (t_method)t3_timer_ft1, gensym("ft1"), A_FLOAT, 0); + class_sethelpsymbol(t3_timer_class, gensym("iemhelp/help-t3_timer")); +} |