moved delay to own files

This commit is contained in:
Ahmet Inan 2011-09-08 14:16:43 +02:00
parent 27132b6e00
commit 1e7c47c1e2
4 changed files with 44 additions and 31 deletions

View file

@ -9,6 +9,7 @@
#include "mmap_file.h"
#include "pcm.h"
#include "ddc.h"
#include "delay.h"
float lerp(float a, float b, float x)
{
@ -31,36 +32,6 @@ float limit(float min, float max, float x)
return tmp > max ? max : tmp;
}
typedef struct {
float *s;
int last;
int len;
} delay_t;
float do_delay(delay_t *d, float input)
{
d->s[d->last] = input;
d->last = (d->last + 1) < d->len ? d->last + 1 : 0;
return d->s[d->last];
}
delay_t *alloc_delay(int samples)
{
int len = samples + 1;
delay_t *d = malloc(sizeof(delay_t));
d->s = malloc(sizeof(float) * len);
d->last = 0;
d->len = len;
for (int i = 0; i < len; i++)
d->s[i] = 0.0;
return d;
}
void free_delay(delay_t *delay)
{
free(delay->s);
free(delay);
}
typedef struct {
uint32_t ChunkID;
uint32_t ChunkSize;