1
0
mirror of synced 2024-11-12 10:10:53 +01:00

fix: Sound visualizer being really laggy

This commit is contained in:
WerWolv 2023-01-24 23:57:29 +01:00
parent 94cd83e0dc
commit 8ea0e9ce9c

View File

@ -340,7 +340,12 @@ namespace hex::plugin::builtin {
index = dragPos;
}
ImPlot::PlotLine("##audio", waveData.data(), waveData.size());
ImPlot::PlotLineG("##audio", [](void *data, int idx) -> ImPlotPoint {
const auto &waveData = *static_cast<std::vector<i16> *>(data);
auto stride = std::max(1.0, (double(waveData.size()) / ImPlot::GetPlotSize().x)) / 2;
return { double(idx * stride), double(waveData[u64(idx * stride)]) };
}, &waveData, waveData.size() / (std::max(1.0, (double(waveData.size()) / ImPlot::GetPlotSize().x)) / 2));
ImPlot::EndPlot();
}
@ -383,7 +388,9 @@ namespace hex::plugin::builtin {
if (resetTask.isRunning())
ImGui::TextSpinner("Loading...");
else
ImGui::TextFormatted("{:02d}:{:02d}", (index / sampleRate) / 60, (index / sampleRate) % 60);
ImGui::TextFormatted("{:02d}:{:02d} / {:02d}:{:02d}",
(index / sampleRate) / 60, (index / sampleRate) % 60,
(waveData.size() / sampleRate) / 60, (waveData.size() / sampleRate) % 60);
}
}