keep passing lockin outputs during hold
This commit is contained in:
parent
ad8ae87ac8
commit
d54e816ff4
24
sndlock.cpp
24
sndlock.cpp
@ -38,8 +38,10 @@ static float in_wave[HIST_DEPTH];
|
||||
|
||||
static std::atomic<int> multiplier[SND_PCHAN];
|
||||
static std::atomic<double> lpf_bandwidth[SND_PCHAN];
|
||||
static std::atomic<double> li_mag[SND_PCHAN];
|
||||
static std::atomic<double> li_phase[SND_PCHAN];
|
||||
static std::mutex li_hist_mutex;
|
||||
static std::atomic<bool> li_hist_pause[SND_PCHAN];
|
||||
static std::atomic<bool> li_hist_hold[SND_PCHAN];
|
||||
static float li_hist_mag[SND_PCHAN][HIST_DEPTH];
|
||||
static float li_hist_phase[SND_PCHAN][HIST_DEPTH];
|
||||
|
||||
@ -202,16 +204,20 @@ static void dsp_thread()
|
||||
|
||||
for(int j=0;j<SND_PCHAN;j++) {
|
||||
std::complex<double> lockin_out = lockin[j].update(sample);
|
||||
double mag = std::abs(lockin_out);
|
||||
double phase = std::arg(lockin_out);
|
||||
|
||||
if(!li_hist_pause[j]) {
|
||||
li_mag[j] = mag;
|
||||
li_phase[j] = phase;
|
||||
if(!li_hist_hold[j]) {
|
||||
li_count[j]++;
|
||||
if(li_count[j] == 200) {
|
||||
li_count[j] = 0;
|
||||
std::lock_guard<std::mutex> guard(li_hist_mutex);
|
||||
std::memmove(&li_hist_mag[j][0], &li_hist_mag[j][1], (HIST_DEPTH-1)*sizeof(float));
|
||||
li_hist_mag[j][HIST_DEPTH-1] = std::abs(lockin_out);
|
||||
li_hist_mag[j][HIST_DEPTH-1] = mag;
|
||||
std::memmove(&li_hist_phase[j][0], &li_hist_phase[j][1], (HIST_DEPTH-1)*sizeof(float));
|
||||
li_hist_phase[j][HIST_DEPTH-1] = std::arg(lockin_out);
|
||||
li_hist_phase[j][HIST_DEPTH-1] = phase;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -379,11 +385,11 @@ int main(int argc, char* argv[])
|
||||
multiplier[i] = multiplier_l;
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("/");
|
||||
bool pause_l = li_hist_pause[i];
|
||||
bool hold_l = li_hist_hold[i];
|
||||
ImGui::SameLine();
|
||||
sprintf(str, "pause##%d", i);
|
||||
ImGui::Checkbox(str, &pause_l);
|
||||
li_hist_pause[i] = pause_l;
|
||||
sprintf(str, "hold plot##%d", i);
|
||||
ImGui::Checkbox(str, &hold_l);
|
||||
li_hist_hold[i] = hold_l;
|
||||
sprintf(str, "LPF BW##%d", i);
|
||||
float lpf_bandwidth_l = lpf_bandwidth[i];
|
||||
ImGui::SliderFloat(str, &lpf_bandwidth_l, 0.5f, 200.0f);
|
||||
@ -397,8 +403,8 @@ int main(int argc, char* argv[])
|
||||
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);
|
||||
ImGui::PlotLines(str, li_hist_phase[i], HIST_DEPTH, 0, 0, -M_PI, M_PI, ImVec2(0.0f, 200.0f));
|
||||
ImGui::Text("values: %8.5f %8.5f rad", li_hist_mag[i][511], li_hist_phase[i][511]);
|
||||
}
|
||||
ImGui::Text("values: %8.5f %8.5f rad", (double)li_mag[i], (double)li_phase[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user