Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. #include "m_pd.h"
  2.  
  3. static t_class *counter_class;
  4.  
  5. typedef struct _counter{
  6.     t_object x_obj;
  7.     t_int i_count;
  8. } t_counter;
  9.  
  10. void counter_bang(t_counter *x){
  11.     t_float f = x-> i_count;
  12.     x->i_count++;
  13.     outlet_float(x->x_obj.ob_outlet, f);
  14. }
  15.  
  16. void *counter_new(t_floatarg f){
  17.     t_counter *x = (t_counter *)pd_new(counter_class);
  18.  
  19.     x->i_count = (t_int) f;
  20.     outlet_new(&x->x_obj, &(s_float));
  21.  
  22.     return (void *)x;
  23. }
  24.  
  25. void counter_setup(void){
  26.     counter_class = class_new(
  27.             gensym("counter"),
  28.             (t_newmethod) counter_new,
  29.             0, sizeof(t_counter),
  30.             CLASS_DEFAULT,
  31.             A_DEFFLOAT, 0
  32.     );
  33.  
  34.     class_addbang(counter_class, counter_bang);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement