-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcount.c
44 lines (40 loc) · 894 Bytes
/
count.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdlib.h>
#include "soundpipe.h"
int sp_count_create(sp_count **p)
{
*p = malloc(sizeof(sp_count));
return SP_OK;
}
int sp_count_destroy(sp_count **p)
{
free(*p);
return SP_OK;
}
int sp_count_init(sp_data *sp, sp_count *p)
{
p->count = 4;
p->curcount = -1;
p->mode = 0;
return SP_OK;
}
int sp_count_compute(sp_data *sp, sp_count *p, SPFLOAT *in, SPFLOAT *out)
{
if(*in){
if(p->mode == 0) {
p->curcount = (p->curcount + 1) % p->count;
} else {
if(p->curcount == -2) {
*out = -2;
return SP_OK;
}
if(p->curcount >= p->count - 1) {
p->curcount = -2;
} else {
if(p->curcount == -1) p->curcount = 0;
else p->curcount++;
}
}
}
*out = p->curcount;
return SP_OK;
}