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

« back to all changes in this revision

Viewing changes to src/minmax.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
/* minmax :: get minimum and maximum of a list */
 
20
 
 
21
static t_class *minmax_class;
 
22
 
 
23
typedef struct _minmax
 
24
{
 
25
  t_object x_obj;
 
26
  t_float min;
 
27
  t_float max;
 
28
 
 
29
  t_outlet *mino, *maxo;
 
30
} t_minmax;
 
31
 
 
32
static void minmax_bang(t_minmax *x)
 
33
{
 
34
  outlet_float(x->maxo,x->max);
 
35
  outlet_float(x->mino,x->min);
 
36
}
 
37
 
 
38
static void minmax_list(t_minmax *x, t_symbol *s, int argc, t_atom *argv)
 
39
{
 
40
  ZEXY_USEVAR(s);
 
41
  if(argc){
 
42
    t_float min = atom_getfloat(argv++);
 
43
    t_float max=min;
 
44
    argc--;
 
45
    
 
46
    while(argc--){
 
47
      t_float f = atom_getfloat(argv++);
 
48
      if (f<min)min=f;
 
49
      else if (f>max)max=f;
 
50
    }
 
51
    
 
52
    x->min=min;
 
53
    x->max=max;
 
54
  }
 
55
  minmax_bang(x);
 
56
}
 
57
 
 
58
static void *minmax_new(void)
 
59
{
 
60
  t_minmax *x = (t_minmax *)pd_new(minmax_class);
 
61
 
 
62
  x->mino=outlet_new(&x->x_obj, &s_float);
 
63
  x->maxo=outlet_new(&x->x_obj, &s_float);
 
64
 
 
65
  x->min = x->max = 0;
 
66
 
 
67
  return (x);
 
68
}
 
69
 
 
70
static void minmax_help(void)
 
71
{
 
72
  post("minmax\t:: get minimum and maximum of a list of floats");
 
73
}
 
74
 
 
75
void minmax_setup(void)
 
76
{
 
77
  minmax_class = class_new(gensym("minmax"), (t_newmethod)minmax_new, 0,
 
78
                         sizeof(t_minmax), 0, A_DEFFLOAT, 0);
 
79
 
 
80
  class_addlist(minmax_class, (t_method)minmax_list);
 
81
  class_addbang(minmax_class, (t_method)minmax_bang);
 
82
  class_addmethod(minmax_class, (t_method)minmax_help, gensym("help"), 0);
 
83
 
 
84
  zexy_register("minmax");
 
85
}