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

« back to all changes in this revision

Viewing changes to src/tabdump.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
 *
 
4
 * zexy - implementation file
 
5
 *
 
6
 * copyleft (c) IOhannes m zm�lnig
 
7
 *
 
8
 *   1999:forum::f�r::uml�ute:2004
 
9
 *
 
10
 *   institute of electronic music and acoustics (iem)
 
11
 *
 
12
 ******************************************************
 
13
 *
 
14
 * license: GNU General Public License v.2
 
15
 *
 
16
 ******************************************************/
 
17
 
 
18
 
 
19
/* hack : 2108:forum::f�r::uml�ute:1999 @ iem */
 
20
 
 
21
#include "zexy.h"
 
22
 
 
23
 
 
24
/* =================== tabdump ====================== */
 
25
 
 
26
static t_class *tabdump_class;
 
27
 
 
28
typedef struct _tabdump
 
29
{
 
30
  t_object x_obj;
 
31
  t_symbol *x_arrayname;
 
32
  t_int startindex, stopindex;
 
33
} t_tabdump;
 
34
 
 
35
static void tabdump_bang(t_tabdump *x)
 
36
{
 
37
  t_garray *A;
 
38
  int npoints;
 
39
  zarray_t *vec;
 
40
 
 
41
  if (!(A = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
 
42
    error("%s: no such array", x->x_arrayname->s_name);
 
43
  else if (!zarray_getarray(A, &npoints, &vec))
 
44
    error("%s: bad template for tabdump", x->x_arrayname->s_name);
 
45
  else
 
46
    {
 
47
      int n;
 
48
      t_atom *atombuf;
 
49
 
 
50
      int start=x->startindex;
 
51
      int stop =x->stopindex;
 
52
      if(start<0||start>stop)start=0;
 
53
      if(stop<start||stop>npoints)stop=npoints;
 
54
      npoints=stop-start;
 
55
 
 
56
      atombuf = (t_atom *)getbytes(sizeof(t_atom)*npoints);
 
57
      for (n = 0; n < npoints; n++) SETFLOAT(&atombuf[n], zarray_getfloat(vec, start+n));
 
58
      outlet_list(x->x_obj.ob_outlet, &s_list, npoints, atombuf);
 
59
      freebytes(atombuf,sizeof(t_atom)*npoints);
 
60
    }
 
61
}
 
62
 
 
63
static void tabdump_list(t_tabdump *x, t_symbol*s,int argc, t_atom*argv)
 
64
{
 
65
  int a,b;
 
66
  ZEXY_USEVAR(s);
 
67
  switch(argc){
 
68
  case 2:
 
69
    a=atom_getint(argv);
 
70
    b=atom_getint(argv+1);
 
71
    x->startindex=(a<b)?a:b;
 
72
    x->stopindex =(a>b)?a:b;
 
73
    tabdump_bang(x);
 
74
    break;
 
75
  default:
 
76
    error("tabdump: list must be 2 floats (is %d atoms)", argc);
 
77
  }
 
78
}
 
79
 
 
80
static void tabdump_set(t_tabdump *x, t_symbol *s)
 
81
{
 
82
  x->x_arrayname = s;
 
83
}
 
84
 
 
85
static void *tabdump_new(t_symbol *s)
 
86
{
 
87
  t_tabdump *x = (t_tabdump *)pd_new(tabdump_class);
 
88
  x->x_arrayname = s;
 
89
  x->startindex=0;
 
90
  x->stopindex=-1;
 
91
  outlet_new(&x->x_obj, &s_list);
 
92
 
 
93
  return (x);
 
94
}
 
95
 
 
96
static void tabdump_helper(void)
 
97
{
 
98
  post("\n%c tabdump - object : dumps a table as a package of floats", HEARTSYMBOL);
 
99
  post("'set <table>'\t: read out another table\n"
 
100
       "'bang'\t\t: dump the table\n"
 
101
       "outlet\t\t: table-data as package of floats");
 
102
  post("creation\t: \"tabdump <table>\"");
 
103
 
 
104
}
 
105
 
 
106
void tabdump_setup(void)
 
107
{
 
108
  tabdump_class = class_new(gensym("tabdump"), (t_newmethod)tabdump_new,
 
109
                             0, sizeof(t_tabdump), 0, A_DEFSYM, 0);
 
110
  class_addbang(tabdump_class, (t_method)tabdump_bang);
 
111
  class_addlist(tabdump_class, (t_method)tabdump_list);
 
112
 
 
113
  class_addmethod(tabdump_class, (t_method)tabdump_set, gensym("set"),
 
114
                  A_SYMBOL, 0);
 
115
 
 
116
  class_addmethod(tabdump_class, (t_method)tabdump_helper, gensym("help"), 0);
 
117
  zexy_register("tabdump");
 
118
}