diff --git a/wdsp/RXA.cpp b/wdsp/RXA.cpp index a0db6e1ea..dbe97dc18 100644 --- a/wdsp/RXA.cpp +++ b/wdsp/RXA.cpp @@ -158,7 +158,6 @@ RXA* RXA::create_rxa ( 0.100, // averaging time constant 0.100, // peak decay time constant rxa->meter, // result vector - rxa->pmtupdate, // locks for meter access RXA_ADC_AV, // index for average value RXA_ADC_PK, // index for peak value -1, // index for gain value - disabled @@ -232,7 +231,6 @@ RXA* RXA::create_rxa ( 0.100, // averaging time constant 0.100, // peak decay time constant rxa->meter, // result vector - rxa->pmtupdate, // locks for meter access RXA_S_AV, // index for average value RXA_S_PK, // index for peak value -1, // index for gain value - disabled @@ -450,7 +448,6 @@ RXA* RXA::create_rxa ( 0.100, // averaging time constant 0.100, // peak decay time constant rxa->meter, // result vector - rxa->pmtupdate, // locks for meter access RXA_AGC_AV, // index for average value RXA_AGC_PK, // index for peak value RXA_AGC_GAIN, // index for gain value @@ -691,11 +688,11 @@ void RXA::xrxa (RXA *rxa) void RXA::setInputSamplerate (RXA *rxa, int in_rate) { - rxa->csDSP.lock(); if (in_rate >= rxa->dsp_rate) rxa->dsp_insize = rxa->dsp_size * (in_rate / rxa->dsp_rate); else rxa->dsp_insize = rxa->dsp_size / (rxa->dsp_rate / in_rate); + rxa->in_rate = in_rate; // buffers delete[] (rxa->inbuff); @@ -717,16 +714,15 @@ void RXA::setInputSamplerate (RXA *rxa, int in_rate) RESAMPLE::setSize_resample (rxa->rsmpin.p, rxa->dsp_insize); RESAMPLE::setInRate_resample (rxa->rsmpin.p, rxa->in_rate); ResCheck (*rxa); - rxa->csDSP.unlock(); } void RXA::setOutputSamplerate (RXA *rxa, int out_rate) { - rxa->csDSP.lock(); if (out_rate >= rxa->dsp_rate) rxa->dsp_outsize = rxa->dsp_size * (out_rate / rxa->dsp_rate); else rxa->dsp_outsize = rxa->dsp_size / (rxa->dsp_rate / out_rate); + rxa->out_rate = out_rate; // buffers delete[] (rxa->outbuff); @@ -735,20 +731,20 @@ void RXA::setOutputSamplerate (RXA *rxa, int out_rate) RESAMPLE::setBuffers_resample (rxa->rsmpout.p, rxa->midbuff, rxa->outbuff); RESAMPLE::setOutRate_resample (rxa->rsmpout.p, rxa->out_rate); ResCheck (*rxa); - rxa->csDSP.unlock(); } void RXA::setDSPSamplerate (RXA *rxa, int dsp_rate) { - rxa->csDSP.lock(); if (rxa->in_rate >= dsp_rate) rxa->dsp_insize = rxa->dsp_size * (rxa->in_rate / dsp_rate); else rxa->dsp_insize = rxa->dsp_size / (dsp_rate / rxa->in_rate); + if (rxa->out_rate >= dsp_rate) rxa->dsp_outsize = rxa->dsp_size * (rxa->out_rate / dsp_rate); else rxa->dsp_outsize = rxa->dsp_size / (dsp_rate / rxa->out_rate); + rxa->dsp_rate = dsp_rate; // buffers delete[] (rxa->inbuff); @@ -798,20 +794,20 @@ void RXA::setDSPSamplerate (RXA *rxa, int dsp_rate) RESAMPLE::setBuffers_resample (rxa->rsmpout.p, rxa->midbuff, rxa->outbuff); RESAMPLE::setInRate_resample (rxa->rsmpout.p, rxa->dsp_rate); ResCheck (*rxa); - rxa->csDSP.unlock(); } void RXA::setDSPBuffsize (RXA *rxa, int dsp_size) { - rxa->csDSP.lock(); if (rxa->in_rate >= rxa->dsp_rate) rxa->dsp_insize = dsp_size * (rxa->in_rate / rxa->dsp_rate); else rxa->dsp_insize = dsp_size / (rxa->dsp_rate / rxa->in_rate); + if (rxa->out_rate >= rxa->dsp_rate) rxa->dsp_outsize = dsp_size * (rxa->out_rate / rxa->dsp_rate); else rxa->dsp_outsize = dsp_size / (rxa->dsp_rate / rxa->out_rate); + rxa->dsp_size = dsp_size; // buffers delete[](rxa->inbuff); @@ -884,7 +880,6 @@ void RXA::setDSPBuffsize (RXA *rxa, int dsp_size) // output resampler RESAMPLE::setBuffers_resample (rxa->rsmpout.p, rxa->midbuff, rxa->outbuff); RESAMPLE::setSize_resample (rxa->rsmpout.p, rxa->dsp_size); - rxa->csDSP.unlock(); } void RXA::setSpectrumProbe(BufferProbe *spectrumProbe) @@ -913,7 +908,6 @@ void RXA::SetMode (RXA& rxa, int mode) rxa.anf.p->run, rxa.anr.p->run ); - rxa.csDSP.lock(); rxa.mode = mode; rxa.amd.p->run = 0; rxa.fmd.p->run = 0; @@ -940,7 +934,6 @@ void RXA::SetMode (RXA& rxa, int mode) bp1Set (rxa); bpsnbaSet (rxa); // update variables - rxa.csDSP.unlock(); } } diff --git a/wdsp/RXA.hpp b/wdsp/RXA.hpp index 90cb88193..7ccff2224 100644 --- a/wdsp/RXA.hpp +++ b/wdsp/RXA.hpp @@ -28,8 +28,6 @@ warren@wpratt.com #ifndef wdsp_rxa_h #define wdsp_rxa_h -#include - #include "comm.hpp" #include "unit.hpp" #include "export.h" @@ -99,7 +97,7 @@ public: int mode; double meter[RXA_METERTYPE_LAST]; - QRecursiveMutex *pmtupdate[RXA_METERTYPE_LAST]; + struct { METER *p; diff --git a/wdsp/TXA.cpp b/wdsp/TXA.cpp index 8cc38e5bc..e8aeca73b 100644 --- a/wdsp/TXA.cpp +++ b/wdsp/TXA.cpp @@ -130,7 +130,6 @@ TXA* TXA::create_txa ( 0.100, // averaging time constant 0.100, // peak decay time constant txa->meter, // result vector - txa->pmtupdate, // locks for meter access TXA_MIC_AV, // index for average value TXA_MIC_PK, // index for peak value -1, // index for gain value @@ -180,7 +179,6 @@ TXA* TXA::create_txa ( 0.100, // averaging time constant 0.100, // peak decay time constant txa->meter, // result vector - txa->pmtupdate, // locks for meter access TXA_EQ_AV, // index for average value TXA_EQ_PK, // index for peak value -1, // index for gain value @@ -233,7 +231,6 @@ TXA* TXA::create_txa ( 0.100, // averaging time constant 0.100, // peak decay time constant txa->meter, // result vector - txa->pmtupdate, // locks for meter access TXA_LVLR_AV, // index for average value TXA_LVLR_PK, // index for peak value TXA_LVLR_GAIN, // index for gain value @@ -274,7 +271,6 @@ TXA* TXA::create_txa ( 0.100, // averaging time constant 0.100, // peak decay time constant txa->meter, // result vector - txa->pmtupdate, // locks for meter access TXA_CFC_AV, // index for average value TXA_CFC_PK, // index for peak value TXA_CFC_GAIN, // index for gain value @@ -346,7 +342,6 @@ TXA* TXA::create_txa ( 0.100, // averaging time constant 0.100, // peak decay time constant txa->meter, // result vector - txa->pmtupdate, // locks for meter access TXA_COMP_AV, // index for average value TXA_COMP_PK, // index for peak value -1, // index for gain value @@ -429,7 +424,6 @@ TXA* TXA::create_txa ( 0.100, // averaging time constant 0.100, // peak decay time constant txa->meter, // result vector - txa->pmtupdate, // locks for meter access TXA_ALC_AV, // index for average value TXA_ALC_PK, // index for peak value TXA_ALC_GAIN, // index for gain value @@ -512,7 +506,6 @@ TXA* TXA::create_txa ( 0.100, // averaging time constant 0.100, // peak decay time constant txa->meter, // result vector - txa->pmtupdate, // locks for meter access TXA_OUT_AV, // index for average value TXA_OUT_PK, // index for peak value -1, // index for gain value @@ -639,8 +632,6 @@ void xtxa (TXA* txa) void TXA::setInputSamplerate (TXA *txa, int in_rate) { - txa->csDSP.lock(); - if (in_rate >= txa->dsp_rate) txa->dsp_insize = txa->dsp_size * (in_rate / txa->dsp_rate); else @@ -655,13 +646,10 @@ void TXA::setInputSamplerate (TXA *txa, int in_rate) RESAMPLE::setSize_resample (txa->rsmpin.p, txa->dsp_insize); RESAMPLE::setInRate_resample (txa->rsmpin.p, txa->in_rate); ResCheck (*txa); - txa->csDSP.unlock(); } void TXA::setOutputSamplerate (TXA* txa, int out_rate) { - txa->csDSP.lock(); - if (out_rate >= txa->dsp_rate) txa->dsp_outsize = txa->dsp_size * (out_rate / txa->dsp_rate); else @@ -681,13 +669,10 @@ void TXA::setOutputSamplerate (TXA* txa, int out_rate) METER::setBuffers_meter (txa->outmeter.p, txa->outbuff); METER::setSize_meter (txa->outmeter.p, txa->dsp_outsize); METER::setSamplerate_meter (txa->outmeter.p, txa->out_rate); - txa->csDSP.unlock(); } void TXA::setDSPSamplerate (TXA *txa, int dsp_rate) { - txa->csDSP.lock(); - if (txa->in_rate >= dsp_rate) txa->dsp_insize = txa->dsp_size * (txa->in_rate / dsp_rate); else @@ -743,13 +728,10 @@ void TXA::setDSPSamplerate (TXA *txa, int dsp_rate) // output meter METER::setBuffers_meter (txa->outmeter.p, txa->outbuff); METER::setSize_meter (txa->outmeter.p, txa->dsp_outsize); - txa->csDSP.unlock(); } void TXA::setDSPBuffsize (TXA *txa, int dsp_size) { - txa->csDSP.lock(); - if (txa->in_rate >= txa->dsp_rate) txa->dsp_insize = dsp_size * (txa->in_rate / txa->dsp_rate); else @@ -832,7 +814,6 @@ void TXA::setDSPBuffsize (TXA *txa, int dsp_size) // output meter METER::setBuffers_meter (txa->outmeter.p, txa->outbuff); METER::setSize_meter (txa->outmeter.p, txa->dsp_outsize); - txa->csDSP.unlock(); } /******************************************************************************************************** @@ -845,11 +826,11 @@ void TXA::SetMode (TXA& txa, int mode) { if (txa.mode != mode) { - txa.csDSP.lock(); txa.mode = mode; txa.ammod.p->run = 0; txa.fmmod.p->run = 0; txa.preemph.p->run = 0; + switch (mode) { case TXA_AM: @@ -874,8 +855,8 @@ void TXA::SetMode (TXA& txa, int mode) break; } + SetupBPFilters (txa); - txa.csDSP.unlock(); } } diff --git a/wdsp/TXA.hpp b/wdsp/TXA.hpp index cc8c08c7b..a48375d58 100644 --- a/wdsp/TXA.hpp +++ b/wdsp/TXA.hpp @@ -29,7 +29,6 @@ warren@wpratt.com #define wdsp_txa_h #include -#include #include "comm.hpp" #include "unit.hpp" @@ -128,8 +127,8 @@ public: float f_low; float f_high; double meter[TXA_METERTYPE_LAST]; - QRecursiveMutex *pmtupdate[TXA_METERTYPE_LAST]; std::atomic upslew; + struct { METER *p; diff --git a/wdsp/amd.cpp b/wdsp/amd.cpp index 717767e09..f38e221e0 100644 --- a/wdsp/amd.cpp +++ b/wdsp/amd.cpp @@ -287,25 +287,19 @@ void AMD::SetAMDRun(RXA& rxa, int run) rxa.anf.p->run, rxa.anr.p->run ); - rxa.csDSP.lock(); a->run = run; RXA::bp1Set (rxa); - rxa.csDSP.unlock(); } } void AMD::SetAMDSBMode(RXA& rxa, int sbmode) { - rxa.csDSP.lock(); rxa.amd.p->sbmode = sbmode; - rxa.csDSP.unlock(); } void AMD::SetAMDFadeLevel(RXA& rxa, int levelfade) { - rxa.csDSP.lock(); rxa.amd.p->levelfade = levelfade; - rxa.csDSP.unlock(); } } // namesoace WDSP diff --git a/wdsp/ammod.cpp b/wdsp/ammod.cpp index 938f43bc9..bc4c1d7fe 100644 --- a/wdsp/ammod.cpp +++ b/wdsp/ammod.cpp @@ -26,7 +26,6 @@ warren@wpratt.com */ #include -#include #include "ammod.hpp" #include "comm.hpp" @@ -110,10 +109,8 @@ void AMMOD::setSize_ammod(AMMOD *a, int size) void AMMOD::SetAMCarrierLevel (TXA& txa, float c_level) { - txa.csDSP.lock(); txa.ammod.p->c_level = c_level; txa.ammod.p->a_level = 1.0 - c_level; - txa.csDSP.unlock(); } } // namespace WDSP diff --git a/wdsp/amsq.cpp b/wdsp/amsq.cpp index ad6efe630..efd136ba0 100644 --- a/wdsp/amsq.cpp +++ b/wdsp/amsq.cpp @@ -25,8 +25,6 @@ warren@wpratt.com */ -#include - #include "comm.hpp" #include "amsq.hpp" #include "RXA.hpp" @@ -231,28 +229,22 @@ void AMSQ::setSize_amsq (AMSQ *a, int size) void AMSQ::SetAMSQRun (RXA& rxa, int run) { - rxa.csDSP.lock(); rxa.amsq.p->run = run; - rxa.csDSP.unlock(); } void AMSQ::SetAMSQThreshold (RXA& rxa, double threshold) { double thresh = pow (10.0, threshold / 20.0); - rxa.csDSP.lock(); rxa.amsq.p->tail_thresh = 0.9 * thresh; rxa.amsq.p->unmute_thresh = thresh; - rxa.csDSP.unlock(); } void AMSQ::SetAMSQMaxTail (RXA& rxa, double tail) { AMSQ *a; - rxa.csDSP.lock(); a = rxa.amsq.p; if (tail < a->min_tail) tail = a->min_tail; a->max_tail = tail; - rxa.csDSP.unlock(); } /******************************************************************************************************** @@ -263,28 +255,22 @@ void AMSQ::SetAMSQMaxTail (RXA& rxa, double tail) void AMSQ::SetAMSQRun (TXA& txa, int run) { - txa.csDSP.lock(); txa.amsq.p->run = run; - txa.csDSP.unlock(); } void AMSQ::SetAMSQMutedGain (TXA& txa, double dBlevel) { // dBlevel is negative AMSQ *a; - txa.csDSP.lock(); a = txa.amsq.p; a->muted_gain = pow (10.0, dBlevel / 20.0); compute_slews(a); - txa.csDSP.unlock(); } void AMSQ::SetAMSQThreshold (TXA& txa, double threshold) { double thresh = pow (10.0, threshold / 20.0); - txa.csDSP.lock(); txa.amsq.p->tail_thresh = 0.9 * thresh; txa.amsq.p->unmute_thresh = thresh; - txa.csDSP.unlock(); } } // namespace WDSP diff --git a/wdsp/anb.cpp b/wdsp/anb.cpp index cbba2d80e..5d70be11e 100644 --- a/wdsp/anb.cpp +++ b/wdsp/anb.cpp @@ -99,9 +99,7 @@ void ANB::destroy_anb (ANB *a) void ANB::flush_anb (ANB *a) { - a->cs_update.lock(); initBlanker (a); - a->cs_update.unlock(); } void ANB::xanb (ANB *a) @@ -111,7 +109,6 @@ void ANB::xanb (ANB *a) int i; if (a->run) { - a->cs_update.lock(); for (i = 0; i < a->buffsize; i++) { mag = sqrt(a->in[2 * i + 0] * a->in[2 * i + 0] + a->in[2 * i + 1] * a->in[2 * i + 1]); @@ -179,7 +176,6 @@ void ANB::xanb (ANB *a) if (++a->in_idx == a->dline_size) a->in_idx = 0; if (++a->out_idx == a->dline_size) a->out_idx = 0; } - a->cs_update.unlock(); } else if (a->in != a->out) memcpy (a->out, a->in, a->buffsize * sizeof (wcomplex)); @@ -212,70 +208,54 @@ void ANB::setSize_anb (ANB *a, int size) void ANB::SetANBRun (RXA& rxa, int run) { ANB *a = rxa.anb.p; - a->cs_update.lock(); a->run = run; - a->cs_update.unlock(); } void ANB::SetANBBuffsize (RXA& rxa, int size) { ANB *a = rxa.anb.p; - a->cs_update.lock(); a->buffsize = size; - a->cs_update.unlock(); } void ANB::SetANBSamplerate (RXA& rxa, int rate) { ANB *a = rxa.anb.p; - a->cs_update.lock(); a->samplerate = (double) rate; initBlanker (a); - a->cs_update.unlock(); } void ANB::SetANBTau (RXA& rxa, double tau) { ANB *a = rxa.anb.p; - a->cs_update.lock(); a->tau = tau; initBlanker (a); - a->cs_update.unlock(); } void ANB::SetANBHangtime (RXA& rxa, double time) { ANB *a = rxa.anb.p; - a->cs_update.lock(); a->hangtime = time; initBlanker (a); - a->cs_update.unlock(); } void ANB::SetANBAdvtime (RXA& rxa, double time) { ANB *a = rxa.anb.p; - a->cs_update.lock(); a->advtime = time; initBlanker (a); - a->cs_update.unlock(); } void ANB::SetANBBacktau (RXA& rxa, double tau) { ANB *a = rxa.anb.p; - a->cs_update.lock(); a->backtau = tau; initBlanker (a); - a->cs_update.unlock(); } void ANB::SetANBThreshold (RXA& rxa, double thresh) { ANB *a = rxa.anb.p; - a->cs_update.lock(); a->threshold = thresh; - a->cs_update.unlock(); } } diff --git a/wdsp/anb.hpp b/wdsp/anb.hpp index 5b493c884..7a38069fc 100644 --- a/wdsp/anb.hpp +++ b/wdsp/anb.hpp @@ -28,8 +28,6 @@ warren@wpratt.com #ifndef wdsp_anb_h #define wdsp_anb_h -#include - namespace WDSP { class RXA; @@ -66,7 +64,6 @@ public: int count; // set each time a noise sample is detected, counts down double backmult; // multiplier for waveform averaging double ombackmult; // multiplier for waveform averaging - QRecursiveMutex cs_update; float *legacy; static ANB* create_anb ( diff --git a/wdsp/anf.cpp b/wdsp/anf.cpp index 5b48c75c3..9a67a5b0f 100644 --- a/wdsp/anf.cpp +++ b/wdsp/anf.cpp @@ -175,69 +175,62 @@ void ANF::setSize_anf (ANF *a, int size) void ANF::SetANFRun (RXA& rxa, int run) { ANF *a = rxa.anf.p; + if (a->run != run) { - RXA::bp1Check (rxa, rxa.amd.p->run, rxa.snba.p->run, - rxa.emnr.p->run, run, rxa.anr.p->run); - rxa.csDSP.lock(); + RXA::bp1Check ( + rxa, + rxa.amd.p->run, + rxa.snba.p->run, + rxa.emnr.p->run, + run, + rxa.anr.p->run + ); a->run = run; RXA::bp1Set (rxa); flush_anf (a); - rxa.csDSP.unlock(); } } void ANF::SetANFVals (RXA& rxa, int taps, int delay, float gain, float leakage) { - rxa.csDSP.lock(); rxa.anf.p->n_taps = taps; rxa.anf.p->delay = delay; rxa.anf.p->two_mu = gain; //try two_mu = 1e-4 rxa.anf.p->gamma = leakage; //try gamma = 0.10 flush_anf (rxa.anf.p); - rxa.csDSP.unlock(); } void ANF::SetANFTaps (RXA& rxa, int taps) { - rxa.csDSP.lock(); rxa.anf.p->n_taps = taps; flush_anf (rxa.anf.p); - rxa.csDSP.unlock(); } void ANF::SetANFDelay (RXA& rxa, int delay) { - rxa.csDSP.lock(); rxa.anf.p->delay = delay; flush_anf (rxa.anf.p); - rxa.csDSP.unlock(); } void ANF::SetANFGain (RXA& rxa, float gain) { - rxa.csDSP.lock(); rxa.anf.p->two_mu = gain; flush_anf (rxa.anf.p); - rxa.csDSP.unlock(); } void ANF::SetANFLeakage (RXA& rxa, float leakage) { - rxa.csDSP.lock(); rxa.anf.p->gamma = leakage; flush_anf (rxa.anf.p); - rxa.csDSP.unlock(); } void ANF::SetANFPosition (RXA& rxa, int position) { - rxa.csDSP.lock(); rxa.anf.p->position = position; rxa.bp1.p->position = position; flush_anf (rxa.anf.p); - rxa.csDSP.unlock(); } } // namespace WDSP diff --git a/wdsp/anr.cpp b/wdsp/anr.cpp index 5c44da011..8673ccb2c 100644 --- a/wdsp/anr.cpp +++ b/wdsp/anr.cpp @@ -25,8 +25,6 @@ warren@wpratt.com */ -#include - #include "comm.hpp" #include "anr.hpp" #include "amd.hpp" @@ -178,68 +176,55 @@ void ANR::setSize_anr (ANR *a, int size) void ANR::SetANRRun (RXA& rxa, int run) { ANR *a = rxa.anr.p; + if (a->run != run) { RXA::bp1Check (rxa, rxa.amd.p->run, rxa.snba.p->run, rxa.emnr.p->run, rxa.anf.p->run, run); - rxa.csDSP.lock(); a->run = run; RXA::bp1Set (rxa); flush_anr (a); - rxa.csDSP.unlock(); } } void ANR::SetANRVals (RXA& rxa, int taps, int delay, float gain, float leakage) { - rxa.csDSP.lock(); rxa.anr.p->n_taps = taps; rxa.anr.p->delay = delay; rxa.anr.p->two_mu = gain; rxa.anr.p->gamma = leakage; flush_anr (rxa.anr.p); - rxa.csDSP.unlock(); } void ANR::SetANRTaps (RXA& rxa, int taps) { - rxa.csDSP.lock(); rxa.anr.p->n_taps = taps; flush_anr (rxa.anr.p); - rxa.csDSP.unlock(); } void ANR::SetANRDelay (RXA& rxa, int delay) { - rxa.csDSP.lock(); rxa.anr.p->delay = delay; flush_anr (rxa.anr.p); - rxa.csDSP.unlock(); } void ANR::SetANRGain (RXA& rxa, float gain) { - rxa.csDSP.lock(); rxa.anr.p->two_mu = gain; flush_anr (rxa.anr.p); - rxa.csDSP.unlock(); } void ANR::SetANRLeakage (RXA& rxa, float leakage) { - rxa.csDSP.lock(); rxa.anr.p->gamma = leakage; flush_anr (rxa.anr.p); - rxa.csDSP.unlock(); } void ANR::SetANRPosition (RXA& rxa, int position) { - rxa.csDSP.lock(); rxa.anr.p->position = position; rxa.bp1.p->position = position; flush_anr (rxa.anr.p); - rxa.csDSP.unlock(); } } // namespace WDSP diff --git a/wdsp/bandpass.cpp b/wdsp/bandpass.cpp index d8ac236c2..57ad3a07e 100644 --- a/wdsp/bandpass.cpp +++ b/wdsp/bandpass.cpp @@ -202,13 +202,12 @@ void BANDPASS::SetBandpassFreqs (RXA& rxa, float f_low, float f_high) 1, a->gain / (float)(2 * a->size) ); + FIRCORE::setImpulse_fircore (a->p, impulse, 0); delete[] (impulse); - rxa.csDSP.lock(); a->f_low = f_low; a->f_high = f_high; FIRCORE::setUpdate_fircore (a->p); - rxa.csDSP.unlock(); } } @@ -216,7 +215,6 @@ void BANDPASS::SetBandpassNC (RXA& rxa, int nc) { // NOTE: 'nc' must be >= 'size' BANDPASS *a; - rxa.csDSP.lock(); a = rxa.bp1.p; if (nc != a->nc) @@ -234,8 +232,6 @@ void BANDPASS::SetBandpassNC (RXA& rxa, int nc) FIRCORE::setNc_fircore (a->p, a->nc, impulse); delete[] (impulse); } - - rxa.csDSP.unlock(); } void BANDPASS::SetBandpassMP (RXA& rxa, int mp) @@ -294,7 +290,6 @@ void BANDPASS::SetBandpassNC (TXA& txa, int nc) { // NOTE: 'nc' must be >= 'size' BANDPASS *a; - txa.csDSP.lock(); a = txa.bp0.p; if (a->nc != nc) @@ -348,8 +343,6 @@ void BANDPASS::SetBandpassNC (TXA& txa, int nc) FIRCORE::setNc_fircore (a->p, a->nc, impulse); delete[] (impulse); } - - txa.csDSP.unlock(); } void BANDPASS::SetBandpassMP (TXA& txa, int mp) diff --git a/wdsp/bps.cpp b/wdsp/bps.cpp index 20945ead1..be4a5f6af 100644 --- a/wdsp/bps.cpp +++ b/wdsp/bps.cpp @@ -25,8 +25,6 @@ warren@wpratt.com */ -#include - #include "comm.hpp" #include "bps.hpp" #include "fir.hpp" @@ -152,17 +150,15 @@ void BPS::setFreqs_bps (BPS *a, float f_low, float f_high) void BPS::SetBPSRun (RXA& rxa, int run) { - rxa.csDSP.lock(); rxa.bp1.p->run = run; - rxa.csDSP.unlock(); } void BPS::SetBPSFreqs (RXA& rxa, float f_low, float f_high) { float* impulse; BPS *a1; - rxa.csDSP.lock(); a1 = rxa.bps1.p; + if ((f_low != a1->f_low) || (f_high != a1->f_high)) { a1->f_low = f_low; @@ -172,15 +168,14 @@ void BPS::SetBPSFreqs (RXA& rxa, float f_low, float f_high) a1->mults = FIR::fftcv_mults (2 * a1->size, impulse); delete[] (impulse); } - rxa.csDSP.unlock(); } void BPS::SetBPSWindow (RXA& rxa, int wintype) { float* impulse; BPS *a1; - rxa.csDSP.lock(); a1 = rxa.bps1.p; + if ((a1->wintype != wintype)) { a1->wintype = wintype; @@ -189,7 +184,6 @@ void BPS::SetBPSWindow (RXA& rxa, int wintype) a1->mults = FIR::fftcv_mults (2 * a1->size, impulse); delete[] (impulse); } - rxa.csDSP.unlock(); } /******************************************************************************************************** @@ -200,17 +194,15 @@ void BPS::SetBPSWindow (RXA& rxa, int wintype) // UNCOMMENT properties when pointers in place in txa void BPS::SetBPSRun (TXA& txa, int run) { - txa.csDSP.lock(); txa.bp1.p->run = run; - txa.csDSP.unlock(); } void BPS::SetBPSFreqs (TXA& txa, float f_low, float f_high) { float* impulse; BPS *a; - txa.csDSP.lock(); a = txa.bps0.p; + if ((f_low != a->f_low) || (f_high != a->f_high)) { a->f_low = f_low; @@ -220,7 +212,9 @@ void BPS::SetBPSFreqs (TXA& txa, float f_low, float f_high) a->mults = FIR::fftcv_mults (2 * a->size, impulse); delete[] (impulse); } + a = txa.bps1.p; + if ((f_low != a->f_low) || (f_high != a->f_high)) { a->f_low = f_low; @@ -230,7 +224,9 @@ void BPS::SetBPSFreqs (TXA& txa, float f_low, float f_high) a->mults = FIR::fftcv_mults (2 * a->size, impulse); delete[] (impulse); } + a = txa.bps2.p; + if ((f_low != a->f_low) || (f_high != a->f_high)) { a->f_low = f_low; @@ -240,15 +236,14 @@ void BPS::SetBPSFreqs (TXA& txa, float f_low, float f_high) a->mults = FIR::fftcv_mults (2 * a->size, impulse); delete[] (impulse); } - txa.csDSP.unlock(); } void BPS::SetBPSWindow (TXA& txa, int wintype) { float* impulse; BPS *a; - txa.csDSP.lock(); a = txa.bps0.p; + if (a->wintype != wintype) { a->wintype = wintype; @@ -257,7 +252,9 @@ void BPS::SetBPSWindow (TXA& txa, int wintype) a->mults = FIR::fftcv_mults (2 * a->size, impulse); delete[] (impulse); } + a = txa.bps1.p; + if (a->wintype != wintype) { a->wintype = wintype; @@ -266,7 +263,9 @@ void BPS::SetBPSWindow (TXA& txa, int wintype) a->mults = FIR::fftcv_mults (2 * a->size, impulse); delete[] (impulse); } + a = txa.bps2.p; + if (a->wintype != wintype) { a->wintype = wintype; @@ -275,7 +274,6 @@ void BPS::SetBPSWindow (TXA& txa, int wintype) a->mults = FIR::fftcv_mults (2 * a->size, impulse); delete[] (impulse); } - txa.csDSP.unlock(); } } // namespace WDSP diff --git a/wdsp/bpsnba.cpp b/wdsp/bpsnba.cpp index 87ab4dc82..ff1cada46 100644 --- a/wdsp/bpsnba.cpp +++ b/wdsp/bpsnba.cpp @@ -194,7 +194,6 @@ void BPSNBA::recalc_bpsnba_filter (BPSNBA *a, int update) void BPSNBA::BPSNBASetNC (RXA& rxa, int nc) { BPSNBA *a = rxa.bpsnba.p; - rxa.csDSP.lock(); if (a->nc != nc) { @@ -202,8 +201,6 @@ void BPSNBA::BPSNBASetNC (RXA& rxa, int nc) a->bpsnba->nc = a->nc; NBP::setNc_nbp (a->bpsnba); } - - rxa.csDSP.unlock(); } void BPSNBA::BPSNBASetMP (RXA& rxa, int mp) diff --git a/wdsp/cblock.cpp b/wdsp/cblock.cpp index a2bbd1f52..3dd6ed6c1 100644 --- a/wdsp/cblock.cpp +++ b/wdsp/cblock.cpp @@ -124,9 +124,7 @@ void CBL::setSize_cbl (CBL *a, int size) void CBL::SetCBLRun(RXA& rxa, int setit) { - rxa.csDSP.lock(); rxa.cbl.p->run = setit; - rxa.csDSP.unlock(); } } // namespace WDSP diff --git a/wdsp/cfcomp.cpp b/wdsp/cfcomp.cpp index 746b58039..dd0b269ba 100644 --- a/wdsp/cfcomp.cpp +++ b/wdsp/cfcomp.cpp @@ -419,29 +419,24 @@ void CFCOMP::setSize_cfcomp (CFCOMP *a, int size) void CFCOMP::SetCFCOMPRun (TXA& txa, int run) { CFCOMP *a = txa.cfcomp.p; - if (a->run != run) - { - txa.csDSP.lock(); + + if (a->run != run) { a->run = run; - txa.csDSP.unlock(); } } void CFCOMP::SetCFCOMPPosition (TXA& txa, int pos) { CFCOMP *a = txa.cfcomp.p; - if (a->position != pos) - { - txa.csDSP.lock(); + + if (a->position != pos) { a->position = pos; - txa.csDSP.unlock(); } } void CFCOMP::SetCFCOMPprofile (TXA& txa, int nfreqs, float* F, float* G, float *E) { CFCOMP *a = txa.cfcomp.p; - txa.csDSP.lock(); a->nfreqs = nfreqs; delete[] (a->E); delete[] (a->F); @@ -459,57 +454,52 @@ void CFCOMP::SetCFCOMPprofile (TXA& txa, int nfreqs, float* F, float* G, float * a->gp = new float[a->nfreqs]; // (float *) malloc0 ((a->nfreqs + 2) * sizeof (float)); a->ep = new float[a->nfreqs]; // (float *) malloc0 ((a->nfreqs + 2) * sizeof (float)); calc_comp(a); - txa.csDSP.unlock(); } void CFCOMP::SetCFCOMPPrecomp (TXA& txa, float precomp) { CFCOMP *a = txa.cfcomp.p; + if (a->precomp != precomp) { - txa.csDSP.lock(); a->precomp = precomp; a->precomplin = pow (10.0, 0.05 * a->precomp); + for (int i = 0; i < a->msize; i++) { a->cfc_gain[i] = a->precomplin * a->comp[i]; } - txa.csDSP.unlock(); } } void CFCOMP::SetCFCOMPPeqRun (TXA& txa, int run) { CFCOMP *a = txa.cfcomp.p; - if (a->peq_run != run) - { - txa.csDSP.lock(); + + if (a->peq_run != run) { a->peq_run = run; - txa.csDSP.unlock(); } } void CFCOMP::SetCFCOMPPrePeq (TXA& txa, float prepeq) { CFCOMP *a = txa.cfcomp.p; - txa.csDSP.lock(); a->prepeq = prepeq; a->prepeqlin = pow (10.0, 0.05 * a->prepeq); - txa.csDSP.unlock(); } void CFCOMP::GetCFCOMPDisplayCompression (TXA& txa, float* comp_values, int* ready) { int i; CFCOMP *a = txa.cfcomp.p; - txa.csDSP.lock(); + if ((*ready = a->mask_ready)) { memcpy(a->delta_copy, a->delta, a->msize * sizeof(float)); memcpy(a->cfc_gain_copy, a->cfc_gain, a->msize * sizeof(float)); a->mask_ready = 0; } - txa.csDSP.unlock(); + if (*ready) { for (i = 0; i < a->msize; i++) diff --git a/wdsp/cfir.cpp b/wdsp/cfir.cpp index 554d055fb..540909ac1 100644 --- a/wdsp/cfir.cpp +++ b/wdsp/cfir.cpp @@ -237,24 +237,21 @@ float* CFIR::cfir_impulse (int N, int DD, int R, int Pairs, float runrate, float void CFIR::SetCFIRRun (TXA& txa, int run) { - txa.csDSP.lock(); txa.cfir.p->run = run; - txa.csDSP.unlock(); } void CFIR::SetCFIRNC(TXA& txa, int nc) { // NOTE: 'nc' must be >= 'size' CFIR *a; - txa.csDSP.lock(); a = txa.cfir.p; + if (a->nc != nc) { a->nc = nc; decalc_cfir(a); calc_cfir(a); } - txa.csDSP.unlock(); } } // namespace WDSP diff --git a/wdsp/channel.hpp b/wdsp/channel.hpp index cb61e386a..d46e21e36 100644 --- a/wdsp/channel.hpp +++ b/wdsp/channel.hpp @@ -30,7 +30,6 @@ warren@wpratt.com #include -#include #include #include "export.h" @@ -48,8 +47,6 @@ public: int dsp_insize; // size (complex samples) of the output of the r1 (input) buffer int dsp_outsize; // size (complex samples) of the input of the r2 (output) buffer int out_size; // output buffsize (complex samples) in a fexchange() operation - QRecursiveMutex csDSP; // used to block dsp while parameters are updated or buffers flushed - QRecursiveMutex csEXCH; // used to block fexchange() while parameters are updated or buffers flushed int state; // 0 for channel OFF; 1 for channel ON float tdelayup; float tslewup; diff --git a/wdsp/compress.cpp b/wdsp/compress.cpp index 7d4d508c9..6a4dff366 100644 --- a/wdsp/compress.cpp +++ b/wdsp/compress.cpp @@ -102,18 +102,14 @@ void COMPRESSOR::SetCompressorRun (TXA& txa, int run) { if (txa.compressor.p->run != run) { - txa.csDSP.lock(); txa.compressor.p->run = run; TXA::SetupBPFilters (txa); - txa.csDSP.unlock(); } } void COMPRESSOR::SetCompressorGain (TXA& txa, float gain) { - txa.csDSP.lock(); txa.compressor.p->gain = pow (10.0, gain / 20.0); - txa.csDSP.unlock(); } } // namespace WDSP diff --git a/wdsp/delay.cpp b/wdsp/delay.cpp index 80f499e7e..d4a2400fc 100644 --- a/wdsp/delay.cpp +++ b/wdsp/delay.cpp @@ -73,32 +73,39 @@ void DELAY::flush_delay (DELAY *a) void DELAY::xdelay (DELAY *a) { - a->cs_update.lock(); if (a->run) { int i, j, k, idx, n; float Itmp, Qtmp; + for (i = 0; i < a->size; i++) { a->ring[2 * a->idx_in + 0] = a->in[2 * i + 0]; a->ring[2 * a->idx_in + 1] = a->in[2 * i + 1]; Itmp = 0.0; Qtmp = 0.0; - if ((n = a->idx_in + a->snum) >= a->rsize) n -= a->rsize; + + if ((n = a->idx_in + a->snum) >= a->rsize) + n -= a->rsize; + for (j = 0, k = a->L - 1 - a->phnum; j < a->cpp; j++, k+= a->L) { - if ((idx = n + j) >= a->rsize) idx -= a->rsize; + if ((idx = n + j) >= a->rsize) + idx -= a->rsize; + Itmp += a->ring[2 * idx + 0] * a->h[k]; Qtmp += a->ring[2 * idx + 1] * a->h[k]; } + a->out[2 * i + 0] = Itmp; a->out[2 * i + 1] = Qtmp; - if (--a->idx_in < 0) a->idx_in = a->rsize - 1; + + if (--a->idx_in < 0) + a->idx_in = a->rsize - 1; } } else if (a->out != a->in) memcpy (a->out, a->in, a->size * sizeof (wcomplex)); - a->cs_update.unlock(); } /******************************************************************************************************** @@ -109,32 +116,26 @@ void DELAY::xdelay (DELAY *a) void DELAY::SetDelayRun (DELAY *a, int run) { - a->cs_update.lock(); a->run = run; - a->cs_update.unlock(); } float DELAY::SetDelayValue (DELAY *a, float tdelay) { float adelay; - a->cs_update.lock(); a->tdelay = tdelay; a->phnum = (int)(0.5 + a->tdelay / a->adelta); a->snum = a->phnum / a->L; a->phnum %= a->L; a->adelay = a->adelta * (a->snum * a->L + a->phnum); adelay = a->adelay; - a->cs_update.unlock(); return adelay; } void DELAY::SetDelayBuffs (DELAY *a, int size, float* in, float* out) { - a->cs_update.lock(); a->size = size; a->in = in; a->out = out; - a->cs_update.unlock(); } } // namespace WDSP diff --git a/wdsp/delay.hpp b/wdsp/delay.hpp index 708df18d7..01706c541 100644 --- a/wdsp/delay.hpp +++ b/wdsp/delay.hpp @@ -28,8 +28,6 @@ warren@wpratt.com #ifndef wdsp_delay_h #define wdsp_delay_h -#include - #include "export.h" #define WSDEL 1025 // number of supported whole sample delays @@ -62,8 +60,6 @@ public: float adelta; // actual delay increment float adelay; // actual delay - QRecursiveMutex cs_update; - static DELAY* create_delay (int run, int size, float* in, float* out, int rate, float tdelta, float tdelay); static void destroy_delay (DELAY *a); static void flush_delay (DELAY *a); diff --git a/wdsp/emnr.cpp b/wdsp/emnr.cpp index 85efef99f..abf27fe28 100644 --- a/wdsp/emnr.cpp +++ b/wdsp/emnr.cpp @@ -922,6 +922,7 @@ void EMNR::setSize_emnr (EMNR *a, int size) void EMNR::SetEMNRRun (RXA& rxa, int run) { EMNR *a = rxa.emnr.p; + if (a->run != run) { RXA::bp1Check ( @@ -932,54 +933,40 @@ void EMNR::SetEMNRRun (RXA& rxa, int run) rxa.anf.p->run, rxa.anr.p->run ); - rxa.csDSP.lock(); a->run = run; RXA::bp1Set (rxa); - rxa.csDSP.unlock(); } } void EMNR::SetEMNRgainMethod (RXA& rxa, int method) { - rxa.csDSP.lock(); rxa.emnr.p->g.gain_method = method; - rxa.csDSP.unlock(); } void EMNR::SetEMNRnpeMethod (RXA& rxa, int method) { - rxa.csDSP.lock(); rxa.emnr.p->g.npe_method = method; - rxa.csDSP.unlock(); } void EMNR::SetEMNRaeRun (RXA& rxa, int run) { - rxa.csDSP.lock(); rxa.emnr.p->g.ae_run = run; - rxa.csDSP.unlock(); } void EMNR::SetEMNRPosition (RXA& rxa, int position) { - rxa.csDSP.lock(); rxa.emnr.p->position = position; rxa.bp1.p->position = position; - rxa.csDSP.unlock(); } void EMNR::SetEMNRaeZetaThresh (RXA& rxa, double zetathresh) { - rxa.csDSP.lock(); rxa.emnr.p->ae.zetaThresh = zetathresh; - rxa.csDSP.unlock(); } void EMNR::SetEMNRaePsi (RXA& rxa, double psi) { - rxa.csDSP.lock(); rxa.emnr.p->ae.psi = psi; - rxa.csDSP.unlock(); } } // namespace WDSP diff --git a/wdsp/emph.cpp b/wdsp/emph.cpp index 9a8a9026d..d6b2e2073 100644 --- a/wdsp/emph.cpp +++ b/wdsp/emph.cpp @@ -113,9 +113,7 @@ void EMPHP::setSize_emphp (EMPHP *a, int size) void EMPHP::SetFMEmphPosition (TXA& txa, int position) { - txa.csDSP.lock(); txa.preemph.p->position = position; - txa.csDSP.unlock(); } void EMPHP::SetFMEmphMP (TXA& txa, int mp) @@ -133,8 +131,8 @@ void EMPHP::SetFMEmphNC (TXA& txa, int nc) { EMPHP *a; float* impulse; - txa.csDSP.lock(); a = txa.preemph.p; + if (a->nc != nc) { a->nc = nc; @@ -142,15 +140,14 @@ void EMPHP::SetFMEmphNC (TXA& txa, int nc) FIRCORE::setNc_fircore (a->p, a->nc, impulse); delete[] (impulse); } - txa.csDSP.unlock(); } void EMPHP::SetFMPreEmphFreqs (TXA& txa, float low, float high) { EMPHP *a; float* impulse; - txa.csDSP.lock(); a = txa.preemph.p; + if (a->f_low != low || a->f_high != high) { a->f_low = low; @@ -159,7 +156,6 @@ void EMPHP::SetFMPreEmphFreqs (TXA& txa, float low, float high) FIRCORE::setImpulse_fircore (a->p, impulse, 1); delete[] (impulse); } - txa.csDSP.unlock(); } /******************************************************************************************************** diff --git a/wdsp/eq.cpp b/wdsp/eq.cpp index 4cb591b84..5f19c32f1 100644 --- a/wdsp/eq.cpp +++ b/wdsp/eq.cpp @@ -262,17 +262,15 @@ void EQP::setSize_eqp (EQP *a, int size) void EQP::SetEQRun (RXA& rxa, int run) { - rxa.csDSP.lock(); rxa.eqp.p->run = run; - rxa.csDSP.unlock(); } void EQP::SetEQNC (RXA& rxa, int nc) { EQP *a; float* impulse; - rxa.csDSP.lock(); a = rxa.eqp.p; + if (a->nc != nc) { a->nc = nc; @@ -280,7 +278,6 @@ void EQP::SetEQNC (RXA& rxa, int nc) FIRCORE::setNc_fircore (a->p, a->nc, impulse); delete[] (impulse); } - rxa.csDSP.unlock(); } void EQP::SetEQMP (RXA& rxa, int mp) @@ -397,17 +394,15 @@ void EQP::SetGrphEQ10 (RXA& rxa, int *rxeq) void EQP::SetEQRun (TXA& txa, int run) { - txa.csDSP.lock(); txa.eqp.p->run = run; - txa.csDSP.unlock(); } void EQP::SetEQNC (TXA& txa, int nc) { EQP *a; float* impulse; - txa.csDSP.lock(); a = txa.eqp.p; + if (a->nc != nc) { a->nc = nc; @@ -415,7 +410,6 @@ void EQP::SetEQNC (TXA& txa, int nc) FIRCORE::setNc_fircore (a->p, a->nc, impulse); delete[] (impulse); } - txa.csDSP.unlock(); } void EQP::SetEQMP (TXA& txa, int mp) diff --git a/wdsp/fircore.cpp b/wdsp/fircore.cpp index 65bbe1361..a1a71299b 100644 --- a/wdsp/fircore.cpp +++ b/wdsp/fircore.cpp @@ -75,10 +75,12 @@ void FIRCORE::calc_fircore (FIRCORE *a, int flip) // call for change in frequency, rate, wintype, gain // must also call after a call to plan_firopt() int i; + if (a->mp) FIR::mp_imp (a->nc, a->impulse, a->imp, 16, 0); else memcpy (a->imp, a->impulse, a->nc * sizeof (wcomplex)); + for (i = 0; i < a->nfor; i++) { // I right-justified the impulse response => take output from left side of output buff, discard right side @@ -86,12 +88,12 @@ void FIRCORE::calc_fircore (FIRCORE *a, int flip) memcpy (&(a->maskgen[2 * a->size]), &(a->imp[2 * a->size * i]), a->size * sizeof(wcomplex)); fftwf_execute (a->maskplan[1 - a->cset][i]); } + a->masks_ready = 1; + if (flip) { - a->update.lock(); a->cset = 1 - a->cset; - a->update.unlock(); a->masks_ready = 0; } } @@ -163,7 +165,7 @@ void FIRCORE::xfircore (FIRCORE *a) fftwf_execute (a->pcfor[a->buffidx]); k = a->buffidx; memset (a->accum, 0, 2 * a->size * sizeof (wcomplex)); - a->update.lock(); + for (j = 0; j < a->nfor; j++) { for (i = 0; i < 2 * a->size; i++) @@ -171,9 +173,10 @@ void FIRCORE::xfircore (FIRCORE *a) a->accum[2 * i + 0] += a->fftout[k][2 * i + 0] * a->fmask[a->cset][j][2 * i + 0] - a->fftout[k][2 * i + 1] * a->fmask[a->cset][j][2 * i + 1]; a->accum[2 * i + 1] += a->fftout[k][2 * i + 0] * a->fmask[a->cset][j][2 * i + 1] + a->fftout[k][2 * i + 1] * a->fmask[a->cset][j][2 * i + 0]; } + k = (k + a->idxmask) & a->idxmask; } - a->update.unlock(); + a->buffidx = (a->buffidx + 1) & a->idxmask; fftwf_execute (a->crev); memcpy (a->fftin, &(a->fftin[2 * a->size]), a->size * sizeof(wcomplex)); @@ -226,9 +229,7 @@ void FIRCORE::setUpdate_fircore (FIRCORE *a) { if (a->masks_ready) { - a->update.lock(); a->cset = 1 - a->cset; - a->update.unlock(); a->masks_ready = 0; } } diff --git a/wdsp/fircore.hpp b/wdsp/fircore.hpp index b57aa2c06..3dbb82334 100644 --- a/wdsp/fircore.hpp +++ b/wdsp/fircore.hpp @@ -34,7 +34,6 @@ warren@wpratt.com #ifndef wdsp_fircore_h #define wdsp_fircore_h -#include #include "fftw3.h" #include "export.h" @@ -60,7 +59,6 @@ public: fftwf_plan* pcfor; // array of forward FFT plans fftwf_plan crev; // reverse fft plan fftwf_plan** maskplan; // plans for frequency domain masks - QRecursiveMutex update; int cset; int mp; int masks_ready; diff --git a/wdsp/fmd.cpp b/wdsp/fmd.cpp index aa2d8435c..61c2c50b8 100644 --- a/wdsp/fmd.cpp +++ b/wdsp/fmd.cpp @@ -275,39 +275,33 @@ void FMD::setSize_fmd (FMD *a, int size) void FMD::SetFMDeviation (RXA& rxa, double deviation) { FMD *a; - rxa.csDSP.lock(); a = rxa.fmd.p; a->deviation = deviation; a->again = a->rate / (a->deviation * TWOPI); - rxa.csDSP.unlock(); } void FMD::SetCTCSSFreq (RXA& rxa, double freq) { FMD *a; - rxa.csDSP.lock(); a = rxa.fmd.p; a->ctcss_freq = freq; SNOTCH::SetSNCTCSSFreq (a->sntch, a->ctcss_freq); - rxa.csDSP.unlock(); } void FMD::SetCTCSSRun (RXA& rxa, int run) { FMD *a; - rxa.csDSP.lock(); a = rxa.fmd.p; a->sntch_run = run; SNOTCH::SetSNCTCSSRun (a->sntch, a->sntch_run); - rxa.csDSP.unlock(); } void FMD::SetFMNCde (RXA& rxa, int nc) { FMD *a; float* impulse; - rxa.csDSP.lock(); a = rxa.fmd.p; + if (a->nc_de != nc) { a->nc_de = nc; @@ -315,7 +309,6 @@ void FMD::SetFMNCde (RXA& rxa, int nc) FIRCORE::setNc_fircore (a->pde, a->nc_de, impulse); delete[] (impulse); } - rxa.csDSP.unlock(); } void FMD::SetFMMPde (RXA& rxa, int mp) @@ -333,8 +326,8 @@ void FMD::SetFMNCaud (RXA& rxa, int nc) { FMD *a; float* impulse; - rxa.csDSP.lock(); a = rxa.fmd.p; + if (a->nc_aud != nc) { a->nc_aud = nc; @@ -342,7 +335,6 @@ void FMD::SetFMNCaud (RXA& rxa, int nc) FIRCORE::setNc_fircore (a->paud, a->nc_aud, impulse); delete[] (impulse); } - rxa.csDSP.unlock(); } void FMD::SetFMMPaud (RXA& rxa, int mp) @@ -360,33 +352,30 @@ void FMD::SetFMLimRun (RXA& rxa, int run) { FMD *a; a = rxa.fmd.p; - rxa.csDSP.lock(); - if (a->lim_run != run) - { + + if (a->lim_run != run) { a->lim_run = run; } - rxa.csDSP.unlock(); } void FMD::SetFMLimGain (RXA& rxa, double gaindB) { double gain = pow(10.0, gaindB / 20.0); FMD *a = rxa.fmd.p; - rxa.csDSP.lock(); + if (a->lim_gain != gain) { decalc_fmd(a); a->lim_gain = gain; calc_fmd(a); } - rxa.csDSP.unlock(); } void FMD::SetFMAFFilter(RXA& rxa, double low, double high) { FMD *a = rxa.fmd.p; float* impulse; - rxa.csDSP.lock(); + if (a->f_low != low || a->f_high != high) { a->f_low = low; @@ -400,7 +389,6 @@ void FMD::SetFMAFFilter(RXA& rxa, double low, double high) FIRCORE::setImpulse_fircore (a->paud, impulse, 1); delete[] (impulse); } - rxa.csDSP.unlock(); } } // namespace WDSP diff --git a/wdsp/fmmod.cpp b/wdsp/fmmod.cpp index d8e023ba4..533527baf 100644 --- a/wdsp/fmmod.cpp +++ b/wdsp/fmmod.cpp @@ -172,7 +172,6 @@ void FMMOD::SetFMDeviation (TXA& txa, float deviation) float* impulse = FIR::fir_bandpass (a->nc, -bp_fc, +bp_fc, a->samplerate, 0, 1, 1.0 / (2 * a->size)); FIRCORE::setImpulse_fircore (a->p, impulse, 0); delete[] (impulse); - txa.csDSP.lock(); a->deviation = deviation; // mod a->sphase = 0.0; @@ -180,33 +179,28 @@ void FMMOD::SetFMDeviation (TXA& txa, float deviation) // bandpass a->bp_fc = bp_fc; FIRCORE::setUpdate_fircore (a->p); - txa.csDSP.unlock(); } void FMMOD::SetCTCSSFreq (TXA& txa, float freq) { FMMOD *a; - txa.csDSP.lock(); a = txa.fmmod.p; a->ctcss_freq = freq; a->tphase = 0.0; a->tdelta = TWOPI * a->ctcss_freq / a->samplerate; - txa.csDSP.unlock(); } void FMMOD::SetCTCSSRun (TXA& txa, int run) { - txa.csDSP.lock(); txa.fmmod.p->ctcss_run = run; - txa.csDSP.unlock(); } void FMMOD::SetFMNC (TXA& txa, int nc) { FMMOD *a; float* impulse; - txa.csDSP.lock(); a = txa.fmmod.p; + if (a->nc != nc) { a->nc = nc; @@ -214,7 +208,6 @@ void FMMOD::SetFMNC (TXA& txa, int nc) FIRCORE::setNc_fircore (a->p, a->nc, impulse); delete[] (impulse); } - txa.csDSP.unlock(); } void FMMOD::SetFMMP (TXA& txa, int mp) @@ -232,8 +225,8 @@ void FMMOD::SetFMAFFreqs (TXA& txa, float low, float high) { FMMOD *a; float* impulse; - txa.csDSP.lock(); a = txa.fmmod.p; + if (a->f_low != low || a->f_high != high) { a->f_low = low; @@ -243,7 +236,6 @@ void FMMOD::SetFMAFFreqs (TXA& txa, float low, float high) FIRCORE::setImpulse_fircore (a->p, impulse, 1); delete[] (impulse); } - txa.csDSP.unlock(); } } // namespace WDSP diff --git a/wdsp/fmsq.cpp b/wdsp/fmsq.cpp index 2cd146b27..f357d1402 100644 --- a/wdsp/fmsq.cpp +++ b/wdsp/fmsq.cpp @@ -261,25 +261,21 @@ void FMSQ::setSize_fmsq (FMSQ *a, int size) void FMSQ::SetFMSQRun (RXA& rxa, int run) { - rxa.csDSP.lock(); rxa.fmsq.p->run = run; - rxa.csDSP.unlock(); } void FMSQ::SetFMSQThreshold (RXA& rxa, double threshold) { - rxa.csDSP.lock(); rxa.fmsq.p->tail_thresh = threshold; rxa.fmsq.p->unmute_thresh = 0.9 * threshold; - rxa.csDSP.unlock(); } void FMSQ::SetFMSQNC (RXA& rxa, int nc) { FMSQ *a; float* impulse; - rxa.csDSP.lock(); a = rxa.fmsq.p; + if (a->nc != nc) { a->nc = nc; @@ -287,7 +283,6 @@ void FMSQ::SetFMSQNC (RXA& rxa, int nc) FIRCORE::setNc_fircore (a->p, a->nc, impulse); delete[] (impulse); } - rxa.csDSP.unlock(); } void FMSQ::SetFMSQMP (RXA& rxa, int mp) diff --git a/wdsp/gain.cpp b/wdsp/gain.cpp index 805db98a8..d48b64ed8 100644 --- a/wdsp/gain.cpp +++ b/wdsp/gain.cpp @@ -56,14 +56,16 @@ void GAIN::flush_gain (GAIN *) void GAIN::xgain (GAIN *a) { int srun; - a->cs_update.lock(); + if (a->prun != 0) srun = *(a->prun); else srun = 1; + if (a->run && srun) { int i; + for (i = 0; i < a->size; i++) { a->out[2 * i + 0] = a->Igain * a->in[2 * i + 0]; @@ -72,7 +74,6 @@ void GAIN::xgain (GAIN *a) } else if (a->in != a->out) memcpy (a->out, a->in, a->size * sizeof (wcomplex)); - a->cs_update.unlock(); } void GAIN::setBuffers_gain (GAIN *a, float* in, float* out) @@ -99,24 +100,18 @@ void GAIN::setSize_gain (GAIN *a, int size) void GAIN::pSetTXOutputLevel (GAIN *a, float level) { - a->cs_update.lock(); a->Igain = level; a->Qgain = level; - a->cs_update.unlock(); } void GAIN::pSetTXOutputLevelRun (GAIN *a, int run) { - a->cs_update.lock(); a->run = run; - a->cs_update.unlock(); } void GAIN::pSetTXOutputLevelSize (GAIN *a, int size) { - a->cs_update.lock(); a->size = size; - a->cs_update.unlock(); } } // namespace WDSP diff --git a/wdsp/gain.hpp b/wdsp/gain.hpp index 7548be593..5e6e2e3d0 100644 --- a/wdsp/gain.hpp +++ b/wdsp/gain.hpp @@ -28,8 +28,6 @@ warren@wpratt.com #ifndef wdso_gain_h #define wdsp_gain_h -#include - #include "export.h" namespace WDSP { @@ -44,7 +42,6 @@ public: float* out; float Igain; float Qgain; - QRecursiveMutex cs_update; static GAIN* create_gain (int run, int* prun, int size, float* in, float* out, float Igain, float Qgain); static void destroy_gain (GAIN *a); diff --git a/wdsp/gen.cpp b/wdsp/gen.cpp index 19a7819b2..131b475b2 100644 --- a/wdsp/gen.cpp +++ b/wdsp/gen.cpp @@ -24,6 +24,7 @@ The author can be reached by email at warren@wpratt.com */ +#include #include "comm.hpp" #include "gen.hpp" @@ -134,7 +135,7 @@ GEN* GEN::create_gen (int run, int size, float* in, float* out, int rate, int mo a->tt.f1 = + 900.0; a->tt.f2 = + 1700.0; // noise - srand ((unsigned int)time (0)); + srand ((unsigned int) time (0)); a->noise.mag = 1.0; // sweep a->sweep.mag = 1.0; @@ -389,62 +390,46 @@ void GEN::setSize_gen (GEN *a, int size) void GEN::SetPreGenRun (RXA& rxa, int run) { - rxa.csDSP.lock(); rxa.gen0.p->run = run; - rxa.csDSP.unlock(); } void GEN::SetPreGenMode (RXA& rxa, int mode) { - rxa.csDSP.lock(); rxa.gen0.p->mode = mode; - rxa.csDSP.unlock(); } void GEN::SetPreGenToneMag (RXA& rxa, float mag) { - rxa.csDSP.lock(); rxa.gen0.p->tone.mag = mag; - rxa.csDSP.unlock(); } void GEN::SetPreGenToneFreq (RXA& rxa, float freq) { - rxa.csDSP.lock(); rxa.gen0.p->tone.freq = freq; calc_tone (rxa.gen0.p); - rxa.csDSP.unlock(); } void GEN::SetPreGenNoiseMag (RXA& rxa, float mag) { - rxa.csDSP.lock(); rxa.gen0.p->noise.mag = mag; - rxa.csDSP.unlock(); } void GEN::SetPreGenSweepMag (RXA& rxa, float mag) { - rxa.csDSP.lock(); rxa.gen0.p->sweep.mag = mag; - rxa.csDSP.unlock(); } void GEN::SetPreGenSweepFreq (RXA& rxa, float freq1, float freq2) { - rxa.csDSP.lock(); rxa.gen0.p->sweep.f1 = freq1; rxa.gen0.p->sweep.f2 = freq2; calc_sweep (rxa.gen0.p); - rxa.csDSP.unlock(); } void GEN::SetPreGenSweepRate (RXA& rxa, float rate) { - rxa.csDSP.lock(); rxa.gen0.p->sweep.sweeprate = rate; calc_sweep (rxa.gen0.p); - rxa.csDSP.unlock(); } @@ -458,203 +443,151 @@ void GEN::SetPreGenSweepRate (RXA& rxa, float rate) void GEN::SetPreGenRun (TXA& txa, int run) { - txa.csDSP.lock(); txa.gen0.p->run = run; - txa.csDSP.unlock(); } void GEN::SetPreGenMode (TXA& txa, int mode) { - txa.csDSP.lock(); txa.gen0.p->mode = mode; - txa.csDSP.unlock(); } void GEN::SetPreGenToneMag (TXA& txa, float mag) { - txa.csDSP.lock(); txa.gen0.p->tone.mag = mag; - txa.csDSP.unlock(); } void GEN::SetPreGenToneFreq (TXA& txa, float freq) { - txa.csDSP.lock(); txa.gen0.p->tone.freq = freq; calc_tone (txa.gen0.p); - txa.csDSP.unlock(); } void GEN::SetPreGenNoiseMag (TXA& txa, float mag) { - txa.csDSP.lock(); txa.gen0.p->noise.mag = mag; - txa.csDSP.unlock(); } void GEN::SetPreGenSweepMag (TXA& txa, float mag) { - txa.csDSP.lock(); txa.gen0.p->sweep.mag = mag; - txa.csDSP.unlock(); } void GEN::SetPreGenSweepFreq (TXA& txa, float freq1, float freq2) { - txa.csDSP.lock(); txa.gen0.p->sweep.f1 = freq1; txa.gen0.p->sweep.f2 = freq2; calc_sweep (txa.gen0.p); - txa.csDSP.unlock(); } void GEN::SetPreGenSweepRate (TXA& txa, float rate) { - txa.csDSP.lock(); txa.gen0.p->sweep.sweeprate = rate; calc_sweep (txa.gen0.p); - txa.csDSP.unlock(); } void GEN::SetPreGenSawtoothMag (TXA& txa, float mag) { - txa.csDSP.lock(); txa.gen0.p->saw.mag = mag; - txa.csDSP.unlock(); } void GEN::SetPreGenSawtoothFreq (TXA& txa, float freq) { - txa.csDSP.lock(); txa.gen0.p->saw.f = freq; calc_sawtooth (txa.gen0.p); - txa.csDSP.unlock(); } void GEN::SetPreGenTriangleMag (TXA& txa, float mag) { - txa.csDSP.lock(); txa.gen0.p->tri.mag = mag; - txa.csDSP.unlock(); } void GEN::SetPreGenTriangleFreq (TXA& txa, float freq) { - txa.csDSP.lock(); txa.gen0.p->tri.f = freq; calc_triangle (txa.gen0.p); - txa.csDSP.unlock(); } void GEN::SetPreGenPulseMag (TXA& txa, float mag) { - txa.csDSP.lock(); txa.gen0.p->pulse.mag = mag; - txa.csDSP.unlock(); } void GEN::SetPreGenPulseFreq (TXA& txa, float freq) { - txa.csDSP.lock(); txa.gen0.p->pulse.pf = freq; calc_pulse (txa.gen0.p); - txa.csDSP.unlock(); } void GEN::SetPreGenPulseDutyCycle (TXA& txa, float dc) { - txa.csDSP.lock(); txa.gen0.p->pulse.pdutycycle = dc; calc_pulse (txa.gen0.p); - txa.csDSP.unlock(); } void GEN::SetPreGenPulseToneFreq (TXA& txa, float freq) { - txa.csDSP.lock(); txa.gen0.p->pulse.tf = freq; calc_pulse (txa.gen0.p); - txa.csDSP.unlock(); } void GEN::SetPreGenPulseTransition (TXA& txa, float transtime) { - txa.csDSP.lock(); txa.gen0.p->pulse.ptranstime = transtime; calc_pulse (txa.gen0.p); - txa.csDSP.unlock(); } // 'PostGen', gen1 void GEN::SetPostGenRun (TXA& txa, int run) { - txa.csDSP.lock(); txa.gen1.p->run = run; - txa.csDSP.unlock(); } void GEN::SetPostGenMode (TXA& txa, int mode) { - txa.csDSP.lock(); txa.gen1.p->mode = mode; - txa.csDSP.unlock(); } void GEN::SetPostGenToneMag (TXA& txa, float mag) { - txa.csDSP.lock(); txa.gen1.p->tone.mag = mag; - txa.csDSP.unlock(); } void GEN::SetPostGenToneFreq (TXA& txa, float freq) { - txa.csDSP.lock(); txa.gen1.p->tone.freq = freq; calc_tone (txa.gen1.p); - txa.csDSP.unlock(); } void GEN::SetPostGenTTMag (TXA& txa, float mag1, float mag2) { - txa.csDSP.lock(); txa.gen1.p->tt.mag1 = mag1; txa.gen1.p->tt.mag2 = mag2; - txa.csDSP.unlock(); } void GEN::SetPostGenTTFreq (TXA& txa, float freq1, float freq2) { - txa.csDSP.lock(); txa.gen1.p->tt.f1 = freq1; txa.gen1.p->tt.f2 = freq2; calc_tt (txa.gen1.p); - txa.csDSP.unlock(); } void GEN::SetPostGenSweepMag (TXA& txa, float mag) { - txa.csDSP.lock(); txa.gen1.p->sweep.mag = mag; - txa.csDSP.unlock(); } void GEN::SetPostGenSweepFreq (TXA& txa, float freq1, float freq2) { - txa.csDSP.lock(); txa.gen1.p->sweep.f1 = freq1; txa.gen1.p->sweep.f2 = freq2; calc_sweep (txa.gen1.p); - txa.csDSP.unlock(); } void GEN::SetPostGenSweepRate (TXA& txa, float rate) { - txa.csDSP.lock(); txa.gen1.p->sweep.sweeprate = rate; calc_sweep (txa.gen1.p); - txa.csDSP.unlock(); } } // namespace WDSP diff --git a/wdsp/iir.cpp b/wdsp/iir.cpp index f8f1583e7..ee307ee86 100644 --- a/wdsp/iir.cpp +++ b/wdsp/iir.cpp @@ -79,7 +79,6 @@ void SNOTCH::flush_snotch (SNOTCH *a) void SNOTCH::xsnotch (SNOTCH *a) { - a->cs_update.lock(); if (a->run) { int i; @@ -95,7 +94,6 @@ void SNOTCH::xsnotch (SNOTCH *a) } else if (a->out != a->in) memcpy (a->out, a->in, a->size * sizeof (wcomplex)); - a->cs_update.unlock(); } void SNOTCH::setBuffers_snotch (SNOTCH *a, float* in, float* out) @@ -124,17 +122,13 @@ void SNOTCH::setSize_snotch (SNOTCH *a, int size) void SNOTCH::SetSNCTCSSFreq (SNOTCH *a, float freq) { - a->cs_update.lock(); a->f = freq; calc_snotch (a); - a->cs_update.unlock(); } void SNOTCH::SetSNCTCSSRun (SNOTCH *a, int run) { - a->cs_update.lock(); a->run = run; - a->cs_update.unlock(); } @@ -266,15 +260,16 @@ void SPEAK::flush_speak (SPEAK *a) void SPEAK::xspeak (SPEAK *a) { - a->cs_update.lock(); if (a->run) { int i, j, n; + for (i = 0; i < a->size; i++) { for (j = 0; j < 2; j++) { a->x0[j] = a->fgain * a->in[2 * i + j]; + for (n = 0; n < a->nstages; n++) { if (n > 0) a->x0[2 * n + j] = a->y0[2 * (n - 1) + j]; @@ -288,13 +283,13 @@ void SPEAK::xspeak (SPEAK *a) a->x2[2 * n + j] = a->x1[2 * n + j]; a->x1[2 * n + j] = a->x0[2 * n + j]; } + a->out[2 * i + j] = a->y0[2 * (a->nstages - 1) + j]; } } } else if (a->out != a->in) memcpy (a->out, a->in, a->size * sizeof (wcomplex)); - a->cs_update.unlock(); } void SPEAK::setBuffers_speak (SPEAK *a, float* in, float* out) @@ -324,36 +319,28 @@ void SPEAK::setSize_speak (SPEAK *a, int size) void SPEAK::SetSPCWRun (RXA& rxa, int run) { SPEAK *a = rxa.speak.p; - a->cs_update.lock(); a->run = run; - a->cs_update.unlock(); } void SPEAK::SetSPCWFreq (RXA& rxa, float freq) { SPEAK *a = rxa.speak.p; - a->cs_update.lock(); a->f = freq; calc_speak (a); - a->cs_update.unlock(); } void SPEAK::SetSPCWBandwidth (RXA& rxa, float bw) { SPEAK *a = rxa.speak.p; - a->cs_update.lock(); a->bw = bw; calc_speak (a); - a->cs_update.unlock(); } void SPEAK::SetSPCWGain (RXA& rxa, float gain) { SPEAK *a = rxa.speak.p; - a->cs_update.lock(); a->gain = gain; calc_speak (a); - a->cs_update.unlock(); } /******************************************************************************************************** @@ -436,11 +423,11 @@ void MPEAK::flush_mpeak (MPEAK *a) void MPEAK::xmpeak (MPEAK *a) { - a->cs_update.lock(); if (a->run) { int i, j; memset (a->mix, 0, a->size * sizeof (wcomplex)); + for (i = 0; i < a->npeaks; i++) { if (a->enable[i]) @@ -450,11 +437,12 @@ void MPEAK::xmpeak (MPEAK *a) a->mix[j] += a->tmp[j]; } } + memcpy (a->out, a->mix, a->size * sizeof (wcomplex)); } + else if (a->in != a->out) memcpy (a->out, a->in, a->size * sizeof (wcomplex)); - a->cs_update.unlock(); } void MPEAK::setBuffers_mpeak (MPEAK *a, float* in, float* out) @@ -488,55 +476,43 @@ void MPEAK::setSize_mpeak (MPEAK *a, int size) void MPEAK::SetmpeakRun (RXA& rxa, int run) { MPEAK *a = rxa.mpeak.p; - a->cs_update.lock(); a->run = run; - a->cs_update.unlock(); } void MPEAK::SetmpeakNpeaks (RXA& rxa, int npeaks) { MPEAK *a = rxa.mpeak.p; - a->cs_update.lock(); a->npeaks = npeaks; - a->cs_update.unlock(); } void MPEAK::SetmpeakFilEnable (RXA& rxa, int fil, int enable) { MPEAK *a = rxa.mpeak.p; - a->cs_update.lock(); a->enable[fil] = enable; - a->cs_update.unlock(); } void MPEAK::SetmpeakFilFreq (RXA& rxa, int fil, float freq) { MPEAK *a = rxa.mpeak.p; - a->cs_update.lock(); a->f[fil] = freq; a->pfil[fil]->f = freq; SPEAK::calc_speak(a->pfil[fil]); - a->cs_update.unlock(); } void MPEAK::SetmpeakFilBw (RXA& rxa, int fil, float bw) { MPEAK *a = rxa.mpeak.p; - a->cs_update.lock(); a->bw[fil] = bw; a->pfil[fil]->bw = bw; SPEAK::calc_speak(a->pfil[fil]); - a->cs_update.unlock(); } void MPEAK::SetmpeakFilGain (RXA& rxa, int fil, float gain) { MPEAK *a = rxa.mpeak.p; - a->cs_update.lock(); a->gain[fil] = gain; a->pfil[fil]->gain = gain; SPEAK::calc_speak(a->pfil[fil]); - a->cs_update.unlock(); } @@ -598,7 +574,6 @@ void PHROT::flush_phrot (PHROT *a) void PHROT::xphrot (PHROT *a) { - a->cs_update.lock(); if (a->reverse) { for (int i = 0; i < a->size; i++) @@ -607,9 +582,11 @@ void PHROT::xphrot (PHROT *a) if (a->run) { int i, n; + for (i = 0; i < a->size; i++) { a->x0[0] = a->in[2 * i + 0]; + for (n = 0; n < a->nstages; n++) { if (n > 0) a->x0[n] = a->y0[n - 1]; @@ -619,12 +596,12 @@ void PHROT::xphrot (PHROT *a) a->y1[n] = a->y0[n]; a->x1[n] = a->x0[n]; } + a->out[2 * i + 0] = a->y0[a->nstages - 1]; } } else if (a->out != a->in) memcpy (a->out, a->in, a->size * sizeof (wcomplex)); - a->cs_update.unlock(); } void PHROT::setBuffers_phrot (PHROT *a, float* in, float* out) @@ -655,38 +632,32 @@ void PHROT::setSize_phrot (PHROT *a, int size) void PHROT::SetPHROTRun (TXA& txa, int run) { PHROT *a = txa.phrot.p; - a->cs_update.lock(); a->run = run; - if (a->run) flush_phrot (a); - a->cs_update.unlock(); + + if (a->run) + flush_phrot (a); } void PHROT::SetPHROTCorner (TXA& txa, float corner) { PHROT *a = txa.phrot.p; - a->cs_update.lock(); decalc_phrot (a); a->fc = corner; calc_phrot (a); - a->cs_update.unlock(); } void PHROT::SetPHROTNstages (TXA& txa, int nstages) { PHROT *a = txa.phrot.p; - a->cs_update.lock(); decalc_phrot (a); a->nstages = nstages; calc_phrot (a); - a->cs_update.unlock(); } void PHROT::SetPHROTReverse (TXA& txa, int reverse) { PHROT *a = txa.phrot.p; - a->cs_update.lock(); a->reverse = reverse; - a->cs_update.unlock(); } /******************************************************************************************************** @@ -755,15 +726,16 @@ void BQLP::flush_bqlp(BQLP *a) void BQLP::xbqlp(BQLP *a) { - a->cs_update.lock(); if (a->run) { int i, j, n; + for (i = 0; i < a->size; i++) { for (j = 0; j < 2; j++) { a->x0[j] = a->gain * a->in[2 * i + j]; + for (n = 0; n < a->nstages; n++) { if (n > 0) a->x0[2 * n + j] = a->y0[2 * (n - 1) + j]; @@ -777,13 +749,13 @@ void BQLP::xbqlp(BQLP *a) a->x2[2 * n + j] = a->x1[2 * n + j]; a->x1[2 * n + j] = a->x0[2 * n + j]; } + a->out[2 * i + j] = a->y0[2 * (a->nstages - 1) + j]; } } } else if (a->out != a->in) memcpy(a->out, a->in, a->size * sizeof(wcomplex)); - a->cs_update.unlock(); } void BQLP::setBuffers_bqlp(BQLP *a, float* in, float* out) @@ -869,16 +841,19 @@ void DBQLP::flush_dbqlp(BQLP *a) void DBQLP::xdbqlp(BQLP *a) { - a->cs_update.lock(); if (a->run) { int i, n; + for (i = 0; i < a->size; i++) { a->x0[0] = a->gain * a->in[i]; + for (n = 0; n < a->nstages; n++) { - if (n > 0) a->x0[n] = a->y0[n - 1]; + if (n > 0) + a->x0[n] = a->y0[n - 1]; + a->y0[n] = a->a0 * a->x0[n] + a->a1 * a->x1[n] + a->a2 * a->x2[n] @@ -889,12 +864,12 @@ void DBQLP::xdbqlp(BQLP *a) a->x2[n] = a->x1[n]; a->x1[n] = a->x0[n]; } + a->out[i] = a->y0[a->nstages - 1]; } } else if (a->out != a->in) memcpy(a->out, a->in, a->size * sizeof(float)); - a->cs_update.unlock(); } void DBQLP::setBuffers_dbqlp(BQLP *a, float* in, float* out) @@ -986,18 +961,21 @@ void BQBP::flush_bqbp(BQBP *a) void BQBP::xbqbp(BQBP *a) { - a->cs_update.lock(); if (a->run) { int i, j, n; + for (i = 0; i < a->size; i++) { for (j = 0; j < 2; j++) { a->x0[j] = a->gain * a->in[2 * i + j]; + for (n = 0; n < a->nstages; n++) { - if (n > 0) a->x0[2 * n + j] = a->y0[2 * (n - 1) + j]; + if (n > 0) + a->x0[2 * n + j] = a->y0[2 * (n - 1) + j]; + a->y0[2 * n + j] = a->a0 * a->x0[2 * n + j] + a->a1 * a->x1[2 * n + j] + a->a2 * a->x2[2 * n + j] @@ -1008,13 +986,13 @@ void BQBP::xbqbp(BQBP *a) a->x2[2 * n + j] = a->x1[2 * n + j]; a->x1[2 * n + j] = a->x0[2 * n + j]; } + a->out[2 * i + j] = a->y0[2 * (a->nstages - 1) + j]; } } } else if (a->out != a->in) memcpy(a->out, a->in, a->size * sizeof(wcomplex)); - a->cs_update.unlock(); } void BQBP::setBuffers_bqbp(BQBP *a, float* in, float* out) @@ -1104,16 +1082,19 @@ void BQBP::flush_dbqbp(BQBP *a) void BQBP::xdbqbp(BQBP *a) { - a->cs_update.lock(); if (a->run) { int i, n; + for (i = 0; i < a->size; i++) { a->x0[0] = a->gain * a->in[i]; + for (n = 0; n < a->nstages; n++) { - if (n > 0) a->x0[n] = a->y0[n - 1]; + if (n > 0) + a->x0[n] = a->y0[n - 1]; + a->y0[n] = a->a0 * a->x0[n] + a->a1 * a->x1[n] + a->a2 * a->x2[n] @@ -1124,12 +1105,12 @@ void BQBP::xdbqbp(BQBP *a) a->x2[n] = a->x1[n]; a->x1[n] = a->x0[n]; } + a->out[i] = a->y0[a->nstages - 1]; } } else if (a->out != a->in) memcpy(a->out, a->in, a->size * sizeof(float)); - a->cs_update.unlock(); } void BQBP::setBuffers_dbqbp(BQBP *a, float* in, float* out) @@ -1207,7 +1188,6 @@ void SPHP::flush_sphp(SPHP *a) void SPHP::xsphp(SPHP *a) { - a->cs_update.lock(); if (a->run) { int i, j, n; @@ -1216,22 +1196,25 @@ void SPHP::xsphp(SPHP *a) for (j = 0; j < 2; j++) { a->x0[j] = a->in[2 * i + j]; + for (n = 0; n < a->nstages; n++) { - if (n > 0) a->x0[2 * n + j] = a->y0[2 * (n - 1) + j]; + if (n > 0) + a->x0[2 * n + j] = a->y0[2 * (n - 1) + j]; + a->y0[2 * n + j] = a->b0 * a->x0[2 * n + j] + a->b1 * a->x1[2 * n + j] - a->a1 * a->y1[2 * n + j]; a->y1[2 * n + j] = a->y0[2 * n + j]; a->x1[2 * n + j] = a->x0[2 * n + j]; } + a->out[2 * i + j] = a->y0[2 * (a->nstages - 1) + j]; } } } else if (a->out != a->in) memcpy(a->out, a->in, a->size * sizeof(wcomplex)); - a->cs_update.unlock(); } void SPHP::setBuffers_sphp(SPHP *a, float* in, float* out) @@ -1310,28 +1293,31 @@ void SPHP::flush_dsphp(SPHP *a) void SPHP::xdsphp(SPHP *a) { - a->cs_update.lock(); if (a->run) { int i, n; + for (i = 0; i < a->size; i++) { a->x0[0] = a->in[i]; + for (n = 0; n < a->nstages; n++) { - if (n > 0) a->x0[n] = a->y0[n - 1]; + if (n > 0) + a->x0[n] = a->y0[n - 1]; + a->y0[n] = a->b0 * a->x0[n] + a->b1 * a->x1[n] - a->a1 * a->y1[n]; a->y1[n] = a->y0[n]; a->x1[n] = a->x0[n]; } + a->out[i] = a->y0[a->nstages - 1]; } } else if (a->out != a->in) memcpy(a->out, a->in, a->size * sizeof(float)); - a->cs_update.unlock(); } void SPHP::setBuffers_dsphp(SPHP *a, float* in, float* out) diff --git a/wdsp/iir.hpp b/wdsp/iir.hpp index 6d0b9ae2d..be23fbc4b 100644 --- a/wdsp/iir.hpp +++ b/wdsp/iir.hpp @@ -34,8 +34,6 @@ warren@wpratt.com #ifndef wdsp_snotch_h #define wdsp_snotch_h -#include - #include "export.h" namespace WDSP { @@ -52,7 +50,6 @@ public: float bw; float a0, a1, a2, b1, b2; float x0, x1, x2, y1, y2; - QRecursiveMutex cs_update; static SNOTCH* create_snotch (int run, int size, float* in, float* out, int rate, float f, float bw); static void destroy_snotch (SNOTCH *a); @@ -104,7 +101,6 @@ public: int design; float a0, a1, a2, b1, b2; float *x0, *x1, *x2, *y0, *y1, *y2; - QRecursiveMutex cs_update; static SPEAK* create_speak (int run, int size, float* in, float* out, int rate, float f, float bw, float gain, int nstages, int design); static void destroy_speak (SPEAK *a); @@ -157,7 +153,6 @@ public: SPEAK** pfil; float* tmp; float* mix; - QRecursiveMutex cs_update; static MPEAK* create_mpeak (int run, int size, float* in, float* out, int rate, int npeaks, int* enable, float* f, float* bw, float* gain, int nstages); static void destroy_mpeak (MPEAK *a); @@ -212,7 +207,6 @@ public: // normalized such that a0 = 1 float a1, b0, b1; float *x0, *x1, *y0, *y1; - QRecursiveMutex cs_update; static PHROT* create_phrot (int run, int size, float* in, float* out, int rate, float fc, int nstages); static void destroy_phrot (PHROT *a); @@ -263,7 +257,6 @@ public: int nstages; float a0, a1, a2, b1, b2; float* x0, * x1, * x2, * y0, * y1, * y2; - QRecursiveMutex cs_update; static BQLP* create_bqlp(int run, int size, float* in, float* out, float rate, float fc, float Q, float gain, int nstages); static void destroy_bqlp(BQLP *a); @@ -340,7 +333,6 @@ public: int nstages; float a0, a1, a2, b1, b2; float* x0, * x1, * x2, * y0, * y1, * y2; - QRecursiveMutex cs_update; static BQBP* create_bqbp(int run, int size, float* in, float* out, float rate, float f_low, float f_high, float gain, int nstages); static void destroy_bqbp(BQBP *a); @@ -393,7 +385,6 @@ public: int nstages; float a1, b0, b1; float* x0, * x1, * y0, * y1; - QRecursiveMutex cs_update; static SPHP* create_dsphp(int run, int size, float* in, float* out, float rate, float fc, int nstages); static void destroy_dsphp(SPHP *a); diff --git a/wdsp/iqc.cpp b/wdsp/iqc.cpp index 90a9ae0f0..96e07e67d 100644 --- a/wdsp/iqc.cpp +++ b/wdsp/iqc.cpp @@ -153,9 +153,7 @@ void IQC::xiqc (IQC *a) a->dog.full_ints++; if (a->dog.full_ints == a->ints) { - a->dog.cs.lock(); ++a->dog.count; - a->dog.cs.unlock(); a->dog.full_ints = 0; memset (a->dog.cpi, 0, a->ints * sizeof (int)); } @@ -235,31 +233,26 @@ void IQC::setSize_iqc (IQC *a, int size) void IQC::GetiqcValues (TXA& txa, float* cm, float* cc, float* cs) { IQC *a; - txa.csDSP.lock(); a = txa.iqc.p0; memcpy (cm, a->cm[a->cset], a->ints * 4 * sizeof (float)); memcpy (cc, a->cc[a->cset], a->ints * 4 * sizeof (float)); memcpy (cs, a->cs[a->cset], a->ints * 4 * sizeof (float)); - txa.csDSP.unlock(); } void IQC::SetiqcValues (TXA& txa, float* cm, float* cc, float* cs) { IQC *a; - txa.csDSP.lock(); a = txa.iqc.p0; a->cset = 1 - a->cset; memcpy (a->cm[a->cset], cm, a->ints * 4 * sizeof (float)); memcpy (a->cc[a->cset], cc, a->ints * 4 * sizeof (float)); memcpy (a->cs[a->cset], cs, a->ints * 4 * sizeof (float)); a->state = RUN; - txa.csDSP.unlock(); } void IQC::SetiqcSwap (TXA& txa, float* cm, float* cc, float* cs) { IQC *a = txa.iqc.p1; - txa.csDSP.lock(); a->cset = 1 - a->cset; memcpy (a->cm[a->cset], cm, a->ints * 4 * sizeof (float)); memcpy (a->cc[a->cset], cc, a->ints * 4 * sizeof (float)); @@ -267,7 +260,6 @@ void IQC::SetiqcSwap (TXA& txa, float* cm, float* cc, float* cs) a->busy = 1; // InterlockedBitTestAndSet (&a->busy, 0); a->state = SWAP; a->count = 0; - txa.csDSP.unlock(); // while (_InterlockedAnd (&a->busy, 1)) Sleep(1); while (a->busy == 1) { std::this_thread::sleep_for(std::chrono::seconds(1)); @@ -277,7 +269,6 @@ void IQC::SetiqcSwap (TXA& txa, float* cm, float* cc, float* cs) void IQC::SetiqcStart (TXA& txa, float* cm, float* cc, float* cs) { IQC *a = txa.iqc.p1; - txa.csDSP.lock(); a->cset = 0; memcpy (a->cm[a->cset], cm, a->ints * 4 * sizeof (float)); memcpy (a->cc[a->cset], cc, a->ints * 4 * sizeof (float)); @@ -285,7 +276,6 @@ void IQC::SetiqcStart (TXA& txa, float* cm, float* cc, float* cs) a->busy = 1; // InterlockedBitTestAndSet (&a->busy, 0); a->state = BEGIN; a->count = 0; - txa.csDSP.unlock(); txa.iqc.p1->run = 1; //InterlockedBitTestAndSet (&txa.iqc.p1->run, 0); // while (_InterlockedAnd (&a->busy, 1)) Sleep(1); while (a->busy == 1) { @@ -296,11 +286,9 @@ void IQC::SetiqcStart (TXA& txa, float* cm, float* cc, float* cs) void IQC::SetiqcEnd (TXA& txa) { IQC *a = txa.iqc.p1; - txa.csDSP.lock(); a->busy = 1; // InterlockedBitTestAndSet (&a->busy, 0); a->state = END; a->count = 0; - txa.csDSP.unlock(); // while (_InterlockedAnd (&a->busy, 1)) Sleep(1); while (a->busy == 1) { std::this_thread::sleep_for(std::chrono::seconds(1)); @@ -311,17 +299,13 @@ void IQC::SetiqcEnd (TXA& txa) void IQC::GetiqcDogCount (TXA& txa, int* count) { IQC *a = txa.iqc.p1; - a->dog.cs.lock(); *count = a->dog.count; - a->dog.cs.unlock(); } void IQC::SetiqcDogCount (TXA& txa, int count) { IQC *a = txa.iqc.p1; - a->dog.cs.lock(); a->dog.count = count; - a->dog.cs.unlock(); } } // namespace WDSP diff --git a/wdsp/iqc.hpp b/wdsp/iqc.hpp index e6e47b80c..3ac5df8b2 100644 --- a/wdsp/iqc.hpp +++ b/wdsp/iqc.hpp @@ -29,7 +29,6 @@ warren@wpratt.com #define wdsp_iqc_h #include -#include #include "export.h" @@ -63,7 +62,6 @@ public: int* cpi; int full_ints; int count; - QRecursiveMutex cs; } dog; static IQC* create_iqc (int run, int size, float* in, float* out, float rate, int ints, float tup, int spi); diff --git a/wdsp/meter.cpp b/wdsp/meter.cpp index 92b47b8d0..095f0b1a4 100644 --- a/wdsp/meter.cpp +++ b/wdsp/meter.cpp @@ -49,7 +49,6 @@ METER* METER::create_meter ( double tau_av, double tau_decay, double* result, - QRecursiveMutex** pmtupdate, int enum_av, int enum_pk, int enum_gain, @@ -70,9 +69,6 @@ METER* METER::create_meter ( a->enum_gain = enum_gain; a->pgain = pgain; calc_meter(a); - pmtupdate[enum_av] = &a->mtupdate; - pmtupdate[enum_pk] = &a->mtupdate; - pmtupdate[enum_gain] = &a->mtupdate; return a; } @@ -94,16 +90,18 @@ void METER::flush_meter (METER *a) void METER::xmeter (METER *a) { int srun; - a->mtupdate.lock(); + if (a->prun != 0) srun = *(a->prun); else srun = 1; + if (a->run && srun) { int i; double smag; double np = 0.0; + for (i = 0; i < a->size; i++) { smag = a->buff[2 * i + 0] * a->buff[2 * i + 0] + a->buff[2 * i + 1] * a->buff[2 * i + 1]; @@ -111,9 +109,13 @@ void METER::xmeter (METER *a) a->peak *= a->mult_peak; if (smag > np) np = smag; } - if (np > a->peak) a->peak = np; + + if (np > a->peak) + a->peak = np; + a->result[a->enum_av] = 10.0 * MemLog::mlog10 (a->avg + 1.0e-40); a->result[a->enum_pk] = 10.0 * MemLog::mlog10 (a->peak + 1.0e-40); + if ((a->pgain != 0) && (a->enum_gain >= 0)) a->result[a->enum_gain] = 20.0 * MemLog::mlog10 (*a->pgain + 1.0e-40); } @@ -123,7 +125,6 @@ void METER::xmeter (METER *a) if (a->enum_pk >= 0) a->result[a->enum_pk] = -400.0; if (a->enum_gain >= 0) a->result[a->enum_gain] = 0.0; } - a->mtupdate.unlock(); } void METER::setBuffers_meter (METER *a, float* in) @@ -152,9 +153,7 @@ void METER::setSize_meter (METER *a, int size) double METER::GetMeter (RXA& rxa, int mt) { double val; - rxa.pmtupdate[mt]->lock(); val = rxa.meter[mt]; - rxa.pmtupdate[mt]->unlock(); return val; } @@ -167,9 +166,7 @@ double METER::GetMeter (RXA& rxa, int mt) double METER::GetMeter (TXA& txa, int mt) { double val; - txa.pmtupdate[mt]->lock(); val = txa.meter[mt]; - txa.pmtupdate[mt]->unlock(); return val; } diff --git a/wdsp/meter.hpp b/wdsp/meter.hpp index 449d304ab..44d2966b8 100644 --- a/wdsp/meter.hpp +++ b/wdsp/meter.hpp @@ -28,8 +28,6 @@ warren@wpratt.com #ifndef _meter_h #define _meter_h -#include - #include "export.h" namespace WDSP { @@ -56,7 +54,6 @@ public: double* pgain; double avg; double peak; - QRecursiveMutex mtupdate; static METER* create_meter ( int run, @@ -67,7 +64,6 @@ public: double tau_av, double tau_decay, double* result, - QRecursiveMutex** pmtupdate, int enum_av, int enum_pk, int enum_gain, diff --git a/wdsp/nbp.cpp b/wdsp/nbp.cpp index f8fc5ad17..a279245d8 100644 --- a/wdsp/nbp.cpp +++ b/wdsp/nbp.cpp @@ -467,8 +467,8 @@ int NBP::NBPGetNotch (RXA& rxa, int notch, float* fcenter, float* fwidth, int* a { NOTCHDB *a; int rval; - rxa.csDSP.lock(); a = rxa.ndb.p; + if (notch < a->nn) { *fcenter = a->fcenter[notch]; @@ -483,7 +483,7 @@ int NBP::NBPGetNotch (RXA& rxa, int notch, float* fcenter, float* fwidth, int* a *active = -1; rval = -1; } - rxa.csDSP.unlock(); + return rval; } @@ -535,16 +535,15 @@ int NBP::NBPEditNotch (RXA& rxa, int notch, float fcenter, float fwidth, int act void NBP::NBPGetNumNotches (RXA& rxa, int* nnotches) { NOTCHDB *a; - rxa.csDSP.lock(); a = rxa.ndb.p; *nnotches = a->nn; - rxa.csDSP.unlock(); } void NBP::NBPSetTuneFrequency (RXA& rxa, float tunefreq) { NOTCHDB *a; a = rxa.ndb.p; + if (tunefreq != a->tunefreq) { a->tunefreq = tunefreq; @@ -567,6 +566,7 @@ void NBP::NBPSetNotchesRun (RXA& rxa, int run) { NOTCHDB *a = rxa.ndb.p; NBP *b = rxa.nbp0.p; + if ( run != a->master_run) { a->master_run = run; // update variables @@ -575,10 +575,8 @@ void NBP::NBPSetNotchesRun (RXA& rxa, int run) calc_nbp_impulse (b); // recalc nbp impulse response FIRCORE::setImpulse_fircore (b->p, b->impulse, 0); // calculate new filter masks delete[] (b->impulse); - rxa.csDSP.lock(); // block DSP channel processing RXA::bpsnbaSet (rxa); FIRCORE::setUpdate_fircore (b->p); // apply new filter masks - rxa.csDSP.unlock(); // unblock channel processing } } @@ -587,16 +585,15 @@ void NBP::NBPSetNotchesRun (RXA& rxa, int run) void NBP::NBPSetRun (RXA& rxa, int run) { NBP *a; - rxa.csDSP.lock(); a = rxa.nbp0.p; a->run = run; - rxa.csDSP.unlock(); } void NBP::NBPSetFreqs (RXA& rxa, float flow, float fhigh) { NBP *a; a = rxa.nbp0.p; + if ((flow != a->flow) || (fhigh != a->fhigh)) { a->flow = flow; @@ -613,6 +610,7 @@ void NBP::NBPSetWindow (RXA& rxa, int wintype) BPSNBA *b; a = rxa.nbp0.p; b = rxa.bpsnba.p; + if ((a->wintype != wintype)) { a->wintype = wintype; @@ -620,6 +618,7 @@ void NBP::NBPSetWindow (RXA& rxa, int wintype) FIRCORE::setImpulse_fircore (a->p, a->impulse, 1); delete[] (a->impulse); } + if ((b->wintype != wintype)) { b->wintype = wintype; @@ -631,20 +630,20 @@ void NBP::NBPSetNC (RXA& rxa, int nc) { // NOTE: 'nc' must be >= 'size' NBP *a; - rxa.csDSP.lock(); a = rxa.nbp0.p; + if (a->nc != nc) { a->nc = nc; setNc_nbp (a); } - rxa.csDSP.unlock(); } void NBP::NBPSetMP (RXA& rxa, int mp) { NBP *a; a = rxa.nbp0.p; + if (a->mp != mp) { a->mp = mp; @@ -655,10 +654,8 @@ void NBP::NBPSetMP (RXA& rxa, int mp) void NBP::NBPGetMinNotchWidth (RXA& rxa, float* minwidth) { NBP *a; - rxa.csDSP.lock(); a = rxa.nbp0.p; *minwidth = min_notch_width (a); - rxa.csDSP.unlock(); } void NBP::NBPSetAutoIncrease (RXA& rxa, int autoincr) @@ -667,6 +664,7 @@ void NBP::NBPSetAutoIncrease (RXA& rxa, int autoincr) BPSNBA *b; a = rxa.nbp0.p; b = rxa.bpsnba.p; + if ((a->autoincr != autoincr)) { a->autoincr = autoincr; @@ -674,6 +672,7 @@ void NBP::NBPSetAutoIncrease (RXA& rxa, int autoincr) FIRCORE::setImpulse_fircore (a->p, a->impulse, 1); delete[] (a->impulse); } + if ((b->autoincr != autoincr)) { b->autoincr = autoincr; diff --git a/wdsp/nob.cpp b/wdsp/nob.cpp index f3f16d442..511681366 100644 --- a/wdsp/nob.cpp +++ b/wdsp/nob.cpp @@ -170,7 +170,7 @@ void NOB::xnob (NOB *a) int len; int ffcount; int staydown; - a->cs_update.lock(); + if (a->run) { for (i = 0; i < a->buffsize; i++) @@ -492,7 +492,6 @@ void NOB::xnob (NOB *a) } else if (a->in != a->out) memcpy (a->out, a->in, a->buffsize * sizeof (wcomplex)); - a->cs_update.unlock(); } void NOB::setBuffers_nob (NOB *a, float* in, float* out) @@ -522,79 +521,61 @@ void NOB::setSize_nob (NOB *a, int size) void NOB::SetNOBRun (RXA& rxa, int run) { NOB *a = rxa.nob.p; - a->cs_update.lock(); a->run = run; - a->cs_update.unlock(); } void NOB::SetNOBMode (RXA& rxa, int mode) { NOB *a = rxa.nob.p; - a->cs_update.lock(); a->mode = mode; - a->cs_update.unlock(); } void NOB::SetNOBBuffsize (RXA& rxa, int size) { NOB *a = rxa.nob.p; - a->cs_update.lock(); a->buffsize = size; - a->cs_update.unlock(); } void NOB::SetNOBSamplerate (RXA& rxa, int rate) { NOB *a = rxa.nob.p; - a->cs_update.lock(); a->samplerate = (double) rate; init_nob (a); - a->cs_update.unlock(); } void NOB::SetNOBTau (RXA& rxa, double tau) { NOB *a = rxa.nob.p; - a->cs_update.lock(); a->advslewtime = tau; a->hangslewtime = tau; init_nob (a); - a->cs_update.unlock(); } void NOB::SetNOBHangtime (RXA& rxa, double time) { NOB *a = rxa.nob.p; - a->cs_update.lock(); a->hangtime = time; init_nob (a); - a->cs_update.unlock(); } void NOB::SetNOBAdvtime (RXA& rxa, double time) { NOB *a = rxa.nob.p; - a->cs_update.lock(); a->advtime = time; init_nob (a); - a->cs_update.unlock(); } void NOB::SetNOBBacktau (RXA& rxa, double tau) { NOB *a = rxa.nob.p; - a->cs_update.lock(); a->backtau = tau; init_nob (a); - a->cs_update.unlock(); } void NOB::SetNOBThreshold (RXA& rxa, double thresh) { NOB *a = rxa.nob.p; - a->cs_update.lock(); a->threshold = thresh; - a->cs_update.unlock(); } } // namespace diff --git a/wdsp/nob.hpp b/wdsp/nob.hpp index 51c7634f2..2c590d2ec 100644 --- a/wdsp/nob.hpp +++ b/wdsp/nob.hpp @@ -28,8 +28,6 @@ warren@wpratt.com #ifndef wdsp_nob_h #define wdsp_nob_h -#include - namespace WDSP { class RXA; @@ -82,7 +80,6 @@ public: double deltaI, deltaQ; double Inext, Qnext; int overflow; - QRecursiveMutex cs_update; double *legacy; //////////// legacy interface - remove diff --git a/wdsp/osctrl.cpp b/wdsp/osctrl.cpp index f05dda92b..6098f6499 100644 --- a/wdsp/osctrl.cpp +++ b/wdsp/osctrl.cpp @@ -148,10 +148,8 @@ void OSCTRL::SetosctrlRun (TXA& txa, int run) { if (txa.osctrl.p->run != run) { - txa.csDSP.lock(); txa.osctrl.p->run = run; TXA::SetupBPFilters (txa); - txa.csDSP.unlock(); } } diff --git a/wdsp/patchpanel.cpp b/wdsp/patchpanel.cpp index 5e685bfa1..630a9643d 100644 --- a/wdsp/patchpanel.cpp +++ b/wdsp/patchpanel.cpp @@ -139,37 +139,29 @@ void PANEL::setSize_panel (PANEL *a, int size) void PANEL::SetPanelRun (RXA& rxa, int run) { - rxa.csDSP.lock(); rxa.panel.p->run = run; - rxa.csDSP.unlock(); } void PANEL::SetPanelSelect (RXA& rxa, int select) { - rxa.csDSP.lock(); rxa.panel.p->inselect = select; - rxa.csDSP.unlock(); } void PANEL::SetPanelGain1 (RXA& rxa, float gain) { - rxa.csDSP.lock(); rxa.panel.p->gain1 = gain; - rxa.csDSP.unlock(); } void PANEL::SetPanelGain2 (RXA& rxa, float gainI, float gainQ) { - rxa.csDSP.lock(); rxa.panel.p->gain2I = gainI; rxa.panel.p->gain2Q = gainQ; - rxa.csDSP.unlock(); } void PANEL::SetPanelPan (RXA& rxa, float pan) { float gain1, gain2; - rxa.csDSP.lock(); + if (pan <= 0.5) { gain1 = 1.0; @@ -180,23 +172,19 @@ void PANEL::SetPanelPan (RXA& rxa, float pan) gain1 = sin (pan * PI); gain2 = 1.0; } + rxa.panel.p->gain2I = gain1; rxa.panel.p->gain2Q = gain2; - rxa.csDSP.unlock(); } void PANEL::SetPanelCopy (RXA& rxa, int copy) { - rxa.csDSP.lock(); rxa.panel.p->copy = copy; - rxa.csDSP.unlock(); } void PANEL::SetPanelBinaural (RXA& rxa, int bin) { - rxa.csDSP.lock(); rxa.panel.p->copy = 1 - bin; - rxa.csDSP.unlock(); } /******************************************************************************************************** @@ -207,28 +195,23 @@ void PANEL::SetPanelBinaural (RXA& rxa, int bin) void PANEL::SetPanelRun (TXA& txa, int run) { - txa.csDSP.lock(); txa.panel.p->run = run; - txa.csDSP.unlock(); } void PANEL::SetPanelGain1 (TXA& txa, float gain) { - txa.csDSP.lock(); txa.panel.p->gain1 = gain; //print_message ("micgainset.txt", "Set MIC Gain to", (int)(100.0 * gain), 0, 0); - txa.csDSP.unlock(); } void PANEL::SetPanelSelect (TXA& txa, int select) { - txa.csDSP.lock(); if (select == 1) txa.panel.p->copy = 3; else txa.panel.p->copy = 0; + txa.panel.p->inselect = select; - txa.csDSP.unlock(); } } // namespace WDSP diff --git a/wdsp/rmatch.cpp b/wdsp/rmatch.cpp index 4d4159b38..e17c893d6 100644 --- a/wdsp/rmatch.cpp +++ b/wdsp/rmatch.cpp @@ -270,11 +270,9 @@ void RMATCH::control (RMATCH *a, int change) int deviation = a->n_ring - a->rsize / 2; MAV::xmav (a->propmav, deviation, &a->av_deviation); } - a->cs_var.lock(); a->var = a->feed_forward - a->pr_gain * a->av_deviation; if (a->var > 1.04) a->var = 1.04; if (a->var < 0.96) a->var = 0.96; - a->cs_var.unlock(); } void RMATCH::blend (RMATCH *a) @@ -310,20 +308,21 @@ void RMATCH::xrmatchIN (void* b, float* in) int newsamps, first, second, ovfl; float var; a->v->in = a->in = in; - a->cs_var.lock(); + if (!a->force) var = a->var; else var = a->fvar; - a->cs_var.unlock(); + newsamps = VARSAMP::xvarsamp (a->v, var); - a->cs_ring.lock(); a->n_ring += newsamps; + if ((ovfl = a->n_ring - a->rsize) > 0) { a->overflows += 1; // a->n_ring = a->rsize / 2; a->n_ring = a->rsize; // + if ((a->ntslew + 1) > (a->rsize - a->iout)) { first = a->rsize - a->iout; @@ -334,11 +333,13 @@ void RMATCH::xrmatchIN (void* b, float* in) first = a->ntslew + 1; second = 0; } + memcpy (a->baux, a->ring + 2 * a->iout, first * sizeof (wcomplex)); memcpy (a->baux + 2 * first, a->ring, second * sizeof (wcomplex)); // a->iout = (a->iout + ovfl + a->rsize / 2) % a->rsize; a->iout = (a->iout + ovfl) % a->rsize; // } + if (newsamps > (a->rsize - a->iin)) { first = a->rsize - a->iin; @@ -349,19 +350,27 @@ void RMATCH::xrmatchIN (void* b, float* in) first = newsamps; second = 0; } + memcpy (a->ring + 2 * a->iin, a->resout, first * sizeof (wcomplex)); memcpy (a->ring, a->resout + 2 * first, second * sizeof (wcomplex)); - if (a->ucnt >= 0) upslew(a, newsamps); + + if (a->ucnt >= 0) + upslew(a, newsamps); + a->iin = (a->iin + newsamps) % a->rsize; - if (ovfl > 0) blend (a); + + if (ovfl > 0) + blend (a); + if (!a->control_flag) { a->writesamps += a->insize; if ((a->readsamps >= a->read_startup) && (a->writesamps >= a->write_startup)) a->control_flag = 1; } - if (a->control_flag) control (a, a->insize); - a->cs_ring.unlock(); + + if (a->control_flag) + control (a, a->insize); } } @@ -436,13 +445,14 @@ void RMATCH::xrmatchOUT (void* b, float* out) { int first, second; a->out = out; - a->cs_ring.lock(); + if (a->n_ring < a->outsize) { dslew (a); a->ucnt = a->ntslew; a->underflows += 1; } + if (a->outsize > (a->rsize - a->iout)) { first = a->rsize - a->iout; @@ -453,20 +463,24 @@ void RMATCH::xrmatchOUT (void* b, float* out) first = a->outsize; second = 0; } + memcpy (a->out, a->ring + 2 * a->iout, first * sizeof (wcomplex)); memcpy (a->out + 2 * first, a->ring, second * sizeof (wcomplex)); a->iout = (a->iout + a->outsize) % a->rsize; a->n_ring -= a->outsize; a->dlast[0] = a->out[2 * (a->outsize - 1) + 0]; a->dlast[1] = a->out[2 * (a->outsize - 1) + 1]; + if (!a->control_flag) { a->readsamps += a->outsize; + if ((a->readsamps >= a->read_startup) && (a->writesamps >= a->write_startup)) a->control_flag = 1; } - if (a->control_flag) control (a, -(a->outsize)); - a->cs_ring.unlock(); + + if (a->control_flag) + control (a, -(a->outsize)); } } @@ -478,11 +492,9 @@ void RMATCH::getRMatchDiags (void* b, int* underflows, int* overflows, float* va *overflows = a->overflows; a->underflows &= 0xFFFFFFFF; a->overflows &= 0xFFFFFFFF; - a->cs_var.lock(); *var = a->var; *ringsize = a->ringsize; *nring = a->n_ring; - a->cs_var.unlock(); } @@ -497,10 +509,8 @@ void RMATCH::resetRMatchDiags (void*) void RMATCH::forceRMatchVar (void* b, int force, float fvar) { RMATCH *a = (RMATCH*) b; - a->cs_var.lock(); a->force = force; a->fvar = fvar; - a->cs_var.unlock(); } @@ -603,10 +613,8 @@ void RMATCH::setRMatchRingsize (void* ptr, int ringsize) void RMATCH::setRMatchFeedbackGain (void* b, float feedback_gain) { RMATCH *a = (RMATCH*) b; - a->cs_var.lock(); a->prop_gain = feedback_gain; a->pr_gain = a->prop_gain * 48000.0 / (float)a->nom_outrate; - a->cs_var.unlock(); } @@ -706,9 +714,7 @@ void RMATCH::setRMatchFFAlpha(void* ptr, float ff_alpha) void RMATCH::getControlFlag(void* ptr, int* control_flag) { RMATCH *a = (RMATCH*) ptr; - a->cs_ring.lock(); *control_flag = a->control_flag; - a->cs_ring.unlock(); } // the following function is DEPRECATED diff --git a/wdsp/rmatch.hpp b/wdsp/rmatch.hpp index fe6f8a8bf..df24d5895 100644 --- a/wdsp/rmatch.hpp +++ b/wdsp/rmatch.hpp @@ -29,7 +29,6 @@ warren@wpratt.com #define wdsp_rmatch_h #include -#include #include "export.h" @@ -113,8 +112,6 @@ public: float av_deviation; VARSAMP *v; int varmode; - QRecursiveMutex cs_ring; - QRecursiveMutex cs_var; // blend / slew float tslew; int ntslew; diff --git a/wdsp/sender.cpp b/wdsp/sender.cpp index 1bd4b23f0..938edfb8c 100644 --- a/wdsp/sender.cpp +++ b/wdsp/sender.cpp @@ -94,11 +94,9 @@ void SENDER::setSize_sender (SENDER *a, int size) void SENDER::SetSpectrum (RXA& rxa, int flag, BufferProbe *spectrumProbe) { SENDER *a; - rxa.csDSP.lock(); a = rxa.sender.p; a->flag = flag; a->spectrumProbe = spectrumProbe; - rxa.csDSP.unlock(); } } // namespace WDSP diff --git a/wdsp/shift.cpp b/wdsp/shift.cpp index fdd5bb15a..132e8635f 100644 --- a/wdsp/shift.cpp +++ b/wdsp/shift.cpp @@ -116,17 +116,13 @@ void SHIFT::setSize_shift (SHIFT *a, int size) void SHIFT::SetShiftRun (RXA& rxa, int run) { - rxa.csDSP.lock(); rxa.shift.p->run = run; - rxa.csDSP.unlock(); } void SHIFT::SetShiftFreq (RXA& rxa, float fshift) { - rxa.csDSP.lock(); rxa.shift.p->shift = fshift; calc_shift (rxa.shift.p); - rxa.csDSP.unlock(); } } // namespace WDSP diff --git a/wdsp/siphon.cpp b/wdsp/siphon.cpp index 10fd766a8..eb21c88e4 100644 --- a/wdsp/siphon.cpp +++ b/wdsp/siphon.cpp @@ -110,7 +110,7 @@ void SIPHON::flush_siphon (SIPHON *a) void SIPHON::xsiphon (SIPHON *a, int pos) { int first, second; - a->update.lock(); + if (a->run && a->position == pos) { switch (a->mode) @@ -140,7 +140,6 @@ void SIPHON::xsiphon (SIPHON *a, int pos) break; } } - a->update.unlock(); } void SIPHON::setBuffers_siphon (SIPHON *a, float* in) @@ -197,12 +196,10 @@ void SIPHON::GetaSipF (RXA& rxa, float* out, int size) { // return raw samples as floats SIPHON *a=rxa.sip1.p; int i; - a->update.lock(); a->outsize = size; suck (a); - a->update.unlock(); - for (i = 0; i < size; i++) - { + + for (i = 0; i < size; i++) { out[i] = (float)a->sipout[2 * i + 0]; } } @@ -211,10 +208,9 @@ void SIPHON::GetaSipF1 (RXA& rxa, float* out, int size) { // return raw samples as floats SIPHON *a=rxa.sip1.p; int i; - a->update.lock(); a->outsize = size; suck (a); - a->update.unlock(); + for (i = 0; i < size; i++) { out[2 * i + 0] = (float)a->sipout[2 * i + 0]; @@ -231,37 +227,29 @@ void SIPHON::GetaSipF1 (RXA& rxa, float* out, int size) void SIPHON::SetSipPosition (TXA& txa, int pos) { SIPHON *a = txa.sip1.p; - a->update.lock(); a->position = pos; - a->update.unlock(); } void SIPHON::SetSipMode (TXA& txa, int mode) { SIPHON *a = txa.sip1.p; - a->update.lock(); a->mode = mode; - a->update.unlock(); } void SIPHON::SetSipDisplay (TXA& txa, int disp) { SIPHON *a = txa.sip1.p; - a->update.lock(); a->disp = disp; - a->update.unlock(); } void SIPHON::GetaSipF (TXA& txa, float* out, int size) { // return raw samples as floats SIPHON *a = txa.sip1.p; int i; - a->update.lock(); a->outsize = size; suck (a); - a->update.unlock(); - for (i = 0; i < size; i++) - { + + for (i = 0; i < size; i++) { out[i] = (float)a->sipout[2 * i + 0]; } } @@ -270,10 +258,9 @@ void SIPHON::GetaSipF1 (TXA& txa, float* out, int size) { // return raw samples as floats SIPHON *a = txa.sip1.p; int i; - a->update.lock(); a->outsize = size; suck (a); - a->update.unlock(); + for (i = 0; i < size; i++) { out[2 * i + 0] = (float)a->sipout[2 * i + 0]; @@ -294,26 +281,29 @@ void SIPHON::GetSpecF1 (TXA& txa, float* out) { // return spectrum magnitudes in dB SIPHON *a = txa.sip1.p; int i, j, mid, m, n; - a->update.lock(); a->outsize = a->fftsize; suck (a); - a->update.unlock(); sip_spectrum (a); mid = a->fftsize / 2; + if (a->specmode != 1) + { // swap the halves of the spectrum for (i = 0, j = mid; i < mid; i++, j++) { out[i] = (float)(10.0 * MemLog::mlog10 (a->specout[2 * j + 0] * a->specout[2 * j + 0] + a->specout[2 * j + 1] * a->specout[2 * j + 1] + 1.0e-60)); out[j] = (float)(10.0 * MemLog::mlog10 (a->specout[2 * i + 0] * a->specout[2 * i + 0] + a->specout[2 * i + 1] * a->specout[2 * i + 1] + 1.0e-60)); } + } else + { // mirror each half of the spectrum in-place for (i = 0, j = mid - 1, m = mid, n = a->fftsize - 1; i < mid; i++, j--, m++, n--) { out[i] = (float)(10.0 * MemLog::mlog10 (a->specout[2 * j + 0] * a->specout[2 * j + 0] + a->specout[2 * j + 1] * a->specout[2 * j + 1] + 1.0e-60)); out[m] = (float)(10.0 * MemLog::mlog10 (a->specout[2 * n + 0] * a->specout[2 * n + 0] + a->specout[2 * n + 1] * a->specout[2 * n + 1] + 1.0e-60)); } + } } /******************************************************************************************************** diff --git a/wdsp/siphon.hpp b/wdsp/siphon.hpp index eeeaa8730..6f3f3cfc2 100644 --- a/wdsp/siphon.hpp +++ b/wdsp/siphon.hpp @@ -35,7 +35,6 @@ warren@wpratt.com #include "export.h" #include -#include namespace WDSP { @@ -61,7 +60,6 @@ public: std::atomic specmode; fftwf_plan sipplan; float* window; - QRecursiveMutex update; static SIPHON* create_siphon ( int run, diff --git a/wdsp/slew.cpp b/wdsp/slew.cpp index d2b565404..5492b44dd 100644 --- a/wdsp/slew.cpp +++ b/wdsp/slew.cpp @@ -189,12 +189,10 @@ void USLEW::setSize_uslew (USLEW *a, int size) void USLEW::SetuSlewTime (TXA& txa, float time) { // NOTE: 'time' is in seconds - txa.csDSP.lock(); USLEW *a = txa.uslew.p; decalc_uslew (a); a->tupslew = time; calc_uslew (a); - txa.csDSP.unlock(); } } // namespace WDSP diff --git a/wdsp/snba.cpp b/wdsp/snba.cpp index b1bc61a7d..fc6e49cbe 100644 --- a/wdsp/snba.cpp +++ b/wdsp/snba.cpp @@ -696,77 +696,57 @@ void SNBA::SetSNBARun (RXA& rxa, int run) rxa.anf.p->run, rxa.anr.p->run ); - rxa.csDSP.lock(); a->run = run; RXA::bp1Set (rxa); RXA::bpsnbaSet (rxa); - rxa.csDSP.unlock(); } } void SNBA::SetSNBAovrlp (RXA& rxa, int ovrlp) { - rxa.csDSP.lock(); decalc_snba (rxa.snba.p); rxa.snba.p->ovrlp = ovrlp; calc_snba (rxa.snba.p); - rxa.csDSP.unlock(); } void SNBA::SetSNBAasize (RXA& rxa, int size) { - rxa.csDSP.lock(); rxa.snba.p->exec.asize = size; - rxa.csDSP.unlock(); } void SNBA::SetSNBAnpasses (RXA& rxa, int npasses) { - rxa.csDSP.lock(); rxa.snba.p->exec.npasses = npasses; - rxa.csDSP.unlock(); } void SNBA::SetSNBAk1 (RXA& rxa, double k1) { - rxa.csDSP.lock(); rxa.snba.p->sdet.k1 = k1; - rxa.csDSP.unlock(); } void SNBA::SetSNBAk2 (RXA& rxa, double k2) { - rxa.csDSP.lock(); rxa.snba.p->sdet.k2 = k2; - rxa.csDSP.unlock(); } void SNBA::SetSNBAbridge (RXA& rxa, int bridge) { - rxa.csDSP.lock(); rxa.snba.p->sdet.b = bridge; - rxa.csDSP.unlock(); } void SNBA::SetSNBApresamps (RXA& rxa, int presamps) { - rxa.csDSP.lock(); rxa.snba.p->sdet.pre = presamps; - rxa.csDSP.unlock(); } void SNBA::SetSNBApostsamps (RXA& rxa, int postsamps) { - rxa.csDSP.lock(); rxa.snba.p->sdet.post = postsamps; - rxa.csDSP.unlock(); } void SNBA::SetSNBApmultmin (RXA& rxa, double pmultmin) { - rxa.csDSP.lock(); rxa.snba.p->scan.pmultmin = pmultmin; - rxa.csDSP.unlock(); } void SNBA::SetSNBAOutputBandwidth (RXA& rxa, double flow, double fhigh) @@ -774,32 +754,41 @@ void SNBA::SetSNBAOutputBandwidth (RXA& rxa, double flow, double fhigh) SNBA *a = rxa.snba.p; RESAMPLE *d = a->outresamp; double f_low, f_high; - rxa.csDSP.lock(); if (flow >= 0 && fhigh >= 0) { - if (fhigh < a->out_low_cut) fhigh = a->out_low_cut; - if (flow > a->out_high_cut) flow = a->out_high_cut; + if (fhigh < a->out_low_cut) + fhigh = a->out_low_cut; + + if (flow > a->out_high_cut) + flow = a->out_high_cut; + f_low = std::max ( a->out_low_cut, flow); f_high = std::min (a->out_high_cut, fhigh); } else if (flow <= 0 && fhigh <= 0) { - if (flow > -a->out_low_cut) flow = -a->out_low_cut; - if (fhigh < -a->out_high_cut) fhigh = -a->out_high_cut; + if (flow > -a->out_low_cut) + flow = -a->out_low_cut; + + if (fhigh < -a->out_high_cut) + fhigh = -a->out_high_cut; + f_low = std::max ( a->out_low_cut, -fhigh); f_high = std::min (a->out_high_cut, -flow); } else if (flow < 0 && fhigh > 0) { double absmax = std::max (-flow, fhigh); - if (absmax < a->out_low_cut) absmax = a->out_low_cut; + + if (absmax < a->out_low_cut) + absmax = a->out_low_cut; + f_low = a->out_low_cut; f_high = std::min (a->out_high_cut, absmax); } RESAMPLE::setBandwidth_resample (d, f_low, f_high); - rxa.csDSP.unlock(); } } // namespace diff --git a/wdsp/ssql.cpp b/wdsp/ssql.cpp index d62a8cb52..508b2a453 100644 --- a/wdsp/ssql.cpp +++ b/wdsp/ssql.cpp @@ -350,18 +350,14 @@ void SSQL::setSize_ssql (SSQL *a, int size) void SSQL::SetSSQLRun (RXA& rxa, int run) { - rxa.csDSP.lock(); rxa.ssql.p->run = run; - rxa.csDSP.unlock(); } void SSQL::SetSSQLThreshold (RXA& rxa, double threshold) { // 'threshold' should be between 0.0 and 1.0 // WU2O testing: 0.16 is a good default for 'threshold'; => 0.08 for 'wthresh' - rxa.csDSP.lock(); rxa.ssql.p->wthresh = threshold / 2.0; - rxa.csDSP.unlock(); } void SSQL::SetSSQLTauMute (RXA& rxa, double tau_mute) @@ -369,10 +365,8 @@ void SSQL::SetSSQLTauMute (RXA& rxa, double tau_mute) // reasonable (wide) range is 0.1 to 2.0 // WU2O testing: 0.1 is good default value SSQL *a = rxa.ssql.p; - rxa.csDSP.lock(); a->tr_tau_mute = tau_mute; a->mute_mult = 1.0 - exp (-1.0 / (a->rate * a->tr_tau_mute)); - rxa.csDSP.unlock(); } void SSQL::SetSSQLTauUnMute (RXA& rxa, double tau_unmute) @@ -380,10 +374,8 @@ void SSQL::SetSSQLTauUnMute (RXA& rxa, double tau_unmute) // reasonable (wide) range is 0.1 to 1.0 // WU2O testing: 0.1 is good default value SSQL *a = rxa.ssql.p; - rxa.csDSP.lock(); a->tr_tau_unmute = tau_unmute; a->unmute_mult = 1.0 - exp (-1.0 / (a->rate * a->tr_tau_unmute)); - rxa.csDSP.unlock(); } } // namespace WDSP diff --git a/wdsp/unit.hpp b/wdsp/unit.hpp index 35d917533..09000f0c3 100644 --- a/wdsp/unit.hpp +++ b/wdsp/unit.hpp @@ -28,8 +28,6 @@ warren@wpratt.com #ifndef wdsp_unit_h #define wdsp_unit_h -#include - #include "export.h" namespace WDSP { @@ -43,8 +41,6 @@ public: int dsp_size; // number complex samples processed per buffer in mainstream dsp processing int dsp_insize; // size (complex samples) of the input buffer int dsp_outsize; // size (complex samples) of the output buffer - QRecursiveMutex csDSP; // used to block dsp while parameters are updated or buffers flushed - QRecursiveMutex csEXCH; // used to block fexchange() while parameters are updated or buffers flushed int state; // 0 for unit OFF; 1 for unit ON }; diff --git a/wdsp/wcpAGC.cpp b/wdsp/wcpAGC.cpp index bcf82f31f..53e5d219c 100644 --- a/wdsp/wcpAGC.cpp +++ b/wdsp/wcpAGC.cpp @@ -376,7 +376,6 @@ void WCPAGC::setSize_wcpagc (WCPAGC *a, int size) void WCPAGC::SetAGCMode (RXA& rxa, int mode) { - rxa.csDSP.lock(); switch (mode) { case 0: //agcOFF @@ -413,139 +412,108 @@ void WCPAGC::SetAGCMode (RXA& rxa, int mode) rxa.agc.p->mode = 5; break; } - rxa.csDSP.unlock(); } void WCPAGC::SetAGCAttack (RXA& rxa, int attack) { - rxa.csDSP.lock(); rxa.agc.p->tau_attack = (float)attack / 1000.0; loadWcpAGC ( rxa.agc.p ); - rxa.csDSP.unlock(); } void WCPAGC::SetAGCDecay (RXA& rxa, int decay) { - rxa.csDSP.lock(); rxa.agc.p->tau_decay = (float)decay / 1000.0; loadWcpAGC ( rxa.agc.p ); - rxa.csDSP.unlock(); } void WCPAGC::SetAGCHang (RXA& rxa, int hang) { - rxa.csDSP.lock(); rxa.agc.p->hangtime = (float)hang / 1000.0; loadWcpAGC ( rxa.agc.p ); - rxa.csDSP.unlock(); } void WCPAGC::GetAGCHangLevel(RXA& rxa, float *hangLevel) //for line on bandscope { - rxa.csDSP.lock(); *hangLevel = 20.0 * log10( rxa.agc.p->hang_level / 0.637 ); - rxa.csDSP.unlock(); } void WCPAGC::SetAGCHangLevel(RXA& rxa, float hangLevel) //for line on bandscope { float convert, tmp; - rxa.csDSP.lock(); + if (rxa.agc.p->max_input > rxa.agc.p->min_volts) { convert = pow (10.0, hangLevel / 20.0); - tmp = std::max(1e-8, (convert - rxa.agc.p->min_volts) / - (rxa.agc.p->max_input - rxa.agc.p->min_volts)); + tmp = std::max(1e-8, (convert - rxa.agc.p->min_volts) / (rxa.agc.p->max_input - rxa.agc.p->min_volts)); rxa.agc.p->hang_thresh = 1.0 + 0.125 * log10 (tmp); } else rxa.agc.p->hang_thresh = 1.0; + loadWcpAGC ( rxa.agc.p ); - rxa.csDSP.unlock(); } void WCPAGC::GetAGCHangThreshold(RXA& rxa, int *hangthreshold) //for slider in setup { - rxa.csDSP.lock(); *hangthreshold = (int)(100.0 * rxa.agc.p->hang_thresh); - rxa.csDSP.unlock(); } void WCPAGC::SetAGCHangThreshold (RXA& rxa, int hangthreshold) //For slider in setup { - rxa.csDSP.lock(); rxa.agc.p->hang_thresh = (float)hangthreshold / 100.0; loadWcpAGC ( rxa.agc.p ); - rxa.csDSP.unlock(); } void WCPAGC::GetAGCThresh(RXA& rxa, float *thresh, float size, float rate) //for line on bandscope. { float noise_offset; - rxa.csDSP.lock(); - noise_offset = 10.0 * log10((rxa.nbp0.p->fhigh - rxa.nbp0.p->flow) - * size / rate); + noise_offset = 10.0 * log10((rxa.nbp0.p->fhigh - rxa.nbp0.p->flow) * size / rate); *thresh = 20.0 * log10( rxa.agc.p->min_volts ) - noise_offset; - rxa.csDSP.unlock(); } void WCPAGC::SetAGCThresh(RXA& rxa, float thresh, float size, float rate) //for line on bandscope { float noise_offset; - rxa.csDSP.lock(); - noise_offset = 10.0 * log10((rxa.nbp0.p->fhigh - rxa.nbp0.p->flow) - * size / rate); - rxa.agc.p->max_gain = rxa.agc.p->out_target / - (rxa.agc.p->var_gain * pow (10.0, (thresh + noise_offset) / 20.0)); + noise_offset = 10.0 * log10((rxa.nbp0.p->fhigh - rxa.nbp0.p->flow) * size / rate); + rxa.agc.p->max_gain = rxa.agc.p->out_target / (rxa.agc.p->var_gain * pow (10.0, (thresh + noise_offset) / 20.0)); loadWcpAGC ( rxa.agc.p ); - rxa.csDSP.unlock(); } void WCPAGC::GetAGCTop(RXA& rxa, float *max_agc) //for AGC Max Gain in setup { - rxa.csDSP.lock(); *max_agc = 20 * log10 (rxa.agc.p->max_gain); - rxa.csDSP.unlock(); } void WCPAGC::SetAGCTop (RXA& rxa, float max_agc) //for AGC Max Gain in setup { - rxa.csDSP.lock(); rxa.agc.p->max_gain = pow (10.0, (float)max_agc / 20.0); loadWcpAGC ( rxa.agc.p ); - rxa.csDSP.unlock(); } void WCPAGC::SetAGCSlope (RXA& rxa, int slope) { - rxa.csDSP.lock(); rxa.agc.p->var_gain = pow (10.0, (float)slope / 20.0 / 10.0); loadWcpAGC ( rxa.agc.p ); - rxa.csDSP.unlock(); } void WCPAGC::SetAGCFixed (RXA& rxa, float fixed_agc) { - rxa.csDSP.lock(); rxa.agc.p->fixed_gain = pow (10.0, (float)fixed_agc / 20.0); loadWcpAGC ( rxa.agc.p ); - rxa.csDSP.unlock(); } void WCPAGC::SetAGCMaxInputLevel (RXA& rxa, float level) { - rxa.csDSP.lock(); rxa.agc.p->max_input = level; loadWcpAGC ( rxa.agc.p ); - rxa.csDSP.unlock(); } /******************************************************************************************************** @@ -556,80 +524,60 @@ void WCPAGC::SetAGCMaxInputLevel (RXA& rxa, float level) void WCPAGC::SetALCSt (TXA& txa, int state) { - txa.csDSP.lock(); txa.alc.p->run = state; - txa.csDSP.unlock(); } void WCPAGC::SetALCAttack (TXA& txa, int attack) { - txa.csDSP.lock(); txa.alc.p->tau_attack = (float)attack / 1000.0; loadWcpAGC(txa.alc.p); - txa.csDSP.unlock(); } void WCPAGC::SetALCDecay (TXA& txa, int decay) { - txa.csDSP.lock(); txa.alc.p->tau_decay = (float)decay / 1000.0; loadWcpAGC(txa.alc.p); - txa.csDSP.unlock(); } void WCPAGC::SetALCHang (TXA& txa, int hang) { - txa.csDSP.lock(); txa.alc.p->hangtime = (float)hang / 1000.0; loadWcpAGC(txa.alc.p); - txa.csDSP.unlock(); } void WCPAGC::SetALCMaxGain (TXA& txa, float maxgain) { - txa.csDSP.lock(); txa.alc.p->max_gain = pow (10.0,(float)maxgain / 20.0); loadWcpAGC(txa.alc.p); - txa.csDSP.unlock(); } void WCPAGC::SetLevelerSt (TXA& txa, int state) { - txa.csDSP.lock(); txa.leveler.p->run = state; - txa.csDSP.unlock(); } void WCPAGC::SetLevelerAttack (TXA& txa, int attack) { - txa.csDSP.lock(); txa.leveler.p->tau_attack = (float)attack / 1000.0; loadWcpAGC(txa.leveler.p); - txa.csDSP.unlock(); } void WCPAGC::SetLevelerDecay (TXA& txa, int decay) { - txa.csDSP.lock(); txa.leveler.p->tau_decay = (float)decay / 1000.0; loadWcpAGC(txa.leveler.p); - txa.csDSP.unlock(); } void WCPAGC::SetLevelerHang (TXA& txa, int hang) { - txa.csDSP.lock(); txa.leveler.p->hangtime = (float)hang / 1000.0; loadWcpAGC(txa.leveler.p); - txa.csDSP.unlock(); } void WCPAGC::SetLevelerTop (TXA& txa, float maxgain) { - txa.csDSP.lock(); txa.leveler.p->max_gain = pow (10.0,(float)maxgain / 20.0); loadWcpAGC(txa.leveler.p); - txa.csDSP.unlock(); } } // namespace WDSP