~ubuntu-branches/ubuntu/raring/pd-smlib/raring

« back to all changes in this revision

Viewing changes to prevl.c

  • Committer: Package Import Robot
  • Author(s): Hans-Christoph Steiner
  • Date: 2012-09-25 12:20:08 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: package-import@ubuntu.com-20120925122008-1915rs1wniolkddt
Tags: upstream-0.12.2
ImportĀ upstreamĀ versionĀ 0.12.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
typedef struct _prevl
8
8
{
9
9
    t_object x_obj;
10
 
        float m_lo;
11
 
        float m_hi;
 
10
        t_float m_lo;
 
11
        t_float m_hi;
12
12
        int m_buffer_size;
13
13
        int m_buffer_index;
14
 
        float *m_buffer;  // circular buffer
 
14
        t_float *m_buffer;  // circular buffer
15
15
} t_prevl;
16
16
 
 
17
static void prevl_set(t_prevl *x, t_float lo, t_float hi, t_float size);
17
18
 
18
19
static void prevl_perform_float(t_prevl *x, t_float f)
19
20
{
28
29
{
29
30
        int lo,hi,n,index,size;
30
31
        t_atom *ap,*app;
31
 
        float *buffer, *bp;
 
32
        t_float *buffer, *bp;
32
33
 
 
34
    prevl_set(x, x->m_lo, x->m_hi, x->m_buffer_size);
33
35
        lo=(int)x->m_lo;
34
36
        hi=(int)x->m_hi;
35
37
 
82
84
static void prevl_clear(t_prevl *x)
83
85
{
84
86
        int i,s;
85
 
        float *f;
 
87
        t_float *f;
86
88
        f=x->m_buffer;
87
89
        s=x->m_buffer_size;
88
90
        for (i=0;i<s;i++)
89
 
                *f++=0.0f;
 
91
                *f++=0.0;
90
92
}
91
93
 
92
94
static void prevl_set(t_prevl *x, t_float lo, t_float hi, t_float size)
94
96
        if (size<1)
95
97
        {
96
98
                size=1;
97
 
                post("prevl: size is minimum 1...");
 
99
                logpost(x, 2, "[prevl] size is minimum 1");
98
100
        }
99
101
        if (hi>size)
100
102
        {
101
 
                post("prevl: higher bound cannot be higher than the buffer size...");   
 
103
                logpost(x, 2, "[prevl] higher bound (%g) cannot be greater than the buffer size (%g)",
 
104
                hi, size);      
102
105
                hi=size;
103
106
        }
104
107
        if (lo<0)
105
108
        {
106
 
                post("prevl: lower bound cannot be negative...");       
 
109
                logpost(x, 2, "[prevl] lower bound cannot be negative");        
107
110
                lo=0;
108
111
        }
109
112
        if (hi<1)
110
113
        {
111
 
                post("prevl: higher bound cannot be smaller than one...");      
 
114
                logpost(x, 2, "[prevl] higher bound (%g) cannot be smaller than 1", hi);
112
115
                hi=1;
113
116
        }
114
117
        if (hi<=lo)
115
118
        {
116
 
                post("prevl: higher bound must be higher than lower bound..."); 
117
 
                lo=hi-1.0f;
 
119
                logpost(x, 2, "[prevl] higher bound (%g) must be greater than lower bound (%g)",
 
120
                hi, lo);        
 
121
                lo=hi-1.0;
118
122
        }
119
123
 
120
 
        freebytes(x->m_buffer, x->m_buffer_size);
121
 
 
122
 
        x->m_hi=(float)((int)hi);
123
 
        x->m_lo=(float)((int)lo);
124
 
        x->m_buffer_size=(int)size;
125
 
    x->m_buffer = (float*)getbytes(sizeof(float)*x->m_buffer_size);
126
 
        prevl_clear(x);
127
 
        x->m_buffer_index=0;
 
124
 
 
125
        x->m_hi=(t_float)((int)hi);
 
126
        x->m_lo=(t_float)((int)lo);
 
127
 
 
128
    if (x->m_buffer_size != size)
 
129
    {
 
130
        x->m_buffer_size=(int)size;
 
131
        freebytes(x->m_buffer, x->m_buffer_size);
 
132
        x->m_buffer = (t_float*)getbytes(sizeof(t_float)*x->m_buffer_size);
 
133
        prevl_clear(x);
 
134
        x->m_buffer_index=0;
 
135
    }
128
136
}
129
137
 
130
138
static void *prevl_new(t_float lo, t_float hi, t_float size)