Mixer and a few filters

This commit is contained in:
2022-07-06 22:17:06 +00:00
parent 1c556a70bc
commit eb49f0fcc5
11 changed files with 350 additions and 104 deletions

View File

@@ -7,7 +7,6 @@ struct circbuf circbuf_init(size_t size, unsigned int len)
{
struct circbuf new;
new.len = powof2(len);
new.len = len;
new.data = calloc(sizeof(short), new.len);
new.read = new.write = 0;
@@ -23,7 +22,7 @@ int cbuf_empty(struct circbuf *buf) {
}
int cbuf_full(struct circbuf *buf) {
return cbuf_size(buf) == buf->len;
return cbuf_size(buf) >= buf->len;
}
uint32_t cbuf_mask(struct circbuf *buf, uint32_t n) {
@@ -31,13 +30,13 @@ uint32_t cbuf_mask(struct circbuf *buf, uint32_t n) {
}
void cbuf_push(struct circbuf *buf, short data) {
assert(!cbuf_full(buf));
//assert(!cbuf_full(buf));
buf->data[cbuf_mask(buf,buf->write++)] = data;
}
short cbuf_shift(struct circbuf *buf) {
assert(!cbuf_empty(buf));
//assert(!cbuf_empty(buf));
return buf->data[cbuf_mask(buf, buf->read++)];
}