You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
837 B
45 lines
837 B
#ifndef __STEREODELAYLINE_H__
|
|
#define __STEREODELAYLINE_H__
|
|
|
|
#include <cstddef>
|
|
|
|
#include "frame.h"
|
|
|
|
template <size_t CAPACITY>
|
|
class StereoDelayLine {
|
|
private:
|
|
frame samples[CAPACITY] = {{0, 0}};
|
|
size_t cursor;
|
|
|
|
public:
|
|
size_t size;
|
|
|
|
StereoDelayLine(size_t size = CAPACITY) : size(size) {}
|
|
|
|
inline frame tick() {
|
|
++cursor;
|
|
if(cursor == size) {
|
|
cursor = 0;
|
|
}
|
|
return samples[cursor];
|
|
}
|
|
|
|
inline frame tick(frame in) {
|
|
samples[cursor++] = in;
|
|
if(cursor == size) {
|
|
cursor = 0;
|
|
}
|
|
return samples[cursor];
|
|
}
|
|
|
|
inline frame tap(size_t n) {
|
|
size_t index = cursor + n;
|
|
if(index < size) {
|
|
return samples[index];
|
|
} else {
|
|
return samples[index - size];
|
|
}
|
|
}
|
|
};
|
|
|
|
#endif |