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

WDSP: FMD and FMSQ: replaced static methods

This commit is contained in:
f4exb 2024-07-26 19:10:53 +02:00
parent a239fe47e9
commit 8c08f40b54
6 changed files with 434 additions and 468 deletions

View File

@ -649,29 +649,29 @@ void WDSPRxSink::applySettings(const WDSPRxSettings& settings, bool force)
// FM options // FM options
if ((m_settings.m_fmDeviation != settings.m_fmDeviation) || force) { if ((m_settings.m_fmDeviation != settings.m_fmDeviation) || force) {
WDSP::FMD::SetFMDeviation(*m_rxa, settings.m_fmDeviation); m_rxa->fmd->setDeviation(settings.m_fmDeviation);
} }
if ((m_settings.m_fmAFLow != settings.m_fmAFLow) if ((m_settings.m_fmAFLow != settings.m_fmAFLow)
|| (m_settings.m_fmAFHigh != settings.m_fmAFHigh) || force) || (m_settings.m_fmAFHigh != settings.m_fmAFHigh) || force)
{ {
WDSP::FMD::SetFMAFFilter(*m_rxa, settings.m_fmAFLow, settings.m_fmAFHigh); m_rxa->fmd->setAFFilter(settings.m_fmAFLow, settings.m_fmAFHigh);
} }
if ((m_settings.m_fmAFLimiter != settings.m_fmAFLimiter) || force) { if ((m_settings.m_fmAFLimiter != settings.m_fmAFLimiter) || force) {
WDSP::FMD::SetFMLimRun(*m_rxa, settings.m_fmAFLimiter ? 1 : 0); m_rxa->fmd->setLimRun(settings.m_fmAFLimiter ? 1 : 0);
} }
if ((m_settings.m_fmAFLimiterGain != settings.m_fmAFLimiterGain) || force) { if ((m_settings.m_fmAFLimiterGain != settings.m_fmAFLimiterGain) || force) {
WDSP::FMD::SetFMLimGain(*m_rxa, settings.m_fmAFLimiterGain); m_rxa->fmd->setLimGain(settings.m_fmAFLimiterGain);
} }
if ((m_settings.m_fmCTCSSNotch != settings.m_fmCTCSSNotch) || force) { if ((m_settings.m_fmCTCSSNotch != settings.m_fmCTCSSNotch) || force) {
WDSP::FMD::SetCTCSSRun(*m_rxa, settings.m_fmCTCSSNotch ? 1 : 0); m_rxa->fmd->setCTCSSRun(settings.m_fmCTCSSNotch ? 1 : 0);
} }
if ((m_settings.m_fmCTCSSNotchFrequency != settings.m_fmCTCSSNotchFrequency) || force) { if ((m_settings.m_fmCTCSSNotchFrequency != settings.m_fmCTCSSNotchFrequency) || force) {
WDSP::FMD::SetCTCSSFreq(*m_rxa, settings.m_fmCTCSSNotchFrequency); m_rxa->fmd->setCTCSSFreq(settings.m_fmCTCSSNotchFrequency);
} }
// Squelch // Squelch
@ -682,7 +682,7 @@ void WDSPRxSink::applySettings(const WDSPRxSettings& settings, bool force)
{ {
WDSP::SSQL::SetSSQLRun(*m_rxa, 0); WDSP::SSQL::SetSSQLRun(*m_rxa, 0);
m_rxa->amsq->setRun(0); m_rxa->amsq->setRun(0);
WDSP::FMSQ::SetFMSQRun(*m_rxa, 0); m_rxa->fmsq->setRun(0);
if (settings.m_squelch) if (settings.m_squelch)
{ {
@ -704,10 +704,10 @@ void WDSPRxSink::applySettings(const WDSPRxSettings& settings, bool force)
break; break;
case WDSPRxProfile::SquelchModeFM: case WDSPRxProfile::SquelchModeFM:
{ {
WDSP::FMSQ::SetFMSQRun(*m_rxa, 1); m_rxa->fmsq->setRun(1);
double threshold = pow(10.0, -2.0 * ((double) settings.m_squelchThreshold) / 100.0); double threshold = pow(10.0, -2.0 * ((double) settings.m_squelchThreshold) / 100.0);
qDebug("WDSPRxSink::applySettings: FM squelch %lf", threshold); qDebug("WDSPRxSink::applySettings: FM squelch %lf", threshold);
WDSP::FMSQ::SetFMSQThreshold(*m_rxa, threshold); m_rxa->fmsq->setThreshold(threshold);
} }
break; break;
default: default:

View File

@ -261,7 +261,7 @@ RXA* RXA::create_rxa (
1.4); // tauI 1.4); // tauI
// FM demodulator // FM demodulator
rxa->fmd = FMD::create_fmd ( rxa->fmd = new FMD(
0, // run 0, // run
rxa->dsp_size, // buffer size rxa->dsp_size, // buffer size
rxa->midbuff, // pointer to input buffer rxa->midbuff, // pointer to input buffer
@ -284,7 +284,7 @@ RXA* RXA::create_rxa (
0); // min phase flag for audio cutoff filter 0); // min phase flag for audio cutoff filter
// FM squelch apply // FM squelch apply
rxa->fmsq = FMSQ::create_fmsq ( rxa->fmsq = new FMSQ(
0, // run 0, // run
rxa->dsp_size, // buffer size rxa->dsp_size, // buffer size
rxa->midbuff, // pointer to input signal buffer rxa->midbuff, // pointer to input signal buffer
@ -578,8 +578,8 @@ void RXA::destroy_rxa (RXA *rxa)
ANF::destroy_anf (rxa->anf); ANF::destroy_anf (rxa->anf);
EQP::destroy_eqp (rxa->eqp); EQP::destroy_eqp (rxa->eqp);
SNBA::destroy_snba (rxa->snba); SNBA::destroy_snba (rxa->snba);
FMSQ::destroy_fmsq (rxa->fmsq); delete (rxa->fmsq);
FMD::destroy_fmd (rxa->fmd); delete (rxa->fmd);
delete (rxa->amd); delete (rxa->amd);
delete (rxa->amsq); delete (rxa->amsq);
delete (rxa->smeter); delete (rxa->smeter);
@ -614,8 +614,8 @@ void RXA::flush_rxa (RXA *rxa)
rxa->smeter->flush(); rxa->smeter->flush();
rxa->amsq->flush(); rxa->amsq->flush();
rxa->amd->flush(); rxa->amd->flush();
FMD::flush_fmd (rxa->fmd); rxa->fmd->flush();
FMSQ::flush_fmsq (rxa->fmsq); rxa->fmsq->flush();
SNBA::flush_snba (rxa->snba); SNBA::flush_snba (rxa->snba);
EQP::flush_eqp (rxa->eqp); EQP::flush_eqp (rxa->eqp);
ANF::flush_anf (rxa->anf); ANF::flush_anf (rxa->anf);
@ -647,8 +647,8 @@ void RXA::xrxa (RXA *rxa)
rxa->amsq->xcap(); rxa->amsq->xcap();
rxa->bpsnba->exec_out(0); rxa->bpsnba->exec_out(0);
rxa->amd->execute(); rxa->amd->execute();
FMD::xfmd (rxa->fmd); rxa->fmd->execute();
FMSQ::xfmsq (rxa->fmsq); rxa->fmsq->execute();
rxa->bpsnba->exec_in(1); rxa->bpsnba->exec_in(1);
rxa->bpsnba->exec_out(1); rxa->bpsnba->exec_out(1);
SNBA::xsnba (rxa->snba); SNBA::xsnba (rxa->snba);
@ -759,9 +759,9 @@ void RXA::setDSPSamplerate (RXA *rxa, int dsp_rate)
rxa->sender->setSamplerate(rxa->dsp_rate); rxa->sender->setSamplerate(rxa->dsp_rate);
rxa->amsq->setSamplerate(rxa->dsp_rate); rxa->amsq->setSamplerate(rxa->dsp_rate);
rxa->amd->setSamplerate(rxa->dsp_rate); rxa->amd->setSamplerate(rxa->dsp_rate);
FMD::setSamplerate_fmd (rxa->fmd, rxa->dsp_rate); rxa->fmd->setSamplerate(rxa->dsp_rate);
FMSQ::setBuffers_fmsq (rxa->fmsq, rxa->midbuff, rxa->midbuff, rxa->fmd->audio); rxa->fmsq->setBuffers(rxa->midbuff, rxa->midbuff, rxa->fmd->audio);
FMSQ::setSamplerate_fmsq (rxa->fmsq, rxa->dsp_rate); rxa->fmsq->setSamplerate(rxa->dsp_rate);
SNBA::setSamplerate_snba (rxa->snba, rxa->dsp_rate); SNBA::setSamplerate_snba (rxa->snba, rxa->dsp_rate);
EQP::setSamplerate_eqp (rxa->eqp, rxa->dsp_rate); EQP::setSamplerate_eqp (rxa->eqp, rxa->dsp_rate);
ANF::setSamplerate_anf (rxa->anf, rxa->dsp_rate); ANF::setSamplerate_anf (rxa->anf, rxa->dsp_rate);
@ -829,10 +829,10 @@ void RXA::setDSPBuffsize (RXA *rxa, int dsp_size)
rxa->amsq->setSize(rxa->dsp_size); rxa->amsq->setSize(rxa->dsp_size);
rxa->amd->setBuffers(rxa->midbuff, rxa->midbuff); rxa->amd->setBuffers(rxa->midbuff, rxa->midbuff);
rxa->amd->setSize(rxa->dsp_size); rxa->amd->setSize(rxa->dsp_size);
FMD::setBuffers_fmd (rxa->fmd, rxa->midbuff, rxa->midbuff); rxa->fmd->setBuffers(rxa->midbuff, rxa->midbuff);
FMD::setSize_fmd (rxa->fmd, rxa->dsp_size); rxa->fmd->setSize(rxa->dsp_size);
FMSQ::setBuffers_fmsq (rxa->fmsq, rxa->midbuff, rxa->midbuff, rxa->fmd->audio); rxa->fmsq->setBuffers(rxa->midbuff, rxa->midbuff, rxa->fmd->audio);
FMSQ::setSize_fmsq (rxa->fmsq, rxa->dsp_size); rxa->fmsq->setSize(rxa->dsp_size);
SNBA::setBuffers_snba (rxa->snba, rxa->midbuff, rxa->midbuff); SNBA::setBuffers_snba (rxa->snba, rxa->midbuff, rxa->midbuff);
SNBA::setSize_snba (rxa->snba, rxa->dsp_size); SNBA::setSize_snba (rxa->snba, rxa->dsp_size);
EQP::setBuffers_eqp (rxa->eqp, rxa->midbuff, rxa->midbuff); EQP::setBuffers_eqp (rxa->eqp, rxa->midbuff, rxa->midbuff);
@ -1225,22 +1225,20 @@ void RXA::NBPSetAutoIncrease (RXA& rxa, int autoincr)
} }
} }
void RXA::SetAMDRun(RXA& rxa, int run) void RXA::SetAMDRun(RXA& rxa, int _run)
{ {
AMD *a = rxa.amd; if (rxa.amd->run != _run)
if (run != run)
{ {
RXA::bp1Check ( RXA::bp1Check (
rxa, rxa,
run, _run,
rxa.snba->run, rxa.snba->run,
rxa.emnr->run, rxa.emnr->run,
rxa.anf->run, rxa.anf->run,
rxa.anr->run rxa.anr->run
); );
run = run; rxa.amd->run = _run;
RXA::bp1Set (rxa); RXA::bp1Set (rxa);
} }
} }
@ -1265,9 +1263,9 @@ void RXA::SetNC (RXA& rxa, int nc)
rxa.bpsnba->SetNC (nc); rxa.bpsnba->SetNC (nc);
BANDPASS::SetBandpassNC (rxa, nc); BANDPASS::SetBandpassNC (rxa, nc);
EQP::SetEQNC (rxa, nc); EQP::SetEQNC (rxa, nc);
FMSQ::SetFMSQNC (rxa, nc); rxa.fmsq->setNC (nc);
FMD::SetFMNCde (rxa, nc); rxa.fmd->setNCde (nc);
FMD::SetFMNCaud (rxa, nc); rxa.fmd->setNCaud (nc);
rxa.state = oldstate; rxa.state = oldstate;
} }
@ -1277,9 +1275,9 @@ void RXA::SetMP (RXA& rxa, int mp)
rxa.bpsnba->SetMP (mp); rxa.bpsnba->SetMP (mp);
BANDPASS::SetBandpassMP (rxa, mp); BANDPASS::SetBandpassMP (rxa, mp);
EQP::SetEQMP (rxa, mp); EQP::SetEQMP (rxa, mp);
FMSQ::SetFMSQMP (rxa, mp); rxa.fmsq->setMP (mp);
FMD::SetFMMPde (rxa, mp); rxa.fmd->setMPde (mp);
FMD::SetFMMPaud (rxa, mp); rxa.fmd->setMPaud (mp);
} }
} // namespace WDSP } // namespace WDSP

View File

@ -32,42 +32,41 @@ warren@wpratt.com
#include "fir.hpp" #include "fir.hpp"
#include "wcpAGC.hpp" #include "wcpAGC.hpp"
#include "fmd.hpp" #include "fmd.hpp"
#include "RXA.hpp"
namespace WDSP { namespace WDSP {
void FMD::calc_fmd (FMD *a) void FMD::calc()
{ {
// pll // pll
a->omega_min = TWOPI * a->fmin / a->rate; omega_min = TWOPI * fmin / rate;
a->omega_max = TWOPI * a->fmax / a->rate; omega_max = TWOPI * fmax / rate;
a->g1 = 1.0 - exp(-2.0 * a->omegaN * a->zeta / a->rate); g1 = 1.0 - exp(-2.0 * omegaN * zeta / rate);
a->g2 = -a->g1 + 2.0 * (1 - exp(-a->omegaN * a->zeta / a->rate) * cos(a->omegaN / a->rate * sqrt(1.0 - a->zeta * a->zeta))); g2 = -g1 + 2.0 * (1 - exp(-omegaN * zeta / rate) * cos(omegaN / rate * sqrt(1.0 - zeta * zeta)));
a->phs = 0.0; phs = 0.0;
a->fil_out = 0.0; fil_out = 0.0;
a->omega = 0.0; omega = 0.0;
a->pllpole = a->omegaN * sqrt(2.0 * a->zeta * a->zeta + 1.0 + sqrt((2.0 * a->zeta * a->zeta + 1.0) * (2.0 * a->zeta * a->zeta + 1.0) + 1)) / TWOPI; pllpole = omegaN * sqrt(2.0 * zeta * zeta + 1.0 + sqrt((2.0 * zeta * zeta + 1.0) * (2.0 * zeta * zeta + 1.0) + 1)) / TWOPI;
// dc removal // dc removal
a->mtau = exp(-1.0 / (a->rate * a->tau)); mtau = exp(-1.0 / (rate * tau));
a->onem_mtau = 1.0 - a->mtau; onem_mtau = 1.0 - mtau;
a->fmdc = 0.0; fmdc = 0.0;
// pll audio gain // pll audio gain
a->again = a->rate / (a->deviation * TWOPI); again = rate / (deviation * TWOPI);
// CTCSS Removal // CTCSS Removal
a->sntch = SNOTCH::create_snotch(1, a->size, a->out, a->out, (int)a->rate, a->ctcss_freq, 0.0002); sntch = SNOTCH::create_snotch(1, size, out, out, (int)rate, ctcss_freq, 0.0002);
// detector limiter // detector limiter
a->plim = WCPAGC::create_wcpagc ( plim = WCPAGC::create_wcpagc (
1, // run - always ON 1, // run - always ON
5, // mode 5, // mode
1, // 0 for max(I,Q), 1 for envelope 1, // 0 for max(I,Q), 1 for envelope
a->out, // input buff pointer out, // input buff pointer
a->out, // output buff pointer out, // output buff pointer
a->size, // io_buffsize size, // io_buffsize
(int)a->rate, // sample rate (int)rate, // sample rate
0.001, // tau_attack 0.001, // tau_attack
0.008, // tau_decay 0.008, // tau_decay
4, // n_tau 4, // n_tau
a->lim_gain, // max_gain (sets threshold, initial value) lim_gain, // max_gain (sets threshold, initial value)
1.0, // var_gain / slope 1.0, // var_gain / slope
1.0, // fixed_gain 1.0, // fixed_gain
1.0, // max_input 1.0, // max_input
@ -82,188 +81,185 @@ void FMD::calc_fmd (FMD *a)
0.100); // tau_hang_decay 0.100); // tau_hang_decay
} }
void FMD::decalc_fmd (FMD *a) void FMD::decalc()
{ {
WCPAGC::destroy_wcpagc(a->plim); WCPAGC::destroy_wcpagc(plim);
SNOTCH::destroy_snotch(a->sntch); SNOTCH::destroy_snotch(sntch);
} }
FMD* FMD::create_fmd( FMD::FMD(
int run, int _run,
int size, int _size,
float* in, float* _in,
float* out, float* _out,
int rate, int _rate,
double deviation, double _deviation,
double f_low, double _f_low,
double f_high, double _f_high,
double fmin, double _fmin,
double fmax, double _fmax,
double zeta, double _zeta,
double omegaN, double _omegaN,
double tau, double _tau,
double afgain, double _afgain,
int sntch_run, int _sntch_run,
double ctcss_freq, double _ctcss_freq,
int nc_de, int _nc_de,
int mp_de, int _mp_de,
int nc_aud, int _nc_aud,
int mp_aud int _mp_aud
) ) :
run(_run),
size(_size),
in(_in),
out(_out),
rate((double) _rate),
f_low(_f_low),
f_high(_f_high),
fmin(_fmin),
fmax(_fmax),
zeta(_zeta),
omegaN(_omegaN),
tau(_tau),
deviation(_deviation),
nc_de(_nc_de),
mp_de(_mp_de),
nc_aud(_nc_aud),
mp_aud(_mp_aud),
afgain(_afgain),
sntch_run(_sntch_run),
ctcss_freq(_ctcss_freq),
lim_run(0),
lim_gain(0.0001), // 2.5
lim_pre_gain(0.01) // 0.4
{ {
FMD *a = new FMD;
float* impulse; float* impulse;
a->run = run; calc();
a->size = size;
a->in = in;
a->out = out;
a->rate = (float)rate;
a->deviation = deviation;
a->f_low = f_low;
a->f_high = f_high;
a->fmin = fmin;
a->fmax = fmax;
a->zeta = zeta;
a->omegaN = omegaN;
a->tau = tau;
a->afgain = afgain;
a->sntch_run = sntch_run;
a->ctcss_freq = ctcss_freq;
a->nc_de = nc_de;
a->mp_de = mp_de;
a->nc_aud = nc_aud;
a->mp_aud = mp_aud;
a->lim_run = 0;
a->lim_pre_gain = 0.01; // 0.4
a->lim_gain = 0.0001; // 2.5
calc_fmd (a);
// de-emphasis filter // de-emphasis filter
a->audio = new float[a->size * 2]; // (float *) malloc0 (a->size * sizeof (complex)); audio = new float[size * 2]; // (float *) malloc0 (size * sizeof (complex));
impulse = FCurve::fc_impulse (a->nc_de, a->f_low, a->f_high, +20.0 * log10(a->f_high / a->f_low), 0.0, 1, a->rate, 1.0 / (2.0 * a->size), 0, 0); impulse = FCurve::fc_impulse (nc_de, f_low, f_high, +20.0 * log10(f_high / f_low), 0.0, 1, rate, 1.0 / (2.0 * size), 0, 0);
a->pde = FIRCORE::create_fircore (a->size, a->audio, a->out, a->nc_de, a->mp_de, impulse); pde = FIRCORE::create_fircore (size, audio, out, nc_de, mp_de, impulse);
delete[] (impulse); delete[] (impulse);
// audio filter // audio filter
impulse = FIR::fir_bandpass(a->nc_aud, 0.8 * a->f_low, 1.1 * a->f_high, a->rate, 0, 1, a->afgain / (2.0 * a->size)); impulse = FIR::fir_bandpass(nc_aud, 0.8 * f_low, 1.1 * f_high, rate, 0, 1, afgain / (2.0 * size));
a->paud = FIRCORE::create_fircore (a->size, a->out, a->out, a->nc_aud, a->mp_aud, impulse); paud = FIRCORE::create_fircore (size, out, out, nc_aud, mp_aud, impulse);
delete[] (impulse); delete[] (impulse);
return a;
} }
void FMD::destroy_fmd (FMD *a) FMD::~FMD()
{ {
FIRCORE::destroy_fircore (a->paud); FIRCORE::destroy_fircore (paud);
FIRCORE::destroy_fircore (a->pde); FIRCORE::destroy_fircore (pde);
delete[] (a->audio); delete[] (audio);
decalc_fmd (a); decalc();
delete (a);
} }
void FMD::flush_fmd (FMD *a) void FMD::flush()
{ {
std::fill(a->audio, a->audio + a->size * 2, 0); std::fill(audio, audio + size * 2, 0);
FIRCORE::flush_fircore (a->pde); FIRCORE::flush_fircore (pde);
FIRCORE::flush_fircore (a->paud); FIRCORE::flush_fircore (paud);
a->phs = 0.0; phs = 0.0;
a->fil_out = 0.0; fil_out = 0.0;
a->omega = 0.0; omega = 0.0;
a->fmdc = 0.0; fmdc = 0.0;
SNOTCH::flush_snotch (a->sntch); SNOTCH::flush_snotch (sntch);
WCPAGC::flush_wcpagc (a->plim); WCPAGC::flush_wcpagc (plim);
} }
void FMD::xfmd (FMD *a) void FMD::execute()
{ {
if (a->run) if (run)
{ {
int i; int i;
double det, del_out; double det, del_out;
double vco[2], corr[2]; double vco[2], corr[2];
for (i = 0; i < a->size; i++) for (i = 0; i < size; i++)
{ {
// pll // pll
vco[0] = cos (a->phs); vco[0] = cos (phs);
vco[1] = sin (a->phs); vco[1] = sin (phs);
corr[0] = + a->in[2 * i + 0] * vco[0] + a->in[2 * i + 1] * vco[1]; corr[0] = + in[2 * i + 0] * vco[0] + in[2 * i + 1] * vco[1];
corr[1] = - a->in[2 * i + 0] * vco[1] + a->in[2 * i + 1] * vco[0]; corr[1] = - in[2 * i + 0] * vco[1] + in[2 * i + 1] * vco[0];
if ((corr[0] == 0.0) && (corr[1] == 0.0)) corr[0] = 1.0; if ((corr[0] == 0.0) && (corr[1] == 0.0)) corr[0] = 1.0;
det = atan2 (corr[1], corr[0]); det = atan2 (corr[1], corr[0]);
del_out = a->fil_out; del_out = fil_out;
a->omega += a->g2 * det; omega += g2 * det;
if (a->omega < a->omega_min) a->omega = a->omega_min; if (omega < omega_min) omega = omega_min;
if (a->omega > a->omega_max) a->omega = a->omega_max; if (omega > omega_max) omega = omega_max;
a->fil_out = a->g1 * det + a->omega; fil_out = g1 * det + omega;
a->phs += del_out; phs += del_out;
while (a->phs >= TWOPI) a->phs -= TWOPI; while (phs >= TWOPI) phs -= TWOPI;
while (a->phs < 0.0) a->phs += TWOPI; while (phs < 0.0) phs += TWOPI;
// dc removal, gain, & demod output // dc removal, gain, & demod output
a->fmdc = a->mtau * a->fmdc + a->onem_mtau * a->fil_out; fmdc = mtau * fmdc + onem_mtau * fil_out;
a->audio[2 * i + 0] = a->again * (a->fil_out - a->fmdc); audio[2 * i + 0] = again * (fil_out - fmdc);
a->audio[2 * i + 1] = a->audio[2 * i + 0]; audio[2 * i + 1] = audio[2 * i + 0];
} }
// de-emphasis // de-emphasis
FIRCORE::xfircore (a->pde); FIRCORE::xfircore (pde);
// audio filter // audio filter
FIRCORE::xfircore (a->paud); FIRCORE::xfircore (paud);
// CTCSS Removal // CTCSS Removal
SNOTCH::xsnotch (a->sntch); SNOTCH::xsnotch (sntch);
if (a->lim_run) if (lim_run)
{ {
for (i = 0; i < 2 * a->size; i++) for (i = 0; i < 2 * size; i++)
a->out[i] *= a->lim_pre_gain; out[i] *= lim_pre_gain;
WCPAGC::xwcpagc (a->plim); WCPAGC::xwcpagc (plim);
} }
} }
else if (a->in != a->out) else if (in != out)
std::copy( a->in, a->in + a->size * 2, a->out); std::copy( in, in + size * 2, out);
} }
void FMD::setBuffers_fmd (FMD *a, float* in, float* out) void FMD::setBuffers(float* _in, float* _out)
{ {
decalc_fmd (a); decalc();
a->in = in; in = _in;
a->out = out; out = _out;
calc_fmd (a); calc();
FIRCORE::setBuffers_fircore (a->pde, a->audio, a->out); FIRCORE::setBuffers_fircore (pde, audio, out);
FIRCORE::setBuffers_fircore (a->paud, a->out, a->out); FIRCORE::setBuffers_fircore (paud, out, out);
WCPAGC::setBuffers_wcpagc (a->plim, a->out, a->out); WCPAGC::setBuffers_wcpagc (plim, out, out);
} }
void FMD::setSamplerate_fmd (FMD *a, int rate) void FMD::setSamplerate(int _rate)
{ {
float* impulse; float* impulse;
decalc_fmd (a); decalc();
a->rate = rate; rate = _rate;
calc_fmd (a); calc();
// de-emphasis filter // de-emphasis filter
impulse = FCurve::fc_impulse (a->nc_de, a->f_low, a->f_high, +20.0 * log10(a->f_high / a->f_low), 0.0, 1, a->rate, 1.0 / (2.0 * a->size), 0, 0); impulse = FCurve::fc_impulse (nc_de, f_low, f_high, +20.0 * log10(f_high / f_low), 0.0, 1, rate, 1.0 / (2.0 * size), 0, 0);
FIRCORE::setImpulse_fircore (a->pde, impulse, 1); FIRCORE::setImpulse_fircore (pde, impulse, 1);
delete[] (impulse); delete[] (impulse);
// audio filter // audio filter
impulse = FIR::fir_bandpass(a->nc_aud, 0.8 * a->f_low, 1.1 * a->f_high, a->rate, 0, 1, a->afgain / (2.0 * a->size)); impulse = FIR::fir_bandpass(nc_aud, 0.8 * f_low, 1.1 * f_high, rate, 0, 1, afgain / (2.0 * size));
FIRCORE::setImpulse_fircore (a->paud, impulse, 1); FIRCORE::setImpulse_fircore (paud, impulse, 1);
delete[] (impulse); delete[] (impulse);
WCPAGC::setSamplerate_wcpagc (a->plim, (int)a->rate); WCPAGC::setSamplerate_wcpagc (plim, (int)rate);
} }
void FMD::setSize_fmd (FMD *a, int size) void FMD::setSize(int _size)
{ {
float* impulse; float* impulse;
decalc_fmd (a); decalc();
delete[] (a->audio); delete[] (audio);
a->size = size; size = _size;
calc_fmd (a); calc();
a->audio = new float[a->size * 2]; // (float *) malloc0 (a->size * sizeof (complex)); audio = new float[size * 2]; // (float *) malloc0 (size * sizeof (complex));
// de-emphasis filter // de-emphasis filter
FIRCORE::destroy_fircore (a->pde); FIRCORE::destroy_fircore (pde);
impulse = FCurve::fc_impulse (a->nc_de, a->f_low, a->f_high, +20.0 * log10(a->f_high / a->f_low), 0.0, 1, a->rate, 1.0 / (2.0 * a->size), 0, 0); impulse = FCurve::fc_impulse (nc_de, f_low, f_high, +20.0 * log10(f_high / f_low), 0.0, 1, rate, 1.0 / (2.0 * size), 0, 0);
a->pde = FIRCORE::create_fircore (a->size, a->audio, a->out, a->nc_de, a->mp_de, impulse); pde = FIRCORE::create_fircore (size, audio, out, nc_de, mp_de, impulse);
delete[] (impulse); delete[] (impulse);
// audio filter // audio filter
FIRCORE::destroy_fircore (a->paud); FIRCORE::destroy_fircore (paud);
impulse = FIR::fir_bandpass(a->nc_aud, 0.8 * a->f_low, 1.1 * a->f_high, a->rate, 0, 1, a->afgain / (2.0 * a->size)); impulse = FIR::fir_bandpass(nc_aud, 0.8 * f_low, 1.1 * f_high, rate, 0, 1, afgain / (2.0 * size));
a->paud = FIRCORE::create_fircore (a->size, a->out, a->out, a->nc_aud, a->mp_aud, impulse); paud = FIRCORE::create_fircore (size, out, out, nc_aud, mp_aud, impulse);
delete[] (impulse); delete[] (impulse);
WCPAGC::setSize_wcpagc (a->plim, a->size); WCPAGC::setSize_wcpagc (plim, size);
} }
/******************************************************************************************************** /********************************************************************************************************
@ -272,121 +268,102 @@ void FMD::setSize_fmd (FMD *a, int size)
* * * *
********************************************************************************************************/ ********************************************************************************************************/
void FMD::SetFMDeviation (RXA& rxa, double deviation) void FMD::setDeviation(double _deviation)
{ {
FMD *a; deviation = _deviation;
a = rxa.fmd; again = rate / (deviation * TWOPI);
a->deviation = deviation;
a->again = a->rate / (a->deviation * TWOPI);
} }
void FMD::SetCTCSSFreq (RXA& rxa, double freq) void FMD::setCTCSSFreq(double freq)
{ {
FMD *a; ctcss_freq = freq;
a = rxa.fmd; SNOTCH::SetSNCTCSSFreq (sntch, ctcss_freq);
a->ctcss_freq = freq;
SNOTCH::SetSNCTCSSFreq (a->sntch, a->ctcss_freq);
} }
void FMD::SetCTCSSRun (RXA& rxa, int run) void FMD::setCTCSSRun(int run)
{ {
FMD *a; sntch_run = run;
a = rxa.fmd; SNOTCH::SetSNCTCSSRun (sntch, sntch_run);
a->sntch_run = run;
SNOTCH::SetSNCTCSSRun (a->sntch, a->sntch_run);
} }
void FMD::SetFMNCde (RXA& rxa, int nc) void FMD::setNCde(int nc)
{ {
FMD *a;
float* impulse; float* impulse;
a = rxa.fmd;
if (a->nc_de != nc) if (nc_de != nc)
{ {
a->nc_de = nc; nc_de = nc;
impulse = FCurve::fc_impulse (a->nc_de, a->f_low, a->f_high, +20.0 * log10(a->f_high / a->f_low), 0.0, 1, a->rate, 1.0 / (2.0 * a->size), 0, 0); impulse = FCurve::fc_impulse (nc_de, f_low, f_high, +20.0 * log10(f_high / f_low), 0.0, 1, rate, 1.0 / (2.0 * size), 0, 0);
FIRCORE::setNc_fircore (a->pde, a->nc_de, impulse); FIRCORE::setNc_fircore (pde, nc_de, impulse);
delete[] (impulse); delete[] (impulse);
} }
} }
void FMD::SetFMMPde (RXA& rxa, int mp) void FMD::setMPde(int mp)
{ {
FMD *a; if (mp_de != mp)
a = rxa.fmd;
if (a->mp_de != mp)
{ {
a->mp_de = mp; mp_de = mp;
FIRCORE::setMp_fircore (a->pde, a->mp_de); FIRCORE::setMp_fircore (pde, mp_de);
} }
} }
void FMD::SetFMNCaud (RXA& rxa, int nc) void FMD::setNCaud(int nc)
{ {
FMD *a;
float* impulse; float* impulse;
a = rxa.fmd;
if (a->nc_aud != nc) if (nc_aud != nc)
{ {
a->nc_aud = nc; nc_aud = nc;
impulse = FIR::fir_bandpass(a->nc_aud, 0.8 * a->f_low, 1.1 * a->f_high, a->rate, 0, 1, a->afgain / (2.0 * a->size)); impulse = FIR::fir_bandpass(nc_aud, 0.8 * f_low, 1.1 * f_high, rate, 0, 1, afgain / (2.0 * size));
FIRCORE::setNc_fircore (a->paud, a->nc_aud, impulse); FIRCORE::setNc_fircore (paud, nc_aud, impulse);
delete[] (impulse); delete[] (impulse);
} }
} }
void FMD::SetFMMPaud (RXA& rxa, int mp) void FMD::setMPaud(int mp)
{ {
FMD *a; if (mp_aud != mp)
a = rxa.fmd;
if (a->mp_aud != mp)
{ {
a->mp_aud = mp; mp_aud = mp;
FIRCORE::setMp_fircore (a->paud, a->mp_aud); FIRCORE::setMp_fircore (paud, mp_aud);
} }
} }
void FMD::SetFMLimRun (RXA& rxa, int run) void FMD::setLimRun(int run)
{ {
FMD *a; if (lim_run != run) {
a = rxa.fmd; lim_run = run;
if (a->lim_run != run) {
a->lim_run = run;
} }
} }
void FMD::SetFMLimGain (RXA& rxa, double gaindB) void FMD::setLimGain(double gaindB)
{ {
double gain = pow(10.0, gaindB / 20.0); double gain = pow(10.0, gaindB / 20.0);
FMD *a = rxa.fmd;
if (a->lim_gain != gain) if (lim_gain != gain)
{ {
decalc_fmd(a); decalc();
a->lim_gain = gain; lim_gain = gain;
calc_fmd(a); calc();
} }
} }
void FMD::SetFMAFFilter(RXA& rxa, double low, double high) void FMD::setAFFilter(double low, double high)
{ {
FMD *a = rxa.fmd;
float* impulse; float* impulse;
if (a->f_low != low || a->f_high != high) if (f_low != low || f_high != high)
{ {
a->f_low = low; f_low = low;
a->f_high = high; f_high = high;
// de-emphasis filter // de-emphasis filter
impulse = FCurve::fc_impulse (a->nc_de, a->f_low, a->f_high, +20.0 * log10(a->f_high / a->f_low), 0.0, 1, a->rate, 1.0 / (2.0 * a->size), 0, 0); impulse = FCurve::fc_impulse (nc_de, f_low, f_high, +20.0 * log10(f_high / f_low), 0.0, 1, rate, 1.0 / (2.0 * size), 0, 0);
FIRCORE::setImpulse_fircore (a->pde, impulse, 1); FIRCORE::setImpulse_fircore (pde, impulse, 1);
delete[] (impulse); delete[] (impulse);
// audio filter // audio filter
impulse = FIR::fir_bandpass (a->nc_aud, 0.8 * a->f_low, 1.1 * a->f_high, a->rate, 0, 1, a->afgain / (2.0 * a->size)); impulse = FIR::fir_bandpass (nc_aud, 0.8 * f_low, 1.1 * f_high, rate, 0, 1, afgain / (2.0 * size));
FIRCORE::setImpulse_fircore (a->paud, impulse, 1); FIRCORE::setImpulse_fircore (paud, impulse, 1);
delete[] (impulse); delete[] (impulse);
} }
} }

View File

@ -35,7 +35,6 @@ namespace WDSP {
class FIRCORE; class FIRCORE;
class SNOTCH; class SNOTCH;
class WCPAGC; class WCPAGC;
class RXA;
class WDSP_API FMD class WDSP_API FMD
{ {
@ -87,7 +86,7 @@ public:
double lim_gain; double lim_gain;
double lim_pre_gain; double lim_pre_gain;
static FMD* create_fmd ( FMD(
int run, int run,
int size, int size,
float* in, float* in,
@ -109,27 +108,28 @@ public:
int nc_aud, int nc_aud,
int mp_aud int mp_aud
); );
static void destroy_fmd (FMD *a); ~FMD();
static void flush_fmd (FMD *a);
static void xfmd (FMD *a); void flush();
static void setBuffers_fmd (FMD *a, float* in, float* out); void execute();
static void setSamplerate_fmd (FMD *a, int rate); void setBuffers(float* in, float* out);
static void setSize_fmd (FMD *a, int size); void setSamplerate(int rate);
void setSize(int size);
// RXA Properties // RXA Properties
static void SetFMDeviation (RXA& rxa, double deviation); void setDeviation(double deviation);
static void SetCTCSSFreq (RXA& rxa, double freq); void setCTCSSFreq(double freq);
static void SetCTCSSRun (RXA& rxa, int run); void setCTCSSRun(int run);
static void SetFMNCde (RXA& rxa, int nc); void setNCde(int nc);
static void SetFMMPde (RXA& rxa, int mp); void setMPde(int mp);
static void SetFMNCaud (RXA& rxa, int nc); void setNCaud(int nc);
static void SetFMMPaud (RXA& rxa, int mp); void setMPaud(int mp);
static void SetFMLimRun (RXA& rxa, int run); void setLimRun(int run);
static void SetFMLimGain (RXA& rxa, double gaindB); void setLimGain(double gaindB);
static void SetFMAFFilter(RXA& rxa, double low, double high); void setAFFilter(double low, double high);
private: private:
static void calc_fmd (FMD *a); void calc();
static void decalc_fmd (FMD *a); void decalc();
}; };
} // namespace WDSP } // namespace WDSP

View File

@ -29,132 +29,128 @@ warren@wpratt.com
#include "fircore.hpp" #include "fircore.hpp"
#include "eq.hpp" #include "eq.hpp"
#include "fmsq.hpp" #include "fmsq.hpp"
#include "RXA.hpp"
namespace WDSP { namespace WDSP {
void FMSQ::calc_fmsq (FMSQ *a) void FMSQ::calc()
{ {
double delta, theta; double delta, theta;
float* impulse; float* impulse;
int i; int i;
// noise filter // noise filter
a->noise = new float[2 * a->size * 2]; // (float *)malloc0(2 * a->size * sizeof(complex)); noise = new float[2 * size * 2]; // (float *)malloc0(2 * size * sizeof(complex));
a->F[0] = 0.0; F[0] = 0.0;
a->F[1] = a->fc; F[1] = fc;
a->F[2] = *a->pllpole; F[2] = *pllpole;
a->F[3] = 20000.0; F[3] = 20000.0;
a->G[0] = 0.0; G[0] = 0.0;
a->G[1] = 0.0; G[1] = 0.0;
a->G[2] = 3.0; G[2] = 3.0;
a->G[3] = +20.0 * log10(20000.0 / *a->pllpole); G[3] = +20.0 * log10(20000.0 / *pllpole);
impulse = EQP::eq_impulse (a->nc, 3, a->F, a->G, a->rate, 1.0 / (2.0 * a->size), 0, 0); impulse = EQP::eq_impulse (nc, 3, F, G, rate, 1.0 / (2.0 * size), 0, 0);
a->p = FIRCORE::create_fircore (a->size, a->trigger, a->noise, a->nc, a->mp, impulse); p = FIRCORE::create_fircore (size, trigger, noise, nc, mp, impulse);
delete[] (impulse); delete[] (impulse);
// noise averaging // noise averaging
a->avm = exp(-1.0 / (a->rate * a->avtau)); avm = exp(-1.0 / (rate * avtau));
a->onem_avm = 1.0 - a->avm; onem_avm = 1.0 - avm;
a->avnoise = 100.0; avnoise = 100.0;
a->longavm = exp(-1.0 / (a->rate * a->longtau)); longavm = exp(-1.0 / (rate * longtau));
a->onem_longavm = 1.0 - a->longavm; onem_longavm = 1.0 - longavm;
a->longnoise = 1.0; longnoise = 1.0;
// level change // level change
a->ntup = (int)(a->tup * a->rate); ntup = (int)(tup * rate);
a->ntdown = (int)(a->tdown * a->rate); ntdown = (int)(tdown * rate);
a->cup = new double[a->ntup + 1]; // (float *)malloc0 ((a->ntup + 1) * sizeof(float)); cup = new double[ntup + 1]; // (float *)malloc0 ((ntup + 1) * sizeof(float));
a->cdown = new double[a->ntdown + 1]; //(float *)malloc0 ((a->ntdown + 1) * sizeof(float)); cdown = new double[ntdown + 1]; //(float *)malloc0 ((ntdown + 1) * sizeof(float));
delta = PI / (double) a->ntup; delta = PI / (double) ntup;
theta = 0.0; theta = 0.0;
for (i = 0; i <= a->ntup; i++) for (i = 0; i <= ntup; i++)
{ {
a->cup[i] = 0.5 * (1.0 - cos(theta)); cup[i] = 0.5 * (1.0 - cos(theta));
theta += delta; theta += delta;
} }
delta = PI / (double) a->ntdown; delta = PI / (double) ntdown;
theta = 0.0; theta = 0.0;
for (i = 0; i <= a->ntdown; i++) for (i = 0; i <= ntdown; i++)
{ {
a->cdown[i] = 0.5 * (1 + cos(theta)); cdown[i] = 0.5 * (1 + cos(theta));
theta += delta; theta += delta;
} }
// control // control
a->state = 0; state = 0;
a->ready = 0; ready = 0;
a->ramp = 0.0; ramp = 0.0;
a->rstep = 1.0 / a->rate; rstep = 1.0 / rate;
} }
void FMSQ::decalc_fmsq (FMSQ *a) void FMSQ::decalc()
{ {
delete[] (a->cdown); delete[] (cdown);
delete[] (a->cup); delete[] (cup);
FIRCORE::destroy_fircore (a->p); FIRCORE::destroy_fircore (p);
delete[] (a->noise); delete[] (noise);
} }
FMSQ* FMSQ::create_fmsq ( FMSQ::FMSQ(
int run, int _run,
int size, int _size,
float* insig, float* _insig,
float* outsig, float* _outsig,
float* trigger, float* _trigger,
int rate, int _rate,
double fc, double _fc,
double* pllpole, double* _pllpole,
double tdelay, double _tdelay,
double avtau, double _avtau,
double longtau, double _longtau,
double tup, double _tup,
double tdown, double _tdown,
double tail_thresh, double _tail_thresh,
double unmute_thresh, double _unmute_thresh,
double min_tail, double _min_tail,
double max_tail, double _max_tail,
int nc, int _nc,
int mp int _mp
) ) :
run(_run),
size(_size),
insig(_insig),
outsig(_outsig),
trigger(_trigger),
rate((double) _rate),
fc(_fc),
pllpole(_pllpole),
tdelay(_tdelay),
avtau(_avtau),
longtau(_longtau),
tup(_tup),
tdown(_tdown),
tail_thresh(_tail_thresh),
unmute_thresh(_unmute_thresh),
min_tail(_min_tail),
max_tail(_max_tail),
nc(_nc),
mp(_mp)
{ {
FMSQ *a = new FMSQ; calc();
a->run = run;
a->size = size;
a->insig = insig;
a->outsig = outsig;
a->trigger = trigger;
a->rate = (float)rate;
a->fc = fc;
a->pllpole = pllpole;
a->tdelay = tdelay;
a->avtau = avtau;
a->longtau = longtau;
a->tup = tup;
a->tdown = tdown;
a->tail_thresh = tail_thresh;
a->unmute_thresh = unmute_thresh;
a->min_tail = min_tail;
a->max_tail = max_tail;
a->nc = nc;
a->mp = mp;
calc_fmsq (a);
return a;
} }
void FMSQ::destroy_fmsq (FMSQ *a) FMSQ::~FMSQ()
{ {
decalc_fmsq (a); decalc();
delete (a);
} }
void FMSQ::flush_fmsq (FMSQ *a) void FMSQ::flush()
{ {
FIRCORE::flush_fircore (a->p); FIRCORE::flush_fircore (p);
a->avnoise = 100.0; avnoise = 100.0;
a->longnoise = 1.0; longnoise = 1.0;
a->state = 0; state = 0;
a->ready = 0; ready = 0;
a->ramp = 0.0; ramp = 0.0;
} }
enum _fmsqstate enum _fmsqstate
@ -166,120 +162,120 @@ enum _fmsqstate
DECREASE DECREASE
}; };
void FMSQ::xfmsq (FMSQ *a) void FMSQ::execute()
{ {
if (a->run) if (run)
{ {
int i; int i;
double noise, lnlimit; double _noise, lnlimit;
FIRCORE::xfircore (a->p); FIRCORE::xfircore (p);
for (i = 0; i < a->size; i++) for (i = 0; i < size; i++)
{ {
double noise0 = a->noise[2 * i + 0]; double noise0 = noise[2 * i + 0];
double noise1 = a->noise[2 * i + 1]; double noise1 = noise[2 * i + 1];
noise = sqrt(noise0 * noise0 + noise1 * noise1); _noise = sqrt(noise0 * noise0 + noise1 * noise1);
a->avnoise = a->avm * a->avnoise + a->onem_avm * noise; avnoise = avm * avnoise + onem_avm * _noise;
a->longnoise = a->longavm * a->longnoise + a->onem_longavm * noise; longnoise = longavm * longnoise + onem_longavm * _noise;
if (!a->ready) if (!ready)
a->ramp += a->rstep; ramp += rstep;
if (a->ramp >= a->tdelay) if (ramp >= tdelay)
a->ready = 1; ready = 1;
switch (a->state) switch (state)
{ {
case MUTED: case MUTED:
if (a->avnoise < a->unmute_thresh && a->ready) if (avnoise < unmute_thresh && ready)
{ {
a->state = INCREASE; state = INCREASE;
a->count = a->ntup; count = ntup;
} }
a->outsig[2 * i + 0] = 0.0; outsig[2 * i + 0] = 0.0;
a->outsig[2 * i + 1] = 0.0; outsig[2 * i + 1] = 0.0;
break; break;
case INCREASE: case INCREASE:
a->outsig[2 * i + 0] = a->insig[2 * i + 0] * a->cup[a->ntup - a->count]; outsig[2 * i + 0] = insig[2 * i + 0] * cup[ntup - count];
a->outsig[2 * i + 1] = a->insig[2 * i + 1] * a->cup[a->ntup - a->count]; outsig[2 * i + 1] = insig[2 * i + 1] * cup[ntup - count];
if (a->count-- == 0) if (count-- == 0)
a->state = UNMUTED; state = UNMUTED;
break; break;
case UNMUTED: case UNMUTED:
if (a->avnoise > a->tail_thresh) if (avnoise > tail_thresh)
{ {
a->state = TAIL; state = TAIL;
if ((lnlimit = a->longnoise) > 1.0) if ((lnlimit = longnoise) > 1.0)
lnlimit = 1.0; lnlimit = 1.0;
a->count = (int)((a->min_tail + (a->max_tail - a->min_tail) * lnlimit) * a->rate); count = (int)((min_tail + (max_tail - min_tail) * lnlimit) * rate);
} }
a->outsig[2 * i + 0] = a->insig[2 * i + 0]; outsig[2 * i + 0] = insig[2 * i + 0];
a->outsig[2 * i + 1] = a->insig[2 * i + 1]; outsig[2 * i + 1] = insig[2 * i + 1];
break; break;
case TAIL: case TAIL:
a->outsig[2 * i + 0] = a->insig[2 * i + 0]; outsig[2 * i + 0] = insig[2 * i + 0];
a->outsig[2 * i + 1] = a->insig[2 * i + 1]; outsig[2 * i + 1] = insig[2 * i + 1];
if (a->avnoise < a->unmute_thresh) if (avnoise < unmute_thresh)
{ {
a->state = UNMUTED; state = UNMUTED;
} }
else if (a->count-- == 0) else if (count-- == 0)
{ {
a->state = DECREASE; state = DECREASE;
a->count = a->ntdown; count = ntdown;
} }
break; break;
case DECREASE: case DECREASE:
a->outsig[2 * i + 0] = a->insig[2 * i + 0] * a->cdown[a->ntdown - a->count]; outsig[2 * i + 0] = insig[2 * i + 0] * cdown[ntdown - count];
a->outsig[2 * i + 1] = a->insig[2 * i + 1] * a->cdown[a->ntdown - a->count]; outsig[2 * i + 1] = insig[2 * i + 1] * cdown[ntdown - count];
if (a->count-- == 0) if (count-- == 0)
a->state = MUTED; state = MUTED;
break; break;
} }
} }
} }
else if (a->insig != a->outsig) else if (insig != outsig)
{ {
std::copy(a->insig, a->insig + a->size * 2, a->outsig); std::copy(insig, insig + size * 2, outsig);
} }
} }
void FMSQ::setBuffers_fmsq (FMSQ *a, float* in, float* out, float* trig) void FMSQ::setBuffers(float* in, float* out, float* trig)
{ {
a->insig = in; insig = in;
a->outsig = out; outsig = out;
a->trigger = trig; trigger = trig;
FIRCORE::setBuffers_fircore (a->p, a->trigger, a->noise); FIRCORE::setBuffers_fircore (p, trigger, noise);
} }
void FMSQ::setSamplerate_fmsq (FMSQ *a, int rate) void FMSQ::setSamplerate(int _rate)
{ {
decalc_fmsq (a); decalc();
a->rate = rate; rate = _rate;
calc_fmsq (a); calc();
} }
void FMSQ::setSize_fmsq (FMSQ *a, int size) void FMSQ::setSize(int _size)
{ {
decalc_fmsq (a); decalc();
a->size = size; size = _size;
calc_fmsq (a); calc();
} }
/******************************************************************************************************** /********************************************************************************************************
@ -288,41 +284,36 @@ void FMSQ::setSize_fmsq (FMSQ *a, int size)
* * * *
********************************************************************************************************/ ********************************************************************************************************/
void FMSQ::SetFMSQRun (RXA& rxa, int run) void FMSQ::setRun(int _run)
{ {
rxa.fmsq->run = run; run = _run;
} }
void FMSQ::SetFMSQThreshold (RXA& rxa, double threshold) void FMSQ::setThreshold(double threshold)
{ {
rxa.fmsq->tail_thresh = threshold; tail_thresh = threshold;
rxa.fmsq->unmute_thresh = 0.9 * threshold; unmute_thresh = 0.9 * threshold;
} }
void FMSQ::SetFMSQNC (RXA& rxa, int nc) void FMSQ::setNC(int _nc)
{ {
FMSQ *a;
float* impulse; float* impulse;
a = rxa.fmsq;
if (a->nc != nc) if (nc != _nc)
{ {
a->nc = nc; nc = _nc;
impulse = EQP::eq_impulse (a->nc, 3, a->F, a->G, a->rate, 1.0 / (2.0 * a->size), 0, 0); impulse = EQP::eq_impulse (nc, 3, F, G, rate, 1.0 / (2.0 * size), 0, 0);
FIRCORE::setNc_fircore (a->p, a->nc, impulse); FIRCORE::setNc_fircore (p, nc, impulse);
delete[] (impulse); delete[] (impulse);
} }
} }
void FMSQ::SetFMSQMP (RXA& rxa, int mp) void FMSQ::setMP(int _mp)
{ {
FMSQ *a; if (mp != _mp)
a = rxa.fmsq;
if (a->mp != mp)
{ {
a->mp = mp; mp = _mp;
FIRCORE::setMp_fircore (a->p, a->mp); FIRCORE::setMp_fircore (p, mp);
} }
} }

View File

@ -33,7 +33,6 @@ warren@wpratt.com
namespace WDSP { namespace WDSP {
class FIRCORE; class FIRCORE;
class RXA;
class WDSP_API FMSQ class WDSP_API FMSQ
{ {
@ -77,42 +76,43 @@ public:
int mp; int mp;
FIRCORE *p; FIRCORE *p;
static FMSQ* create_fmsq ( FMSQ(
int run, int _run,
int size, int _size,
float* insig, float* _insig,
float* outsig, float* _outsig,
float* trigger, float* _trigger,
int rate, int _rate,
double fc, double _fc,
double* pllpole, double* _pllpole,
double tdelay, double _tdelay,
double avtau, double _avtau,
double longtau, double _longtau,
double tup, double _tup,
double tdown, double _tdown,
double tail_thresh, double _tail_thresh,
double unmute_thresh, double _unmute_thresh,
double min_tail, double _min_tail,
double max_tail, double _max_tail,
int nc, int _nc,
int mp int _mp
); );
static void destroy_fmsq (FMSQ *a); ~FMSQ();
static void flush_fmsq (FMSQ *a);
static void xfmsq (FMSQ *a); void flush();
static void setBuffers_fmsq (FMSQ *a, float* in, float* out, float* trig); void execute();
static void setSamplerate_fmsq (FMSQ *a, int rate); void setBuffers(float* in, float* out, float* trig);
static void setSize_fmsq (FMSQ *a, int size); void setSamplerate(int rate);
// RXA Properties void setSize(int size);
static void SetFMSQRun (RXA& rxa, int run); // Public Properties
static void SetFMSQThreshold (RXA& rxa, double threshold); void setRun(int run);
static void SetFMSQNC (RXA& rxa, int nc); void setThreshold(double threshold);
static void SetFMSQMP (RXA& rxa, int mp); void setNC(int nc);
void setMP(int mp);
private: private:
static void calc_fmsq (FMSQ *a); void calc();
static void decalc_fmsq (FMSQ *a); void decalc();
}; };
} // namespace WDSP } // namespace WDSP