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

« back to all changes in this revision

Viewing changes to src/list2int.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
/* 2305:forum::f�r::uml�ute:2001 */
 
18
 
 
19
#include "zexy.h"
 
20
#include <string.h>
 
21
 
 
22
 
 
23
/* ------------------------- list2int ------------------------------- */
 
24
 
 
25
/* cast each float of a list (or anything) to integer */
 
26
 
 
27
static t_class *list2int_class;
 
28
 
 
29
static void list2int_any(t_mypdlist *x, t_symbol *s, int argc, t_atom *argv)
 
30
{
 
31
  t_atom *ap;
 
32
  if (x->x_n != argc) {
 
33
    freebytes(x->x_list, x->x_n * sizeof(t_atom));
 
34
    x->x_n = argc;
 
35
    x->x_list = copybytes(argv, argc * sizeof(t_atom));
 
36
  } else memcpy(x->x_list, argv, argc * sizeof(t_atom));
 
37
  ap = x->x_list;
 
38
  while(argc--){
 
39
    if(ap->a_type == A_FLOAT)ap->a_w.w_float=(int)ap->a_w.w_float;
 
40
    ap++;
 
41
  }
 
42
  outlet_anything(x->x_obj.ob_outlet, s, x->x_n, x->x_list);
 
43
}
 
44
static void list2int_bang(t_mypdlist *x)
 
45
{  outlet_bang(x->x_obj.ob_outlet);}
 
46
static void list2int_float(t_mypdlist *x, t_float f)
 
47
{  outlet_float(x->x_obj.ob_outlet, (int)f);}
 
48
static void list2int_symbol(t_mypdlist *x, t_symbol *s)
 
49
{  outlet_symbol(x->x_obj.ob_outlet, s);}
 
50
static void list2int_pointer(t_mypdlist *x, t_gpointer *p)
 
51
{  outlet_pointer(x->x_obj.ob_outlet, p);}
 
52
 
 
53
static void *list2int_new(t_symbol *s, int argc, t_atom *argv)
 
54
{
 
55
  t_mypdlist *x = (t_mypdlist *)pd_new(list2int_class);
 
56
  outlet_new(&x->x_obj, 0);
 
57
  x->x_n = 0;
 
58
  x->x_list = 0;
 
59
 
 
60
  list2int_any(x, s, argc, argv);
 
61
  return (x);
 
62
}
 
63
 
 
64
 
 
65
static void mypdlist_free(t_mypdlist *x)
 
66
{
 
67
  freebytes(x->x_list, x->x_n * sizeof(t_atom)); 
 
68
}
 
69
 
 
70
void list2int_setup(void)
 
71
{
 
72
  list2int_class = class_new(gensym("list2int"), (t_newmethod)list2int_new, 
 
73
                         (t_method)mypdlist_free, sizeof(t_mypdlist), 0, A_GIMME, 0);
 
74
  class_addcreator((t_newmethod)list2int_new, gensym("l2i"), A_GIMME, 0);
 
75
  class_addanything(list2int_class, list2int_any);
 
76
  class_addlist(list2int_class, list2int_any);
 
77
  class_addbang(list2int_class, list2int_bang);
 
78
  class_addfloat(list2int_class, list2int_float);
 
79
  class_addsymbol(list2int_class, list2int_symbol);
 
80
  class_addpointer(list2int_class, list2int_pointer);
 
81
  zexy_register("list2int");
 
82
}
 
83
 
 
84
void l2i_setup(void)
 
85
{
 
86
  list2int_setup();
 
87
}