~ubuntu-branches/ubuntu/saucy/pd-smlib/saucy

« back to all changes in this revision

Viewing changes to SMLib.c

  • Committer: Bazaar Package Importer
  • Author(s): Hans-Christoph Steiner
  • Date: 2010-11-10 15:17:58 UTC
  • Revision ID: james.westby@ubuntu.com-20101110151758-3acjf69kiudo3gh4
Tags: upstream-0.12.1
ImportĀ upstreamĀ versionĀ 0.12.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* --------------------- SMLib ----------------------------- */
 
2
/*
 
3
 
 
4
  Signal processing for Mapping
 
5
        objects:
 
6
 
 
7
  float stream
 
8
                - pid controller?
 
9
                - deltas (generate difference vector between current values and values of the past)
 
10
  vector 
 
11
                - vquant (quantizer with hysteresis)
 
12
                - vv/
 
13
                - vv>
 
14
                - vv<
 
15
                - s2v (stream to vector, incl ola)
 
16
                - v2s (vector to stream, incl ola)
 
17
 
 
18
  vector math
 
19
                - vreverse
 
20
 
 
21
                - delread
 
22
                - delwrite
 
23
                - upsample
 
24
                - fir
 
25
                - autorescale
 
26
*/      
 
27
 
 
28
#include "defines.h"
 
29
 
 
30
 
 
31
// in alphabetical order
 
32
extern void bp_setup();
 
33
extern void decimator_setup();
 
34
extern void     deltas_setup();
 
35
extern void     hip_setup();
 
36
extern void hist_setup();
 
37
extern void itov_setup();
 
38
extern void lavg_setup();
 
39
extern void lhist_setup();
 
40
extern void lhisti_setup();
 
41
extern void linspace_setup();
 
42
extern void lmax_setup();
 
43
extern void lmin_setup();
 
44
extern void lrange_setup();
 
45
extern void lstd_setup();
 
46
extern void prevl_setup();
 
47
extern void threshold_setup();
 
48
extern void vabs_setup();
 
49
extern void vclip_setup();
 
50
extern void vcog_setup();
 
51
extern void vdbtorms_setup();
 
52
extern void vdelta_setup();
 
53
extern void vfmod_setup();
 
54
extern void vftom_setup();
 
55
extern void vlavg_setup();
 
56
extern void vlmax_setup();
 
57
extern void vlmin_setup();
 
58
extern void vlrange_setup();
 
59
extern void vmax_setup();
 
60
extern void vmin_setup();
 
61
extern void vmtof_setup();
 
62
extern void vpow_setup();
 
63
extern void vrms_setup();
 
64
extern void vrmstodb_setup();
 
65
extern void vstd_setup();
 
66
extern void vsum_setup();
 
67
extern void vthreshold_setup();
 
68
extern void vvconv_setup();
 
69
extern void vvminus_setup();
 
70
extern void vvplus_setup();
 
71
 
 
72
static t_class *SMLib_class;
 
73
 
 
74
typedef struct _lstd
 
75
{
 
76
    t_object x_obj;
 
77
} t_SMLib;
 
78
 
 
79
static void SMLib_help(t_SMLib *x)
 
80
{
 
81
        /*
 
82
        */
 
83
        post("");
 
84
        post("");
 
85
        post("    ..........................................................");
 
86
        post("    . SMLib                                                  .");
 
87
        post("    .   Signal processing for Mapping                        .");
 
88
        post("    .     v0.12 24/11/2002                                   .");
 
89
        post("    ..........................................................");
 
90
        post("    . processing stream of floats (context) (float output)   .");
 
91
        post("    .                                                        .");
 
92
        post("    .   lavg        leaky average                            .");
 
93
        post("    .   lmax        leaky maximum                            .");
 
94
        post("    .   lmin        leaky minimum                            .");
 
95
        post("    .   lrange      leaky range                              .");
 
96
        post("    u   lstd        leaky standard deviation                 .");
 
97
        post("    u   decimator   passes 1 in n input values               .");
 
98
        post("    .   threshold   detection with hysteresis                .");
 
99
        post("    .   hip         first order high-pass filter             .");
 
100
        post("    .   bp          second order (resonant) high-pass filter .");
 
101
        post("    ..........................................................");
 
102
        post("    . analyzing stream of floats (vector output)             .");
 
103
        post("    .                                                        .");
 
104
        post("    .   hist        histogram                                .");
 
105
        post("    .   lhist       leaky histogram, clips samples           .");
 
106
        post("    .   lhisti      leaky histogram, ignore samples          .");
 
107
        post("    .                 outside bins                           .");
 
108
        post("    .   itov        bin index to value (for the histograms   .");
 
109
        post("    .   prevl       previous floats in a list                .");
 
110
        post("    .   deltas      difference between last float and        .");
 
111
        post("    .                 previous floats                        .");
 
112
//      post("    o   filterbank  lineairly spaced set of bandpass filters .");
 
113
        post("    ..........................................................");
 
114
        post("    . immediate vector analysis (float output)               .");
 
115
        post("    .                                                        .");
 
116
        post("    .   vsum        sum of vector elements                   .");
 
117
        post("    .   vcog        center of gravity                        .");
 
118
        post("    .   vmax        maximum and its location                 .");
 
119
        post("    .   vmin        minimum and its location                 .");
 
120
        post("    .   vrms        root mean square                         .");
 
121
        post("    .   vstd        standard deviation                       .");
 
122
        post("    ..........................................................");
 
123
        post("    . vector processors (vector output)                      .");
 
124
        post("    .                                                        .");
 
125
        post("    .   vv+         vector addition                          .");
 
126
        post("    .   vv-         vector substraction                      .");
 
127
        post("    .   vvconv      vector convolution                       .");
 
128
        post("    .   vclip       clip elements                            .");
 
129
        post("    .   vfmod       floating point modulo                    .");
 
130
        post("    .   vpow        power                                    .");
 
131
        post("    .   vthreshold  detections with hysteresises             .");
 
132
        post("    .                                                        .");
 
133
        post("    . unit conversions on vectors                            .");
 
134
        post("    .                                                        .");
 
135
        post("    .   vftom       frequency to midi                        .");
 
136
        post("    .   vmtof       midi to frequency                        .");
 
137
        post("    .   vdbtorms    dB to rms                                .");
 
138
        post("    .   vrmstodb    rms to dB                                .");
 
139
        post("    ..........................................................");
 
140
        post("    . vector synthesis (vector output)                       .");
 
141
        post("    .                                                        .");
 
142
        post("    .   linspace    linearly spaced vector                   .");
 
143
//      post("    o   logspace    logarithmically spaced vector            .");
 
144
//      post("    o   rand        uniformly distributed random vector      .");
 
145
//      post("    o   randn       normally distributed random vector       .");
 
146
        post("    ..........................................................");
 
147
        post("    . vector stream processing (vector output) (context)     .");
 
148
        post("    .                                                        .");
 
149
        post("    .   vlavg       leaky averages                           .");
 
150
        post("    .   vlmax       leaky maxima                             .");
 
151
        post("    .   vlmin       leaky minima                             .");
 
152
        post("    .   vlrange     leaky ranges                             .");
 
153
        post("    .   vdelta      difference between successive vectors    .");
 
154
        post("    ..........................................................");
 
155
//      post("    .              o    = future additions                   .");
 
156
//      post("    .              e    = experimental                       .");
 
157
        post("    .              u    = undocumented                       .");
 
158
        post("    .              j#|@ = johannes.taelman@rug.ac.be         .");
 
159
        post("    ..........................................................");
 
160
        post("");
 
161
        post("");
 
162
}
 
163
 
 
164
static void *SMLib_new()
 
165
{
 
166
        t_SMLib *x=(t_SMLib *)pd_new(SMLib_class);
 
167
        return (void *)x;
 
168
}
 
169
 
 
170
#ifdef WIN32
 
171
__declspec(dllexport) void __cdecl SMLib_setup( void)
 
172
#else
 
173
void SMLib_setup( void)
 
174
#endif
 
175
{
 
176
        // dummy object for help-system
 
177
    SMLib_class = class_new(gensym("SMLib"),
 
178
        (t_newmethod)SMLib_new, 0,
 
179
                sizeof(t_SMLib), 
 
180
                CLASS_DEFAULT,
 
181
            0);
 
182
    class_addbang(SMLib_class, (t_method)SMLib_help);
 
183
        class_addmethod(SMLib_class, (t_method)SMLib_help, gensym("help"),0);
 
184
                
 
185
        // real objects in alphabetical order
 
186
        bp_setup();
 
187
        decimator_setup();
 
188
        deltas_setup();
 
189
        hip_setup();
 
190
        hist_setup();
 
191
        itov_setup();
 
192
        lavg_setup();
 
193
        lhist_setup();
 
194
        lhisti_setup();
 
195
        linspace_setup();
 
196
        lmax_setup();
 
197
        lmin_setup();
 
198
        lrange_setup();
 
199
        lstd_setup();
 
200
        prevl_setup();
 
201
        threshold_setup();
 
202
        vabs_setup();
 
203
        vclip_setup();
 
204
        vcog_setup();
 
205
        vdbtorms_setup();
 
206
        vdelta_setup();
 
207
        vfmod_setup();
 
208
        vftom_setup();
 
209
        vlavg_setup();
 
210
        vlmax_setup();
 
211
        vlmin_setup();
 
212
        vlrange_setup();
 
213
        vmax_setup();
 
214
        vmin_setup();
 
215
        vmtof_setup();
 
216
        vpow_setup();
 
217
        vrms_setup();
 
218
        vrmstodb_setup();
 
219
        vstd_setup();
 
220
        vsum_setup();
 
221
        vthreshold_setup();
 
222
        vvconv_setup();
 
223
        vvminus_setup();
 
224
        vvplus_setup();
 
225
 
 
226
        post("");
 
227
        post("    ..........................................................");
 
228
        post("    .   SMLib                                                .");
 
229
        post("    .    Signal processing for Mapping                       .");
 
230
        post("    .     v0.12 24/11/2002                                   .");
 
231
        post("    ..........................................................");
 
232
        post("");
 
233
 
 
234
}