Use SIMD helpers for zero-filling
This commit is contained in:
parent
e31bf1381f
commit
ee056bcea8
1 changed files with 11 additions and 10 deletions
|
|
@ -5,6 +5,7 @@
|
||||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||||
|
|
||||||
#include "BeatClock.h"
|
#include "BeatClock.h"
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Debug.h"
|
#include "Debug.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
@ -161,18 +162,18 @@ void BeatClock::fillBufferUpTo(unsigned delay)
|
||||||
int *beatNumberData = runningBeatNumber_.data();
|
int *beatNumberData = runningBeatNumber_.data();
|
||||||
float *beatNumberPosition = runningBeatPosition_.data();
|
float *beatNumberPosition = runningBeatPosition_.data();
|
||||||
int *beatsPerBarData = runningBeatsPerBar_.data();
|
int *beatsPerBarData = runningBeatsPerBar_.data();
|
||||||
unsigned fill = currentCycleFill_;
|
unsigned fillIdx = currentCycleFill_;
|
||||||
|
|
||||||
const TimeSignature sig = timeSig_;
|
const TimeSignature sig = timeSig_;
|
||||||
for (unsigned i = fill; i < delay; ++i)
|
for (unsigned i = fillIdx; i < delay; ++i)
|
||||||
beatsPerBarData[i] = sig.beatsPerBar;
|
beatsPerBarData[i] = sig.beatsPerBar;
|
||||||
|
|
||||||
if (!isPlaying_) {
|
if (!isPlaying_) {
|
||||||
for (; fill < delay; ++fill) {
|
if (fillIdx < delay) {
|
||||||
beatNumberData[fill] = 0;
|
fill(absl::MakeSpan(&beatNumberData[fillIdx], delay - fillIdx), 0);
|
||||||
beatNumberPosition[fill] = 0;
|
fill(absl::MakeSpan(&beatNumberPosition[fillIdx], delay - fillIdx), 0.0f);
|
||||||
}
|
}
|
||||||
currentCycleFill_ = fill;
|
currentCycleFill_ = fillIdx;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -182,18 +183,18 @@ void BeatClock::fillBufferUpTo(unsigned delay)
|
||||||
const BBT hostPos = lastHostPos_;
|
const BBT hostPos = lastHostPos_;
|
||||||
bool mustApplyHostPos = mustApplyHostPos_;
|
bool mustApplyHostPos = mustApplyHostPos_;
|
||||||
|
|
||||||
for (; fill < delay; ++fill) {
|
for (; fillIdx < delay; ++fillIdx) {
|
||||||
clientPos = BBT::fromBeats(sig, clientPos.toBeats(sig) + beatsPerFrame);
|
clientPos = BBT::fromBeats(sig, clientPos.toBeats(sig) + beatsPerFrame);
|
||||||
clientPos = mustApplyHostPos ? hostPos : clientPos;
|
clientPos = mustApplyHostPos ? hostPos : clientPos;
|
||||||
mustApplyHostPos = false;
|
mustApplyHostPos = false;
|
||||||
|
|
||||||
// quantization to nearest for prevention of rounding errors
|
// quantization to nearest for prevention of rounding errors
|
||||||
double beats = clientPos.toBeats(sig);
|
double beats = clientPos.toBeats(sig);
|
||||||
beatNumberData[fill] = dequantize<int>(quantize(beats));
|
beatNumberData[fillIdx] = dequantize<int>(quantize(beats));
|
||||||
beatNumberPosition[fill] = static_cast<float>(beats);
|
beatNumberPosition[fillIdx] = static_cast<float>(beats);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentCycleFill_ = fill;
|
currentCycleFill_ = fillIdx;
|
||||||
lastClientPos_ = clientPos;
|
lastClientPos_ = clientPos;
|
||||||
mustApplyHostPos_ = mustApplyHostPos;
|
mustApplyHostPos_ = mustApplyHostPos;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue