Browse Source

Account for transposer prefill in source coordinates

master
evgeny 3 days ago
parent
commit
4939ee7fb0
  1. 3
      lib/soundtouch-master/source/SoundTouch/RateTransposer.h
  2. 7
      tools/chatgui/tests/test_soundtouch_clock.cpp

3
lib/soundtouch-master/source/SoundTouch/RateTransposer.h

@ -136,7 +136,8 @@ public:
AAFilter *getAAFilter();
/// Enables/disables the anti-alias filter. Zero to disable, nonzero to enable
int unitySourceOffset() const { return bUseAAFilter ? -1 : pTransposer->unitySourceOffset(); }
// clear() добавляет getLatency() нулей: они компенсируют смещение интерполятора.
int unitySourceOffset() const { return bUseAAFilter ? -1 : pTransposer->unitySourceOffset() - getLatency(); }
void enableAAFilter(bool newMode);

7
tools/chatgui/tests/test_soundtouch_clock.cpp

@ -74,6 +74,11 @@ static void check_exact(unsigned channels, unsigned block) {
expected = expected * (1.0f - weight) + source[(s.input1 + i) * channels + ch] * weight;
}
float actual = output[(s.output + i) * channels + ch];
if (std::abs(actual - expected) >= 0.000002f)
DEBUG_ERROR(DEBUG_CATEGORY_CALL, "source mismatch channels=%u block=%u kind=%d out=%llu input0=%llu input1=%llu"
" count=%u i=%u channel=%u actual=%.9g expected=%.9g", channels, block, (int)s.kind,
(unsigned long long)s.output, (unsigned long long)s.input0, (unsigned long long)s.input1,
s.count, i, ch, actual, expected);
CHECK(std::abs(actual - expected) < 0.000002f);
if (s.kind == soundtouch::SourceKind::Copy) CHECK(actual == expected);
}
@ -84,7 +89,7 @@ static void check_exact(unsigned channels, unsigned block) {
tracked.clear(); plain.clear();
CHECK(trace.resets == 2 && trace.spans.empty());
tracked.putSamples(source.data(), 4000); plain.putSamples(source.data(), 4000);
CHECK(!trace.spans.empty() && trace.spans.front().output == 0 && trace.spans.front().input0 == 1);
CHECK(!trace.spans.empty() && trace.spans.front().output == 0 && trace.spans.front().input0 == 0);
CHECK(!tracked.setSourceCallback(source_event, &trace) && trace.reason == soundtouch::SourceError::LateAttach);
trace.invalid = 0;
tracked.setRate(1.01);

Loading…
Cancel
Save