1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-10 18:43:28 -05:00

WDSP: meter: replaced static methods

This commit is contained in:
f4exb 2024-07-24 15:32:21 +02:00
parent 8842b56080
commit 42fa9f5eb2
5 changed files with 156 additions and 183 deletions

View File

@ -192,8 +192,8 @@ void WDSPRxSink::processOneSample(Complex &ci)
WDSP::RXA::xrxa(m_rxa);
m_sCount = m_wdspBufSize;
m_sAvg = WDSP::METER::GetMeter(*m_rxa, WDSP::RXA::RXA_S_AV);
m_sPeak = WDSP::METER::GetMeter(*m_rxa, WDSP::RXA::RXA_S_PK);
m_sAvg = m_rxa->smeter->getMeter(WDSP::RXA::RXA_S_AV);
m_sPeak = m_rxa->smeter->getMeter(WDSP::RXA::RXA_S_PK);
for (int i = 0; i < m_rxa->get_outsize(); i++)
{

View File

@ -139,7 +139,7 @@ RXA* RXA::create_rxa (
1.0); // gain
// Input meter - ADC
rxa->adcmeter = METER::create_meter (
rxa->adcmeter = new METER(
0, // run
0, // optional pointer to another 'run'
rxa->dsp_size, // size
@ -212,7 +212,7 @@ RXA* RXA::create_rxa (
// End notched bandpass section
// S-meter
rxa->smeter = METER::create_meter (
rxa->smeter = new METER(
1, // run
0, // optional pointer to another 'run'
rxa->dsp_size, // size
@ -429,7 +429,7 @@ RXA* RXA::create_rxa (
0.100); // tau_hang_decay
// AGC meter
rxa->agcmeter = METER::create_meter (
rxa->agcmeter = new METER(
0, // run
0, // optional pointer to another 'run'
rxa->dsp_size, // size
@ -571,7 +571,7 @@ void RXA::destroy_rxa (RXA *rxa)
CBL::destroy_cbl (rxa->cbl);
SIPHON::destroy_siphon (rxa->sip1);
BANDPASS::destroy_bandpass (rxa->bp1);
METER::destroy_meter (rxa->agcmeter);
delete (rxa->agcmeter);
WCPAGC::destroy_wcpagc (rxa->agc);
EMNR::destroy_emnr (rxa->emnr);
ANR::destroy_anr (rxa->anr);
@ -582,12 +582,12 @@ void RXA::destroy_rxa (RXA *rxa)
FMD::destroy_fmd (rxa->fmd);
AMD::destroy_amd (rxa->amd);
AMSQ::destroy_amsq (rxa->amsq);
METER::destroy_meter (rxa->smeter);
delete (rxa->smeter);
SENDER::destroy_sender (rxa->sender);
BPSNBA::destroy_bpsnba (rxa->bpsnba);
NBP::destroy_nbp (rxa->nbp0);
NOTCHDB::destroy_notchdb (rxa->ndb);
METER::destroy_meter (rxa->adcmeter);
delete (rxa->adcmeter);
delete (rxa->rsmpin);
delete (rxa->shift);
delete (rxa->nob);
@ -607,11 +607,11 @@ void RXA::flush_rxa (RXA *rxa)
rxa->nob->flush();
rxa->shift->flush();
rxa->rsmpin->flush();
METER::flush_meter (rxa->adcmeter);
rxa->adcmeter->flush();
NBP::flush_nbp (rxa->nbp0);
BPSNBA::flush_bpsnba (rxa->bpsnba);
SENDER::flush_sender (rxa->sender);
METER::flush_meter (rxa->smeter);
rxa->smeter->flush();
AMSQ::flush_amsq (rxa->amsq);
AMD::flush_amd (rxa->amd);
FMD::flush_fmd (rxa->fmd);
@ -622,7 +622,7 @@ void RXA::flush_rxa (RXA *rxa)
ANR::flush_anr (rxa->anr);
EMNR::flush_emnr (rxa->emnr);
WCPAGC::flush_wcpagc (rxa->agc);
METER::flush_meter (rxa->agcmeter);
rxa->agcmeter->flush();
BANDPASS::flush_bandpass (rxa->bp1);
SIPHON::flush_siphon (rxa->sip1);
CBL::flush_cbl (rxa->cbl);
@ -639,10 +639,10 @@ void RXA::xrxa (RXA *rxa)
rxa->nob->execute();
rxa->shift->execute();
rxa->rsmpin->execute();
METER::xmeter (rxa->adcmeter);
rxa->adcmeter->execute();
BPSNBA::xbpsnbain (rxa->bpsnba, 0);
NBP::xnbp (rxa->nbp0, 0);
METER::xmeter (rxa->smeter);
rxa->smeter->execute();
SENDER::xsender (rxa->sender);
AMSQ::xamsqcap (rxa->amsq);
BPSNBA::xbpsnbaout (rxa->bpsnba, 0);
@ -662,7 +662,7 @@ void RXA::xrxa (RXA *rxa)
ANR::xanr (rxa->anr, 1);
EMNR::xemnr (rxa->emnr, 1);
BANDPASS::xbandpass (rxa->bp1, 1);
METER::xmeter (rxa->agcmeter);
rxa->agcmeter->execute();
SIPHON::xsiphon (rxa->sip1, 0);
CBL::xcbl (rxa->cbl);
SPEAK::xspeak (rxa->speak);
@ -752,10 +752,10 @@ void RXA::setDSPSamplerate (RXA *rxa, int dsp_rate)
rxa->rsmpin->setSize(rxa->dsp_insize);
rxa->rsmpin->setOutRate(rxa->dsp_rate);
// dsp_rate blocks
METER::setSamplerate_meter (rxa->adcmeter, rxa->dsp_rate);
rxa->adcmeter->setSamplerate(rxa->dsp_rate);
NBP::setSamplerate_nbp (rxa->nbp0, rxa->dsp_rate);
BPSNBA::setSamplerate_bpsnba (rxa->bpsnba, rxa->dsp_rate);
METER::setSamplerate_meter (rxa->smeter, rxa->dsp_rate);
rxa->smeter->setSamplerate(rxa->dsp_rate);
SENDER::setSamplerate_sender (rxa->sender, rxa->dsp_rate);
AMSQ::setSamplerate_amsq (rxa->amsq, rxa->dsp_rate);
AMD::setSamplerate_amd (rxa->amd, rxa->dsp_rate);
@ -769,7 +769,7 @@ void RXA::setDSPSamplerate (RXA *rxa, int dsp_rate)
EMNR::setSamplerate_emnr (rxa->emnr, rxa->dsp_rate);
BANDPASS::setSamplerate_bandpass (rxa->bp1, rxa->dsp_rate);
WCPAGC::setSamplerate_wcpagc (rxa->agc, rxa->dsp_rate);
METER::setSamplerate_meter (rxa->agcmeter, rxa->dsp_rate);
rxa->agcmeter->setSamplerate(rxa->dsp_rate);
SIPHON::setSamplerate_siphon (rxa->sip1, rxa->dsp_rate);
CBL::setSamplerate_cbl (rxa->cbl, rxa->dsp_rate);
SPEAK::setSamplerate_speak (rxa->speak, rxa->dsp_rate);
@ -815,14 +815,14 @@ void RXA::setDSPBuffsize (RXA *rxa, int dsp_size)
rxa->rsmpin->setBuffers(rxa->inbuff, rxa->midbuff);
rxa->rsmpin->setSize(rxa->dsp_insize);
// dsp_size blocks
METER::setBuffers_meter (rxa->adcmeter, rxa->midbuff);
METER::setSize_meter (rxa->adcmeter, rxa->dsp_size);
rxa->adcmeter->setBuffers(rxa->midbuff);
rxa->adcmeter->setSize(rxa->dsp_size);
NBP::setBuffers_nbp (rxa->nbp0, rxa->midbuff, rxa->midbuff);
NBP::setSize_nbp (rxa->nbp0, rxa->dsp_size);
BPSNBA::setBuffers_bpsnba (rxa->bpsnba, rxa->midbuff, rxa->midbuff);
BPSNBA::setSize_bpsnba (rxa->bpsnba, rxa->dsp_size);
METER::setBuffers_meter (rxa->smeter, rxa->midbuff);
METER::setSize_meter (rxa->smeter, rxa->dsp_size);
rxa->smeter->setBuffers(rxa->midbuff);
rxa->smeter->METER::setSize(rxa->dsp_size);
SENDER::setBuffers_sender (rxa->sender, rxa->midbuff);
SENDER::setSize_sender (rxa->sender, rxa->dsp_size);
AMSQ::setBuffers_amsq (rxa->amsq, rxa->midbuff, rxa->midbuff, rxa->midbuff);
@ -847,8 +847,8 @@ void RXA::setDSPBuffsize (RXA *rxa, int dsp_size)
BANDPASS::setSize_bandpass (rxa->bp1, rxa->dsp_size);
WCPAGC::setBuffers_wcpagc (rxa->agc, rxa->midbuff, rxa->midbuff);
WCPAGC::setSize_wcpagc (rxa->agc, rxa->dsp_size);
METER::setBuffers_meter (rxa->agcmeter, rxa->midbuff);
METER::setSize_meter (rxa->agcmeter, rxa->dsp_size);
rxa->agcmeter->METER::setBuffers(rxa->midbuff);
rxa->agcmeter->METER::setSize(rxa->dsp_size);
SIPHON::setBuffers_siphon (rxa->sip1, rxa->midbuff);
SIPHON::setSize_siphon (rxa->sip1, rxa->dsp_size);
CBL::setBuffers_cbl (rxa->cbl, rxa->midbuff, rxa->midbuff);

View File

@ -121,7 +121,7 @@ TXA* TXA::create_txa (
338.0, // 1/2 of phase frequency
8); // number of stages
txa->micmeter.p = METER::create_meter (
txa->micmeter.p = new METER(
1, // run
0, // optional pointer to another 'run'
txa->dsp_size, // size
@ -170,7 +170,7 @@ TXA* TXA::create_txa (
txa->dsp_rate); // samplerate
}
txa->eqmeter.p = METER::create_meter (
txa->eqmeter.p = new METER(
1, // run
&(txa->eqp.p->run), // pointer to eqp 'run'
txa->dsp_size, // size
@ -222,7 +222,7 @@ TXA* TXA::create_txa (
2.000, // hang_thresh
0.100); // tau_hang_decay
txa->lvlrmeter.p = METER::create_meter (
txa->lvlrmeter.p = new METER(
1, // run
&(txa->leveler.p->run), // pointer to leveler 'run'
txa->dsp_size, // size
@ -262,7 +262,7 @@ TXA* TXA::create_txa (
0.50); // display time constant
}
txa->cfcmeter.p = METER::create_meter (
txa->cfcmeter.p = new METER(
1, // run
&(txa->cfcomp.p->run), // pointer to eqp 'run'
txa->dsp_size, // size
@ -333,7 +333,7 @@ TXA* TXA::create_txa (
1, // wintype
1.0); // gain
txa->compmeter.p = METER::create_meter (
txa->compmeter.p = new METER(
1, // run
&(txa->compressor.p->run), // pointer to compressor 'run'
txa->dsp_size, // size
@ -415,7 +415,7 @@ TXA* TXA::create_txa (
0.000, // delay time
0.005); // upslew time
txa->alcmeter.p = METER::create_meter (
txa->alcmeter.p = new METER(
1, // run
0, // optional pointer to a 'run'
txa->dsp_size, // size
@ -497,7 +497,7 @@ TXA* TXA::create_txa (
0, // select ncoef automatically
0.980); // gain
txa->outmeter.p = METER::create_meter (
txa->outmeter.p = new METER(
1, // run
0, // optional pointer to another 'run'
txa->dsp_outsize, // size
@ -519,33 +519,33 @@ TXA* TXA::create_txa (
void TXA::destroy_txa (TXA *txa)
{
// in reverse order, free each item we created
METER::destroy_meter (txa->outmeter.p);
delete (txa->outmeter.p);
delete (txa->rsmpout.p);
CFIR::destroy_cfir(txa->cfir.p);
// destroy_calcc (txa->calcc.p);
IQC::destroy_iqc (txa->iqc.p0);
SIPHON::destroy_siphon (txa->sip1.p);
METER::destroy_meter (txa->alcmeter.p);
delete (txa->alcmeter.p);
USLEW::destroy_uslew (txa->uslew.p);
delete (txa->gen1.p);
FMMOD::destroy_fmmod (txa->fmmod.p);
AMMOD::destroy_ammod (txa->ammod.p);
WCPAGC::destroy_wcpagc (txa->alc.p);
METER::destroy_meter (txa->compmeter.p);
delete (txa->compmeter.p);
BANDPASS::destroy_bandpass (txa->bp2.p);
OSCTRL::destroy_osctrl (txa->osctrl.p);
BANDPASS::destroy_bandpass (txa->bp1.p);
COMPRESSOR::destroy_compressor (txa->compressor.p);
BANDPASS::destroy_bandpass (txa->bp0.p);
METER::destroy_meter (txa->cfcmeter.p);
delete (txa->cfcmeter.p);
CFCOMP::destroy_cfcomp (txa->cfcomp.p);
METER::destroy_meter (txa->lvlrmeter.p);
delete (txa->lvlrmeter.p);
WCPAGC::destroy_wcpagc (txa->leveler.p);
EMPHP::destroy_emphp (txa->preemph.p);
METER::destroy_meter (txa->eqmeter.p);
delete (txa->eqmeter.p);
EQP::destroy_eqp (txa->eqp.p);
AMSQ::destroy_amsq (txa->amsq.p);
METER::destroy_meter (txa->micmeter.p);
delete (txa->micmeter.p);
PHROT::destroy_phrot (txa->phrot.p);
PANEL::destroy_panel (txa->panel.p);
delete (txa->gen0.p);
@ -565,32 +565,32 @@ void TXA::flush_txa (TXA* txa)
txa->gen0.p->flush();
PANEL::flush_panel (txa->panel.p);
PHROT::flush_phrot (txa->phrot.p);
METER::flush_meter (txa->micmeter.p);
txa->micmeter.p->flush ();
AMSQ::flush_amsq (txa->amsq.p);
EQP::flush_eqp (txa->eqp.p);
METER::flush_meter (txa->eqmeter.p);
txa->eqmeter.p->flush ();
EMPHP::flush_emphp (txa->preemph.p);
WCPAGC::flush_wcpagc (txa->leveler.p);
METER::flush_meter (txa->lvlrmeter.p);
txa->lvlrmeter.p->flush ();
CFCOMP::flush_cfcomp (txa->cfcomp.p);
METER::flush_meter (txa->cfcmeter.p);
txa->cfcmeter.p->flush ();
BANDPASS::flush_bandpass (txa->bp0.p);
COMPRESSOR::flush_compressor (txa->compressor.p);
BANDPASS::flush_bandpass (txa->bp1.p);
OSCTRL::flush_osctrl (txa->osctrl.p);
BANDPASS::flush_bandpass (txa->bp2.p);
METER::flush_meter (txa->compmeter.p);
txa->compmeter.p->flush ();
WCPAGC::flush_wcpagc (txa->alc.p);
AMMOD::flush_ammod (txa->ammod.p);
FMMOD::flush_fmmod (txa->fmmod.p);
txa->gen1.p->flush();
USLEW::flush_uslew (txa->uslew.p);
METER::flush_meter (txa->alcmeter.p);
txa->alcmeter.p->flush ();
SIPHON::flush_siphon (txa->sip1.p);
IQC::flush_iqc (txa->iqc.p0);
CFIR::flush_cfir(txa->cfir.p);
txa->rsmpout.p->flush();
METER::flush_meter (txa->outmeter.p);
txa->outmeter.p->flush ();
}
void xtxa (TXA* txa)
@ -599,34 +599,34 @@ void xtxa (TXA* txa)
txa->gen0.p->execute(); // input signal generator
PANEL::xpanel (txa->panel.p); // includes MIC gain
PHROT::xphrot (txa->phrot.p); // phase rotator
METER::xmeter (txa->micmeter.p); // MIC meter
txa->micmeter.p->execute (); // MIC meter
AMSQ::xamsqcap (txa->amsq.p); // downward expander capture
AMSQ::xamsq (txa->amsq.p); // downward expander action
EQP::xeqp (txa->eqp.p); // pre-EQ
METER::xmeter (txa->eqmeter.p); // EQ meter
txa->eqmeter.p->execute (); // EQ meter
EMPHP::xemphp (txa->preemph.p, 0); // FM pre-emphasis (first option)
WCPAGC::xwcpagc (txa->leveler.p); // Leveler
METER::xmeter (txa->lvlrmeter.p); // Leveler Meter
txa->lvlrmeter.p->execute (); // Leveler Meter
CFCOMP::xcfcomp (txa->cfcomp.p, 0); // Continuous Frequency Compressor with post-EQ
METER::xmeter (txa->cfcmeter.p); // CFC+PostEQ Meter
txa->cfcmeter.p->execute (); // CFC+PostEQ Meter
BANDPASS::xbandpass (txa->bp0.p, 0); // primary bandpass filter
COMPRESSOR::xcompressor (txa->compressor.p); // COMP compressor
BANDPASS::xbandpass (txa->bp1.p, 0); // aux bandpass (runs if COMP)
OSCTRL::xosctrl (txa->osctrl.p); // CESSB Overshoot Control
BANDPASS::xbandpass (txa->bp2.p, 0); // aux bandpass (runs if CESSB)
METER::xmeter (txa->compmeter.p); // COMP meter
txa->compmeter.p->execute (); // COMP meter
WCPAGC::xwcpagc (txa->alc.p); // ALC
AMMOD::xammod (txa->ammod.p); // AM Modulator
EMPHP::xemphp (txa->preemph.p, 1); // FM pre-emphasis (second option)
FMMOD::xfmmod (txa->fmmod.p); // FM Modulator
txa->gen1.p->execute(); // output signal generator (TUN and Two-tone)
USLEW::xuslew (txa->uslew.p); // up-slew for AM, FM, and gens
METER::xmeter (txa->alcmeter.p); // ALC Meter
txa->alcmeter.p->execute (); // ALC Meter
SIPHON::xsiphon (txa->sip1.p, 0); // siphon data for display
IQC::xiqc (txa->iqc.p0); // PureSignal correction
CFIR::xcfir(txa->cfir.p); // compensating FIR filter (used Protocol_2 only)
txa->rsmpout.p->execute(); // output resampler
METER::xmeter (txa->outmeter.p); // output meter
txa->outmeter.p->execute (); // output meter
// print_peak_env ("env_exception.txt", txa->dsp_outsize, txa->outbuff, 0.7);
}
@ -666,9 +666,9 @@ void TXA::setOutputSamplerate (TXA* txa, int out_rate)
txa->rsmpout.p->setOutRate(txa->out_rate);
ResCheck (*txa);
// output meter
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->outmeter.p->setBuffers(txa->outbuff);
txa->outmeter.p->setSize(txa->dsp_outsize);
txa->outmeter.p->setSamplerate (txa->out_rate);
}
void TXA::setDSPSamplerate (TXA *txa, int dsp_rate)
@ -697,27 +697,27 @@ void TXA::setDSPSamplerate (TXA *txa, int dsp_rate)
txa->gen0.p->setSamplerate(txa->dsp_rate);
PANEL::setSamplerate_panel (txa->panel.p, txa->dsp_rate);
PHROT::setSamplerate_phrot (txa->phrot.p, txa->dsp_rate);
METER::setSamplerate_meter (txa->micmeter.p, txa->dsp_rate);
txa->micmeter.p->setSamplerate (txa->dsp_rate);
AMSQ::setSamplerate_amsq (txa->amsq.p, txa->dsp_rate);
EQP::setSamplerate_eqp (txa->eqp.p, txa->dsp_rate);
METER::setSamplerate_meter (txa->eqmeter.p, txa->dsp_rate);
txa->eqmeter.p->setSamplerate (txa->dsp_rate);
EMPHP::setSamplerate_emphp (txa->preemph.p, txa->dsp_rate);
WCPAGC::setSamplerate_wcpagc (txa->leveler.p, txa->dsp_rate);
METER::setSamplerate_meter (txa->lvlrmeter.p, txa->dsp_rate);
txa->lvlrmeter.p->setSamplerate (txa->dsp_rate);
CFCOMP::setSamplerate_cfcomp (txa->cfcomp.p, txa->dsp_rate);
METER::setSamplerate_meter (txa->cfcmeter.p, txa->dsp_rate);
txa->cfcmeter.p->setSamplerate (txa->dsp_rate);
BANDPASS::setSamplerate_bandpass (txa->bp0.p, txa->dsp_rate);
COMPRESSOR::setSamplerate_compressor (txa->compressor.p, txa->dsp_rate);
BANDPASS::setSamplerate_bandpass (txa->bp1.p, txa->dsp_rate);
OSCTRL::setSamplerate_osctrl (txa->osctrl.p, txa->dsp_rate);
BANDPASS::setSamplerate_bandpass (txa->bp2.p, txa->dsp_rate);
METER::setSamplerate_meter (txa->compmeter.p, txa->dsp_rate);
txa->compmeter.p->setSamplerate (txa->dsp_rate);
WCPAGC::setSamplerate_wcpagc (txa->alc.p, txa->dsp_rate);
AMMOD::setSamplerate_ammod (txa->ammod.p, txa->dsp_rate);
FMMOD::setSamplerate_fmmod (txa->fmmod.p, txa->dsp_rate);
txa->gen1.p->setSamplerate(txa->dsp_rate);
USLEW::setSamplerate_uslew (txa->uslew.p, txa->dsp_rate);
METER::setSamplerate_meter (txa->alcmeter.p, txa->dsp_rate);
txa->alcmeter.p->setSamplerate (txa->dsp_rate);
SIPHON::setSamplerate_siphon (txa->sip1.p, txa->dsp_rate);
IQC::setSamplerate_iqc (txa->iqc.p0, txa->dsp_rate);
CFIR::setSamplerate_cfir (txa->cfir.p, txa->dsp_rate);
@ -726,8 +726,8 @@ void TXA::setDSPSamplerate (TXA *txa, int dsp_rate)
txa->rsmpout.p->setInRate(txa->dsp_rate);
ResCheck (*txa);
// output meter
METER::setBuffers_meter (txa->outmeter.p, txa->outbuff);
METER::setSize_meter (txa->outmeter.p, txa->dsp_outsize);
txa->outmeter.p->setBuffers(txa->outbuff);
txa->outmeter.p->setSize (txa->dsp_outsize);
}
void TXA::setDSPBuffsize (TXA *txa, int dsp_size)
@ -760,24 +760,24 @@ void TXA::setDSPBuffsize (TXA *txa, int dsp_size)
PANEL::setSize_panel (txa->panel.p, txa->dsp_size);
PHROT::setBuffers_phrot (txa->phrot.p, txa->midbuff, txa->midbuff);
PHROT::setSize_phrot (txa->phrot.p, txa->dsp_size);
METER::setBuffers_meter (txa->micmeter.p, txa->midbuff);
METER::setSize_meter (txa->micmeter.p, txa->dsp_size);
txa->micmeter.p->setBuffers (txa->midbuff);
txa->micmeter.p->setSize (txa->dsp_size);
AMSQ::setBuffers_amsq (txa->amsq.p, txa->midbuff, txa->midbuff, txa->midbuff);
AMSQ::setSize_amsq (txa->amsq.p, txa->dsp_size);
EQP::setBuffers_eqp (txa->eqp.p, txa->midbuff, txa->midbuff);
EQP::setSize_eqp (txa->eqp.p, txa->dsp_size);
METER::setBuffers_meter (txa->eqmeter.p, txa->midbuff);
METER::setSize_meter (txa->eqmeter.p, txa->dsp_size);
txa->eqmeter.p->setBuffers (txa->midbuff);
txa->eqmeter.p->setSize (txa->dsp_size);
EMPHP::setBuffers_emphp (txa->preemph.p, txa->midbuff, txa->midbuff);
EMPHP::setSize_emphp (txa->preemph.p, txa->dsp_size);
WCPAGC::setBuffers_wcpagc (txa->leveler.p, txa->midbuff, txa->midbuff);
WCPAGC::setSize_wcpagc (txa->leveler.p, txa->dsp_size);
METER::setBuffers_meter (txa->lvlrmeter.p, txa->midbuff);
METER::setSize_meter (txa->lvlrmeter.p, txa->dsp_size);
txa->lvlrmeter.p->setBuffers(txa->midbuff);
txa->lvlrmeter.p->setSize(txa->dsp_size);
CFCOMP::setBuffers_cfcomp (txa->cfcomp.p, txa->midbuff, txa->midbuff);
CFCOMP::setSize_cfcomp (txa->cfcomp.p, txa->dsp_size);
METER::setBuffers_meter (txa->cfcmeter.p, txa->midbuff);
METER::setSize_meter (txa->cfcmeter.p, txa->dsp_size);
txa->cfcmeter.p->setBuffers(txa->midbuff);
txa->cfcmeter.p->setSize(txa->dsp_size);
BANDPASS::setBuffers_bandpass (txa->bp0.p, txa->midbuff, txa->midbuff);
BANDPASS::setSize_bandpass (txa->bp0.p, txa->dsp_size);
COMPRESSOR::setBuffers_compressor (txa->compressor.p, txa->midbuff, txa->midbuff);
@ -788,8 +788,8 @@ void TXA::setDSPBuffsize (TXA *txa, int dsp_size)
OSCTRL::setSize_osctrl (txa->osctrl.p, txa->dsp_size);
BANDPASS::setBuffers_bandpass (txa->bp2.p, txa->midbuff, txa->midbuff);
BANDPASS::setSize_bandpass (txa->bp2.p, txa->dsp_size);
METER::setBuffers_meter (txa->compmeter.p, txa->midbuff);
METER::setSize_meter (txa->compmeter.p, txa->dsp_size);
txa->compmeter.p->setBuffers(txa->midbuff);
txa->compmeter.p->setSize(txa->dsp_size);
WCPAGC::setBuffers_wcpagc (txa->alc.p, txa->midbuff, txa->midbuff);
WCPAGC::setSize_wcpagc (txa->alc.p, txa->dsp_size);
AMMOD::setBuffers_ammod (txa->ammod.p, txa->midbuff, txa->midbuff);
@ -800,8 +800,8 @@ void TXA::setDSPBuffsize (TXA *txa, int dsp_size)
txa->gen1.p->setSize(txa->dsp_size);
USLEW::setBuffers_uslew (txa->uslew.p, txa->midbuff, txa->midbuff);
USLEW::setSize_uslew (txa->uslew.p, txa->dsp_size);
METER::setBuffers_meter (txa->alcmeter.p, txa->midbuff);
METER::setSize_meter (txa->alcmeter.p, txa->dsp_size);
txa->alcmeter.p->setBuffers (txa->midbuff);
txa->alcmeter.p->setSize(txa->dsp_size);
SIPHON::setBuffers_siphon (txa->sip1.p, txa->midbuff);
SIPHON::setSize_siphon (txa->sip1.p, txa->dsp_size);
IQC::setBuffers_iqc (txa->iqc.p0, txa->midbuff, txa->midbuff);
@ -812,8 +812,8 @@ void TXA::setDSPBuffsize (TXA *txa, int dsp_size)
txa->rsmpout.p->setBuffers(txa->midbuff, txa->outbuff);
txa->rsmpout.p->setSize(txa->dsp_size);
// output meter
METER::setBuffers_meter (txa->outmeter.p, txa->outbuff);
METER::setSize_meter (txa->outmeter.p, txa->dsp_outsize);
txa->outmeter.p->setBuffers(txa->outbuff);
txa->outmeter.p->setSize(txa->dsp_outsize);
}
/********************************************************************************************************

View File

@ -28,152 +28,130 @@ warren@wpratt.com
#include "comm.hpp"
#include "meterlog10.hpp"
#include "meter.hpp"
#include "RXA.hpp"
#include "TXA.hpp"
namespace WDSP {
void METER::calc_meter (METER *a)
void METER::calc()
{
a->mult_average = exp(-1.0 / (a->rate * a->tau_average));
a->mult_peak = exp(-1.0 / (a->rate * a->tau_peak_decay));
flush_meter(a);
mult_average = exp(-1.0 / (rate * tau_average));
mult_peak = exp(-1.0 / (rate * tau_peak_decay));
flush();
}
METER* METER::create_meter (
int run,
int* prun,
int size,
float* buff,
int rate,
double tau_av,
double tau_decay,
double* result,
int enum_av,
int enum_pk,
int enum_gain,
double* pgain
METER::METER(
int _run,
int* _prun,
int _size,
float* _buff,
int _rate,
double _tau_av,
double _tau_decay,
double* _result,
int _enum_av,
int _enum_pk,
int _enum_gain,
double* _pgain
)
{
METER *a = new METER;
a->run = run;
a->prun = prun;
a->size = size;
a->buff = buff;
a->rate = (double) rate;
a->tau_average = tau_av;
a->tau_peak_decay = tau_decay;
a->result = result;
a->enum_av = enum_av;
a->enum_pk = enum_pk;
a->enum_gain = enum_gain;
a->pgain = pgain;
calc_meter(a);
return a;
run = _run;
prun = _prun;
size = _size;
buff = _buff;
rate = (double) _rate;
tau_average = _tau_av;
tau_peak_decay = _tau_decay;
result = _result;
enum_av = _enum_av;
enum_pk = _enum_pk;
enum_gain = _enum_gain;
pgain = _pgain;
calc();
}
void METER::destroy_meter (METER *a)
void METER::flush()
{
delete a;
avg = 0.0;
peak = 0.0;
result[enum_av] = -100.0;
result[enum_pk] = -100.0;
if ((pgain != 0) && (enum_gain >= 0))
result[enum_gain] = 0.0;
}
void METER::flush_meter (METER *a)
{
a->avg = 0.0;
a->peak = 0.0;
a->result[a->enum_av] = -100.0;
a->result[a->enum_pk] = -100.0;
if ((a->pgain != 0) && (a->enum_gain >= 0))
a->result[a->enum_gain] = 0.0;
}
void METER::xmeter (METER *a)
void METER::execute()
{
int srun;
if (a->prun != 0)
srun = *(a->prun);
if (prun != 0)
srun = *(prun);
else
srun = 1;
if (a->run && srun)
if (run && srun)
{
int i;
double smag;
double np = 0.0;
for (i = 0; i < a->size; i++)
for (i = 0; i < size; i++)
{
double xr = a->buff[2 * i + 0];
double xi = a->buff[2 * i + 1];
double xr = buff[2 * i + 0];
double xi = buff[2 * i + 1];
smag = xr*xr + xi*xi;
a->avg = a->avg * a->mult_average + (1.0 - a->mult_average) * smag;
a->peak *= a->mult_peak;
avg = avg * mult_average + (1.0 - mult_average) * smag;
peak *= mult_peak;
if (smag > np)
np = smag;
}
if (np > a->peak)
a->peak = np;
if (np > peak)
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);
result[enum_av] = 10.0 * MemLog::mlog10 (avg + 1.0e-40);
result[enum_pk] = 10.0 * MemLog::mlog10 (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);
if ((pgain != 0) && (enum_gain >= 0))
result[enum_gain] = 20.0 * MemLog::mlog10 (*pgain + 1.0e-40);
}
else
{
if (a->enum_av >= 0)
a->result[a->enum_av] = -100.0;
if (a->enum_pk >= 0)
a->result[a->enum_pk] = -100.0;
if (a->enum_gain >= 0)
a->result[a->enum_gain] = 0.0;
if (enum_av >= 0)
result[enum_av] = -100.0;
if (enum_pk >= 0)
result[enum_pk] = -100.0;
if (enum_gain >= 0)
result[enum_gain] = 0.0;
}
}
void METER::setBuffers_meter (METER *a, float* in)
void METER::setBuffers(float* in)
{
a->buff = in;
buff = in;
}
void METER::setSamplerate_meter (METER *a, int rate)
void METER::setSamplerate(int _rate)
{
a->rate = (double) rate;
calc_meter(a);
rate = (double) _rate;
calc();
}
void METER::setSize_meter (METER *a, int size)
void METER::setSize(int _size)
{
a->size = size;
flush_meter (a);
size = _size;
flush();
}
/********************************************************************************************************
* *
* RXA Properties *
* Public Properties *
* *
********************************************************************************************************/
double METER::GetMeter (RXA& rxa, int mt)
double METER::getMeter(int mt)
{
double val = rxa.meter[mt];
return val;
}
/********************************************************************************************************
* *
* TXA Properties *
* *
********************************************************************************************************/
double METER::GetMeter (TXA& txa, int mt)
{
double val = txa.meter[mt];
return val;
return result[mt];
}
} // namespace WDSP

View File

@ -32,9 +32,6 @@ warren@wpratt.com
namespace WDSP {
class RXA;
class TXA;
class WDSP_API METER
{
public:
@ -55,7 +52,7 @@ public:
double avg;
double peak;
static METER* create_meter (
METER(
int run,
int* prun,
int size,
@ -69,19 +66,17 @@ public:
int enum_gain,
double* pgain
);
static void destroy_meter (METER *a);
static void flush_meter (METER *a);
static void xmeter (METER *a);
static void setBuffers_meter (METER *a, float* in);
static void setSamplerate_meter (METER *a, int rate);
static void setSize_meter (METER *a, int size);
// RXA Properties
static double GetMeter (RXA& rxa, int mt);
// TXA Properties
static double GetMeter (TXA& txa, int mt);
~METER() = default;
void flush();
void execute();
void setBuffers(float* in);
void setSamplerate(int rate);
void setSize(int size);
double getMeter(int mt);
private:
static void calc_meter (METER *a);
void calc();
};