~ubuntu-branches/ubuntu/natty/pd-zexy/natty

« back to all changes in this revision

Viewing changes to src/avg~.c

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard, IOhannes m zmölnig, Jonas Smedegaard
  • Date: 2010-08-20 12:17:41 UTC
  • mfrom: (2.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100820121741-4kxozn8b9rhee9fr
Tags: 2.2.3-1
* New upstream version

[ IOhannes m zmölnig ]
* Adopt package, on behalf of Multimedia Team.
  Closes: #546964
* Simply debian/rules with CDBS, and don't unconditionally strip
  binaries.
  Closes: #437763
* Install into /usr/lib/pd/extra/zexy/. Document usage in REAME.Debian
  and warn about change in NEWS.
* git'ify package. Add Vcs-* stanzas to control file.
* Use dpkg source format 3.0 (quilt). Drop build-dependency on quilt.

[ Jonas Smedegaard ]
* Enable CDBS copyright-check routine.
* Add copyright and licensing header to debian/rules.
* Add myself as uploader.
* Rewrite debian/copyright using rev. 135 of draft DEP5 format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************
 
2
 *
 
3
 * zexy - implementation file
 
4
 *
 
5
 * copyleft (c) IOhannes m zm�lnig
 
6
 *
 
7
 *   1999:forum::f�r::uml�ute:2004
 
8
 *
 
9
 *   institute of electronic music and acoustics (iem)
 
10
 *
 
11
 ******************************************************
 
12
 *
 
13
 * license: GNU General Public License v.2
 
14
 *
 
15
 ******************************************************/
 
16
 
 
17
#include "zexy.h"
 
18
 
 
19
/* ------------------------ average~ ----------------------------- */
 
20
 
 
21
/* tilde object to take absolute value. */
 
22
 
 
23
static t_class *avg_class;
 
24
 
 
25
typedef struct _avg
 
26
{
 
27
  t_object x_obj;
 
28
 
 
29
  t_float n_inv;
 
30
  int blocks;
 
31
} t_avg;
 
32
 
 
33
 
 
34
/* average :: arithmetic mean of one signal-vector */
 
35
 
 
36
static t_int *avg_perform(t_int *w)
 
37
{
 
38
  t_sample *in = (t_sample *)(w[1]);
 
39
 
 
40
  t_avg *x = (t_avg *)w[2];
 
41
  int n = (int)(w[3]);
 
42
 
 
43
  t_sample buf = 0.;
 
44
 
 
45
  while (n--)
 
46
    {
 
47
      buf += *in++;
 
48
    }
 
49
  outlet_float(x->x_obj.ob_outlet, buf*x->n_inv);
 
50
 
 
51
  return (w+4);
 
52
}
 
53
 
 
54
static void avg_dsp(t_avg *x, t_signal **sp)
 
55
{
 
56
  x->n_inv=1./sp[0]->s_n;
 
57
  dsp_add(avg_perform, 3, sp[0]->s_vec, x, sp[0]->s_n);
 
58
}
 
59
 
 
60
static void *avg_new(void)
 
61
{
 
62
  t_avg *x = (t_avg *)pd_new(avg_class);
 
63
  outlet_new(&x->x_obj, &s_float);
 
64
  return (x);
 
65
}
 
66
 
 
67
static void avg_help(void)
 
68
{
 
69
  post("avg~\t:: outputs the arithmetic mean of each signal-vector");
 
70
}
 
71
 
 
72
 
 
73
void avg_tilde_setup(void)
 
74
{
 
75
  avg_class = class_new(gensym("avg~"), (t_newmethod)avg_new, 0,
 
76
                        sizeof(t_avg), 0, A_DEFFLOAT, 0);
 
77
  class_addmethod(avg_class, nullfn, gensym("signal"), 0);
 
78
  class_addmethod(avg_class, (t_method)avg_dsp, gensym("dsp"), 0);
 
79
 
 
80
  class_addmethod(avg_class, (t_method)avg_help, gensym("help"), 0);
 
81
  zexy_register("avg~");
 
82
}