1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-03-21 03:38:38 -04:00

WDSP: SNBA and EQ: replaced static methods and more...

This commit is contained in:
f4exb 2024-07-27 05:32:45 +02:00
parent 8c08f40b54
commit d3cbfe0e3c
28 changed files with 1321 additions and 1434 deletions

View File

@ -565,7 +565,7 @@ void WDSPRxSink::applySettings(const WDSPRxSettings& settings, bool force)
// Caution: Causes corruption
if ((m_settings.m_snb != settings.m_snb) || force) {
WDSP::SNBA::SetSNBARun(*m_rxa, settings.m_snb ? 1 : 0);
WDSP::RXA::SetSNBARun(*m_rxa, settings.m_snb ? 1 : 0);
}
// CW Peaking
@ -731,13 +731,13 @@ void WDSPRxSink::applySettings(const WDSPRxSettings& settings, bool force)
// Equalizer
if ((m_settings.m_equalizer != settings.m_equalizer) || force) {
WDSP::EQP::SetEQRun(*m_rxa, settings.m_equalizer ? 1 : 0);
m_rxa->eqp->setRun(settings.m_equalizer ? 1 : 0);
}
if ((m_settings.m_eqF != settings.m_eqF)
|| (m_settings.m_eqG != settings.m_eqG) || force)
{
WDSP::EQP::SetEQProfile(*m_rxa, 10, settings.m_eqF.data(), settings.m_eqG.data());
m_rxa->eqp->setProfile(10, settings.m_eqF.data(), settings.m_eqG.data());
}
// Audio panel

View File

@ -20,7 +20,7 @@ set(wdsp_SOURCES
delay.cpp
emnr.cpp
emph.cpp
eq.cpp
eqp.cpp
fcurve.cpp
fir.cpp
fircore.cpp
@ -77,7 +77,7 @@ set(wdsp_HEADERS
delay.hpp
emnr.hpp
emph.hpp
eq.hpp
eqp.hpp
fcurve.hpp
fir.hpp
fircore.hpp

View File

@ -41,7 +41,7 @@ warren@wpratt.com
#include "amsq.hpp"
#include "fmd.hpp"
#include "fmsq.hpp"
#include "eq.hpp"
#include "eqp.hpp"
#include "anf.hpp"
#include "anr.hpp"
#include "emnr.hpp"
@ -306,7 +306,7 @@ RXA* RXA::create_rxa (
0); // minimum phase flag
// Spectral noise blanker (SNB)
rxa->snba = SNBA::create_snba (
rxa->snba = new SNBA(
0, // run
rxa->midbuff, // input buffer
rxa->midbuff, // output buffer
@ -331,7 +331,7 @@ RXA* RXA::create_rxa (
float default_F[11] = {0.0, 32.0, 63.0, 125.0, 250.0, 500.0, 1000.0, 2000.0, 4000.0, 8000.0, 16000.0};
//float default_G[11] = {0.0, -12.0, -12.0, -12.0, -1.0, +1.0, +4.0, +9.0, +12.0, -10.0, -10.0};
float default_G[11] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
rxa->eqp = EQP::create_eqp (
rxa->eqp = new EQP(
0, // run - OFF by default
rxa->dsp_size, // buffer size
std::max(2048, rxa->dsp_size), // number of filter coefficients
@ -576,8 +576,8 @@ void RXA::destroy_rxa (RXA *rxa)
EMNR::destroy_emnr (rxa->emnr);
ANR::destroy_anr (rxa->anr);
ANF::destroy_anf (rxa->anf);
EQP::destroy_eqp (rxa->eqp);
SNBA::destroy_snba (rxa->snba);
delete (rxa->eqp);
delete (rxa->snba);
delete (rxa->fmsq);
delete (rxa->fmd);
delete (rxa->amd);
@ -616,8 +616,8 @@ void RXA::flush_rxa (RXA *rxa)
rxa->amd->flush();
rxa->fmd->flush();
rxa->fmsq->flush();
SNBA::flush_snba (rxa->snba);
EQP::flush_eqp (rxa->eqp);
rxa->snba->flush();
rxa->eqp->flush();
ANF::flush_anf (rxa->anf);
ANR::flush_anr (rxa->anr);
EMNR::flush_emnr (rxa->emnr);
@ -651,8 +651,8 @@ void RXA::xrxa (RXA *rxa)
rxa->fmsq->execute();
rxa->bpsnba->exec_in(1);
rxa->bpsnba->exec_out(1);
SNBA::xsnba (rxa->snba);
EQP::xeqp (rxa->eqp);
rxa->snba->execute();
rxa->eqp->execute();
ANF::xanf (rxa->anf, 0);
ANR::xanr (rxa->anr, 0);
EMNR::xemnr (rxa->emnr, 0);
@ -762,8 +762,8 @@ void RXA::setDSPSamplerate (RXA *rxa, int dsp_rate)
rxa->fmd->setSamplerate(rxa->dsp_rate);
rxa->fmsq->setBuffers(rxa->midbuff, rxa->midbuff, rxa->fmd->audio);
rxa->fmsq->setSamplerate(rxa->dsp_rate);
SNBA::setSamplerate_snba (rxa->snba, rxa->dsp_rate);
EQP::setSamplerate_eqp (rxa->eqp, rxa->dsp_rate);
rxa->snba->setSamplerate(rxa->dsp_rate);
rxa->eqp->setSamplerate(rxa->dsp_rate);
ANF::setSamplerate_anf (rxa->anf, rxa->dsp_rate);
ANR::setSamplerate_anr (rxa->anr, rxa->dsp_rate);
EMNR::setSamplerate_emnr (rxa->emnr, rxa->dsp_rate);
@ -833,10 +833,10 @@ void RXA::setDSPBuffsize (RXA *rxa, int dsp_size)
rxa->fmd->setSize(rxa->dsp_size);
rxa->fmsq->setBuffers(rxa->midbuff, rxa->midbuff, rxa->fmd->audio);
rxa->fmsq->setSize(rxa->dsp_size);
SNBA::setBuffers_snba (rxa->snba, rxa->midbuff, rxa->midbuff);
SNBA::setSize_snba (rxa->snba, rxa->dsp_size);
EQP::setBuffers_eqp (rxa->eqp, rxa->midbuff, rxa->midbuff);
EQP::setSize_eqp (rxa->eqp, rxa->dsp_size);
rxa->snba->setBuffers(rxa->midbuff, rxa->midbuff);
rxa->snba->setSize(rxa->dsp_size);
rxa->eqp->setBuffers(rxa->midbuff, rxa->midbuff);
rxa->eqp->setSize(rxa->dsp_size);
ANF::setBuffers_anf (rxa->anf, rxa->midbuff, rxa->midbuff);
ANF::setSize_anf (rxa->anf, rxa->dsp_size);
ANR::setBuffers_anr (rxa->anr, rxa->midbuff, rxa->midbuff);
@ -1243,6 +1243,27 @@ void RXA::SetAMDRun(RXA& rxa, int _run)
}
}
void RXA::SetSNBARun (RXA& rxa, int run)
{
SNBA *a = rxa.snba;
if (a->run != run)
{
RXA::bpsnbaCheck (rxa, rxa.mode, rxa.ndb->master_run);
RXA::bp1Check (
rxa,
rxa.amd->run,
run,
rxa.emnr->run,
rxa.anf->run,
rxa.anr->run
);
a->run = run;
RXA::bp1Set (rxa);
RXA::bpsnbaSet (rxa);
}
}
/********************************************************************************************************
* *
* Collectives *
@ -1252,7 +1273,7 @@ void RXA::SetAMDRun(RXA& rxa, int _run)
void RXA::SetPassband (RXA& rxa, float f_low, float f_high)
{
BANDPASS::SetBandpassFreqs (rxa, f_low, f_high); // After spectral noise reduction ( AM || ANF || ANR || EMNR)
SNBA::SetSNBAOutputBandwidth (rxa, f_low, f_high); // Spectral noise blanker (SNB)
rxa.snba->setOutputBandwidth (f_low, f_high); // Spectral noise blanker (SNB)
rxa.nbp0->SetFreqs (f_low, f_high); // Notched bandpass
}
@ -1262,7 +1283,7 @@ void RXA::SetNC (RXA& rxa, int nc)
rxa.nbp0->SetNC (nc);
rxa.bpsnba->SetNC (nc);
BANDPASS::SetBandpassNC (rxa, nc);
EQP::SetEQNC (rxa, nc);
rxa.eqp->setNC (nc);
rxa.fmsq->setNC (nc);
rxa.fmd->setNCde (nc);
rxa.fmd->setNCaud (nc);
@ -1274,7 +1295,7 @@ void RXA::SetMP (RXA& rxa, int mp)
rxa.nbp0->SetMP (mp);
rxa.bpsnba->SetMP (mp);
BANDPASS::SetBandpassMP (rxa, mp);
EQP::SetEQMP (rxa, mp);
rxa.eqp->setMP (mp);
rxa.fmsq->setMP (mp);
rxa.fmd->setMPde (mp);
rxa.fmd->setMPaud (mp);

View File

@ -169,6 +169,8 @@ public:
static void NBPSetAutoIncrease (RXA& rxa, int autoincr);
// AMD
static void SetAMDRun(RXA& rxa, int run);
// SNBA
static void SetSNBARun (RXA& rxa, int run);
// Collectives
static void SetPassband (RXA& rxa, float f_low, float f_high);

View File

@ -82,7 +82,7 @@ TXA* TXA::create_txa (
txa->outbuff = new float[1 * txa->dsp_outsize * 2]; // (float *) malloc0 (1 * txa->dsp_outsize * sizeof (complex));
txa->midbuff = new float[3 * txa->dsp_size * 2]; //(float *) malloc0 (2 * txa->dsp_size * sizeof (complex));
txa->rsmpin.p = new RESAMPLE(
txa->rsmpin = new RESAMPLE(
0, // run - will be turned on below if needed
txa->dsp_insize, // input buffer size
txa->inbuff, // pointer to input buffer
@ -93,7 +93,7 @@ TXA* TXA::create_txa (
0, // select ncoef automatically
1.0); // gain
txa->gen0.p = new GEN(
txa->gen0 = new GEN(
0, // run
txa->dsp_size, // buffer size
txa->midbuff, // input buffer
@ -101,7 +101,7 @@ TXA* TXA::create_txa (
txa->dsp_rate, // sample rate
2); // mode
txa->panel.p = PANEL::create_panel (
txa->panel = PANEL::create_panel (
1, // run
txa->dsp_size, // size
txa->midbuff, // pointer to input buffer
@ -112,7 +112,7 @@ TXA* TXA::create_txa (
2, // 1 to use Q, 2 to use I for input
0); // 0, no copy
txa->phrot.p = PHROT::create_phrot (
txa->phrot = PHROT::create_phrot (
0, // run
txa->dsp_size, // size
txa->midbuff, // input buffer
@ -121,7 +121,7 @@ TXA* TXA::create_txa (
338.0, // 1/2 of phase frequency
8); // number of stages
txa->micmeter.p = new METER(
txa->micmeter = new METER(
1, // run
0, // optional pointer to another 'run'
txa->dsp_size, // size
@ -135,7 +135,7 @@ TXA* TXA::create_txa (
-1, // index for gain value
0); // pointer for gain computation
txa->amsq.p = new AMSQ(
txa->amsq = new AMSQ(
0, // run
txa->dsp_size, // size
txa->midbuff, // input buffer
@ -155,7 +155,7 @@ TXA* TXA::create_txa (
float default_F[11] = {0.0, 32.0, 63.0, 125.0, 250.0, 500.0, 1000.0, 2000.0, 4000.0, 8000.0, 16000.0};
float default_G[11] = {0.0, -12.0, -12.0, -12.0, -1.0, +1.0, +4.0, +9.0, +12.0, -10.0, -10.0};
//float default_G[11] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
txa->eqp.p = EQP::create_eqp (
txa->eqp = new EQP (
0, // run - OFF by default
txa->dsp_size, // size
std::max(2048, txa->dsp_size), // number of filter coefficients
@ -170,9 +170,9 @@ TXA* TXA::create_txa (
txa->dsp_rate); // samplerate
}
txa->eqmeter.p = new METER(
txa->eqmeter = new METER(
1, // run
&(txa->eqp.p->run), // pointer to eqp 'run'
&(txa->eqp->run), // pointer to eqp 'run'
txa->dsp_size, // size
txa->midbuff, // pointer to buffer
txa->dsp_rate, // samplerate
@ -184,7 +184,7 @@ TXA* TXA::create_txa (
-1, // index for gain value
0); // pointer for gain computation
txa->preemph.p = EMPHP::create_emphp (
txa->preemph = EMPHP::create_emphp (
0, // run
1, // position
txa->dsp_size, // size
@ -197,7 +197,7 @@ TXA* TXA::create_txa (
300.0, // f_low
3000.0); // f_high
txa->leveler.p = WCPAGC::create_wcpagc (
txa->leveler = WCPAGC::create_wcpagc (
0, // run - OFF by default
5, // mode
0, // 0 for max(I,Q), 1 for envelope
@ -222,9 +222,9 @@ TXA* TXA::create_txa (
2.000, // hang_thresh
0.100); // tau_hang_decay
txa->lvlrmeter.p = new METER(
txa->lvlrmeter = new METER(
1, // run
&(txa->leveler.p->run), // pointer to leveler 'run'
&(txa->leveler->run), // pointer to leveler 'run'
txa->dsp_size, // size
txa->midbuff, // pointer to buffer
txa->dsp_rate, // samplerate
@ -234,13 +234,13 @@ TXA* TXA::create_txa (
TXA_LVLR_AV, // index for average value
TXA_LVLR_PK, // index for peak value
TXA_LVLR_GAIN, // index for gain value
&txa->leveler.p->gain); // pointer for gain computation
&txa->leveler->gain); // pointer for gain computation
{
float default_F[5] = {200.0, 1000.0, 2000.0, 3000.0, 4000.0};
float default_G[5] = {0.0, 5.0, 10.0, 10.0, 5.0};
float default_E[5] = {7.0, 7.0, 7.0, 7.0, 7.0};
txa->cfcomp.p = CFCOMP::create_cfcomp(
txa->cfcomp = CFCOMP::create_cfcomp(
0, // run
0, // position
0, // post-equalizer run
@ -262,9 +262,9 @@ TXA* TXA::create_txa (
0.50); // display time constant
}
txa->cfcmeter.p = new METER(
txa->cfcmeter = new METER(
1, // run
&(txa->cfcomp.p->run), // pointer to eqp 'run'
&(txa->cfcomp->run), // pointer to eqp 'run'
txa->dsp_size, // size
txa->midbuff, // pointer to buffer
txa->dsp_rate, // samplerate
@ -274,9 +274,9 @@ TXA* TXA::create_txa (
TXA_CFC_AV, // index for average value
TXA_CFC_PK, // index for peak value
TXA_CFC_GAIN, // index for gain value
(double*) &txa->cfcomp.p->gain); // pointer for gain computation
(double*) &txa->cfcomp->gain); // pointer for gain computation
txa->bp0.p = BANDPASS::create_bandpass (
txa->bp0 = BANDPASS::create_bandpass (
1, // always runs
0, // position
txa->dsp_size, // size
@ -290,14 +290,14 @@ TXA* TXA::create_txa (
1, // wintype
2.0); // gain
txa->compressor.p = COMPRESSOR::create_compressor (
txa->compressor = COMPRESSOR::create_compressor (
0, // run - OFF by default
txa->dsp_size, // size
txa->midbuff, // pointer to input buffer
txa->midbuff, // pointer to output buffer
3.0); // gain
txa->bp1.p = BANDPASS::create_bandpass (
txa->bp1 = BANDPASS::create_bandpass (
0, // ONLY RUNS WHEN COMPRESSOR IS USED
0, // position
txa->dsp_size, // size
@ -311,7 +311,7 @@ TXA* TXA::create_txa (
1, // wintype
2.0); // gain
txa->osctrl.p = OSCTRL::create_osctrl (
txa->osctrl = OSCTRL::create_osctrl (
0, // run
txa->dsp_size, // size
txa->midbuff, // input buffer
@ -319,7 +319,7 @@ TXA* TXA::create_txa (
txa->dsp_rate, // sample rate
1.95); // gain for clippings
txa->bp2.p = BANDPASS::create_bandpass (
txa->bp2 = BANDPASS::create_bandpass (
0, // ONLY RUNS WHEN COMPRESSOR IS USED
0, // position
txa->dsp_size, // size
@ -333,9 +333,9 @@ TXA* TXA::create_txa (
1, // wintype
1.0); // gain
txa->compmeter.p = new METER(
txa->compmeter = new METER(
1, // run
&(txa->compressor.p->run), // pointer to compressor 'run'
&(txa->compressor->run), // pointer to compressor 'run'
txa->dsp_size, // size
txa->midbuff, // pointer to buffer
txa->dsp_rate, // samplerate
@ -347,7 +347,7 @@ TXA* TXA::create_txa (
-1, // index for gain value
0); // pointer for gain computation
txa->alc.p = WCPAGC::create_wcpagc (
txa->alc = WCPAGC::create_wcpagc (
1, // run - always ON
5, // mode
1, // 0 for max(I,Q), 1 for envelope
@ -372,7 +372,7 @@ TXA* TXA::create_txa (
2.000, // hang_thresh
0.100); // tau_hang_decay
txa->ammod.p = AMMOD::create_ammod (
txa->ammod = AMMOD::create_ammod (
0, // run - OFF by default
0, // mode: 0=>AM, 1=>DSB
txa->dsp_size, // size
@ -381,7 +381,7 @@ TXA* TXA::create_txa (
0.5); // carrier level
txa->fmmod.p = FMMOD::create_fmmod (
txa->fmmod = FMMOD::create_fmmod (
0, // run - OFF by default
txa->dsp_size, // size
txa->midbuff, // pointer to input buffer
@ -397,7 +397,7 @@ TXA* TXA::create_txa (
std::max(2048, txa->dsp_size), // number coefficients for bandpass filter
0); // minimum phase flag
txa->gen1.p = new GEN(
txa->gen1 = new GEN(
0, // run
txa->dsp_size, // buffer size
txa->midbuff, // input buffer
@ -405,7 +405,7 @@ TXA* TXA::create_txa (
txa->dsp_rate, // sample rate
0); // mode
txa->uslew.p = USLEW::create_uslew (
txa->uslew = USLEW::create_uslew (
txa,
&(txa->upslew), // pointer to channel upslew flag
txa->dsp_size, // buffer size
@ -415,7 +415,7 @@ TXA* TXA::create_txa (
0.000, // delay time
0.005); // upslew time
txa->alcmeter.p = new METER(
txa->alcmeter = new METER(
1, // run
0, // optional pointer to a 'run'
txa->dsp_size, // size
@ -427,9 +427,9 @@ TXA* TXA::create_txa (
TXA_ALC_AV, // index for average value
TXA_ALC_PK, // index for peak value
TXA_ALC_GAIN, // index for gain value
&txa->alc.p->gain); // pointer for gain computation
&txa->alc->gain); // pointer for gain computation
txa->sip1.p = SIPHON::create_siphon (
txa->sip1 = SIPHON::create_siphon (
1, // run
0, // position
0, // mode
@ -440,7 +440,7 @@ TXA* TXA::create_txa (
16384, // fft size for spectrum
1); // specmode
// txa->calcc.p = create_calcc (
// txa->calcc = create_calcc (
// channel, // channel number
// 1, // run calibration
// 1024, // input buffer size
@ -469,7 +469,7 @@ TXA* TXA::create_txa (
0.005, // changeover time
256); // spi
txa->cfir.p = CFIR::create_cfir(
txa->cfir = CFIR::create_cfir(
0, // run
txa->dsp_size, // size
std::max(2048, txa->dsp_size), // number of filter coefficients
@ -486,7 +486,7 @@ TXA* TXA::create_txa (
0.0, // raised-cosine transition width
0); // window type
txa->rsmpout.p = new RESAMPLE(
txa->rsmpout = new RESAMPLE(
0, // run - will be turned ON below if needed
txa->dsp_size, // input size
txa->midbuff, // pointer to input buffer
@ -497,7 +497,7 @@ TXA* TXA::create_txa (
0, // select ncoef automatically
0.980); // gain
txa->outmeter.p = new METER(
txa->outmeter = new METER(
1, // run
0, // optional pointer to another 'run'
txa->dsp_outsize, // size
@ -519,37 +519,37 @@ TXA* TXA::create_txa (
void TXA::destroy_txa (TXA *txa)
{
// in reverse order, free each item we created
delete (txa->outmeter.p);
delete (txa->rsmpout.p);
CFIR::destroy_cfir(txa->cfir.p);
// destroy_calcc (txa->calcc.p);
delete (txa->outmeter);
delete (txa->rsmpout);
CFIR::destroy_cfir(txa->cfir);
// destroy_calcc (txa->calcc);
IQC::destroy_iqc (txa->iqc.p0);
SIPHON::destroy_siphon (txa->sip1.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);
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);
delete (txa->cfcmeter.p);
CFCOMP::destroy_cfcomp (txa->cfcomp.p);
delete (txa->lvlrmeter.p);
WCPAGC::destroy_wcpagc (txa->leveler.p);
EMPHP::destroy_emphp (txa->preemph.p);
delete (txa->eqmeter.p);
EQP::destroy_eqp (txa->eqp.p);
delete (txa->amsq.p);
delete (txa->micmeter.p);
PHROT::destroy_phrot (txa->phrot.p);
PANEL::destroy_panel (txa->panel.p);
delete (txa->gen0.p);
delete (txa->rsmpin.p);
SIPHON::destroy_siphon (txa->sip1);
delete (txa->alcmeter);
USLEW::destroy_uslew (txa->uslew);
delete (txa->gen1);
FMMOD::destroy_fmmod (txa->fmmod);
AMMOD::destroy_ammod (txa->ammod);
WCPAGC::destroy_wcpagc (txa->alc);
delete (txa->compmeter);
BANDPASS::destroy_bandpass (txa->bp2);
OSCTRL::destroy_osctrl (txa->osctrl);
BANDPASS::destroy_bandpass (txa->bp1);
COMPRESSOR::destroy_compressor (txa->compressor);
BANDPASS::destroy_bandpass (txa->bp0);
delete (txa->cfcmeter);
CFCOMP::destroy_cfcomp (txa->cfcomp);
delete (txa->lvlrmeter);
WCPAGC::destroy_wcpagc (txa->leveler);
EMPHP::destroy_emphp (txa->preemph);
delete (txa->eqmeter);
delete (txa->eqp);
delete (txa->amsq);
delete (txa->micmeter);
PHROT::destroy_phrot (txa->phrot);
PANEL::destroy_panel (txa->panel);
delete (txa->gen0);
delete (txa->rsmpin);
delete[] (txa->midbuff);
delete[] (txa->outbuff);
delete[] (txa->inbuff);
@ -561,72 +561,72 @@ void TXA::flush_txa (TXA* txa)
std::fill(txa->inbuff, txa->inbuff + 1 * txa->dsp_insize * 2, 0);
std::fill(txa->outbuff, txa->outbuff + 1 * txa->dsp_outsize * 2, 0);
std::fill(txa->midbuff, txa->midbuff + 2 * txa->dsp_size * 2, 0);
txa->rsmpin.p->flush();
txa->gen0.p->flush();
PANEL::flush_panel (txa->panel.p);
PHROT::flush_phrot (txa->phrot.p);
txa->micmeter.p->flush ();
txa->amsq.p->flush ();
EQP::flush_eqp (txa->eqp.p);
txa->eqmeter.p->flush ();
EMPHP::flush_emphp (txa->preemph.p);
WCPAGC::flush_wcpagc (txa->leveler.p);
txa->lvlrmeter.p->flush ();
CFCOMP::flush_cfcomp (txa->cfcomp.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);
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);
txa->alcmeter.p->flush ();
SIPHON::flush_siphon (txa->sip1.p);
txa->rsmpin->flush();
txa->gen0->flush();
PANEL::flush_panel (txa->panel);
PHROT::flush_phrot (txa->phrot);
txa->micmeter->flush ();
txa->amsq->flush ();
txa->eqp->flush();
txa->eqmeter->flush ();
EMPHP::flush_emphp (txa->preemph);
WCPAGC::flush_wcpagc (txa->leveler);
txa->lvlrmeter->flush ();
CFCOMP::flush_cfcomp (txa->cfcomp);
txa->cfcmeter->flush ();
BANDPASS::flush_bandpass (txa->bp0);
COMPRESSOR::flush_compressor (txa->compressor);
BANDPASS::flush_bandpass (txa->bp1);
OSCTRL::flush_osctrl (txa->osctrl);
BANDPASS::flush_bandpass (txa->bp2);
txa->compmeter->flush ();
WCPAGC::flush_wcpagc (txa->alc);
AMMOD::flush_ammod (txa->ammod);
FMMOD::flush_fmmod (txa->fmmod);
txa->gen1->flush();
USLEW::flush_uslew (txa->uslew);
txa->alcmeter->flush ();
SIPHON::flush_siphon (txa->sip1);
IQC::flush_iqc (txa->iqc.p0);
CFIR::flush_cfir(txa->cfir.p);
txa->rsmpout.p->flush();
txa->outmeter.p->flush ();
CFIR::flush_cfir(txa->cfir);
txa->rsmpout->flush();
txa->outmeter->flush ();
}
void xtxa (TXA* txa)
{
txa->rsmpin.p->execute(); // input resampler
txa->gen0.p->execute(); // input signal generator
PANEL::xpanel (txa->panel.p); // includes MIC gain
PHROT::xphrot (txa->phrot.p); // phase rotator
txa->micmeter.p->execute (); // MIC meter
txa->amsq.p->xcap (); // downward expander capture
txa->amsq.p->execute (); // downward expander action
EQP::xeqp (txa->eqp.p); // pre-EQ
txa->eqmeter.p->execute (); // EQ meter
EMPHP::xemphp (txa->preemph.p, 0); // FM pre-emphasis (first option)
WCPAGC::xwcpagc (txa->leveler.p); // Leveler
txa->lvlrmeter.p->execute (); // Leveler Meter
CFCOMP::xcfcomp (txa->cfcomp.p, 0); // Continuous Frequency Compressor with post-EQ
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)
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
txa->alcmeter.p->execute (); // ALC Meter
SIPHON::xsiphon (txa->sip1.p, 0); // siphon data for display
txa->rsmpin->execute(); // input resampler
txa->gen0->execute(); // input signal generator
PANEL::xpanel (txa->panel); // includes MIC gain
PHROT::xphrot (txa->phrot); // phase rotator
txa->micmeter->execute (); // MIC meter
txa->amsq->xcap (); // downward expander capture
txa->amsq->execute (); // downward expander action
txa->eqp->execute (); // pre-EQ
txa->eqmeter->execute (); // EQ meter
EMPHP::xemphp (txa->preemph, 0); // FM pre-emphasis (first option)
WCPAGC::xwcpagc (txa->leveler); // Leveler
txa->lvlrmeter->execute (); // Leveler Meter
CFCOMP::xcfcomp (txa->cfcomp, 0); // Continuous Frequency Compressor with post-EQ
txa->cfcmeter->execute (); // CFC+PostEQ Meter
BANDPASS::xbandpass (txa->bp0, 0); // primary bandpass filter
COMPRESSOR::xcompressor (txa->compressor); // COMP compressor
BANDPASS::xbandpass (txa->bp1, 0); // aux bandpass (runs if COMP)
OSCTRL::xosctrl (txa->osctrl); // CESSB Overshoot Control
BANDPASS::xbandpass (txa->bp2, 0); // aux bandpass (runs if CESSB)
txa->compmeter->execute (); // COMP meter
WCPAGC::xwcpagc (txa->alc); // ALC
AMMOD::xammod (txa->ammod); // AM Modulator
EMPHP::xemphp (txa->preemph, 1); // FM pre-emphasis (second option)
FMMOD::xfmmod (txa->fmmod); // FM Modulator
txa->gen1->execute(); // output signal generator (TUN and Two-tone)
USLEW::xuslew (txa->uslew); // up-slew for AM, FM, and gens
txa->alcmeter->execute (); // ALC Meter
SIPHON::xsiphon (txa->sip1, 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
txa->outmeter.p->execute (); // output meter
CFIR::xcfir(txa->cfir); // compensating FIR filter (used Protocol_2 only)
txa->rsmpout->execute(); // output resampler
txa->outmeter->execute (); // output meter
// print_peak_env ("env_exception.txt", txa->dsp_outsize, txa->outbuff, 0.7);
}
@ -642,9 +642,9 @@ void TXA::setInputSamplerate (TXA *txa, int in_rate)
delete[] (txa->inbuff);
txa->inbuff = new float[1 * txa->dsp_insize * 2]; //(float *)malloc0(1 * txa->dsp_insize * sizeof(complex));
// input resampler
txa->rsmpin.p->setBuffers(txa->inbuff, txa->midbuff);
txa->rsmpin.p->setSize(txa->dsp_insize);
txa->rsmpin.p->setInRate(txa->in_rate);
txa->rsmpin->setBuffers(txa->inbuff, txa->midbuff);
txa->rsmpin->setSize(txa->dsp_insize);
txa->rsmpin->setInRate(txa->in_rate);
ResCheck (*txa);
}
@ -660,15 +660,15 @@ void TXA::setOutputSamplerate (TXA* txa, int out_rate)
delete[] (txa->outbuff);
txa->outbuff = new float[1 * txa->dsp_outsize * 2]; // (float *)malloc0(1 * txa->dsp_outsize * sizeof(complex));
// cfir - needs to know input rate of firmware CIC
CFIR::setOutRate_cfir (txa->cfir.p, txa->out_rate);
CFIR::setOutRate_cfir (txa->cfir, txa->out_rate);
// output resampler
txa->rsmpout.p->setBuffers(txa->midbuff, txa->outbuff);
txa->rsmpout.p->setOutRate(txa->out_rate);
txa->rsmpout->setBuffers(txa->midbuff, txa->outbuff);
txa->rsmpout->setOutRate(txa->out_rate);
ResCheck (*txa);
// output meter
txa->outmeter.p->setBuffers(txa->outbuff);
txa->outmeter.p->setSize(txa->dsp_outsize);
txa->outmeter.p->setSamplerate (txa->out_rate);
txa->outmeter->setBuffers(txa->outbuff);
txa->outmeter->setSize(txa->dsp_outsize);
txa->outmeter->setSamplerate (txa->out_rate);
}
void TXA::setDSPSamplerate (TXA *txa, int dsp_rate)
@ -690,44 +690,44 @@ void TXA::setDSPSamplerate (TXA *txa, int dsp_rate)
delete[] (txa->outbuff);
txa->outbuff = new float[1 * txa->dsp_outsize * 2]; // (float *)malloc0(1 * txa->dsp_outsize * sizeof(complex));
// input resampler
txa->rsmpin.p->setBuffers(txa->inbuff, txa->midbuff);
txa->rsmpin.p->setSize(txa->dsp_insize);
txa->rsmpin.p->setOutRate(txa->dsp_rate);
txa->rsmpin->setBuffers(txa->inbuff, txa->midbuff);
txa->rsmpin->setSize(txa->dsp_insize);
txa->rsmpin->setOutRate(txa->dsp_rate);
// dsp_rate blocks
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);
txa->micmeter.p->setSamplerate (txa->dsp_rate);
txa->amsq.p->setSamplerate (txa->dsp_rate);
EQP::setSamplerate_eqp (txa->eqp.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);
txa->lvlrmeter.p->setSamplerate (txa->dsp_rate);
CFCOMP::setSamplerate_cfcomp (txa->cfcomp.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);
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);
txa->alcmeter.p->setSamplerate (txa->dsp_rate);
SIPHON::setSamplerate_siphon (txa->sip1.p, txa->dsp_rate);
txa->gen0->setSamplerate(txa->dsp_rate);
PANEL::setSamplerate_panel (txa->panel, txa->dsp_rate);
PHROT::setSamplerate_phrot (txa->phrot, txa->dsp_rate);
txa->micmeter->setSamplerate (txa->dsp_rate);
txa->amsq->setSamplerate (txa->dsp_rate);
txa->eqp->setSamplerate (txa->dsp_rate);
txa->eqmeter->setSamplerate (txa->dsp_rate);
EMPHP::setSamplerate_emphp (txa->preemph, txa->dsp_rate);
WCPAGC::setSamplerate_wcpagc (txa->leveler, txa->dsp_rate);
txa->lvlrmeter->setSamplerate (txa->dsp_rate);
CFCOMP::setSamplerate_cfcomp (txa->cfcomp, txa->dsp_rate);
txa->cfcmeter->setSamplerate (txa->dsp_rate);
BANDPASS::setSamplerate_bandpass (txa->bp0, txa->dsp_rate);
COMPRESSOR::setSamplerate_compressor (txa->compressor, txa->dsp_rate);
BANDPASS::setSamplerate_bandpass (txa->bp1, txa->dsp_rate);
OSCTRL::setSamplerate_osctrl (txa->osctrl, txa->dsp_rate);
BANDPASS::setSamplerate_bandpass (txa->bp2, txa->dsp_rate);
txa->compmeter->setSamplerate (txa->dsp_rate);
WCPAGC::setSamplerate_wcpagc (txa->alc, txa->dsp_rate);
AMMOD::setSamplerate_ammod (txa->ammod, txa->dsp_rate);
FMMOD::setSamplerate_fmmod (txa->fmmod, txa->dsp_rate);
txa->gen1->setSamplerate(txa->dsp_rate);
USLEW::setSamplerate_uslew (txa->uslew, txa->dsp_rate);
txa->alcmeter->setSamplerate (txa->dsp_rate);
SIPHON::setSamplerate_siphon (txa->sip1, txa->dsp_rate);
IQC::setSamplerate_iqc (txa->iqc.p0, txa->dsp_rate);
CFIR::setSamplerate_cfir (txa->cfir.p, txa->dsp_rate);
CFIR::setSamplerate_cfir (txa->cfir, txa->dsp_rate);
// output resampler
txa->rsmpout.p->setBuffers(txa->midbuff, txa->outbuff);
txa->rsmpout.p->setInRate(txa->dsp_rate);
txa->rsmpout->setBuffers(txa->midbuff, txa->outbuff);
txa->rsmpout->setInRate(txa->dsp_rate);
ResCheck (*txa);
// output meter
txa->outmeter.p->setBuffers(txa->outbuff);
txa->outmeter.p->setSize (txa->dsp_outsize);
txa->outmeter->setBuffers(txa->outbuff);
txa->outmeter->setSize (txa->dsp_outsize);
}
void TXA::setDSPBuffsize (TXA *txa, int dsp_size)
@ -751,69 +751,69 @@ void TXA::setDSPBuffsize (TXA *txa, int dsp_size)
delete[] (txa->outbuff);
txa->outbuff = new float[1 * txa->dsp_outsize * 2]; // (float *)malloc0(1 * txa->dsp_outsize * sizeof(complex));
// input resampler
txa->rsmpin.p->setBuffers(txa->inbuff, txa->midbuff);
txa->rsmpin.p->setSize(txa->dsp_insize);
txa->rsmpin->setBuffers(txa->inbuff, txa->midbuff);
txa->rsmpin->setSize(txa->dsp_insize);
// dsp_size blocks
txa->gen0.p->setBuffers(txa->midbuff, txa->midbuff);
txa->gen0.p->setSize(txa->dsp_size);
PANEL::setBuffers_panel (txa->panel.p, txa->midbuff, txa->midbuff);
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);
txa->micmeter.p->setBuffers (txa->midbuff);
txa->micmeter.p->setSize (txa->dsp_size);
txa->amsq.p->setBuffers (txa->midbuff, txa->midbuff, txa->midbuff);
txa->amsq.p->setSize (txa->dsp_size);
EQP::setBuffers_eqp (txa->eqp.p, txa->midbuff, txa->midbuff);
EQP::setSize_eqp (txa->eqp.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);
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);
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);
COMPRESSOR::setSize_compressor (txa->compressor.p, txa->dsp_size);
BANDPASS::setBuffers_bandpass (txa->bp1.p, txa->midbuff, txa->midbuff);
BANDPASS::setSize_bandpass (txa->bp1.p, txa->dsp_size);
OSCTRL::setBuffers_osctrl (txa->osctrl.p, txa->midbuff, txa->midbuff);
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);
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);
AMMOD::setSize_ammod (txa->ammod.p, txa->dsp_size);
FMMOD::setBuffers_fmmod (txa->fmmod.p, txa->midbuff, txa->midbuff);
FMMOD::setSize_fmmod (txa->fmmod.p, txa->dsp_size);
txa->gen1.p->setBuffers(txa->midbuff, txa->midbuff);
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);
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);
txa->gen0->setBuffers(txa->midbuff, txa->midbuff);
txa->gen0->setSize(txa->dsp_size);
PANEL::setBuffers_panel (txa->panel, txa->midbuff, txa->midbuff);
PANEL::setSize_panel (txa->panel, txa->dsp_size);
PHROT::setBuffers_phrot (txa->phrot, txa->midbuff, txa->midbuff);
PHROT::setSize_phrot (txa->phrot, txa->dsp_size);
txa->micmeter->setBuffers (txa->midbuff);
txa->micmeter->setSize (txa->dsp_size);
txa->amsq->setBuffers (txa->midbuff, txa->midbuff, txa->midbuff);
txa->amsq->setSize (txa->dsp_size);
txa->eqp->setBuffers (txa->midbuff, txa->midbuff);
txa->eqp->setSize (txa->dsp_size);
txa->eqmeter->setBuffers (txa->midbuff);
txa->eqmeter->setSize (txa->dsp_size);
EMPHP::setBuffers_emphp (txa->preemph, txa->midbuff, txa->midbuff);
EMPHP::setSize_emphp (txa->preemph, txa->dsp_size);
WCPAGC::setBuffers_wcpagc (txa->leveler, txa->midbuff, txa->midbuff);
WCPAGC::setSize_wcpagc (txa->leveler, txa->dsp_size);
txa->lvlrmeter->setBuffers(txa->midbuff);
txa->lvlrmeter->setSize(txa->dsp_size);
CFCOMP::setBuffers_cfcomp (txa->cfcomp, txa->midbuff, txa->midbuff);
CFCOMP::setSize_cfcomp (txa->cfcomp, txa->dsp_size);
txa->cfcmeter->setBuffers(txa->midbuff);
txa->cfcmeter->setSize(txa->dsp_size);
BANDPASS::setBuffers_bandpass (txa->bp0, txa->midbuff, txa->midbuff);
BANDPASS::setSize_bandpass (txa->bp0, txa->dsp_size);
COMPRESSOR::setBuffers_compressor (txa->compressor, txa->midbuff, txa->midbuff);
COMPRESSOR::setSize_compressor (txa->compressor, txa->dsp_size);
BANDPASS::setBuffers_bandpass (txa->bp1, txa->midbuff, txa->midbuff);
BANDPASS::setSize_bandpass (txa->bp1, txa->dsp_size);
OSCTRL::setBuffers_osctrl (txa->osctrl, txa->midbuff, txa->midbuff);
OSCTRL::setSize_osctrl (txa->osctrl, txa->dsp_size);
BANDPASS::setBuffers_bandpass (txa->bp2, txa->midbuff, txa->midbuff);
BANDPASS::setSize_bandpass (txa->bp2, txa->dsp_size);
txa->compmeter->setBuffers(txa->midbuff);
txa->compmeter->setSize(txa->dsp_size);
WCPAGC::setBuffers_wcpagc (txa->alc, txa->midbuff, txa->midbuff);
WCPAGC::setSize_wcpagc (txa->alc, txa->dsp_size);
AMMOD::setBuffers_ammod (txa->ammod, txa->midbuff, txa->midbuff);
AMMOD::setSize_ammod (txa->ammod, txa->dsp_size);
FMMOD::setBuffers_fmmod (txa->fmmod, txa->midbuff, txa->midbuff);
FMMOD::setSize_fmmod (txa->fmmod, txa->dsp_size);
txa->gen1->setBuffers(txa->midbuff, txa->midbuff);
txa->gen1->setSize(txa->dsp_size);
USLEW::setBuffers_uslew (txa->uslew, txa->midbuff, txa->midbuff);
USLEW::setSize_uslew (txa->uslew, txa->dsp_size);
txa->alcmeter->setBuffers (txa->midbuff);
txa->alcmeter->setSize(txa->dsp_size);
SIPHON::setBuffers_siphon (txa->sip1, txa->midbuff);
SIPHON::setSize_siphon (txa->sip1, txa->dsp_size);
IQC::setBuffers_iqc (txa->iqc.p0, txa->midbuff, txa->midbuff);
IQC::setSize_iqc (txa->iqc.p0, txa->dsp_size);
CFIR::setBuffers_cfir (txa->cfir.p, txa->midbuff, txa->midbuff);
CFIR::setSize_cfir (txa->cfir.p, txa->dsp_size);
CFIR::setBuffers_cfir (txa->cfir, txa->midbuff, txa->midbuff);
CFIR::setSize_cfir (txa->cfir, txa->dsp_size);
// output resampler
txa->rsmpout.p->setBuffers(txa->midbuff, txa->outbuff);
txa->rsmpout.p->setSize(txa->dsp_size);
txa->rsmpout->setBuffers(txa->midbuff, txa->outbuff);
txa->rsmpout->setSize(txa->dsp_size);
// output meter
txa->outmeter.p->setBuffers(txa->outbuff);
txa->outmeter.p->setSize(txa->dsp_outsize);
txa->outmeter->setBuffers(txa->outbuff);
txa->outmeter->setSize(txa->dsp_outsize);
}
/********************************************************************************************************
@ -827,29 +827,29 @@ void TXA::SetMode (TXA& txa, int mode)
if (txa.mode != mode)
{
txa.mode = mode;
txa.ammod.p->run = 0;
txa.fmmod.p->run = 0;
txa.preemph.p->run = 0;
txa.ammod->run = 0;
txa.fmmod->run = 0;
txa.preemph->run = 0;
switch (mode)
{
case TXA_AM:
case TXA_SAM:
txa.ammod.p->run = 1;
txa.ammod.p->mode = 0;
txa.ammod->run = 1;
txa.ammod->mode = 0;
break;
case TXA_DSB:
txa.ammod.p->run = 1;
txa.ammod.p->mode = 1;
txa.ammod->run = 1;
txa.ammod->mode = 1;
break;
case TXA_AM_LSB:
case TXA_AM_USB:
txa.ammod.p->run = 1;
txa.ammod.p->mode = 2;
txa.ammod->run = 1;
txa.ammod->mode = 2;
break;
case TXA_FM:
txa.fmmod.p->run = 1;
txa.preemph.p->run = 1;
txa.fmmod->run = 1;
txa.preemph->run = 1;
break;
default:
@ -879,12 +879,12 @@ void TXA::SetBandpassFreqs (TXA& txa, float f_low, float f_high)
void TXA::ResCheck (TXA& txa)
{
RESAMPLE *a = txa.rsmpin.p;
RESAMPLE *a = txa.rsmpin;
if (txa.in_rate != txa.dsp_rate)
a->run = 1;
else
a->run = 0;
a = txa.rsmpout.p;
a = txa.rsmpout;
if (txa.dsp_rate != txa.out_rate)
a->run = 1;
else
@ -893,17 +893,17 @@ void TXA::ResCheck (TXA& txa)
int TXA::UslewCheck (TXA& txa)
{
return (txa.ammod.p->run == 1) ||
(txa.fmmod.p->run == 1) ||
(txa.gen0.p->run == 1) ||
(txa.gen1.p->run == 1);
return (txa.ammod->run == 1) ||
(txa.fmmod->run == 1) ||
(txa.gen0->run == 1) ||
(txa.gen1->run == 1);
}
void TXA::SetupBPFilters (TXA& txa)
{
txa.bp0.p->run = 1;
txa.bp1.p->run = 0;
txa.bp2.p->run = 0;
txa.bp0->run = 1;
txa.bp1->run = 0;
txa.bp2->run = 0;
switch (txa.mode)
{
case TXA_LSB:
@ -914,15 +914,15 @@ void TXA::SetupBPFilters (TXA& txa)
case TXA_DIGU:
case TXA_SPEC:
case TXA_DRM:
BANDPASS::CalcBandpassFilter (txa.bp0.p, txa.f_low, txa.f_high, 2.0);
if (txa.compressor.p->run)
BANDPASS::CalcBandpassFilter (txa.bp0, txa.f_low, txa.f_high, 2.0);
if (txa.compressor->run)
{
BANDPASS::CalcBandpassFilter (txa.bp1.p, txa.f_low, txa.f_high, 2.0);
txa.bp1.p->run = 1;
if (txa.osctrl.p->run)
BANDPASS::CalcBandpassFilter (txa.bp1, txa.f_low, txa.f_high, 2.0);
txa.bp1->run = 1;
if (txa.osctrl->run)
{
BANDPASS::CalcBandpassFilter (txa.bp2.p, txa.f_low, txa.f_high, 1.0);
txa.bp2.p->run = 1;
BANDPASS::CalcBandpassFilter (txa.bp2, txa.f_low, txa.f_high, 1.0);
txa.bp2->run = 1;
}
}
break;
@ -930,45 +930,45 @@ void TXA::SetupBPFilters (TXA& txa)
case TXA_AM:
case TXA_SAM:
case TXA_FM:
if (txa.compressor.p->run)
if (txa.compressor->run)
{
BANDPASS::CalcBandpassFilter (txa.bp0.p, 0.0, txa.f_high, 2.0);
BANDPASS::CalcBandpassFilter (txa.bp1.p, 0.0, txa.f_high, 2.0);
txa.bp1.p->run = 1;
if (txa.osctrl.p->run)
BANDPASS::CalcBandpassFilter (txa.bp0, 0.0, txa.f_high, 2.0);
BANDPASS::CalcBandpassFilter (txa.bp1, 0.0, txa.f_high, 2.0);
txa.bp1->run = 1;
if (txa.osctrl->run)
{
BANDPASS::CalcBandpassFilter (txa.bp2.p, 0.0, txa.f_high, 1.0);
txa.bp2.p->run = 1;
BANDPASS::CalcBandpassFilter (txa.bp2, 0.0, txa.f_high, 1.0);
txa.bp2->run = 1;
}
}
else
{
BANDPASS::CalcBandpassFilter (txa.bp0.p, txa.f_low, txa.f_high, 1.0);
BANDPASS::CalcBandpassFilter (txa.bp0, txa.f_low, txa.f_high, 1.0);
}
break;
case TXA_AM_LSB:
BANDPASS::CalcBandpassFilter (txa.bp0.p, -txa.f_high, 0.0, 2.0);
if (txa.compressor.p->run)
BANDPASS::CalcBandpassFilter (txa.bp0, -txa.f_high, 0.0, 2.0);
if (txa.compressor->run)
{
BANDPASS::CalcBandpassFilter (txa.bp1.p, -txa.f_high, 0.0, 2.0);
txa.bp1.p->run = 1;
if (txa.osctrl.p->run)
BANDPASS::CalcBandpassFilter (txa.bp1, -txa.f_high, 0.0, 2.0);
txa.bp1->run = 1;
if (txa.osctrl->run)
{
BANDPASS::CalcBandpassFilter (txa.bp2.p, -txa.f_high, 0.0, 1.0);
txa.bp2.p->run = 1;
BANDPASS::CalcBandpassFilter (txa.bp2, -txa.f_high, 0.0, 1.0);
txa.bp2->run = 1;
}
}
break;
case TXA_AM_USB:
BANDPASS::CalcBandpassFilter (txa.bp0.p, 0.0, txa.f_high, 2.0);
if (txa.compressor.p->run)
BANDPASS::CalcBandpassFilter (txa.bp0, 0.0, txa.f_high, 2.0);
if (txa.compressor->run)
{
BANDPASS::CalcBandpassFilter (txa.bp1.p, 0.0, txa.f_high, 2.0);
txa.bp1.p->run = 1;
if (txa.osctrl.p->run)
BANDPASS::CalcBandpassFilter (txa.bp1, 0.0, txa.f_high, 2.0);
txa.bp1->run = 1;
if (txa.osctrl->run)
{
BANDPASS::CalcBandpassFilter (txa.bp2.p, 0.0, txa.f_high, 1.0);
txa.bp2.p->run = 1;
BANDPASS::CalcBandpassFilter (txa.bp2, 0.0, txa.f_high, 1.0);
txa.bp2->run = 1;
}
}
break;
@ -986,7 +986,7 @@ void TXA::SetNC (TXA& txa, int nc)
int oldstate = txa.state;
BANDPASS::SetBandpassNC (txa, nc);
EMPHP::SetFMEmphNC (txa, nc);
EQP::SetEQNC (txa, nc);
txa.eqp->setNC (nc);
FMMOD::SetFMNC (txa, nc);
CFIR::SetCFIRNC (txa, nc);
txa.state = oldstate;
@ -996,7 +996,7 @@ void TXA::SetMP (TXA& txa, int mp)
{
BANDPASS::SetBandpassMP (txa, mp);
EMPHP::SetFMEmphMP (txa, mp);
EQP::SetEQMP (txa, mp);
txa.eqp->setMP (mp);
FMMOD::SetFMMP (txa, mp);
}

View File

@ -36,7 +36,7 @@ warren@wpratt.com
#include "resample.hpp"
#include "patchpanel.hpp"
#include "amsq.hpp"
#include "eq.hpp"
#include "eqp.hpp"
#include "iir.hpp"
#include "cfcomp.hpp"
#include "compress.hpp"
@ -127,78 +127,37 @@ public:
double meter[TXA_METERTYPE_LAST];
long upslew;
struct
{
METER *p;
} micmeter, eqmeter, lvlrmeter, cfcmeter, compmeter, alcmeter, outmeter;
struct
{
RESAMPLE *p;
} rsmpin, rsmpout;
struct
{
PANEL *p;
} panel;
struct
{
AMSQ *p;
} amsq;
struct
{
EQP *p;
} eqp;
struct
{
PHROT *p;
} phrot;
struct
{
CFCOMP *p;
} cfcomp;
struct
{
COMPRESSOR *p;
} compressor;
struct
{
BANDPASS *p;
} bp0, bp1, bp2;
struct
{
BPS *p;
} bps0, bps1, bps2;
struct
{
OSCTRL *p;
} osctrl;
struct
{
WCPAGC *p;
} leveler, alc;
struct
{
AMMOD *p;
} ammod;
struct
{
EMPHP *p;
} preemph;
struct
{
FMMOD *p;
} fmmod;
struct
{
SIPHON *p;
} sip1;
struct
{
GEN *p;
} gen0, gen1;
struct
{
USLEW *p;
} uslew;
METER *micmeter;
METER *eqmeter;
METER *lvlrmeter;
METER *cfcmeter;
METER *compmeter;
METER *alcmeter;
METER *outmeter;
RESAMPLE *rsmpin;
RESAMPLE *rsmpout;
PANEL *panel;
AMSQ *amsq;
EQP *eqp;
PHROT *phrot;
CFCOMP *cfcomp;
COMPRESSOR *compressor;
BANDPASS *bp0;
BANDPASS *bp1;
BANDPASS *bp2;
BPS *bps0;
BPS *bps1;
BPS *bps2;
OSCTRL *osctrl;
WCPAGC *leveler;
WCPAGC *alc;
AMMOD *ammod;
EMPHP *preemph;
FMMOD *fmmod;
SIPHON *sip1;
GEN *gen0;
GEN *gen1;
USLEW *uslew;
// struct
// {
// CALCC *p;
@ -209,10 +168,7 @@ public:
IQC *p0, *p1;
// p0 for dsp-synchronized reference, p1 for other
} iqc;
struct
{
CFIR *p;
} cfir;
CFIR *cfir;
static TXA* create_txa (
int in_rate, // input samplerate

View File

@ -109,8 +109,8 @@ void AMMOD::setSize_ammod(AMMOD *a, int size)
void AMMOD::SetAMCarrierLevel (TXA& txa, float c_level)
{
txa.ammod.p->c_level = c_level;
txa.ammod.p->a_level = 1.0 - c_level;
txa.ammod->c_level = c_level;
txa.ammod->a_level = 1.0 - c_level;
}
} // namespace WDSP

View File

@ -257,7 +257,7 @@ void BANDPASS::SetBandpassMP (RXA& rxa, int mp)
//{
// float* impulse;
// BANDPASS a;
// a = txa.bp0.p;
// a = txa.bp0;
// if ((f_low != a->f_low) || (f_high != a->f_high))
// {
// a->f_low = f_low;
@ -266,7 +266,7 @@ void BANDPASS::SetBandpassMP (RXA& rxa, int mp)
// setImpulse_fircore (a->p, impulse, 1);
// delete[] (impulse);
// }
// a = txa.bp1.p;
// a = txa.bp1;
// if ((f_low != a->f_low) || (f_high != a->f_high))
// {
// a->f_low = f_low;
@ -275,7 +275,7 @@ void BANDPASS::SetBandpassMP (RXA& rxa, int mp)
// setImpulse_fircore (a->p, impulse, 1);
// delete[] (impulse);
// }
// a = txa.bp2.p;
// a = txa.bp2;
// if ((f_low != a->f_low) || (f_high != a->f_high))
// {
// a->f_low = f_low;
@ -290,7 +290,7 @@ void BANDPASS::SetBandpassNC (TXA& txa, int nc)
{
// NOTE: 'nc' must be >= 'size'
BANDPASS *a;
a = txa.bp0.p;
a = txa.bp0;
if (a->nc != nc)
{
@ -308,7 +308,7 @@ void BANDPASS::SetBandpassNC (TXA& txa, int nc)
delete[] (impulse);
}
a = txa.bp1.p;
a = txa.bp1;
if (a->nc != nc)
{
@ -326,7 +326,7 @@ void BANDPASS::SetBandpassNC (TXA& txa, int nc)
delete[] (impulse);
}
a = txa.bp2.p;
a = txa.bp2;
if (a->nc != nc)
{
@ -348,7 +348,7 @@ void BANDPASS::SetBandpassNC (TXA& txa, int nc)
void BANDPASS::SetBandpassMP (TXA& txa, int mp)
{
BANDPASS *a;
a = txa.bp0.p;
a = txa.bp0;
if (mp != a->mp)
{
@ -356,7 +356,7 @@ void BANDPASS::SetBandpassMP (TXA& txa, int mp)
FIRCORE::setMp_fircore (a->p, a->mp);
}
a = txa.bp1.p;
a = txa.bp1;
if (mp != a->mp)
{
@ -364,7 +364,7 @@ void BANDPASS::SetBandpassMP (TXA& txa, int mp)
FIRCORE::setMp_fircore (a->p, a->mp);
}
a = txa.bp2.p;
a = txa.bp2;
if (mp != a->mp)
{

View File

@ -204,14 +204,14 @@ void BPS::SetBPSWindow (RXA& rxa, int wintype)
// UNCOMMENT properties when pointers in place in txa
void BPS::SetBPSRun (TXA& txa, int run)
{
txa.bp1.p->run = run;
txa.bp1->run = run;
}
void BPS::SetBPSFreqs (TXA& txa, float f_low, float f_high)
{
float* impulse;
BPS *a;
a = txa.bps0.p;
a = txa.bps0;
if ((f_low != a->f_low) || (f_high != a->f_high))
{
@ -223,7 +223,7 @@ void BPS::SetBPSFreqs (TXA& txa, float f_low, float f_high)
delete[] (impulse);
}
a = txa.bps1.p;
a = txa.bps1;
if ((f_low != a->f_low) || (f_high != a->f_high))
{
@ -235,7 +235,7 @@ void BPS::SetBPSFreqs (TXA& txa, float f_low, float f_high)
delete[] (impulse);
}
a = txa.bps2.p;
a = txa.bps2;
if ((f_low != a->f_low) || (f_high != a->f_high))
{
@ -252,7 +252,7 @@ void BPS::SetBPSWindow (TXA& txa, int wintype)
{
float* impulse;
BPS *a;
a = txa.bps0.p;
a = txa.bps0;
if (a->wintype != wintype)
{
@ -263,7 +263,7 @@ void BPS::SetBPSWindow (TXA& txa, int wintype)
delete[] (impulse);
}
a = txa.bps1.p;
a = txa.bps1;
if (a->wintype != wintype)
{
@ -274,7 +274,7 @@ void BPS::SetBPSWindow (TXA& txa, int wintype)
delete[] (impulse);
}
a = txa.bps2.p;
a = txa.bps2;
if (a->wintype != wintype)
{

View File

@ -417,7 +417,7 @@ void CFCOMP::setSize_cfcomp (CFCOMP *a, int size)
void CFCOMP::SetCFCOMPRun (TXA& txa, int run)
{
CFCOMP *a = txa.cfcomp.p;
CFCOMP *a = txa.cfcomp;
if (a->run != run) {
a->run = run;
@ -426,7 +426,7 @@ void CFCOMP::SetCFCOMPRun (TXA& txa, int run)
void CFCOMP::SetCFCOMPPosition (TXA& txa, int pos)
{
CFCOMP *a = txa.cfcomp.p;
CFCOMP *a = txa.cfcomp;
if (a->position != pos) {
a->position = pos;
@ -435,7 +435,7 @@ void CFCOMP::SetCFCOMPPosition (TXA& txa, int pos)
void CFCOMP::SetCFCOMPprofile (TXA& txa, int nfreqs, float* F, float* G, float *E)
{
CFCOMP *a = txa.cfcomp.p;
CFCOMP *a = txa.cfcomp;
a->nfreqs = nfreqs < 1 ? 1 : nfreqs;
delete[] (a->E);
delete[] (a->F);
@ -457,7 +457,7 @@ void CFCOMP::SetCFCOMPprofile (TXA& txa, int nfreqs, float* F, float* G, float *
void CFCOMP::SetCFCOMPPrecomp (TXA& txa, float precomp)
{
CFCOMP *a = txa.cfcomp.p;
CFCOMP *a = txa.cfcomp;
if (a->precomp != precomp)
{
@ -473,7 +473,7 @@ void CFCOMP::SetCFCOMPPrecomp (TXA& txa, float precomp)
void CFCOMP::SetCFCOMPPeqRun (TXA& txa, int run)
{
CFCOMP *a = txa.cfcomp.p;
CFCOMP *a = txa.cfcomp;
if (a->peq_run != run) {
a->peq_run = run;
@ -482,7 +482,7 @@ void CFCOMP::SetCFCOMPPeqRun (TXA& txa, int run)
void CFCOMP::SetCFCOMPPrePeq (TXA& txa, float prepeq)
{
CFCOMP *a = txa.cfcomp.p;
CFCOMP *a = txa.cfcomp;
a->prepeq = prepeq;
a->prepeqlin = pow (10.0, 0.05 * a->prepeq);
}
@ -490,7 +490,7 @@ void CFCOMP::SetCFCOMPPrePeq (TXA& txa, float prepeq)
void CFCOMP::GetCFCOMPDisplayCompression (TXA& txa, float* comp_values, int* ready)
{
int i;
CFCOMP *a = txa.cfcomp.p;
CFCOMP *a = txa.cfcomp;
if ((*ready = a->mask_ready))
{

View File

@ -267,14 +267,14 @@ float* CFIR::cfir_impulse (
void CFIR::SetCFIRRun (TXA& txa, int run)
{
txa.cfir.p->run = run;
txa.cfir->run = run;
}
void CFIR::SetCFIRNC(TXA& txa, int nc)
{
// NOTE: 'nc' must be >= 'size'
CFIR *a;
a = txa.cfir.p;
a = txa.cfir;
if (a->nc != nc)
{

View File

@ -100,16 +100,16 @@ void COMPRESSOR::setSize_compressor (COMPRESSOR *a, int size)
void COMPRESSOR::SetCompressorRun (TXA& txa, int run)
{
if (txa.compressor.p->run != run)
if (txa.compressor->run != run)
{
txa.compressor.p->run = run;
txa.compressor->run = run;
TXA::SetupBPFilters (txa);
}
}
void COMPRESSOR::SetCompressorGain (TXA& txa, float gain)
{
txa.compressor.p->gain = pow (10.0, gain / 20.0);
txa.compressor->gain = pow (10.0, gain / 20.0);
}
} // namespace WDSP

View File

@ -113,13 +113,13 @@ void EMPHP::setSize_emphp (EMPHP *a, int size)
void EMPHP::SetFMEmphPosition (TXA& txa, int position)
{
txa.preemph.p->position = position;
txa.preemph->position = position;
}
void EMPHP::SetFMEmphMP (TXA& txa, int mp)
{
EMPHP *a;
a = txa.preemph.p;
a = txa.preemph;
if (a->mp != mp)
{
a->mp = mp;
@ -131,7 +131,7 @@ void EMPHP::SetFMEmphNC (TXA& txa, int nc)
{
EMPHP *a;
float* impulse;
a = txa.preemph.p;
a = txa.preemph;
if (a->nc != nc)
{
@ -146,7 +146,7 @@ void EMPHP::SetFMPreEmphFreqs (TXA& txa, float low, float high)
{
EMPHP *a;
float* impulse;
a = txa.preemph.p;
a = txa.preemph;
if (a->f_low != low || a->f_high != high)
{
@ -263,7 +263,7 @@ PORT
void SetTXAFMEmphPosition (int channel, int position)
{
ch.csDSP.lock();
txa.preemph.p->position = position;
txa.preemph->position = position;
ch.csDSP.unlock();
}
*/

View File

@ -27,6 +27,7 @@ warren@wpratt.com
#include "comm.hpp"
#include "eq.hpp"
#include "eqp.hpp"
#include "fircore.hpp"
#include "fir.hpp"
#include "RXA.hpp"
@ -34,515 +35,6 @@ warren@wpratt.com
namespace WDSP {
int EQP::fEQcompare (const void * a, const void * b)
{
if (*(float*)a < *(float*)b)
return -1;
else if (*(float*)a == *(float*)b)
return 0;
else
return 1;
}
float* EQP::eq_impulse (int N, int nfreqs, float* F, float* G, double samplerate, double scale, int ctfmode, int wintype)
{
float* fp = new float[nfreqs + 2]; // (float *) malloc0 ((nfreqs + 2) * sizeof (float));
float* gp = new float[nfreqs + 2]; // (float *) malloc0 ((nfreqs + 2) * sizeof (float));
float* A = new float[N / 2 + 1]; // (float *) malloc0 ((N / 2 + 1) * sizeof (float));
float* sary = new float[2 * nfreqs]; // (float *) malloc0 (2 * nfreqs * sizeof (float));
double gpreamp, f, frac;
float* impulse;
int i, j, mid;
fp[0] = 0.0;
fp[nfreqs + 1] = 1.0;
gpreamp = G[0];
for (i = 1; i <= nfreqs; i++)
{
fp[i] = 2.0 * F[i] / samplerate;
if (fp[i] < 0.0)
fp[i] = 0.0;
if (fp[i] > 1.0)
fp[i] = 1.0;
gp[i] = G[i];
}
for (i = 1, j = 0; i <= nfreqs; i++, j+=2)
{
sary[j + 0] = fp[i];
sary[j + 1] = gp[i];
}
qsort (sary, nfreqs, 2 * sizeof (float), fEQcompare);
for (i = 1, j = 0; i <= nfreqs; i++, j+=2)
{
fp[i] = sary[j + 0];
gp[i] = sary[j + 1];
}
gp[0] = gp[1];
gp[nfreqs + 1] = gp[nfreqs];
mid = N / 2;
j = 0;
if (N & 1)
{
for (i = 0; i <= mid; i++)
{
f = (double)i / (double)mid;
while ((f > fp[j + 1]) && (j < nfreqs))
j++;
frac = (f - fp[j]) / (fp[j + 1] - fp[j]);
A[i] = pow (10.0, 0.05 * (frac * gp[j + 1] + (1.0 - frac) * gp[j] + gpreamp)) * scale;
}
}
else
{
for (i = 0; i < mid; i++)
{
f = ((double)i + 0.5) / (double)mid;
while ((f > fp[j + 1]) && (j < nfreqs))
j++;
frac = (f - fp[j]) / (fp[j + 1] - fp[j]);
A[i] = pow (10.0, 0.05 * (frac * gp[j + 1] + (1.0 - frac) * gp[j] + gpreamp)) * scale;
}
}
if (ctfmode == 0)
{
int k, low, high;
double lowmag, highmag, flow4, fhigh4;
if (N & 1)
{
low = (int)(fp[1] * mid);
high = (int)(fp[nfreqs] * mid + 0.5);
lowmag = A[low];
highmag = A[high];
flow4 = pow((double)low / (double)mid, 4.0);
fhigh4 = pow((double)high / (double)mid, 4.0);
k = low;
while (--k >= 0)
{
f = (double)k / (double)mid;
lowmag *= (f * f * f * f) / flow4;
if (lowmag < 1.0e-20) lowmag = 1.0e-20;
A[k] = lowmag;
}
k = high;
while (++k <= mid)
{
f = (double)k / (double)mid;
highmag *= fhigh4 / (f * f * f * f);
if (highmag < 1.0e-20) highmag = 1.0e-20;
A[k] = highmag;
}
}
else
{
low = (int)(fp[1] * mid - 0.5);
high = (int)(fp[nfreqs] * mid - 0.5);
lowmag = A[low];
highmag = A[high];
flow4 = pow((double)low / (double)mid, 4.0);
fhigh4 = pow((double)high / (double)mid, 4.0);
k = low;
while (--k >= 0)
{
f = (double)k / (double)mid;
lowmag *= (f * f * f * f) / flow4;
if (lowmag < 1.0e-20) lowmag = 1.0e-20;
A[k] = lowmag;
}
k = high;
while (++k < mid)
{
f = (double)k / (double)mid;
highmag *= fhigh4 / (f * f * f * f);
if (highmag < 1.0e-20) highmag = 1.0e-20;
A[k] = highmag;
}
}
}
if (N & 1)
impulse = FIR::fir_fsamp_odd(N, A, 1, 1.0, wintype);
else
impulse = FIR::fir_fsamp(N, A, 1, 1.0, wintype);
// print_impulse("eq.txt", N, impulse, 1, 0);
delete[] (sary);
delete[] (A);
delete[] (gp);
delete[] (fp);
return impulse;
}
/********************************************************************************************************
* *
* Partitioned Overlap-Save Equalizer *
* *
********************************************************************************************************/
EQP* EQP::create_eqp (
int run,
int size,
int nc,
int mp,
float *in,
float *out,
int nfreqs,
float* F,
float* G,
int ctfmode,
int wintype,
int samplerate
)
{
// NOTE: 'nc' must be >= 'size'
EQP *a = new EQP;
float* impulse;
a->run = run;
a->size = size;
a->nc = nc;
a->mp = mp;
a->in = in;
a->out = out;
a->nfreqs = nfreqs;
a->F = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
a->G = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
memcpy (a->F, F, (nfreqs + 1) * sizeof (float));
memcpy (a->G, G, (nfreqs + 1) * sizeof (float));
a->ctfmode = ctfmode;
a->wintype = wintype;
a->samplerate = (float)samplerate;
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
a->p = FIRCORE::create_fircore (a->size, a->in, a->out, a->nc, a->mp, impulse);
delete[] (impulse);
return a;
}
void EQP::destroy_eqp (EQP *a)
{
FIRCORE::destroy_fircore (a->p);
delete (a);
}
void EQP::flush_eqp (EQP *a)
{
FIRCORE::flush_fircore (a->p);
}
void EQP::xeqp (EQP *a)
{
if (a->run)
FIRCORE::xfircore (a->p);
else
std::copy( a->in, a->in + a->size * 2, a->out);
}
void EQP::setBuffers_eqp (EQP *a, float* in, float* out)
{
a->in = in;
a->out = out;
FIRCORE::setBuffers_fircore (a->p, a->in, a->out);
}
void EQP::setSamplerate_eqp (EQP *a, int rate)
{
float* impulse;
a->samplerate = rate;
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
delete[] (impulse);
}
void EQP::setSize_eqp (EQP *a, int size)
{
float* impulse;
a->size = size;
FIRCORE::setSize_fircore (a->p, a->size);
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
delete[] (impulse);
}
/********************************************************************************************************
* *
* Partitioned Overlap-Save Equalizer: RXA Properties *
* *
********************************************************************************************************/
void EQP::SetEQRun (RXA& rxa, int run)
{
rxa.eqp->run = run;
}
void EQP::SetEQNC (RXA& rxa, int nc)
{
EQP *a;
float* impulse;
a = rxa.eqp;
if (a->nc != nc)
{
a->nc = nc;
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
FIRCORE::setNc_fircore (a->p, a->nc, impulse);
delete[] (impulse);
}
}
void EQP::SetEQMP (RXA& rxa, int mp)
{
EQP *a;
a = rxa.eqp;
if (a->mp != mp)
{
a->mp = mp;
FIRCORE::setMp_fircore (a->p, a->mp);
}
}
void EQP::SetEQProfile (RXA& rxa, int nfreqs, const float* F, const float* G)
{
EQP *a;
float* impulse;
a = rxa.eqp;
delete[] (a->G);
delete[] (a->F);
a->nfreqs = nfreqs;
a->F = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
a->G = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
memcpy (a->F, F, (nfreqs + 1) * sizeof (float));
memcpy (a->G, G, (nfreqs + 1) * sizeof (float));
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G,
a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
delete[] (impulse);
}
void EQP::SetEQCtfmode (RXA& rxa, int mode)
{
EQP *a;
float* impulse;
a = rxa.eqp;
a->ctfmode = mode;
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
delete[] (impulse);
}
void EQP::SetEQWintype (RXA& rxa, int wintype)
{
EQP *a;
float* impulse;
a = rxa.eqp;
a->wintype = wintype;
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
delete[] (impulse);
}
void EQP::SetGrphEQ (RXA& rxa, int *rxeq)
{ // three band equalizer (legacy compatibility)
EQP *a;
float* impulse;
a = rxa.eqp;
delete[] (a->G);
delete[] (a->F);
a->nfreqs = 4;
a->F = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
a->G = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
a->F[1] = 150.0;
a->F[2] = 400.0;
a->F[3] = 1500.0;
a->F[4] = 6000.0;
a->G[0] = (float)rxeq[0];
a->G[1] = (float)rxeq[1];
a->G[2] = (float)rxeq[1];
a->G[3] = (float)rxeq[2];
a->G[4] = (float)rxeq[3];
a->ctfmode = 0;
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
delete[] (impulse);
}
void EQP::SetGrphEQ10 (RXA& rxa, int *rxeq)
{ // ten band equalizer (legacy compatibility)
EQP *a;
float* impulse;
int i;
a = rxa.eqp;
delete[] (a->G);
delete[] (a->F);
a->nfreqs = 10;
a->F = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
a->G = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
a->F[1] = 32.0;
a->F[2] = 63.0;
a->F[3] = 125.0;
a->F[4] = 250.0;
a->F[5] = 500.0;
a->F[6] = 1000.0;
a->F[7] = 2000.0;
a->F[8] = 4000.0;
a->F[9] = 8000.0;
a->F[10] = 16000.0;
for (i = 0; i <= a->nfreqs; i++)
a->G[i] = (float)rxeq[i];
a->ctfmode = 0;
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
// print_impulse ("rxeq.txt", a->nc, impulse, 1, 0);
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
delete[] (impulse);
}
/********************************************************************************************************
* *
* Partitioned Overlap-Save Equalizer: TXA Properties *
* *
********************************************************************************************************/
void EQP::SetEQRun (TXA& txa, int run)
{
txa.eqp.p->run = run;
}
void EQP::SetEQNC (TXA& txa, int nc)
{
EQP *a;
float* impulse;
a = txa.eqp.p;
if (a->nc != nc)
{
a->nc = nc;
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
FIRCORE::setNc_fircore (a->p, a->nc, impulse);
delete[] (impulse);
}
}
void EQP::SetEQMP (TXA& txa, int mp)
{
EQP *a;
a = txa.eqp.p;
if (a->mp != mp)
{
a->mp = mp;
FIRCORE::setMp_fircore (a->p, a->mp);
}
}
void EQP::SetEQProfile (TXA& txa, int nfreqs, const float* F, const float* G)
{
EQP *a;
float* impulse;
a = txa.eqp.p;
delete[] (a->G);
delete[] (a->F);
a->nfreqs = nfreqs;
a->F = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
a->G = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
memcpy (a->F, F, (nfreqs + 1) * sizeof (float));
memcpy (a->G, G, (nfreqs + 1) * sizeof (float));
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
delete[] (impulse);
}
void EQP::SetEQCtfmode (TXA& txa, int mode)
{
EQP *a;
float* impulse;
a = txa.eqp.p;
a->ctfmode = mode;
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
delete[] (impulse);
}
void EQP::SetEQWintype (TXA& txa, int wintype)
{
EQP *a;
float* impulse;
a = txa.eqp.p;
a->wintype = wintype;
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
delete[] (impulse);
}
void EQP::SetGrphEQ (TXA& txa, int *txeq)
{ // three band equalizer (legacy compatibility)
EQP *a;
float* impulse;
a = txa.eqp.p;
delete[] (a->G);
delete[] (a->F);
a->nfreqs = 4;
a->F = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
a->G = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
a->F[1] = 150.0;
a->F[2] = 400.0;
a->F[3] = 1500.0;
a->F[4] = 6000.0;
a->G[0] = (float)txeq[0];
a->G[1] = (float)txeq[1];
a->G[2] = (float)txeq[1];
a->G[3] = (float)txeq[2];
a->G[4] = (float)txeq[3];
a->ctfmode = 0;
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
delete[] (impulse);
}
void EQP::SetGrphEQ10 (TXA& txa, int *txeq)
{ // ten band equalizer (legacy compatibility)
EQP *a;
float* impulse;
int i;
a = txa.eqp.p;
delete[] (a->G);
delete[] (a->F);
a->nfreqs = 10;
a->F = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
a->G = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
a->F[1] = 32.0;
a->F[2] = 63.0;
a->F[3] = 125.0;
a->F[4] = 250.0;
a->F[5] = 500.0;
a->F[6] = 1000.0;
a->F[7] = 2000.0;
a->F[8] = 4000.0;
a->F[9] = 8000.0;
a->F[10] = 16000.0;
for (i = 0; i <= a->nfreqs; i++)
a->G[i] = (float)txeq[i];
a->ctfmode = 0;
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
delete[] (impulse);
}
/********************************************************************************************************
* *
* Overlap-Save Equalizer *
@ -550,9 +42,9 @@ void EQP::SetGrphEQ10 (TXA& txa, int *txeq)
********************************************************************************************************/
float* EQP::eq_mults (int size, int nfreqs, float* F, float* G, float samplerate, float scale, int ctfmode, int wintype)
float* EQ::eq_mults (int size, int nfreqs, float* F, float* G, float samplerate, float scale, int ctfmode, int wintype)
{
float* impulse = eq_impulse (size + 1, nfreqs, F, G, samplerate, scale, ctfmode, wintype);
float* impulse = EQP::eq_impulse (size + 1, nfreqs, F, G, samplerate, scale, ctfmode, wintype);
float* mults = FIR::fftcv_mults(2 * size, impulse);
delete[] (impulse);
return mults;
@ -565,7 +57,7 @@ void EQ::calc_eq (EQ *a)
a->product = new float[2 * a->size * 2]; // (float *)malloc0(2 * a->size * sizeof(complex));
a->CFor = fftwf_plan_dft_1d(2 * a->size, (fftwf_complex *)a->infilt, (fftwf_complex *)a->product, FFTW_FORWARD, FFTW_PATIENT);
a->CRev = fftwf_plan_dft_1d(2 * a->size, (fftwf_complex *)a->product, (fftwf_complex *)a->out, FFTW_BACKWARD, FFTW_PATIENT);
a->mults = EQP::eq_mults(a->size, a->nfreqs, a->F, a->G, a->samplerate, a->scale, a->ctfmode, a->wintype);
a->mults = EQ::eq_mults(a->size, a->nfreqs, a->F, a->G, a->samplerate, a->scale, a->ctfmode, a->wintype);
}
void EQ::decalc_eq (EQ *a)
@ -663,7 +155,7 @@ PORT
void SetRXAEQRun (int channel, int run)
{
ch.csDSP.lock();
rxa.eq.p->run = run;
rxa.eq->run = run;
ch.csDSP.unlock();
}
@ -672,7 +164,7 @@ void SetRXAEQProfile (int channel, int nfreqs, float* F, float* G)
{
EQ a;
ch.csDSP.lock();
a = rxa.eq.p;
a = rxa.eq;
delete[] (a->G);
delete[] (a->F);
a->nfreqs = nfreqs;
@ -690,7 +182,7 @@ void SetRXAEQCtfmode (int channel, int mode)
{
EQ a;
ch.csDSP.lock();
a = rxa.eq.p;
a = rxa.eq;
a->ctfmode = mode;
delete[] (a->mults);
a->mults = eq_mults (a->size, a->nfreqs, a->F, a->G, a->samplerate, a->scale, a->ctfmode, a->wintype);
@ -702,7 +194,7 @@ void SetRXAEQWintype (int channel, int wintype)
{
EQ a;
ch.csDSP.lock();
a = rxa.eq.p;
a = rxa.eq;
a->wintype = wintype;
delete[] (a->mults);
a->mults = eq_mults (a->size, a->nfreqs, a->F, a->G, a->samplerate, a->scale, a->ctfmode, a->wintype);
@ -714,7 +206,7 @@ void SetRXAGrphEQ (int channel, int *rxeq)
{ // three band equalizer (legacy compatibility)
EQ a;
ch.csDSP.lock();
a = rxa.eq.p;
a = rxa.eq;
delete[] (a->G);
delete[] (a->F);
a->nfreqs = 4;
@ -741,7 +233,7 @@ void SetRXAGrphEQ10 (int channel, int *rxeq)
EQ a;
int i;
ch.csDSP.lock();
a = rxa.eq.p;
a = rxa.eq;
delete[] (a->G);
delete[] (a->F);
a->nfreqs = 10;
@ -775,7 +267,7 @@ PORT
void SetTXAEQRun (int channel, int run)
{
ch.csDSP.lock();
txa.eq.p->run = run;
txa.eq->run = run;
ch.csDSP.unlock();
}
@ -784,7 +276,7 @@ void SetTXAEQProfile (int channel, int nfreqs, float* F, float* G)
{
EQ a;
ch.csDSP.lock();
a = txa.eq.p;
a = txa.eq;
delete[] (a->G);
delete[] (a->F);
a->nfreqs = nfreqs;
@ -802,7 +294,7 @@ void SetTXAEQCtfmode (int channel, int mode)
{
EQ a;
ch.csDSP.lock();
a = txa.eq.p;
a = txa.eq;
a->ctfmode = mode;
delete[] (a->mults);
a->mults = eq_mults (a->size, a->nfreqs, a->F, a->G, a->samplerate, a->scale, a->ctfmode, a->wintype);
@ -814,7 +306,7 @@ void SetTXAEQMethod (int channel, int wintype)
{
EQ a;
ch.csDSP.lock();
a = txa.eq.p;
a = txa.eq;
a->wintype = wintype;
delete[] (a->mults);
a->mults = eq_mults (a->size, a->nfreqs, a->F, a->G, a->samplerate, a->scale, a->ctfmode, a->wintype);
@ -826,7 +318,7 @@ void SetTXAGrphEQ (int channel, int *txeq)
{ // three band equalizer (legacy compatibility)
EQ a;
ch.csDSP.lock();
a = txa.eq.p;
a = txa.eq;
delete[] (a->G);
delete[] (a->F);
a->nfreqs = 4;
@ -853,7 +345,7 @@ void SetTXAGrphEQ10 (int channel, int *txeq)
EQ a;
int i;
ch.csDSP.lock();
a = txa.eq.p;
a = txa.eq;
delete[] (a->G);
delete[] (a->F);
a->nfreqs = 10;

View File

@ -25,92 +25,6 @@ warren@wpratt.com
*/
/********************************************************************************************************
* *
* Partitioned Overlap-Save Equalizer *
* *
********************************************************************************************************/
#ifndef wdsp_eqp_h
#define wdsp_eqp_h
#include "export.h"
namespace WDSP {
class FIRCORE;
class RXA;
class TXA;
class WDSP_API EQP
{
public:
int run;
int size;
int nc;
int mp;
float* in;
float* out;
int nfreqs;
float* F;
float* G;
int ctfmode;
int wintype;
double samplerate;
FIRCORE *p;
static EQP* create_eqp (
int run,
int size,
int nc,
int mp,
float *in,
float *out,
int nfreqs,
float* F,
float* G,
int ctfmode,
int wintype,
int samplerate
);
static float* eq_impulse (int N, int nfreqs, float* F, float* G, double samplerate, double scale, int ctfmode, int wintype);
static void destroy_eqp (EQP *a);
static void flush_eqp (EQP *a);
static void xeqp (EQP *a);
static void setBuffers_eqp (EQP *a, float* in, float* out);
static void setSamplerate_eqp (EQP *a, int rate);
static void setSize_eqp (EQP *a, int size);
// RXA
static void SetEQRun (RXA& rxa, int run);
static void SetEQNC (RXA& rxa, int nc);
static void SetEQMP (RXA& rxa, int mp);
static void SetEQProfile (RXA& rxa, int nfreqs, const float* F, const float* G);
static void SetEQCtfmode (RXA& rxa, int mode);
static void SetEQWintype (RXA& rxa, int wintype);
static void SetGrphEQ (RXA& rxa, int *rxeq);
static void SetGrphEQ10 (RXA& rxa, int *rxeq);
// TXA
static void SetEQRun (TXA& txa, int run);
static void SetEQNC (TXA& txa, int nc);
static void SetEQMP (TXA& txa, int mp);
static void SetEQProfile (TXA& txa, int nfreqs, const float* F, const float* G);
static void SetEQCtfmode (TXA& txa, int mode);
static void SetEQWintype (TXA& txa, int wintype);
static void SetGrphEQ (TXA& txa, int *txeq);
static void SetGrphEQ10 (TXA& txa, int *txeq);
static float* eq_mults (int size, int nfreqs, float* F, float* G, float samplerate, float scale, int ctfmode, int wintype);
private:
static int fEQcompare (const void * a, const void * b);
};
} // namespace WDSP
#endif
/********************************************************************************************************
* *
* Overlap-Save Equalizer *
@ -155,6 +69,7 @@ public:
static void setSize_eq (EQ *a, int size);
private:
static float* eq_mults (int size, int nfreqs, float* F, float* G, float samplerate, float scale, int ctfmode, int wintype);
static void calc_eq (EQ *a);
static void decalc_eq (EQ *a);
};

399
wdsp/eqp.cpp Normal file
View File

@ -0,0 +1,399 @@
/* eq.c
This file is part of a program that implements a Software-Defined Radio.
Copyright (C) 2013, 2016, 2017 Warren Pratt, NR0V
Copyright (C) 2024 Edouard Griffiths, F4EXB Adapted to SDRangel
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached by email at
warren@wpratt.com
*/
#include "comm.hpp"
#include "eqp.hpp"
#include "fircore.hpp"
#include "fir.hpp"
#include "RXA.hpp"
#include "TXA.hpp"
namespace WDSP {
int EQP::fEQcompare (const void * a, const void * b)
{
if (*(float*)a < *(float*)b)
return -1;
else if (*(float*)a == *(float*)b)
return 0;
else
return 1;
}
float* EQP::eq_impulse (int N, int nfreqs, float* F, float* G, double samplerate, double scale, int ctfmode, int wintype)
{
float* fp = new float[nfreqs + 2]; // (float *) malloc0 ((nfreqs + 2) * sizeof (float));
float* gp = new float[nfreqs + 2]; // (float *) malloc0 ((nfreqs + 2) * sizeof (float));
float* A = new float[N / 2 + 1]; // (float *) malloc0 ((N / 2 + 1) * sizeof (float));
float* sary = new float[2 * nfreqs]; // (float *) malloc0 (2 * nfreqs * sizeof (float));
double gpreamp, f, frac;
float* impulse;
int i, j, mid;
fp[0] = 0.0;
fp[nfreqs + 1] = 1.0;
gpreamp = G[0];
for (i = 1; i <= nfreqs; i++)
{
fp[i] = 2.0 * F[i] / samplerate;
if (fp[i] < 0.0)
fp[i] = 0.0;
if (fp[i] > 1.0)
fp[i] = 1.0;
gp[i] = G[i];
}
for (i = 1, j = 0; i <= nfreqs; i++, j+=2)
{
sary[j + 0] = fp[i];
sary[j + 1] = gp[i];
}
qsort (sary, nfreqs, 2 * sizeof (float), fEQcompare);
for (i = 1, j = 0; i <= nfreqs; i++, j+=2)
{
fp[i] = sary[j + 0];
gp[i] = sary[j + 1];
}
gp[0] = gp[1];
gp[nfreqs + 1] = gp[nfreqs];
mid = N / 2;
j = 0;
if (N & 1)
{
for (i = 0; i <= mid; i++)
{
f = (double)i / (double)mid;
while ((f > fp[j + 1]) && (j < nfreqs))
j++;
frac = (f - fp[j]) / (fp[j + 1] - fp[j]);
A[i] = pow (10.0, 0.05 * (frac * gp[j + 1] + (1.0 - frac) * gp[j] + gpreamp)) * scale;
}
}
else
{
for (i = 0; i < mid; i++)
{
f = ((double)i + 0.5) / (double)mid;
while ((f > fp[j + 1]) && (j < nfreqs))
j++;
frac = (f - fp[j]) / (fp[j + 1] - fp[j]);
A[i] = pow (10.0, 0.05 * (frac * gp[j + 1] + (1.0 - frac) * gp[j] + gpreamp)) * scale;
}
}
if (ctfmode == 0)
{
int k, low, high;
double lowmag, highmag, flow4, fhigh4;
if (N & 1)
{
low = (int)(fp[1] * mid);
high = (int)(fp[nfreqs] * mid + 0.5);
lowmag = A[low];
highmag = A[high];
flow4 = pow((double)low / (double)mid, 4.0);
fhigh4 = pow((double)high / (double)mid, 4.0);
k = low;
while (--k >= 0)
{
f = (double)k / (double)mid;
lowmag *= (f * f * f * f) / flow4;
if (lowmag < 1.0e-20) lowmag = 1.0e-20;
A[k] = lowmag;
}
k = high;
while (++k <= mid)
{
f = (double)k / (double)mid;
highmag *= fhigh4 / (f * f * f * f);
if (highmag < 1.0e-20) highmag = 1.0e-20;
A[k] = highmag;
}
}
else
{
low = (int)(fp[1] * mid - 0.5);
high = (int)(fp[nfreqs] * mid - 0.5);
lowmag = A[low];
highmag = A[high];
flow4 = pow((double)low / (double)mid, 4.0);
fhigh4 = pow((double)high / (double)mid, 4.0);
k = low;
while (--k >= 0)
{
f = (double)k / (double)mid;
lowmag *= (f * f * f * f) / flow4;
if (lowmag < 1.0e-20) lowmag = 1.0e-20;
A[k] = lowmag;
}
k = high;
while (++k < mid)
{
f = (double)k / (double)mid;
highmag *= fhigh4 / (f * f * f * f);
if (highmag < 1.0e-20) highmag = 1.0e-20;
A[k] = highmag;
}
}
}
if (N & 1)
impulse = FIR::fir_fsamp_odd(N, A, 1, 1.0, wintype);
else
impulse = FIR::fir_fsamp(N, A, 1, 1.0, wintype);
// print_impulse("eq.txt", N, impulse, 1, 0);
delete[] (sary);
delete[] (A);
delete[] (gp);
delete[] (fp);
return impulse;
}
/********************************************************************************************************
* *
* Partitioned Overlap-Save Equalizer *
* *
********************************************************************************************************/
EQP::EQP(
int _run,
int _size,
int _nc,
int _mp,
float *_in,
float *_out,
int _nfreqs,
float* _F,
float* _G,
int _ctfmode,
int _wintype,
int _samplerate
)
{
// NOTE: 'nc' must be >= 'size'
float* impulse;
run = _run;
size = _size;
nc = _nc;
mp = _mp;
in = _in;
out = _out;
nfreqs = _nfreqs;
F = new float[nfreqs + 1]; // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
G = new float[nfreqs + 1]; // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
memcpy (F, _F, (_nfreqs + 1) * sizeof (float));
memcpy (G, _G, (_nfreqs + 1) * sizeof (float));
ctfmode = _ctfmode;
wintype = _wintype;
samplerate = (double) _samplerate;
impulse = eq_impulse (nc, nfreqs, F, G, samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
fircore = FIRCORE::create_fircore (size, in, out, nc, mp, impulse);
delete[] (impulse);
}
EQP::~EQP()
{
FIRCORE::destroy_fircore (fircore);
}
void EQP::flush()
{
FIRCORE::flush_fircore (fircore);
}
void EQP::execute()
{
if (run)
FIRCORE::xfircore (fircore);
else
std::copy(in, in + size * 2, out);
}
void EQP::setBuffers(float* _in, float* _out)
{
in = _in;
out = _out;
FIRCORE::setBuffers_fircore (fircore, in, out);
}
void EQP::setSamplerate(int rate)
{
float* impulse;
samplerate = rate;
impulse = eq_impulse (nc, nfreqs, F, G, samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
delete[] (impulse);
}
void EQP::setSize(int _size)
{
float* impulse;
size = _size;
FIRCORE::setSize_fircore (fircore, size);
impulse = eq_impulse (nc, nfreqs, F, G, samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
delete[] (impulse);
}
/********************************************************************************************************
* *
* Partitioned Overlap-Save Equalizer: Public Properties *
* *
********************************************************************************************************/
void EQP::setRun(int _run)
{
run = _run;
}
void EQP::setNC(int _nc)
{
float* impulse;
if (nc != _nc)
{
nc = _nc;
impulse = eq_impulse (nc, nfreqs, F, G, samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
FIRCORE::setNc_fircore (fircore, nc, impulse);
delete[] (impulse);
}
}
void EQP::setMP(int _mp)
{
if (mp != _mp)
{
mp = _mp;
FIRCORE::setMp_fircore (fircore, mp);
}
}
void EQP::setProfile(int _nfreqs, const float* _F, const float* _G)
{
float* impulse;
delete[] (G);
delete[] (F);
nfreqs = _nfreqs;
F = new float[nfreqs + 1]; // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
G = new float[nfreqs + 1]; // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
memcpy (F, _F, (_nfreqs + 1) * sizeof (float));
memcpy (G, _G, (_nfreqs + 1) * sizeof (float));
impulse = eq_impulse (nc, nfreqs, F, G,
samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
delete[] (impulse);
}
void EQP::setCtfmode(int _mode)
{
float* impulse;
ctfmode = _mode;
impulse = eq_impulse (nc, nfreqs, F, G, samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
delete[] (impulse);
}
void EQP::setWintype(int _wintype)
{
float* impulse;
wintype = _wintype;
impulse = eq_impulse (nc, nfreqs, F, G, samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
delete[] (impulse);
}
void EQP::setGrphEQ(int *rxeq)
{ // three band equalizer (legacy compatibility)
float* impulse;
delete[] (G);
delete[] (F);
nfreqs = 4;
F = new float[nfreqs + 1]; // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
G = new float[nfreqs + 1]; // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
F[1] = 150.0;
F[2] = 400.0;
F[3] = 1500.0;
F[4] = 6000.0;
G[0] = (float)rxeq[0];
G[1] = (float)rxeq[1];
G[2] = (float)rxeq[1];
G[3] = (float)rxeq[2];
G[4] = (float)rxeq[3];
ctfmode = 0;
impulse = eq_impulse (nc, nfreqs, F, G, samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
delete[] (impulse);
}
void EQP::setGrphEQ10(int *rxeq)
{ // ten band equalizer (legacy compatibility)
float* impulse;
int i;
delete[] (G);
delete[] (F);
nfreqs = 10;
F = new float[nfreqs + 1]; // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
G = new float[nfreqs + 1]; // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
F[1] = 32.0;
F[2] = 63.0;
F[3] = 125.0;
F[4] = 250.0;
F[5] = 500.0;
F[6] = 1000.0;
F[7] = 2000.0;
F[8] = 4000.0;
F[9] = 8000.0;
F[10] = 16000.0;
for (i = 0; i <= nfreqs; i++)
G[i] = (float)rxeq[i];
ctfmode = 0;
impulse = eq_impulse (nc, nfreqs, F, G, samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
// print_impulse ("rxeq.txt", nc, impulse, 1, 0);
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
delete[] (impulse);
}
} // namespace WDSP

101
wdsp/eqp.hpp Normal file
View File

@ -0,0 +1,101 @@
/* eq.h
This file is part of a program that implements a Software-Defined Radio.
Copyright (C) 2013, 2016 Warren Pratt, NR0V
Copyright (C) 2024 Edouard Griffiths, F4EXB Adapted to SDRangel
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached by email at
warren@wpratt.com
*/
/********************************************************************************************************
* *
* Partitioned Overlap-Save Equalizer *
* *
********************************************************************************************************/
#ifndef wdsp_eqp_h
#define wdsp_eqp_h
#include "export.h"
namespace WDSP {
class FIRCORE;
class RXA;
class TXA;
class WDSP_API EQP
{
public:
int run;
int size;
int nc;
int mp;
float* in;
float* out;
int nfreqs;
float* F;
float* G;
int ctfmode;
int wintype;
double samplerate;
FIRCORE *fircore;
EQP(
int run,
int size,
int nc,
int mp,
float *in,
float *out,
int nfreqs,
float* F,
float* G,
int ctfmode,
int wintype,
int samplerate
);
~EQP();
void flush();
void execute();
void setBuffers(float* in, float* out);
void setSamplerate(int rate);
void setSize(int size);
// Public properties
void setRun(int run);
void setNC(int nc);
void setMP(int mp);
void setProfile(int nfreqs, const float* F, const float* G);
void setCtfmode(int mode);
void setWintype(int wintype);
void setGrphEQ(int *rxeq);
void setGrphEQ10(int *rxeq);
static float* eq_impulse (int N, int nfreqs, float* F, float* G, double samplerate, double scale, int ctfmode, int wintype);
private:
static int fEQcompare (const void * a, const void * b);
};
} // namespace WDSP
#endif

View File

@ -167,7 +167,7 @@ void FMMOD::setSize_fmmod (FMMOD *a, int size)
void FMMOD::SetFMDeviation (TXA& txa, float deviation)
{
FMMOD *a = txa.fmmod.p;
FMMOD *a = txa.fmmod;
float bp_fc = a->f_high + 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);
@ -184,7 +184,7 @@ void FMMOD::SetFMDeviation (TXA& txa, float deviation)
void FMMOD::SetCTCSSFreq (TXA& txa, float freq)
{
FMMOD *a;
a = txa.fmmod.p;
a = txa.fmmod;
a->ctcss_freq = freq;
a->tphase = 0.0;
a->tdelta = TWOPI * a->ctcss_freq / a->samplerate;
@ -192,14 +192,14 @@ void FMMOD::SetCTCSSFreq (TXA& txa, float freq)
void FMMOD::SetCTCSSRun (TXA& txa, int run)
{
txa.fmmod.p->ctcss_run = run;
txa.fmmod->ctcss_run = run;
}
void FMMOD::SetFMNC (TXA& txa, int nc)
{
FMMOD *a;
float* impulse;
a = txa.fmmod.p;
a = txa.fmmod;
if (a->nc != nc)
{
@ -213,7 +213,7 @@ void FMMOD::SetFMNC (TXA& txa, int nc)
void FMMOD::SetFMMP (TXA& txa, int mp)
{
FMMOD *a;
a = txa.fmmod.p;
a = txa.fmmod;
if (a->mp != mp)
{
a->mp = mp;
@ -225,7 +225,7 @@ void FMMOD::SetFMAFFreqs (TXA& txa, float low, float high)
{
FMMOD *a;
float* impulse;
a = txa.fmmod.p;
a = txa.fmmod;
if (a->f_low != low || a->f_high != high)
{

View File

@ -27,7 +27,7 @@ warren@wpratt.com
#include "comm.hpp"
#include "fircore.hpp"
#include "eq.hpp"
#include "eqp.hpp"
#include "fmsq.hpp"
namespace WDSP {
@ -123,7 +123,6 @@ FMSQ::FMSQ(
rate((double) _rate),
fc(_fc),
pllpole(_pllpole),
tdelay(_tdelay),
avtau(_avtau),
longtau(_longtau),
tup(_tup),
@ -132,6 +131,7 @@ FMSQ::FMSQ(
unmute_thresh(_unmute_thresh),
min_tail(_min_tail),
max_tail(_max_tail),
tdelay(_tdelay),
nc(_nc),
mp(_mp)
{

View File

@ -449,151 +449,151 @@ void GEN::SetPreSweepRate(float rate)
void GEN::SetPreGenRun (TXA& txa, int run)
{
txa.gen0.p->run = run;
txa.gen0->run = run;
}
void GEN::SetPreGenMode (TXA& txa, int mode)
{
txa.gen0.p->mode = mode;
txa.gen0->mode = mode;
}
void GEN::SetPreGenToneMag (TXA& txa, float mag)
{
txa.gen0.p->tone.mag = mag;
txa.gen0->tone.mag = mag;
}
void GEN::SetPreGenToneFreq (TXA& txa, float freq)
{
txa.gen0.p->tone.freq = freq;
txa.gen0.p->calc_tone();
txa.gen0->tone.freq = freq;
txa.gen0->calc_tone();
}
void GEN::SetPreGenNoiseMag (TXA& txa, float mag)
{
txa.gen0.p->noise.mag = mag;
txa.gen0->noise.mag = mag;
}
void GEN::SetPreGenSweepMag (TXA& txa, float mag)
{
txa.gen0.p->sweep.mag = mag;
txa.gen0->sweep.mag = mag;
}
void GEN::SetPreGenSweepFreq (TXA& txa, float freq1, float freq2)
{
txa.gen0.p->sweep.f1 = freq1;
txa.gen0.p->sweep.f2 = freq2;
txa.gen0.p->calc_sweep();
txa.gen0->sweep.f1 = freq1;
txa.gen0->sweep.f2 = freq2;
txa.gen0->calc_sweep();
}
void GEN::SetPreGenSweepRate (TXA& txa, float rate)
{
txa.gen0.p->sweep.sweeprate = rate;
txa.gen0.p->calc_sweep();
txa.gen0->sweep.sweeprate = rate;
txa.gen0->calc_sweep();
}
void GEN::SetPreGenSawtoothMag (TXA& txa, float mag)
{
txa.gen0.p->saw.mag = mag;
txa.gen0->saw.mag = mag;
}
void GEN::SetPreGenSawtoothFreq (TXA& txa, float freq)
{
txa.gen0.p->saw.f = freq;
txa.gen0.p->calc_sawtooth();
txa.gen0->saw.f = freq;
txa.gen0->calc_sawtooth();
}
void GEN::SetPreGenTriangleMag (TXA& txa, float mag)
{
txa.gen0.p->tri.mag = mag;
txa.gen0->tri.mag = mag;
}
void GEN::SetPreGenTriangleFreq (TXA& txa, float freq)
{
txa.gen0.p->tri.f = freq;
txa.gen0.p->calc_triangle();
txa.gen0->tri.f = freq;
txa.gen0->calc_triangle();
}
void GEN::SetPreGenPulseMag (TXA& txa, float mag)
{
txa.gen0.p->pulse.mag = mag;
txa.gen0->pulse.mag = mag;
}
void GEN::SetPreGenPulseFreq (TXA& txa, float freq)
{
txa.gen0.p->pulse.pf = freq;
txa.gen0.p->calc_pulse();
txa.gen0->pulse.pf = freq;
txa.gen0->calc_pulse();
}
void GEN::SetPreGenPulseDutyCycle (TXA& txa, float dc)
{
txa.gen0.p->pulse.pdutycycle = dc;
txa.gen0.p->calc_pulse();
txa.gen0->pulse.pdutycycle = dc;
txa.gen0->calc_pulse();
}
void GEN::SetPreGenPulseToneFreq (TXA& txa, float freq)
{
txa.gen0.p->pulse.tf = freq;
txa.gen0.p->calc_pulse();
txa.gen0->pulse.tf = freq;
txa.gen0->calc_pulse();
}
void GEN::SetPreGenPulseTransition (TXA& txa, float transtime)
{
txa.gen0.p->pulse.ptranstime = transtime;
txa.gen0.p->calc_pulse();
txa.gen0->pulse.ptranstime = transtime;
txa.gen0->calc_pulse();
}
// 'PostGen', gen1
void GEN::SetPostGenRun (TXA& txa, int run)
{
txa.gen1.p->run = run;
txa.gen1->run = run;
}
void GEN::SetPostGenMode (TXA& txa, int mode)
{
txa.gen1.p->mode = mode;
txa.gen1->mode = mode;
}
void GEN::SetPostGenToneMag (TXA& txa, float mag)
{
txa.gen1.p->tone.mag = mag;
txa.gen1->tone.mag = mag;
}
void GEN::SetPostGenToneFreq (TXA& txa, float freq)
{
txa.gen1.p->tone.freq = freq;
txa.gen1.p->calc_tone();
txa.gen1->tone.freq = freq;
txa.gen1->calc_tone();
}
void GEN::SetPostGenTTMag (TXA& txa, float mag1, float mag2)
{
txa.gen1.p->tt.mag1 = mag1;
txa.gen1.p->tt.mag2 = mag2;
txa.gen1->tt.mag1 = mag1;
txa.gen1->tt.mag2 = mag2;
}
void GEN::SetPostGenTTFreq (TXA& txa, float freq1, float freq2)
{
txa.gen1.p->tt.f1 = freq1;
txa.gen1.p->tt.f2 = freq2;
txa.gen1.p->calc_tt();
txa.gen1->tt.f1 = freq1;
txa.gen1->tt.f2 = freq2;
txa.gen1->calc_tt();
}
void GEN::SetPostGenSweepMag (TXA& txa, float mag)
{
txa.gen1.p->sweep.mag = mag;
txa.gen1->sweep.mag = mag;
}
void GEN::SetPostGenSweepFreq (TXA& txa, float freq1, float freq2)
{
txa.gen1.p->sweep.f1 = freq1;
txa.gen1.p->sweep.f2 = freq2;
txa.gen1.p->calc_sweep();
txa.gen1->sweep.f1 = freq1;
txa.gen1->sweep.f2 = freq2;
txa.gen1->calc_sweep();
}
void GEN::SetPostGenSweepRate (TXA& txa, float rate)
{
txa.gen1.p->sweep.sweeprate = rate;
txa.gen1.p->calc_sweep();
txa.gen1->sweep.sweeprate = rate;
txa.gen1->calc_sweep();
}
} // namespace WDSP

View File

@ -663,7 +663,7 @@ void PHROT::setSize_phrot (PHROT *a, int size)
void PHROT::SetPHROTRun (TXA& txa, int run)
{
PHROT *a = txa.phrot.p;
PHROT *a = txa.phrot;
a->run = run;
if (a->run)
@ -672,7 +672,7 @@ void PHROT::SetPHROTRun (TXA& txa, int run)
void PHROT::SetPHROTCorner (TXA& txa, double corner)
{
PHROT *a = txa.phrot.p;
PHROT *a = txa.phrot;
decalc_phrot (a);
a->fc = corner;
calc_phrot (a);
@ -680,7 +680,7 @@ void PHROT::SetPHROTCorner (TXA& txa, double corner)
void PHROT::SetPHROTNstages (TXA& txa, int nstages)
{
PHROT *a = txa.phrot.p;
PHROT *a = txa.phrot;
decalc_phrot (a);
a->nstages = nstages;
calc_phrot (a);
@ -688,7 +688,7 @@ void PHROT::SetPHROTNstages (TXA& txa, int nstages)
void PHROT::SetPHROTReverse (TXA& txa, int reverse)
{
PHROT *a = txa.phrot.p;
PHROT *a = txa.phrot;
a->reverse = reverse;
}

View File

@ -146,9 +146,9 @@ void OSCTRL::setSize_osctrl (OSCTRL *a, int size)
void OSCTRL::SetosctrlRun (TXA& txa, int run)
{
if (txa.osctrl.p->run != run)
if (txa.osctrl->run != run)
{
txa.osctrl.p->run = run;
txa.osctrl->run = run;
TXA::SetupBPFilters (txa);
}
}

View File

@ -195,23 +195,23 @@ void PANEL::SetPanelBinaural (RXA& rxa, int bin)
void PANEL::SetPanelRun (TXA& txa, int run)
{
txa.panel.p->run = run;
txa.panel->run = run;
}
void PANEL::SetPanelGain1 (TXA& txa, double gain)
{
txa.panel.p->gain1 = gain;
txa.panel->gain1 = gain;
//print_message ("micgainset.txt", "Set MIC Gain to", (int)(100.0 * gain), 0, 0);
}
void PANEL::SetPanelSelect (TXA& txa, int select)
{
if (select == 1)
txa.panel.p->copy = 3;
txa.panel->copy = 3;
else
txa.panel.p->copy = 0;
txa.panel->copy = 0;
txa.panel.p->inselect = select;
txa.panel->inselect = select;
}
} // namespace WDSP

View File

@ -226,25 +226,25 @@ void SIPHON::GetaSipF1 (RXA& rxa, float* out, int size)
void SIPHON::SetSipPosition (TXA& txa, int pos)
{
SIPHON *a = txa.sip1.p;
SIPHON *a = txa.sip1;
a->position = pos;
}
void SIPHON::SetSipMode (TXA& txa, int mode)
{
SIPHON *a = txa.sip1.p;
SIPHON *a = txa.sip1;
a->mode = mode;
}
void SIPHON::SetSipDisplay (TXA& txa, int disp)
{
SIPHON *a = txa.sip1.p;
SIPHON *a = txa.sip1;
a->disp = disp;
}
void SIPHON::GetaSipF (TXA& txa, float* out, int size)
{ // return raw samples as floats
SIPHON *a = txa.sip1.p;
SIPHON *a = txa.sip1;
int i;
a->outsize = size;
suck (a);
@ -256,7 +256,7 @@ void SIPHON::GetaSipF (TXA& txa, float* out, int size)
void SIPHON::GetaSipF1 (TXA& txa, float* out, int size)
{ // return raw samples as floats
SIPHON *a = txa.sip1.p;
SIPHON *a = txa.sip1;
int i;
a->outsize = size;
suck (a);
@ -270,7 +270,7 @@ void SIPHON::GetaSipF1 (TXA& txa, float* out, int size)
void SIPHON::SetSipSpecmode (TXA& txa, int mode)
{
SIPHON *a = txa.sip1.p;
SIPHON *a = txa.sip1;
if (mode == 0)
a->specmode = 0;
else
@ -279,7 +279,7 @@ void SIPHON::SetSipSpecmode (TXA& txa, int mode)
void SIPHON::GetSpecF1 (TXA& txa, float* out)
{ // return spectrum magnitudes in dB
SIPHON *a = txa.sip1.p;
SIPHON *a = txa.sip1;
int i, j, mid, m, n;
a->outsize = a->fftsize;
suck (a);

View File

@ -198,7 +198,7 @@ void USLEW::setSize_uslew (USLEW *a, int size)
void USLEW::SetuSlewTime (TXA& txa, float time)
{
// NOTE: 'time' is in seconds
USLEW *a = txa.uslew.p;
USLEW *a = txa.uslew;
decalc_uslew (a);
a->tupslew = time;
calc_uslew (a);

View File

@ -35,238 +35,251 @@ warren@wpratt.com
#include "anr.hpp"
#include "emnr.hpp"
#include "snba.hpp"
#include "RXA.hpp"
#define MAXIMP 256
namespace WDSP {
void SNBA::calc_snba (SNBA *d)
void SNBA::calc()
{
if (d->inrate >= d->internalrate)
d->isize = d->bsize / (d->inrate / d->internalrate);
if (inrate >= internalrate)
isize = bsize / (inrate / internalrate);
else
d->isize = d->bsize * (d->internalrate / d->inrate);
isize = bsize * (internalrate / inrate);
d->inbuff = new float[d->isize * 2]; // (double *) malloc0 (d->isize * sizeof (complex));
d->outbuff = new float[d->isize * 2]; // (double *) malloc0 (d->isize * sizeof (complex));
inbuff = new float[isize * 2]; // (double *) malloc0 (isize * sizeof (complex));
outbuff = new float[isize * 2]; // (double *) malloc0 (isize * sizeof (complex));
if (d->inrate != d->internalrate)
d->resamprun = 1;
if (inrate != internalrate)
resamprun = 1;
else
d->resamprun = 0;
resamprun = 0;
d->inresamp = new RESAMPLE(
d->resamprun,
d->bsize,
d->in,
d->inbuff,
d->inrate,
d->internalrate,
inresamp = new RESAMPLE(
resamprun,
bsize,
in,
inbuff,
inrate,
internalrate,
0.0,
0,
2.0
);
d->inresamp->setFCLow(250.0);
d->outresamp = new RESAMPLE(
d->resamprun,
d->isize,
d->outbuff,
d->out,
d->internalrate,
d->inrate,
inresamp->setFCLow(250.0);
outresamp = new RESAMPLE(
resamprun,
isize,
outbuff,
out,
internalrate,
inrate,
0.0,
0,
2.0
);
d->outresamp->setFCLow(200.0);
d->incr = d->xsize / d->ovrlp;
outresamp->setFCLow(200.0);
incr = xsize / ovrlp;
if (d->incr > d->isize)
d->iasize = d->incr;
if (incr > isize)
iasize = incr;
else
d->iasize = d->isize;
iasize = isize;
d->iainidx = 0;
d->iaoutidx = 0;
d->inaccum = new double[d->iasize * 2]; // (double *) malloc0 (d->iasize * sizeof (double));
d->nsamps = 0;
iainidx = 0;
iaoutidx = 0;
inaccum = new double[iasize * 2]; // (double *) malloc0 (iasize * sizeof (double));
nsamps = 0;
if (d->incr > d->isize)
if (incr > isize)
{
d->oasize = d->incr;
d->oainidx = 0;
d->oaoutidx = d->isize;
oasize = incr;
oainidx = 0;
oaoutidx = isize;
}
else
{
d->oasize = d->isize;
d->oainidx = 0;
d->oaoutidx = 0;
oasize = isize;
oainidx = 0;
oaoutidx = 0;
}
d->init_oaoutidx = d->oaoutidx;
d->outaccum = new double[d->oasize * 2]; // (double *) malloc0 (d->oasize * sizeof (double));
init_oaoutidx = oaoutidx;
outaccum = new double[oasize * 2]; // (double *) malloc0 (oasize * sizeof (double));
}
SNBA* SNBA::create_snba (
int run,
float* in,
float* out,
int inrate,
int internalrate,
int bsize,
int ovrlp,
int xsize,
int asize,
int npasses,
double k1,
double k2,
int b,
int pre,
int post,
double pmultmin,
double out_low_cut,
double out_high_cut
)
SNBA::SNBA(
int _run,
float* _in,
float* _out,
int _inrate,
int _internalrate,
int _bsize,
int _ovrlp,
int _xsize,
int _asize,
int _npasses,
double _k1,
double _k2,
int _b,
int _pre,
int _post,
double _pmultmin,
double _out_low_cut,
double _out_high_cut
) :
run(_run),
in(_in),
out(_out),
inrate(_inrate),
internalrate(_internalrate),
bsize(_bsize),
xsize(_xsize),
ovrlp(_ovrlp),
incr(0),
iasize(0),
iainidx(0),
iaoutidx(0),
inaccum(nullptr),
xbase(nullptr),
xaux(nullptr),
nsamps(0),
oasize(0),
oainidx(0),
oaoutidx(0),
init_oaoutidx(0),
outaccum(nullptr),
resamprun(0),
isize(0),
inresamp(nullptr),
outresamp(nullptr),
inbuff(nullptr),
outbuff(nullptr),
out_low_cut(_out_low_cut),
out_high_cut(_out_high_cut)
{
SNBA *d = new SNBA;
d->run = run;
d->in = in;
d->out = out;
d->inrate = inrate;
d->internalrate = internalrate;
d->bsize = bsize;
d->ovrlp = ovrlp;
d->xsize = xsize;
d->exec.asize = asize;
d->exec.npasses = npasses;
d->sdet.k1 = k1;
d->sdet.k2 = k2;
d->sdet.b = b;
d->sdet.pre = pre;
d->sdet.post = post;
d->scan.pmultmin = pmultmin;
d->out_low_cut = out_low_cut;
d->out_high_cut = out_high_cut;
exec.asize = _asize;
exec.npasses = _npasses;
sdet.k1 = _k1;
sdet.k2 = _k2;
sdet.b = _b;
sdet.pre = _pre;
sdet.post = _post;
scan.pmultmin = _pmultmin;
calc_snba (d);
calc();
d->xbase = new double[2 * d->xsize]; // (double *) malloc0 (2 * d->xsize * sizeof (double));
d->xaux = d->xbase + d->xsize;
d->exec.a = new double[d->xsize]; //(double *) malloc0 (d->xsize * sizeof (double));
d->exec.v = new double[d->xsize]; //(double *) malloc0 (d->xsize * sizeof (double));
d->exec.detout = new int[d->xsize]; //(int *) malloc0 (d->xsize * sizeof (int));
d->exec.savex = new double[d->xsize]; //(double *) malloc0 (d->xsize * sizeof (double));
d->exec.xHout = new double[d->xsize]; //(double *) malloc0 (d->xsize * sizeof (double));
d->exec.unfixed = new int[d->xsize]; //(int *) malloc0 (d->xsize * sizeof (int));
d->sdet.vp = new double[d->xsize]; //(double *) malloc0 (d->xsize * sizeof (double));
d->sdet.vpwr = new double[d->xsize]; //(double *) malloc0 (d->xsize * sizeof (double));
xbase = new double[2 * xsize]; // (double *) malloc0 (2 * xsize * sizeof (double));
xaux = xbase + xsize;
exec.a = new double[xsize]; //(double *) malloc0 (xsize * sizeof (double));
exec.v = new double[xsize]; //(double *) malloc0 (xsize * sizeof (double));
exec.detout = new int[xsize]; //(int *) malloc0 (xsize * sizeof (int));
exec.savex = new double[xsize]; //(double *) malloc0 (xsize * sizeof (double));
exec.xHout = new double[xsize]; //(double *) malloc0 (xsize * sizeof (double));
exec.unfixed = new int[xsize]; //(int *) malloc0 (xsize * sizeof (int));
sdet.vp = new double[xsize]; //(double *) malloc0 (xsize * sizeof (double));
sdet.vpwr = new double[xsize]; //(double *) malloc0 (xsize * sizeof (double));
d->wrk.xHat_a1rows_max = d->xsize + d->exec.asize;
d->wrk.xHat_a2cols_max = d->xsize + 2 * d->exec.asize;
d->wrk.xHat_r = new double[d->xsize]; // (double *) malloc0 (d->xsize * sizeof(double));
d->wrk.xHat_ATAI = new double[d->xsize * d->xsize]; // (double *) malloc0 (d->xsize * d->xsize * sizeof(double));
d->wrk.xHat_A1 = new double[d->wrk.xHat_a1rows_max * d->xsize]; // (double *) malloc0 (d->wrk.xHat_a1rows_max * d->xsize * sizeof(double));
d->wrk.xHat_A2 = new double[d->wrk.xHat_a1rows_max * d->wrk.xHat_a2cols_max]; // (double *) malloc0 (d->wrk.xHat_a1rows_max * d->wrk.xHat_a2cols_max * sizeof(double));
d->wrk.xHat_P1 = new double[d->xsize * d->wrk.xHat_a2cols_max]; // (double *) malloc0 (d->xsize * d->wrk.xHat_a2cols_max * sizeof(double));
d->wrk.xHat_P2 = new double[d->xsize]; // (double *) malloc0 (d->xsize * sizeof(double));
d->wrk.trI_y = new double[d->xsize - 1]; // (double *) malloc0 ((d->xsize - 1) * sizeof(double));
d->wrk.trI_v = new double[d->xsize - 1]; // (double *) malloc0 ((d->xsize - 1) * sizeof(double));
d->wrk.dR_z = new double[d->xsize - 2]; // (double *) malloc0 ((d->xsize - 2) * sizeof(double));
d->wrk.asolve_r = new double[d->exec.asize + 1]; // (double *) malloc0 ((d->exec.asize + 1) * sizeof(double));
d->wrk.asolve_z = new double[d->exec.asize + 1]; // (double *) malloc0 ((d->exec.asize + 1) * sizeof(double));
return d;
wrk.xHat_a1rows_max = xsize + exec.asize;
wrk.xHat_a2cols_max = xsize + 2 * exec.asize;
wrk.xHat_r = new double[xsize]; // (double *) malloc0 (xsize * sizeof(double));
wrk.xHat_ATAI = new double[xsize * xsize]; // (double *) malloc0 (xsize * xsize * sizeof(double));
wrk.xHat_A1 = new double[wrk.xHat_a1rows_max * xsize]; // (double *) malloc0 (wrk.xHat_a1rows_max * xsize * sizeof(double));
wrk.xHat_A2 = new double[wrk.xHat_a1rows_max * wrk.xHat_a2cols_max]; // (double *) malloc0 (wrk.xHat_a1rows_max * wrk.xHat_a2cols_max * sizeof(double));
wrk.xHat_P1 = new double[xsize * wrk.xHat_a2cols_max]; // (double *) malloc0 (xsize * wrk.xHat_a2cols_max * sizeof(double));
wrk.xHat_P2 = new double[xsize]; // (double *) malloc0 (xsize * sizeof(double));
wrk.trI_y = new double[xsize - 1]; // (double *) malloc0 ((xsize - 1) * sizeof(double));
wrk.trI_v = new double[xsize - 1]; // (double *) malloc0 ((xsize - 1) * sizeof(double));
wrk.dR_z = new double[xsize - 2]; // (double *) malloc0 ((xsize - 2) * sizeof(double));
wrk.asolve_r = new double[exec.asize + 1]; // (double *) malloc0 ((exec.asize + 1) * sizeof(double));
wrk.asolve_z = new double[exec.asize + 1]; // (double *) malloc0 ((exec.asize + 1) * sizeof(double));
}
void SNBA::decalc_snba (SNBA *d)
void SNBA::decalc()
{
delete (d->outresamp);
delete (d->inresamp);
delete[] (d->outbuff);
delete[] (d->inbuff);
delete[] (d->outaccum);
delete[] (d->inaccum);
delete (outresamp);
delete (inresamp);
delete[] (outbuff);
delete[] (inbuff);
delete[] (outaccum);
delete[] (inaccum);
}
void SNBA::destroy_snba (SNBA *d)
SNBA::~SNBA()
{
delete[] (d->wrk.xHat_r);
delete[] (d->wrk.xHat_ATAI);
delete[] (d->wrk.xHat_A1);
delete[] (d->wrk.xHat_A2);
delete[] (d->wrk.xHat_P1);
delete[] (d->wrk.xHat_P2);
delete[] (d->wrk.trI_y);
delete[] (d->wrk.trI_v);
delete[] (d->wrk.dR_z);
delete[] (d->wrk.asolve_r);
delete[] (d->wrk.asolve_z);
delete[] (wrk.xHat_r);
delete[] (wrk.xHat_ATAI);
delete[] (wrk.xHat_A1);
delete[] (wrk.xHat_A2);
delete[] (wrk.xHat_P1);
delete[] (wrk.xHat_P2);
delete[] (wrk.trI_y);
delete[] (wrk.trI_v);
delete[] (wrk.dR_z);
delete[] (wrk.asolve_r);
delete[] (wrk.asolve_z);
delete[] (d->sdet.vpwr);
delete[] (d->sdet.vp);
delete[] (d->exec.unfixed);
delete[] (d->exec.xHout);
delete[] (d->exec.savex);
delete[] (d->exec.detout);
delete[] (d->exec.v);
delete[] (d->exec.a);
delete[] (sdet.vpwr);
delete[] (sdet.vp);
delete[] (exec.unfixed);
delete[] (exec.xHout);
delete[] (exec.savex);
delete[] (exec.detout);
delete[] (exec.v);
delete[] (exec.a);
delete[] (d->xbase);
delete[] (xbase);
decalc_snba (d);
delete[] (d);
decalc();
}
void SNBA::flush_snba (SNBA *d)
void SNBA::flush()
{
d->iainidx = 0;
d->iaoutidx = 0;
d->nsamps = 0;
d->oainidx = 0;
d->oaoutidx = d->init_oaoutidx;
iainidx = 0;
iaoutidx = 0;
nsamps = 0;
oainidx = 0;
oaoutidx = init_oaoutidx;
memset (d->inaccum, 0, d->iasize * sizeof (double));
memset (d->outaccum, 0, d->oasize * sizeof (double));
memset (d->xaux, 0, d->xsize * sizeof (double));
memset (d->exec.a, 0, d->xsize * sizeof (double));
memset (d->exec.v, 0, d->xsize * sizeof (double));
memset (d->exec.detout, 0, d->xsize * sizeof (int));
memset (d->exec.savex, 0, d->xsize * sizeof (double));
memset (d->exec.xHout, 0, d->xsize * sizeof (double));
memset (d->exec.unfixed, 0, d->xsize * sizeof (int));
memset (d->sdet.vp, 0, d->xsize * sizeof (double));
memset (d->sdet.vpwr, 0, d->xsize * sizeof (double));
memset (inaccum, 0, iasize * sizeof (double));
memset (outaccum, 0, oasize * sizeof (double));
memset (xaux, 0, xsize * sizeof (double));
memset (exec.a, 0, xsize * sizeof (double));
memset (exec.v, 0, xsize * sizeof (double));
memset (exec.detout, 0, xsize * sizeof (int));
memset (exec.savex, 0, xsize * sizeof (double));
memset (exec.xHout, 0, xsize * sizeof (double));
memset (exec.unfixed, 0, xsize * sizeof (int));
memset (sdet.vp, 0, xsize * sizeof (double));
memset (sdet.vpwr, 0, xsize * sizeof (double));
std::fill(d->inbuff, d->inbuff + d->isize * 2, 0);
std::fill(d->outbuff, d->outbuff + d->isize * 2, 0);
std::fill(inbuff, inbuff + isize * 2, 0);
std::fill(outbuff, outbuff + isize * 2, 0);
d->inresamp->flush();
d->outresamp->flush();
inresamp->flush();
outresamp->flush();
}
void SNBA::setBuffers_snba (SNBA *a, float* in, float* out)
void SNBA::setBuffers(float* _in, float* _out)
{
decalc_snba (a);
a->in = in;
a->out = out;
calc_snba (a);
decalc();
in = _in;
out = _out;
calc();
}
void SNBA::setSamplerate_snba (SNBA *a, int rate)
void SNBA::setSamplerate(int rate)
{
decalc_snba (a);
a->inrate = rate;
calc_snba (a);
decalc();
inrate = rate;
calc();
}
void SNBA::setSize_snba (SNBA *a, int size)
void SNBA::setSize(int size)
{
decalc_snba (a);
a->bsize = size;
calc_snba (a);
decalc();
bsize = size;
calc();
}
void SNBA::ATAc0 (int n, int nr, double* A, double* r)
@ -404,35 +417,35 @@ void SNBA::invf(int xsize, int asize, double* a, double* x, double* v)
}
}
void SNBA::det(SNBA *d, int asize, double* v, int* detout)
void SNBA::det(int asize, double* v, int* detout)
{
int i, j;
double medpwr;
double t1, t2;
int bstate, bcount, bsamp;
for (i = asize, j = 0; i < d->xsize; i++, j++)
for (i = asize, j = 0; i < xsize; i++, j++)
{
d->sdet.vpwr[i] = v[i] * v[i];
d->sdet.vp[j] = d->sdet.vpwr[i];
sdet.vpwr[i] = v[i] * v[i];
sdet.vp[j] = sdet.vpwr[i];
}
LMathd::median(d->xsize - asize, d->sdet.vp, &medpwr);
t1 = d->sdet.k1 * medpwr;
LMathd::median(xsize - asize, sdet.vp, &medpwr);
t1 = sdet.k1 * medpwr;
t2 = 0.0;
for (i = asize; i < d->xsize; i++)
for (i = asize; i < xsize; i++)
{
if (d->sdet.vpwr[i] <= t1)
t2 += d->sdet.vpwr[i];
else if (d->sdet.vpwr[i] <= 2.0 * t1)
t2 += 2.0 * t1 - d->sdet.vpwr[i];
if (sdet.vpwr[i] <= t1)
t2 += sdet.vpwr[i];
else if (sdet.vpwr[i] <= 2.0 * t1)
t2 += 2.0 * t1 - sdet.vpwr[i];
}
t2 *= d->sdet.k2 / (double) (d->xsize - asize);
t2 *= sdet.k2 / (double) (xsize - asize);
for (i = asize; i < d->xsize; i++)
for (i = asize; i < xsize; i++)
{
if (d->sdet.vpwr[i] > t2)
if (sdet.vpwr[i] > t2)
detout[i] = 1;
else
detout[i] = 0;
@ -442,7 +455,7 @@ void SNBA::det(SNBA *d, int asize, double* v, int* detout)
bcount = 0;
bsamp = 0;
for (i = asize; i < d->xsize; i++)
for (i = asize; i < xsize; i++)
{
switch (bstate)
{
@ -465,7 +478,7 @@ void SNBA::det(SNBA *d, int asize, double* v, int* detout)
case 2:
++bcount;
if (bcount > d->sdet.b)
if (bcount > sdet.b)
{
if (detout[i] == 1)
bstate = 1;
@ -483,11 +496,11 @@ void SNBA::det(SNBA *d, int asize, double* v, int* detout)
}
}
for (i = asize; i < d->xsize; i++)
for (i = asize; i < xsize; i++)
{
if (detout[i] == 1)
{
for (j = i - 1; j > i - 1 - d->sdet.pre; j--)
for (j = i - 1; j > i - 1 - sdet.pre; j--)
{
if (j >= asize)
detout[j] = 1;
@ -495,13 +508,13 @@ void SNBA::det(SNBA *d, int asize, double* v, int* detout)
}
}
for (i = d->xsize - 1; i >= asize; i--)
for (i = xsize - 1; i >= asize; i--)
{
if (detout[i] == 1)
{
for (j = i + 1; j < i + 1 + d->sdet.post; j++)
for (j = i + 1; j < i + 1 + sdet.post; j++)
{
if (j < d->xsize)
if (j < xsize)
detout[j] = 1;
}
}
@ -619,7 +632,7 @@ int SNBA::scanFrame(
return nimp;
}
void SNBA::execFrame(SNBA *d, double* x)
void SNBA::execFrame(double* x)
{
int i, k;
int pass;
@ -631,200 +644,190 @@ void SNBA::execFrame(SNBA *d, double* x)
int p_opt[MAXIMP];
int next = 0;
int p;
memcpy (d->exec.savex, x, d->xsize * sizeof (double));
LMathd::asolve(d->xsize, d->exec.asize, x, d->exec.a, d->wrk.asolve_r, d->wrk.asolve_z);
invf(d->xsize, d->exec.asize, d->exec.a, x, d->exec.v);
det(d, d->exec.asize, d->exec.v, d->exec.detout);
memcpy (exec.savex, x, xsize * sizeof (double));
LMathd::asolve(xsize, exec.asize, x, exec.a, wrk.asolve_r, wrk.asolve_z);
invf(xsize, exec.asize, exec.a, x, exec.v);
det(exec.asize, exec.v, exec.detout);
for (i = 0; i < d->xsize; i++)
for (i = 0; i < xsize; i++)
{
if (d->exec.detout[i] != 0)
if (exec.detout[i] != 0)
x[i] = 0.0;
}
nimp = scanFrame(d->xsize, d->exec.asize, d->scan.pmultmin, d->exec.detout, bimp, limp, befimp, aftimp, p_opt, &next);
nimp = scanFrame(xsize, exec.asize, scan.pmultmin, exec.detout, bimp, limp, befimp, aftimp, p_opt, &next);
for (pass = 0; pass < d->exec.npasses; pass++)
for (pass = 0; pass < exec.npasses; pass++)
{
memcpy (d->exec.unfixed, d->exec.detout, d->xsize * sizeof (int));
memcpy (exec.unfixed, exec.detout, xsize * sizeof (int));
for (k = 0; k < nimp; k++)
{
if (k > 0)
scanFrame(d->xsize, d->exec.asize, d->scan.pmultmin, d->exec.unfixed, bimp, limp, befimp, aftimp, p_opt, &next);
scanFrame(xsize, exec.asize, scan.pmultmin, exec.unfixed, bimp, limp, befimp, aftimp, p_opt, &next);
if ((p = p_opt[next]) > 0)
{
LMathd::asolve(d->xsize, p, x, d->exec.a, d->wrk.asolve_r, d->wrk.asolve_z);
xHat(limp[next], p, &x[bimp[next] - p], d->exec.a, d->exec.xHout,
d->wrk.xHat_r, d->wrk.xHat_ATAI, d->wrk.xHat_A1, d->wrk.xHat_A2,
d->wrk.xHat_P1, d->wrk.xHat_P2, d->wrk.trI_y, d->wrk.trI_v, d->wrk.dR_z);
memcpy (&x[bimp[next]], d->exec.xHout, limp[next] * sizeof (double));
memset (&d->exec.unfixed[bimp[next]], 0, limp[next] * sizeof (int));
LMathd::asolve(xsize, p, x, exec.a, wrk.asolve_r, wrk.asolve_z);
xHat(
limp[next],
p,
&x[bimp[next] - p],
exec.a,
exec.xHout,
wrk.xHat_r,
wrk.xHat_ATAI,
wrk.xHat_A1,
wrk.xHat_A2,
wrk.xHat_P1,
wrk.xHat_P2,
wrk.trI_y,
wrk.trI_v,
wrk.dR_z
);
memcpy (&x[bimp[next]], exec.xHout, limp[next] * sizeof (double));
memset (&exec.unfixed[bimp[next]], 0, limp[next] * sizeof (int));
}
else
{
memcpy (&x[bimp[next]], &d->exec.savex[bimp[next]], limp[next] * sizeof (double));
memcpy (&x[bimp[next]], &exec.savex[bimp[next]], limp[next] * sizeof (double));
}
}
}
}
void SNBA::xsnba (SNBA *d)
void SNBA::execute()
{
if (d->run)
if (run)
{
int i;
d->inresamp->execute();
inresamp->execute();
for (i = 0; i < 2 * d->isize; i += 2)
for (i = 0; i < 2 * isize; i += 2)
{
d->inaccum[d->iainidx] = d->inbuff[i];
d->iainidx = (d->iainidx + 1) % d->iasize;
inaccum[iainidx] = inbuff[i];
iainidx = (iainidx + 1) % iasize;
}
d->nsamps += d->isize;
nsamps += isize;
while (d->nsamps >= d->incr)
while (nsamps >= incr)
{
memcpy (&d->xaux[d->xsize - d->incr], &d->inaccum[d->iaoutidx], d->incr * sizeof (double));
execFrame (d, d->xaux);
d->iaoutidx = (d->iaoutidx + d->incr) % d->iasize;
d->nsamps -= d->incr;
memcpy (&d->outaccum[d->oainidx], d->xaux, d->incr * sizeof (double));
d->oainidx = (d->oainidx + d->incr) % d->oasize;
memmove (d->xbase, &d->xbase[d->incr], (2 * d->xsize - d->incr) * sizeof (double));
memcpy (&xaux[xsize - incr], &inaccum[iaoutidx], incr * sizeof (double));
execFrame (xaux);
iaoutidx = (iaoutidx + incr) % iasize;
nsamps -= incr;
memcpy (&outaccum[oainidx], xaux, incr * sizeof (double));
oainidx = (oainidx + incr) % oasize;
memmove (xbase, &xbase[incr], (2 * xsize - incr) * sizeof (double));
}
for (i = 0; i < d->isize; i++)
for (i = 0; i < isize; i++)
{
d->outbuff[2 * i + 0] = d->outaccum[d->oaoutidx];
d->outbuff[2 * i + 1] = 0.0;
d->oaoutidx = (d->oaoutidx + 1) % d->oasize;
outbuff[2 * i + 0] = outaccum[oaoutidx];
outbuff[2 * i + 1] = 0.0;
oaoutidx = (oaoutidx + 1) % oasize;
}
d->outresamp->execute();
outresamp->execute();
}
else if (d->out != d->in)
else if (out != in)
{
std::copy(d->in, d->in + d->bsize * 2, d->out);
std::copy(in, in + bsize * 2, out);
}
}
/********************************************************************************************************
* *
* RXA Properties *
* Public Properties *
* *
********************************************************************************************************/
void SNBA::SetSNBARun (RXA& rxa, int run)
void SNBA::setOvrlp(int _ovrlp)
{
SNBA *a = rxa.snba;
if (a->run != run)
{
RXA::bpsnbaCheck (rxa, rxa.mode, rxa.ndb->master_run);
RXA::bp1Check (
rxa,
rxa.amd->run,
run,
rxa.emnr->run,
rxa.anf->run,
rxa.anr->run
);
a->run = run;
RXA::bp1Set (rxa);
RXA::bpsnbaSet (rxa);
}
decalc();
ovrlp = _ovrlp;
calc();
}
void SNBA::SetSNBAovrlp (RXA& rxa, int ovrlp)
void SNBA::setAsize(int size)
{
decalc_snba (rxa.snba);
rxa.snba->ovrlp = ovrlp;
calc_snba (rxa.snba);
exec.asize = size;
}
void SNBA::SetSNBAasize (RXA& rxa, int size)
void SNBA::setNpasses(int npasses)
{
rxa.snba->exec.asize = size;
exec.npasses = npasses;
}
void SNBA::SetSNBAnpasses (RXA& rxa, int npasses)
void SNBA::setK1(double k1)
{
rxa.snba->exec.npasses = npasses;
sdet.k1 = k1;
}
void SNBA::SetSNBAk1 (RXA& rxa, double k1)
void SNBA::setK2(double k2)
{
rxa.snba->sdet.k1 = k1;
sdet.k2 = k2;
}
void SNBA::SetSNBAk2 (RXA& rxa, double k2)
void SNBA::setBridge(int bridge)
{
rxa.snba->sdet.k2 = k2;
sdet.b = bridge;
}
void SNBA::SetSNBAbridge (RXA& rxa, int bridge)
void SNBA::setPresamps(int presamps)
{
rxa.snba->sdet.b = bridge;
sdet.pre = presamps;
}
void SNBA::SetSNBApresamps (RXA& rxa, int presamps)
void SNBA::setPostsamps(int postsamps)
{
rxa.snba->sdet.pre = presamps;
sdet.post = postsamps;
}
void SNBA::SetSNBApostsamps (RXA& rxa, int postsamps)
void SNBA::setPmultmin(double pmultmin)
{
rxa.snba->sdet.post = postsamps;
scan.pmultmin = pmultmin;
}
void SNBA::SetSNBApmultmin (RXA& rxa, double pmultmin)
void SNBA::setOutputBandwidth(double flow, double fhigh)
{
rxa.snba->scan.pmultmin = pmultmin;
}
void SNBA::SetSNBAOutputBandwidth (RXA& rxa, double flow, double fhigh)
{
SNBA *a = rxa.snba;
RESAMPLE *d = a->outresamp;
double f_low, f_high;
if (flow >= 0 && fhigh >= 0)
{
if (fhigh < a->out_low_cut)
fhigh = a->out_low_cut;
if (fhigh < out_low_cut)
fhigh = out_low_cut;
if (flow > a->out_high_cut)
flow = a->out_high_cut;
if (flow > out_high_cut)
flow = out_high_cut;
f_low = std::max ( a->out_low_cut, flow);
f_high = std::min (a->out_high_cut, fhigh);
f_low = std::max ( out_low_cut, flow);
f_high = std::min (out_high_cut, fhigh);
}
else if (flow <= 0 && fhigh <= 0)
{
if (flow > -a->out_low_cut)
flow = -a->out_low_cut;
if (flow > -out_low_cut)
flow = -out_low_cut;
if (fhigh < -a->out_high_cut)
fhigh = -a->out_high_cut;
if (fhigh < -out_high_cut)
fhigh = -out_high_cut;
f_low = std::max ( a->out_low_cut, -fhigh);
f_high = std::min (a->out_high_cut, -flow);
f_low = std::max ( out_low_cut, -fhigh);
f_high = std::min (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 < out_low_cut)
absmax = out_low_cut;
f_low = a->out_low_cut;
f_high = std::min (a->out_high_cut, absmax);
f_low = out_low_cut;
f_high = std::min (out_high_cut, absmax);
}
d->setBandwidth(f_low, f_high);
outresamp->setBandwidth(f_low, f_high);
}
} // namespace

View File

@ -31,7 +31,6 @@ warren@wpratt.com
namespace WDSP{
class RESAMPLE;
class RXA;
class SNBA
{
@ -57,13 +56,15 @@ public:
int oaoutidx;
int init_oaoutidx;
double* outaccum;
int resamprun;
int isize;
RESAMPLE *inresamp;
RESAMPLE *outresamp;
float* inbuff;
float* outbuff;
double out_low_cut;
double out_high_cut;
struct _exec
{
int asize;
@ -105,10 +106,8 @@ public:
double* asolve_r;
double* asolve_z;
} wrk;
double out_low_cut;
double out_high_cut;
static SNBA* create_snba (
SNBA(
int run,
float* in,
float* out,
@ -128,29 +127,28 @@ public:
double out_low_cut,
double out_high_cut
);
~SNBA();
static void destroy_snba (SNBA *d);
static void flush_snba (SNBA *d);
static void xsnba (SNBA *d);
static void setBuffers_snba (SNBA *a, float* in, float* out);
static void setSamplerate_snba (SNBA *a, int rate);
static void setSize_snba (SNBA *a, int size);
// RXA Properties
static void SetSNBARun (RXA& rxa, int run);
static void SetSNBAovrlp (RXA& rxa, int ovrlp);
static void SetSNBAasize (RXA& rxa, int size);
static void SetSNBAnpasses (RXA& rxa, int npasses);
static void SetSNBAk1 (RXA& rxa, double k1);
static void SetSNBAk2 (RXA& rxa, double k2);
static void SetSNBAbridge (RXA& rxa, int bridge);
static void SetSNBApresamps (RXA& rxa, int presamps);
static void SetSNBApostsamps (RXA& rxa, int postsamps);
static void SetSNBApmultmin (RXA& rxa, double pmultmin);
static void SetSNBAOutputBandwidth (RXA& rxa, double flow, double fhigh);
void flush();
void execute();
void setBuffers(float* in, float* out);
void setSamplerate(int rate);
void setSize(int size);
// Public Properties
void setOvrlp(int ovrlp);
void setAsize(int size);
void setNpasses(int npasses);
void setK1(double k1);
void setK2(double k2);
void setBridge(int bridge);
void setPresamps(int presamps);
void setPostsamps(int postsamps);
void setPmultmin(double pmultmin);
void setOutputBandwidth(double flow, double fhigh);
private:
static void calc_snba (SNBA *d);
static void decalc_snba (SNBA *d);
void calc();
void decalc();
static void ATAc0 (int n, int nr, double* A, double* r);
static void multA1TA2(double* a1, double* a2, int m, int n, int q, double* c);
static void multXKE(double* a, double* xk, int m, int q, int p, double* vout);
@ -172,7 +170,6 @@ private:
double* dR_z
);
static void invf(int xsize, int asize, double* a, double* x, double* v);
static void det(SNBA *d, int asize, double* v, int* detout);
static int scanFrame(
int xsize,
int pval,
@ -185,7 +182,8 @@ private:
int* p_opt,
int* next
);
static void execFrame(SNBA *d, double* x);
void det(int asize, double* v, int* detout);
void execFrame(double* x);
};
} // namespace

View File

@ -535,60 +535,60 @@ void WCPAGC::SetAGCMaxInputLevel (RXA& rxa, double level)
void WCPAGC::SetALCSt (TXA& txa, int state)
{
txa.alc.p->run = state;
txa.alc->run = state;
}
void WCPAGC::SetALCAttack (TXA& txa, int attack)
{
txa.alc.p->tau_attack = (double) attack / 1000.0;
loadWcpAGC(txa.alc.p);
txa.alc->tau_attack = (double) attack / 1000.0;
loadWcpAGC(txa.alc);
}
void WCPAGC::SetALCDecay (TXA& txa, int decay)
{
txa.alc.p->tau_decay = (double) decay / 1000.0;
loadWcpAGC(txa.alc.p);
txa.alc->tau_decay = (double) decay / 1000.0;
loadWcpAGC(txa.alc);
}
void WCPAGC::SetALCHang (TXA& txa, int hang)
{
txa.alc.p->hangtime = (double) hang / 1000.0;
loadWcpAGC(txa.alc.p);
txa.alc->hangtime = (double) hang / 1000.0;
loadWcpAGC(txa.alc);
}
void WCPAGC::SetALCMaxGain (TXA& txa, double maxgain)
{
txa.alc.p->max_gain = pow (10.0,(double) maxgain / 20.0);
loadWcpAGC(txa.alc.p);
txa.alc->max_gain = pow (10.0,(double) maxgain / 20.0);
loadWcpAGC(txa.alc);
}
void WCPAGC::SetLevelerSt (TXA& txa, int state)
{
txa.leveler.p->run = state;
txa.leveler->run = state;
}
void WCPAGC::SetLevelerAttack (TXA& txa, int attack)
{
txa.leveler.p->tau_attack = (double) attack / 1000.0;
loadWcpAGC(txa.leveler.p);
txa.leveler->tau_attack = (double) attack / 1000.0;
loadWcpAGC(txa.leveler);
}
void WCPAGC::SetLevelerDecay (TXA& txa, int decay)
{
txa.leveler.p->tau_decay = (double) decay / 1000.0;
loadWcpAGC(txa.leveler.p);
txa.leveler->tau_decay = (double) decay / 1000.0;
loadWcpAGC(txa.leveler);
}
void WCPAGC::SetLevelerHang (TXA& txa, int hang)
{
txa.leveler.p->hangtime = (double) hang / 1000.0;
loadWcpAGC(txa.leveler.p);
txa.leveler->hangtime = (double) hang / 1000.0;
loadWcpAGC(txa.leveler);
}
void WCPAGC::SetLevelerTop (TXA& txa, double maxgain)
{
txa.leveler.p->max_gain = pow (10.0,(double) maxgain / 20.0);
loadWcpAGC(txa.leveler.p);
txa.leveler->max_gain = pow (10.0,(double) maxgain / 20.0);
loadWcpAGC(txa.leveler);
}
} // namespace WDSP