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

« back to all changes in this revision

Viewing changes to src/pack~.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
 
 
20
/* ------------------------ pack~ ----------------------------- */
 
21
/* pack the signal-vector to a float-package */
 
22
 
 
23
static t_class *sigpack_class;
 
24
 
 
25
typedef struct _sigpack
 
26
{
 
27
  t_object x_obj;
 
28
 
 
29
  int vector_length;
 
30
  t_atom *buffer;
 
31
  t_clock*x_clock;
 
32
  int x_outputindsp;
 
33
} t_sigpack;
 
34
 
 
35
static void sigpack_tick(t_sigpack*x)
 
36
{
 
37
  outlet_list(x->x_obj.ob_outlet, &s_list, x->vector_length, x->buffer);
 
38
}
 
39
 
 
40
static t_int *sigpack_perform(t_int *w)
 
41
{
 
42
  t_sample *in = (t_sample *)(w[1]);
 
43
  t_sigpack *x = (t_sigpack *)w[2];
 
44
  int n = (int)(w[3]), i = 0;
 
45
  t_atom *buf = x->buffer;
 
46
 
 
47
  while (n--) {
 
48
    t_float f=*in++;
 
49
    SETFLOAT(&buf[i], f);
 
50
    i++;
 
51
  }
 
52
  if(x->x_outputindsp) {
 
53
    sigpack_tick(x);
 
54
  } else {
 
55
    clock_delay(x->x_clock, 0);
 
56
  }
 
57
 
 
58
  return (w+4);
 
59
}
 
60
 
 
61
static void sigpack_dsp(t_sigpack *x, t_signal **sp)
 
62
{
 
63
  if (x->vector_length != sp[0]->s_n) {
 
64
    freebytes(x->buffer, x->vector_length * sizeof(t_atom));
 
65
    x->vector_length = sp[0]->s_n;
 
66
    x->buffer = (t_atom *)getbytes(x->vector_length * sizeof(t_atom));
 
67
  }
 
68
  dsp_add(sigpack_perform, 3, sp[0]->s_vec, x, sp[0]->s_n);
 
69
}
 
70
 
 
71
static void sigpack_free(t_sigpack*x)
 
72
{
 
73
  clock_free(x->x_clock);
 
74
}
 
75
 
 
76
static void *sigpack_new(void)
 
77
{
 
78
  t_sigpack *x = (t_sigpack *)pd_new(sigpack_class);
 
79
  x->vector_length = 0;
 
80
  x->buffer = 0;
 
81
  outlet_new(&x->x_obj, gensym("list"));
 
82
  x->x_clock=clock_new(x, (t_method)sigpack_tick);
 
83
 
 
84
  x->x_outputindsp=0;
 
85
 
 
86
  return (x);
 
87
}
 
88
 
 
89
static void sigpack_help(void)
 
90
{
 
91
  post("pack~\t:: outputs the signal-vectors as float-packages");
 
92
}
 
93
 
 
94
void pack_tilde_setup(void)
 
95
{
 
96
  sigpack_class = class_new(gensym("pack~"), (t_newmethod)sigpack_new, (t_method)sigpack_free,
 
97
                            sizeof(t_sigpack), 0, A_DEFFLOAT, 0);
 
98
  class_addmethod(sigpack_class, nullfn, gensym("signal"), 0);
 
99
  class_addmethod(sigpack_class, (t_method)sigpack_dsp, gensym("dsp"), 0);
 
100
 
 
101
  class_addmethod(sigpack_class, (t_method)sigpack_help, gensym("help"), 0);
 
102
 
 
103
  zexy_register("pack~");
 
104
}