From d4cb319ddb178258bed1a32a9862fa463e09ccce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Bourdeauducq?= Date: Sun, 5 Jan 2025 15:32:26 +0800 Subject: [PATCH] add multiplier --- dsp_lib.h | 6 +++++- sndlock.cpp | 36 +++++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/dsp_lib.h b/dsp_lib.h index 8962636..73ae85b 100644 --- a/dsp_lib.h +++ b/dsp_lib.h @@ -47,6 +47,7 @@ template class Lockin { private: double scale = 1.0; + phase_t multiplier = 1; phase_t phase = 0; Lowpass, order> lpf; public: @@ -54,12 +55,15 @@ class Lockin { void set_scale(double s) { scale = s; } + void set_multiplier(phase_t m) { + multiplier = m; + } void set_bandwidth(double f) { lpf.set_bandwidth(f); } std::complex update(double x) { std::complex rotated; - rotated = x*std::polar(scale, phase*2.0*M_PI/(double)PHASE_MAX); + rotated = x*std::polar(scale, multiplier*phase*2.0*M_PI/(double)PHASE_MAX); phase -= ftw; // wraps on underflow return lpf.update(rotated); } diff --git a/sndlock.cpp b/sndlock.cpp index 518b140..05d17a8 100644 --- a/sndlock.cpp +++ b/sndlock.cpp @@ -35,6 +35,7 @@ static std::atomic in_wave_trigger; static std::mutex in_wave_mutex; static float in_wave[HIST_DEPTH]; +static std::atomic multiplier[SND_PCHAN]; static std::atomic lpf_bandwidth[SND_PCHAN]; static std::mutex li_hist_mutex; static std::atomic li_hist_pause[SND_PCHAN]; @@ -108,8 +109,10 @@ static void dsp_thread() poll(pfd, nfds, INFTIM); int revents = sio_revents(hdl, pfd); - for(int i=0;i guard(li_hist_mutex); ImGui::Text("values: %8.5f %8.5f rad", li_hist_mag[i][511], li_hist_phase[i][511]); } }