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

« back to all changes in this revision

Viewing changes to src/tabset.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
/* hack : 2108:forum::f�r::uml�ute:1999 @ iem */
 
18
 
 
19
#include "zexy.h"
 
20
 
 
21
 
 
22
/* =================== tabset ====================== */
 
23
 
 
24
static t_class *tabset_class;
 
25
 
 
26
typedef struct _tabset
 
27
{
 
28
  t_object x_obj;
 
29
  t_symbol *x_arrayname;
 
30
} t_tabset;
 
31
 
 
32
static void tabset_float(t_tabset *x, t_floatarg f)
 
33
{
 
34
  t_garray *A;
 
35
  int npoints;
 
36
  zarray_t *vec;
 
37
 
 
38
  if (!(A = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
 
39
    error("%s: no such array", x->x_arrayname->s_name);
 
40
  else if (!zarray_getarray(A, &npoints, &vec))
 
41
    error("%s: bad template for tabset", x->x_arrayname->s_name);
 
42
  else {
 
43
    while(npoints--){
 
44
      zarray_setfloat(vec, 0, f);
 
45
      vec++;
 
46
    }
 
47
    garray_redraw(A);
 
48
  }
 
49
}
 
50
 
 
51
static void tabset_list(t_tabset *x, t_symbol *s, int argc, t_atom* argv)
 
52
{
 
53
  t_garray *A;
 
54
  int npoints;
 
55
  zarray_t *vec;
 
56
  ZEXY_USEVAR(s);
 
57
 
 
58
  if (!(A = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
 
59
    error("%s: no such array", x->x_arrayname->s_name);
 
60
  else if (!zarray_getarray(A, &npoints, &vec))
 
61
    error("%s: bad template for tabset", x->x_arrayname->s_name);
 
62
  else {
 
63
    if (argc>=npoints)
 
64
      while(npoints--){
 
65
        t_float f= atom_getfloat(argv++);
 
66
        zarray_setfloat(vec, 0, f);
 
67
        vec++;
 
68
      }
 
69
    else {
 
70
      npoints-=argc;
 
71
      while (argc--){
 
72
        t_float f= atom_getfloat(argv++);
 
73
        zarray_setfloat(vec, 0, f);
 
74
        vec++;
 
75
      }
 
76
      while (npoints--){
 
77
        zarray_setfloat(vec, 0, 0);
 
78
        vec++;
 
79
      }
 
80
    }
 
81
    garray_redraw(A);
 
82
  }
 
83
}
 
84
static void tabset_set(t_tabset *x, t_symbol *s)
 
85
{
 
86
  x->x_arrayname = s;
 
87
}
 
88
 
 
89
static void *tabset_new(t_symbol *s)
 
90
{
 
91
  t_tabset *x = (t_tabset *)pd_new(tabset_class);
 
92
  x->x_arrayname = s;
 
93
 
 
94
  return (x);
 
95
}
 
96
 
 
97
static void tabset_helper(void)
 
98
{
 
99
  post("\n%c tabset - object : set a table with a package of floats", HEARTSYMBOL);
 
100
  post("'set <table>'\t: set another table\n"
 
101
       "<list>\t\t: set the table"
 
102
       "<float>\t\t: set the table to constant float\n");
 
103
  post("creation\t: \"tabset <table>\"");
 
104
}
 
105
 
 
106
void tabset_setup(void)
 
107
{
 
108
  tabset_class = class_new(gensym("tabset"), (t_newmethod)tabset_new,
 
109
                             0, sizeof(t_tabset), 0, A_DEFSYM, 0);
 
110
  class_addfloat(tabset_class, (t_method)tabset_float);
 
111
  class_addlist (tabset_class, (t_method)tabset_list);
 
112
  class_addmethod(tabset_class, (t_method)tabset_set, gensym("set"),
 
113
                  A_SYMBOL, 0);
 
114
 
 
115
  class_addmethod(tabset_class, (t_method)tabset_helper, gensym("help"), 0);
 
116
  zexy_register("tabset");
 
117
}