HIST_DEPTH

This commit is contained in:
Sébastien Bourdeauducq 2025-01-02 13:52:18 +08:00
parent 7d69f4110a
commit eb7b3a2567

View File

@ -25,12 +25,14 @@
static std::atomic<bool> shutdown_threads; static std::atomic<bool> shutdown_threads;
static std::atomic<double> frequency[SND_PCHAN]; static std::atomic<double> frequency[SND_PCHAN];
static std::atomic<double> amplitude[SND_PCHAN]; static std::atomic<double> amplitude[SND_PCHAN];
static std::atomic<double> lpf_bandwidth[SND_PCHAN];
#define HIST_DEPTH 512
static std::atomic<double> lpf_bandwidth[SND_PCHAN];
static std::mutex li_hist_mutex; static std::mutex li_hist_mutex;
static std::atomic<bool> li_hist_pause[SND_PCHAN]; static std::atomic<bool> li_hist_pause[SND_PCHAN];
static float li_hist_mag[SND_PCHAN][512]; static float li_hist_mag[SND_PCHAN][HIST_DEPTH];
static float li_hist_phase[SND_PCHAN][512]; static float li_hist_phase[SND_PCHAN][HIST_DEPTH];
static void dsp_thread() static void dsp_thread()
{ {
@ -136,10 +138,10 @@ static void dsp_thread()
if(li_count[i] == 200) { if(li_count[i] == 200) {
li_count[i] = 0; li_count[i] = 0;
std::lock_guard<std::mutex> guard(li_hist_mutex); std::lock_guard<std::mutex> guard(li_hist_mutex);
std::memmove(&li_hist_mag[i][0], &li_hist_mag[i][1], 511*sizeof(float)); std::memmove(&li_hist_mag[i][0], &li_hist_mag[i][1], (HIST_DEPTH-1)*sizeof(float));
li_hist_mag[i][511] = std::abs(lockin_out); li_hist_mag[i][HIST_DEPTH-1] = std::abs(lockin_out);
std::memmove(&li_hist_phase[i][0], &li_hist_phase[i][1], 511*sizeof(float)); std::memmove(&li_hist_phase[i][0], &li_hist_phase[i][1], (HIST_DEPTH-1)*sizeof(float));
li_hist_phase[i][511] = std::arg(lockin_out); li_hist_phase[i][HIST_DEPTH-1] = std::arg(lockin_out);
} }
} }
} }
@ -257,9 +259,9 @@ int main(int argc, char* argv[])
{ {
std::lock_guard<std::mutex> guard(li_hist_mutex); std::lock_guard<std::mutex> guard(li_hist_mutex);
sprintf(str, "magnitude##%d", i); sprintf(str, "magnitude##%d", i);
ImGui::PlotLines(str, li_hist_mag[i], 512, 0, 0, -0.0f, 0.1f*plot_scale[i], ImVec2(0.0f, 200.0f)); ImGui::PlotLines(str, li_hist_mag[i], HIST_DEPTH, 0, 0, -0.0f, 0.1f*plot_scale[i], ImVec2(0.0f, 200.0f));
sprintf(str, "phase##%d", i); sprintf(str, "phase##%d", i);
ImGui::PlotLines(str, li_hist_phase[i], 512, 0, 0, -M_PI, M_PI, ImVec2(0.0f, 200.0f)); ImGui::PlotLines(str, li_hist_phase[i], HIST_DEPTH, 0, 0, -M_PI, M_PI, ImVec2(0.0f, 200.0f));
} }
bool pause_l = li_hist_pause[i]; bool pause_l = li_hist_pause[i];
sprintf(str, "pause##%d", i); sprintf(str, "pause##%d", i);