moved delay to own files

master
Ahmet Inan 2011-09-08 14:16:43 +02:00
rodzic 27132b6e00
commit 1e7c47c1e2
4 zmienionych plików z 44 dodań i 31 usunięć

Wyświetl plik

@ -22,5 +22,5 @@ clean:
encode: encode.o mmap_file.o
decode: decode.o mmap_file.o pcm.o wav.o alsa.o window.o ddc.o
decode: decode.o mmap_file.o pcm.o wav.o alsa.o window.o ddc.o delay.o

Wyświetl plik

@ -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;

28
delay.c 100644
Wyświetl plik

@ -0,0 +1,28 @@
#include "delay.h"
#include <stdlib.h>
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);
}

14
delay.h 100644
Wyświetl plik

@ -0,0 +1,14 @@
#ifndef DELAY_H
#define DELAY_H
typedef struct {
float *s;
int last;
int len;
} delay_t;
float do_delay(delay_t *, float);
delay_t *alloc_delay(int);
void free_delay(delay_t *);
#endif