[PD-cvs] externals/iemlib/src/iemlib2 LFO_noise~.c, NONE, 1.1 fade~.c, NONE, 1.1 iem_blocksize~.c, NONE, 1.1 iem_samplerate~.c, NONE, 1.1 m2f~.c, NONE, 1.1 iemlib2.c, 1.5, 1.6 makefile_linux, 1.1, 1.2 makefile_win, 1.7, 1.8

musil tmusil at users.sourceforge.net
Wed Nov 8 11:48:55 CET 2006


Update of /cvsroot/pure-data/externals/iemlib/src/iemlib2
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8592/iemlib/src/iemlib2

Modified Files:
	iemlib2.c makefile_linux makefile_win 
Added Files:
	LFO_noise~.c fade~.c iem_blocksize~.c iem_samplerate~.c m2f~.c 
Log Message:
changed sig* to *_tilde

--- NEW FILE: LFO_noise~.c ---
/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution.

iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */


#include "m_pd.h"
#include "iemlib.h"


/* -------------------- LFO_noise~ --------------------- */
/* ---- outputs a 2 point interpolated white noise ----- */
/* -- with lower cutoff frequency than 0.5 samplerate -- */

static t_class *LFO_noise_tilde_class;

typedef struct _LFO_noise_tilde
{
  t_object     x_obj;
  double       x_range;
  double       x_rcp_range;
  unsigned int x_state;
  t_float      x_fact;
  t_float      x_incr;
  t_float      x_y1;
  t_float      x_y2;
  t_float      x_phase;
} t_LFO_noise_tilde;

static int LFO_noise_makeseed(void)
{
  static unsigned int LFO_noise_nextseed = 1489853723;
  
  LFO_noise_nextseed = LFO_noise_nextseed * 435898247 + 938284287;
  return(LFO_noise_nextseed & 0x7fffffff);
}

static float LFO_noise_new_rand(t_LFO_noise_tilde *x)
{
  unsigned int state = x->x_state;
  double new_val, range = x->x_range;
  
  x->x_state = state = state * 472940017 + 832416023;
  new_val = range * ((double)state) * (1./4294967296.);
  if(new_val >= range)
    new_val = range-1;
  new_val -= 32767.0;
  return(new_val*(1.0/32767.0));
}

static void *LFO_noise_new(t_float freq)
{
  t_LFO_noise_tilde *x = (t_LFO_noise_tilde *)pd_new(LFO_noise_tilde_class);
  
  x->x_range = 65535.0;
  x->x_rcp_range =  (double)x->x_range * (1.0/4294967296.0);
  x->x_state = LFO_noise_makeseed();
  x->x_fact = 2.0f / 44100.0f;
  x->x_incr = freq * x->x_fact;
  if(x->x_incr < 0.0f)
    x->x_incr = 0.0f;
  else if(x->x_incr > 0.1f)
    x->x_incr = 0.1f;
  x->x_y1 = LFO_noise_new_rand(x);
  x->x_y2 = LFO_noise_new_rand(x);
  x->x_phase = 0.0f;
  outlet_new(&x->x_obj, gensym("signal"));
  return (x);
}

static t_int *LFO_noise_perform(t_int *w)
{
  t_float *out = (t_float *)(w[1]);
  t_LFO_noise_tilde *x = (t_LFO_noise_tilde *)(w[2]);
  int n = (int)(w[3]);
  t_float phase = x->x_phase;
  t_float x_y1 = x->x_y1;
  t_float x_y2 = x->x_y2;
  t_float incr = x->x_incr;
  
  while(n--)
  {
    if(phase > 1.0f)
    {
      x_y1 = x_y2;
      x_y2 = LFO_noise_new_rand(x);
      phase -= 1.0;
    }
    *out++ = (x_y2 - x_y1) * phase + x_y1;
    phase += incr;
  }
  x->x_phase = phase;
  x->x_y1 = x_y1;
  x->x_y2 = x_y2;
  return (w+4);
}

static void LFO_noise_float(t_LFO_noise_tilde *x, t_floatarg freq)
{
  x->x_incr = freq * x->x_fact;
  if(x->x_incr < 0.0f)
    x->x_incr = 0.0f;
  else if(x->x_incr > 0.1f)
    x->x_incr = 0.1f;
}

static void LFO_noise_dsp(t_LFO_noise_tilde *x, t_signal **sp)
{
  x->x_fact = 2.0f / sp[0]->s_sr;
  dsp_add(LFO_noise_perform, 3, sp[0]->s_vec, x, sp[0]->s_n);
}

void LFO_noise_tilde_setup(void)
{
  LFO_noise_tilde_class = class_new(gensym("LFO_noise~"),
    (t_newmethod)LFO_noise_new, 0,
    sizeof(t_LFO_noise_tilde), 0, A_DEFFLOAT, 0);
  class_addmethod(LFO_noise_tilde_class, (t_method)LFO_noise_dsp,
    gensym("dsp"), 0);
  class_addfloat(LFO_noise_tilde_class, (t_method)LFO_noise_float);
  class_sethelpsymbol(LFO_noise_tilde_class, gensym("iemhelp/help-LFO_noise~"));
}

Index: makefile_linux
===================================================================
RCS file: /cvsroot/pure-data/externals/iemlib/src/iemlib2/makefile_linux,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** makefile_linux	7 Nov 2006 17:11:40 -0000	1.1
--- makefile_linux	8 Nov 2006 10:48:53 -0000	1.2
***************
*** 22,28 ****
--- 22,30 ----
  	dollarg.c \
  	exp_inc.c \
+ 	fade~.c \
  	float24.c \
  	iem_anything.c \
  	iem_append.c \
+ 	iem_blocksize~.c \
  	iem_i_route.c \
  	iem_pbank_csv.c \
***************
*** 30,37 ****
--- 32,42 ----
  	iem_receive.c \
  	iem_route.c \
+ 	iem_samplerate~.c \
  	iem_sel_any.c \
  	iem_send.c \
  	init.c \
+ 	LFO_noise~.c \
  	list2send.c \
+ 	m2f~.c \
  	mergefilename.c \
  	modulo_counter.c \
***************
*** 43,51 ****
  	receive2list.c \
  	round_zero.c \
- 	sigfade.c \
- 	sigiem_blocksize.c \
- 	sigiem_samplerate.c \
- 	sigLFO_noise.c \
- 	sigm2f.c \
  	speedlim.c \
  	splitfilename.c \
--- 48,51 ----

Index: iemlib2.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iemlib/src/iemlib2/iemlib2.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** iemlib2.c	7 Nov 2006 17:11:40 -0000	1.5
--- iemlib2.c	8 Nov 2006 10:48:53 -0000	1.6
***************
*** 21,27 ****
--- 21,29 ----
  void dollarg_setup(void);
  void exp_inc_setup(void);
+ void fade_tilde_setup(void);
  void float24_setup(void);
  void iem_anything_setup(void);
  void iem_append_setup(void);
+ void iem_blocksize_tilde_setup(void);
  void iem_i_route_setup(void);
  void iem_pbank_csv_setup(void);
***************
*** 29,36 ****
--- 31,41 ----
  void iem_receive_setup(void);
  void iem_route_setup(void);
+ void iem_samplerate_tilde_setup(void);
  void iem_sel_any_setup(void);
  void iem_send_setup(void);
  void init_setup(void);
+ void LFO_noise_tilde_setup(void);
  void list2send_setup(void);
+ void m2f_tilde_setup(void);
  void mergefilename_setup(void);
  void modulo_counter_setup(void);
***************
*** 42,50 ****
  void receive2list_setup(void);
  void round_zero_setup(void);
- void sigfade_setup(void);
- void sigiem_blocksize_setup(void);
- void sigiem_samplerate_setup(void);
- void sigLFO_noise_setup(void);
- void sigm2f_setup(void);
  void speedlim_setup(void);
  void splitfilename_setup(void);
--- 47,50 ----
***************
*** 65,71 ****
--- 65,73 ----
    dollarg_setup();
    exp_inc_setup();
+   fade_tilde_setup();
    float24_setup();
    iem_anything_setup();
    iem_append_setup();
+   iem_blocksize_tilde_setup();
    iem_i_route_setup();
    iem_pbank_csv_setup();
***************
*** 73,80 ****
--- 75,85 ----
    iem_receive_setup();
    iem_route_setup();
+   iem_samplerate_tilde_setup();
    iem_sel_any_setup();
    iem_send_setup();
    init_setup();
+   LFO_noise_tilde_setup();
    list2send_setup();
+   m2f_tilde_setup();
    mergefilename_setup();
    modulo_counter_setup();
***************
*** 86,94 ****
    receive2list_setup();
    round_zero_setup();
-   sigfade_setup();
-   sigiem_blocksize_setup();
-   sigiem_samplerate_setup();
-   sigLFO_noise_setup();
-   sigm2f_setup();
    speedlim_setup();
    splitfilename_setup();
--- 91,94 ----

--- NEW FILE: fade~.c ---
/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution.

iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */

#include "m_pd.h"
#include "iemlib.h"
#include <math.h>

/* ------------------------- fade~ ----------------------------- */
/* --- signal lookup tabel object with input range of 0 to 1 --- */
/* ---- converts a linear signal ramp to the half of a :  ------ */
/* -- sine-wave, hanning-wave, squareroot-wave or mixes of it -- */

t_float *iem_fade_tilde_table_lin=(t_float *)0L;
t_float *iem_fade_tilde_table_linsqrt=(t_float *)0L;
t_float *iem_fade_tilde_table_sqrt=(t_float *)0L;
t_float *iem_fade_tilde_table_sin=(t_float *)0L;
t_float *iem_fade_tilde_table_sinhann=(t_float *)0L;
t_float *iem_fade_tilde_table_hann=(t_float *)0L;

static t_class *fade_tilde_class;

typedef struct _fade
{
  t_object x_obj;
  t_float *x_table;
  t_float x_f;
} t_fade_tilde;

static void fade_set(t_fade_tilde *x, t_symbol *s)
{
  if(s == gensym("_lin"))
    x->x_table = iem_fade_tilde_table_lin;
  else if(s == gensym("_linsqrt"))
    x->x_table = iem_fade_tilde_table_linsqrt;
  else if(s == gensym("_sqrt"))
    x->x_table = iem_fade_tilde_table_sqrt;
  else if(s == gensym("_sin"))
    x->x_table = iem_fade_tilde_table_sin;
  else if(s == gensym("_sinhann"))
    x->x_table = iem_fade_tilde_table_sinhann;
  else if(s == gensym("_hann"))
    x->x_table = iem_fade_tilde_table_hann;
}

static void *fade_new(t_symbol *s)
{
  t_fade_tilde *x = (t_fade_tilde *)pd_new(fade_tilde_class);
  outlet_new(&x->x_obj, gensym("signal"));
  x->x_f = 0;
  x->x_table = iem_fade_tilde_table_lin;
  fade_set(x, s);
  return (x);
}

static t_int *fade_perform(t_int *w)
{
  t_float *in = (t_float *)(w[1]);
  t_float *out = (t_float *)(w[2]);
  t_fade_tilde *x = (t_fade_tilde *)(w[3]);
  int n = (int)(w[4]);
  t_float *tab = x->x_table, *addr, f1, f2, frac;
  double dphase;
  int normhipart;
  union tabfudge tf;
  
  tf.tf_d = UNITBIT32;
  normhipart = tf.tf_i[HIOFFSET];
  
#if 0     /* this is the readable version of the code. */
  while (n--)
  {
    dphase = (double)(*in++ * (t_float)(COSTABSIZE) * 0.99999) + UNITBIT32;
    tf.tf_d = dphase;
    addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1));
    tf.tf_i[HIOFFSET] = normhipart;
    frac = tf.tf_d - UNITBIT32;
    f1 = addr[0];
    f2 = addr[1];
    *out++ = f1 + frac * (f2 - f1);
  }
#endif
#if 1     /* this is the same, unwrapped by hand. */
  dphase = (double)(*in++ * (t_float)(COSTABSIZE) * 0.99999) + UNITBIT32;
  tf.tf_d = dphase;
  addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1));
  tf.tf_i[HIOFFSET] = normhipart;
  while (--n)
  {
    dphase = (double)(*in++ * (t_float)(COSTABSIZE) * 0.99999) + UNITBIT32;
    frac = tf.tf_d - UNITBIT32;
    tf.tf_d = dphase;
    f1 = addr[0];
    f2 = addr[1];
    addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1));
    *out++ = f1 + frac * (f2 - f1);
    tf.tf_i[HIOFFSET] = normhipart;
  }
  frac = tf.tf_d - UNITBIT32;
  f1 = addr[0];
  f2 = addr[1];
  *out++ = f1 + frac * (f2 - f1);
#endif
  return (w+5);
}

static void fade_dsp(t_fade_tilde *x, t_signal **sp)
{
  dsp_add(fade_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n);
}

static void fade_maketable(void)
{
  int i;
  t_float *fp, phase, fff,phsinc = 0.5*3.141592653 / ((t_float)COSTABSIZE*0.99999);
  union tabfudge tf;
  
  if(!iem_fade_tilde_table_sin)
  {
    iem_fade_tilde_table_sin = (t_float *)getbytes(sizeof(t_float) * (COSTABSIZE+1));
    for(i=COSTABSIZE+1, fp=iem_fade_tilde_table_sin, phase=0; i--; fp++, phase+=phsinc)
      *fp = sin(phase);
  }
  if(!iem_fade_tilde_table_sinhann)
  {
    iem_fade_tilde_table_sinhann = (t_float *)getbytes(sizeof(t_float) * (COSTABSIZE+1));
    for(i=COSTABSIZE+1, fp=iem_fade_tilde_table_sinhann, phase=0; i--; fp++, phase+=phsinc)
    {
      fff = sin(phase);
      *fp = fff*sqrt(fff);
    }
  }
  if(!iem_fade_tilde_table_hann)
  {
    iem_fade_tilde_table_hann = (t_float *)getbytes(sizeof(t_float) * (COSTABSIZE+1));
    for(i=COSTABSIZE+1, fp=iem_fade_tilde_table_hann, phase=0; i--; fp++, phase+=phsinc)
    {
      fff = sin(phase);
      *fp = fff*fff;
    }
  }
  phsinc = 1.0 / ((t_float)COSTABSIZE*0.99999);
  if(!iem_fade_tilde_table_lin)
  {
    iem_fade_tilde_table_lin = (t_float *)getbytes(sizeof(t_float) * (COSTABSIZE+1));
    for(i=COSTABSIZE+1, fp=iem_fade_tilde_table_lin, phase=0; i--; fp++, phase+=phsinc)
      *fp = phase;
  }
  if(!iem_fade_tilde_table_linsqrt)
  {
    iem_fade_tilde_table_linsqrt = (t_float *)getbytes(sizeof(t_float) * (COSTABSIZE+1));
    for(i=COSTABSIZE+1, fp=iem_fade_tilde_table_linsqrt, phase=0; i--; fp++, phase+=phsinc)
      *fp = pow(phase, 0.75);
  }
  if(!iem_fade_tilde_table_sqrt)
  {
    iem_fade_tilde_table_sqrt = (t_float *)getbytes(sizeof(t_float) * (COSTABSIZE+1));
    for(i=COSTABSIZE+1, fp=iem_fade_tilde_table_sqrt, phase=0; i--; fp++, phase+=phsinc)
      *fp = sqrt(phase);
  }
  tf.tf_d = UNITBIT32 + 0.5;
  if((unsigned)tf.tf_i[LOWOFFSET] != 0x80000000)
    bug("fade~: unexpected machine alignment");
}

void fade_tilde_setup(void)
{
  fade_tilde_class = class_new(gensym("fade~"), (t_newmethod)fade_new, 0,
    sizeof(t_fade_tilde), 0, A_DEFSYM, 0);
  CLASS_MAINSIGNALIN(fade_tilde_class, t_fade_tilde, x_f);
  class_addmethod(fade_tilde_class, (t_method)fade_dsp, gensym("dsp"), 0);
  class_addmethod(fade_tilde_class, (t_method)fade_set, gensym("set"), A_DEFSYM, 0);
  class_sethelpsymbol(fade_tilde_class, gensym("iemhelp/help-fade~"));
  fade_maketable();
}

--- NEW FILE: iem_samplerate~.c ---
/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution.

iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */


#include "m_pd.h"
#include "iemlib.h"

/* --------------- iem_samplerate~ ----------------- */
/* -- outputs the current samplerate of a window --- */

static t_class *iem_samplerate_tilde_class;

typedef struct _iem_samplerate
{
  t_object  x_obj;
  t_float   x_samplerate;
  t_clock   *x_clock;
  t_float   x_f;
} t_iem_samplerate_tilde;

static void iem_samplerate_out(t_iem_samplerate_tilde *x)
{
  outlet_float(x->x_obj.ob_outlet, x->x_samplerate);
}

static void iem_samplerate_free(t_iem_samplerate_tilde *x)
{
  clock_free(x->x_clock);
}

static void *iem_samplerate_new(t_symbol *s)
{
  t_iem_samplerate_tilde *x = (t_iem_samplerate_tilde *)pd_new(iem_samplerate_tilde_class);
  x->x_clock = clock_new(x, (t_method)iem_samplerate_out);
  outlet_new(&x->x_obj, &s_float);
  x->x_samplerate = 44100.0f;
  x->x_f = 0.0f;
  return (x);
}

static void iem_samplerate_dsp(t_iem_samplerate_tilde *x, t_signal **sp)
{
  x->x_samplerate = (t_float)(sp[0]->s_sr);
  clock_delay(x->x_clock, 0.0f);
}

void iem_samplerate_tilde_setup(void)
{
  iem_samplerate_tilde_class = class_new(gensym("iem_samplerate~"), (t_newmethod)iem_samplerate_new,
    (t_method)iem_samplerate_free, sizeof(t_iem_samplerate_tilde), 0, 0);
  CLASS_MAINSIGNALIN(iem_samplerate_tilde_class, t_iem_samplerate_tilde, x_f);
  class_addmethod(iem_samplerate_tilde_class, (t_method)iem_samplerate_dsp, gensym("dsp"), 0);
}

Index: makefile_win
===================================================================
RCS file: /cvsroot/pure-data/externals/iemlib/src/iemlib2/makefile_win,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** makefile_win	7 Nov 2006 17:11:40 -0000	1.7
--- makefile_win	8 Nov 2006 10:48:53 -0000	1.8
***************
*** 21,37 ****
  	dollarg.c \
  	exp_inc.c \
  	float24.c \
  	iem_anything.c \
  	iem_append.c \
  	iem_i_route.c \
  	iem_pbank_csv.c \
- 	iem_prepend_kernel.c \
  	iem_prepend.c \
  	iem_receive.c \
  	iem_route.c \
  	iem_sel_any.c \
  	iem_send.c \
  	init.c \
  	list2send.c \
  	mergefilename.c \
  	modulo_counter.c \
--- 21,41 ----
  	dollarg.c \
  	exp_inc.c \
+ 	fade~.c \
  	float24.c \
  	iem_anything.c \
  	iem_append.c \
+ 	iem_blocksize~.c \
  	iem_i_route.c \
  	iem_pbank_csv.c \
  	iem_prepend.c \
  	iem_receive.c \
  	iem_route.c \
+ 	iem_samplerate~.c \
  	iem_sel_any.c \
  	iem_send.c \
  	init.c \
+ 	LFO_noise~.c \
  	list2send.c \
+ 	m2f~.c \
  	mergefilename.c \
  	modulo_counter.c \
***************
*** 43,51 ****
  	receive2list.c \
  	round_zero.c \
- 	sigfade.c \
- 	sigiem_blocksize.c \
- 	sigiem_samplerate.c \
- 	sigLFO_noise.c \
- 	sigm2f.c \
  	speedlim.c \
  	splitfilename.c \
--- 47,50 ----

--- NEW FILE: m2f~.c ---
/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution.

iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */


#include "m_pd.h"
#include "iemlib.h"
#include <math.h>

/* ----------- m2f~ ----------- */
/* --------- obsolete --------- */

#define M2FTABSIZE 2048

t_float *iem_m2f_tilde_table=(t_float *)0L;

static t_class *m2f_tilde_class;

typedef struct _m2f
{
  t_object x_obj;
  t_float x_msi;
} t_m2f_tilde;

static void *m2f_new(void)
{
  t_m2f_tilde *x = (t_m2f_tilde *)pd_new(m2f_tilde_class);
  outlet_new(&x->x_obj, gensym("signal"));
  x->x_msi = 0;
  return (x);
}

static t_int *m2f_perform(t_int *w)
{
  t_float *in = (t_float *)(w[1]);
  t_float *out = (t_float *)(w[2]);
  t_m2f_tilde *x = (t_m2f_tilde *)(w[3]);
  int n = (int)(w[4]);
  t_float *tab = iem_m2f_tilde_table, *addr, f1, f2, frac, iinn;
  double dphase;
  int normhipart;
  union tabfudge tf;
  
  tf.tf_d = UNITBIT32;
  normhipart = tf.tf_i[HIOFFSET];
  
#if 0       /* this is the readable version of the code. */
  while (n--)
  {
    iinn = (*in++)*10.0+670.0;
    dphase = (double)iinn + UNITBIT32;
    tf.tf_d = dphase;
    addr = tab + (tf.tf_i[HIOFFSET] & (M2FTABSIZE-1));
    tf.tf_i[HIOFFSET] = normhipart;
    frac = tf.tf_d - UNITBIT32;
    f1 = addr[0];
    f2 = addr[1];
    *out++ = f1 + frac * (f2 - f1);
  }
#endif
#if 1       /* this is the same, unwrapped by hand. */
  iinn = (*in++)*10.0+670.0;
  dphase = (double)iinn + UNITBIT32;
  tf.tf_d = dphase;
  addr = tab + (tf.tf_i[HIOFFSET] & (M2FTABSIZE-1));
  tf.tf_i[HIOFFSET] = normhipart;
  while (--n)
  {
    iinn = (*in++)*10.0+670.0;
    dphase = (double)iinn + UNITBIT32;
    frac = tf.tf_d - UNITBIT32;
    tf.tf_d = dphase;
    f1 = addr[0];
    f2 = addr[1];
    addr = tab + (tf.tf_i[HIOFFSET] & (M2FTABSIZE-1));
    *out++ = f1 + frac * (f2 - f1);
    tf.tf_i[HIOFFSET] = normhipart;
  }
  frac = tf.tf_d - UNITBIT32;
  f1 = addr[0];
  f2 = addr[1];
  *out++ = f1 + frac * (f2 - f1);
#endif
  return (w+5);
}

static void m2f_dsp(t_m2f_tilde *x, t_signal **sp)
{
  dsp_add(m2f_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n);
}

static void m2f_maketable(void)
{
  union tabfudge tf;
  
  if(!iem_m2f_tilde_table)
  {
    int i;
    t_float *fp, midi, refexp=440.0*exp(-5.75*log(2.0));
    
    iem_m2f_tilde_table = (t_float *)getbytes(sizeof(t_float) * (M2FTABSIZE+1));
    for(i=0, fp=iem_m2f_tilde_table, midi=-67.0; i<=M2FTABSIZE; i++, fp++, midi+=0.1)
      *fp = refexp * exp(0.057762265047 * midi);
  }
  tf.tf_d = UNITBIT32 + 0.5;
  if((unsigned)tf.tf_i[LOWOFFSET] != 0x80000000)
    bug("m2f~: unexpected machine alignment");
}

void m2f_tilde_setup(void)
{
  m2f_tilde_class = class_new(gensym("m2f~"), (t_newmethod)m2f_new, 0,
    sizeof(t_m2f_tilde), 0, 0);
  CLASS_MAINSIGNALIN(m2f_tilde_class, t_m2f_tilde, x_msi);
  class_addmethod(m2f_tilde_class, (t_method)m2f_dsp, gensym("dsp"), 0);
  m2f_maketable();
  class_sethelpsymbol(m2f_tilde_class, gensym("iemhelp/help-m2f~"));
}

--- NEW FILE: iem_blocksize~.c ---
/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution.

iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */


#include "m_pd.h"
#include "iemlib.h"

/* ------------------- iem_blocksize~ -------------------- */
/* -- outputs the current signal-blocksize of a window --- */

static t_class *iem_blocksize_tilde_class;

typedef struct _iem_blocksize
{
  t_object  x_obj;
  t_float   x_blocksize;
  t_clock   *x_clock;
  t_float   x_f;
} t_iem_blocksize_tilde;

static void iem_blocksize_out(t_iem_blocksize_tilde *x)
{
  outlet_float(x->x_obj.ob_outlet, x->x_blocksize);
}

static void iem_blocksize_free(t_iem_blocksize_tilde *x)
{
  clock_free(x->x_clock);
}

static void *iem_blocksize_new(t_symbol *s)
{
  t_iem_blocksize_tilde *x = (t_iem_blocksize_tilde *)pd_new(iem_blocksize_tilde_class);
  x->x_clock = clock_new(x, (t_method)iem_blocksize_out);
  outlet_new(&x->x_obj, &s_float);
  x->x_blocksize = 64.0f;
  x->x_f = 0.0f;
  return (x);
}

static void iem_blocksize_dsp(t_iem_blocksize_tilde *x, t_signal **sp)
{
  x->x_blocksize = (t_float)(sp[0]->s_n);
  clock_delay(x->x_clock, 0.0f);
}

void iem_blocksize_tilde_setup(void)
{
  iem_blocksize_tilde_class = class_new(gensym("iem_blocksize~"), (t_newmethod)iem_blocksize_new,
    (t_method)iem_blocksize_free, sizeof(t_iem_blocksize_tilde), 0, 0);
  CLASS_MAINSIGNALIN(iem_blocksize_tilde_class, t_iem_blocksize_tilde, x_f);
  class_addmethod(iem_blocksize_tilde_class, (t_method)iem_blocksize_dsp, gensym("dsp"), 0);
}





More information about the Pd-cvs mailing list