new stuff

This commit is contained in:
Ryzerth
2021-03-20 21:53:44 +01:00
parent f55d591cba
commit f29d683918
61 changed files with 5354 additions and 11 deletions

View File

@@ -151,27 +151,29 @@ namespace dsp {
}
void bufferWorker() {
complex_t* buf = new complex_t[_keep];
T* buf = new T[_keep];
bool delay = _skip < 0;
int readCount = std::min<int>(_keep + _skip, _keep);
int skip = std::max<int>(_skip, 0);
int delaySize = (-_skip) * sizeof(complex_t);
int delaySize = (-_skip) * sizeof(T);
int delayCount = (-_skip);
complex_t* start = &buf[std::max<int>(-_skip, 0)];
complex_t* delayStart = &buf[_keep + _skip];
T* start = &buf[std::max<int>(-_skip, 0)];
T* delayStart = &buf[_keep + _skip];
while (true) {
if (delay) {
memmove(buf, delayStart, delaySize);
for (int i = 0; i < delayCount; i++) {
buf[i].i /= 10.0f;
buf[i].q /= 10.0f;
if constexpr (std::is_same_v<T, complex_t> || std::is_same_v<T, stereo_t>) {
for (int i = 0; i < delayCount; i++) {
buf[i].i /= 10.0f;
buf[i].q /= 10.0f;
}
}
}
if (ringBuf.readAndSkip(start, readCount, skip) < 0) { break; };
memcpy(out.writeBuf, buf, _keep * sizeof(complex_t));
memcpy(out.writeBuf, buf, _keep * sizeof(T));
if (!out.swap(_keep)) { break; }
}
delete[] buf;