implement the FFT deques also for math channels, add an "input overrun" indication

This commit is contained in:
2026-04-09 10:38:43 +02:00
parent 6846c853c0
commit 3f2546edd1
7 changed files with 67 additions and 12 deletions

View File

@@ -334,16 +334,20 @@ void Application::processAudio() {
wfInfo.push_back({c.x, c.y, c.z,
ui_.channelEnabled[ch % kMaxChannels]});
}
// Math channels only available for the latest spectrum;
// include them only on the last iteration.
if (si == histSz - 1) {
for (size_t mi = 0; mi < mathChannels.size(); ++mi) {
if (mathChannels[mi].enabled && mathChannels[mi].waterfall &&
mi < mathSpectra.size()) {
const auto& c = mathChannels[mi].color;
// Math channels: use their own waterfall history.
for (size_t mi = 0; mi < mathChannels.size(); ++mi) {
if (mathChannels[mi].enabled && mathChannels[mi].waterfall &&
mi < mathSpectra.size()) {
const auto& c = mathChannels[mi].color;
const auto& mHist = audio_.mathWaterfallHistory(static_cast<int>(mi));
int mHistSz = static_cast<int>(mHist.size());
int mIdx = std::max(0, mHistSz - (histSz - si));
if (mIdx < mHistSz) {
wfSpectra.push_back(mHist[mIdx]);
} else {
wfSpectra.push_back(mathSpectra[mi]);
wfInfo.push_back({c[0], c[1], c[2], true});
}
wfInfo.push_back({c[0], c[1], c[2], true});
}
}
waterfall_.pushLineMulti(wfSpectra, wfInfo, ui_.minDB, ui_.maxDB);

View File

@@ -95,6 +95,23 @@ void ControlPanel::render(AudioEngine& audio, UIState& ui,
ImGui::GetWindowDrawList()->AddText({tx, ty}, IM_COL32(255, 255, 255, 220), overlayText);
if (ImGui::IsItemHovered()) ImGui::SetTooltip("Overlap");
}
// Overrun indicator
{
int overruns = audio.overrunCount();
float now = static_cast<float>(ImGui::GetTime());
if (overruns > lastOverrunCount_) {
lastOverrunCount_ = overruns;
lastOverrunTime_ = now;
}
if (overruns > 0 && (now - lastOverrunTime_) < 3.0f) {
ImGui::TextColored({1.0f, 0.4f, 0.4f, 1.0f},
"Input overrun: %d FFTs", overruns);
} else if (overruns > 0) {
audio.resetOverrunCount();
lastOverrunCount_ = 0;
}
}
}
// ── Display ──

View File

@@ -45,6 +45,10 @@ private:
bool needsSave_ = false;
bool needsUpdate_ = false;
// Overrun display
int lastOverrunCount_ = 0;
float lastOverrunTime_ = 0.0f; // ImGui time of last overrun
void flagSave() { needsSave_ = true; }
void flagUpdate() { needsUpdate_ = true; }
};