mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-10 18:43:28 -05:00
WDSP: rework SSQL and PANEL classes
This commit is contained in:
parent
71fe079ee3
commit
cd38f356d0
@ -680,7 +680,7 @@ void WDSPRxSink::applySettings(const WDSPRxSettings& settings, bool force)
|
||||
|| (m_settings.m_squelchThreshold != settings.m_squelchThreshold)
|
||||
|| (m_settings.m_squelchMode != settings.m_squelchMode) || force)
|
||||
{
|
||||
WDSP::SSQL::SetSSQLRun(*m_rxa, 0);
|
||||
m_rxa->ssql->setRun(0);
|
||||
m_rxa->amsq->setRun(0);
|
||||
m_rxa->fmsq->setRun(0);
|
||||
|
||||
@ -690,9 +690,9 @@ void WDSPRxSink::applySettings(const WDSPRxSettings& settings, bool force)
|
||||
{
|
||||
case WDSPRxProfile::SquelchModeVoice:
|
||||
{
|
||||
WDSP::SSQL::SetSSQLRun(*m_rxa, 1);
|
||||
m_rxa->ssql->setRun(1);
|
||||
double threshold = 0.0075 * settings.m_squelchThreshold;
|
||||
WDSP::SSQL::SetSSQLThreshold(*m_rxa, threshold);
|
||||
m_rxa->ssql->setThreshold(threshold);
|
||||
}
|
||||
break;
|
||||
case WDSPRxProfile::SquelchModeAM:
|
||||
@ -717,11 +717,11 @@ void WDSPRxSink::applySettings(const WDSPRxSettings& settings, bool force)
|
||||
}
|
||||
|
||||
if ((m_settings.m_ssqlTauMute != settings.m_ssqlTauMute) || force) {
|
||||
WDSP::SSQL::SetSSQLTauMute(*m_rxa, settings.m_ssqlTauMute);
|
||||
m_rxa->ssql->setTauMute(settings.m_ssqlTauMute);
|
||||
}
|
||||
|
||||
if ((m_settings.m_ssqlTauUnmute != settings.m_ssqlTauUnmute) || force) {
|
||||
WDSP::SSQL::SetSSQLTauUnMute(*m_rxa, settings.m_ssqlTauUnmute);
|
||||
m_rxa->ssql->setTauUnMute(settings.m_ssqlTauUnmute);
|
||||
}
|
||||
|
||||
if ((m_settings.m_amsqMaxTail != settings.m_amsqMaxTail) || force) {
|
||||
@ -743,7 +743,7 @@ void WDSPRxSink::applySettings(const WDSPRxSettings& settings, bool force)
|
||||
// Audio panel
|
||||
|
||||
if ((m_settings.m_volume != settings.m_volume) || force) {
|
||||
WDSP::PANEL::SetPanelGain1(*m_rxa, settings.m_volume);
|
||||
m_rxa->panel->setGain1(settings.m_volume);
|
||||
}
|
||||
|
||||
if ((m_settings.m_audioBinaural != settings.m_audioBinaural)
|
||||
@ -752,13 +752,13 @@ void WDSPRxSink::applySettings(const WDSPRxSettings& settings, bool force)
|
||||
{
|
||||
if (settings.m_audioBinaural)
|
||||
{
|
||||
WDSP::PANEL::SetPanelCopy(*m_rxa, settings.m_audioFlipChannels ? 3 : 0);
|
||||
WDSP::PANEL::SetPanelPan(*m_rxa, settings.m_audioPan);
|
||||
m_rxa->panel->setCopy(settings.m_audioFlipChannels ? 3 : 0);
|
||||
m_rxa->panel->setPan(settings.m_audioPan);
|
||||
}
|
||||
else
|
||||
{
|
||||
WDSP::PANEL::SetPanelCopy(*m_rxa, settings.m_audioFlipChannels ? 2 : 1);
|
||||
WDSP::PANEL::SetPanelPan(*m_rxa, 0.5);
|
||||
m_rxa->panel->setCopy(settings.m_audioFlipChannels ? 2 : 1);
|
||||
m_rxa->panel->setPan(0.5);
|
||||
}
|
||||
}
|
||||
|
||||
|
28
wdsp/RXA.cpp
28
wdsp/RXA.cpp
@ -515,7 +515,7 @@ RXA* RXA::create_rxa (
|
||||
}
|
||||
|
||||
// Syllabic squelch (Voice suelch) - Not in the block diagram
|
||||
rxa->ssql = SSQL::create_ssql(
|
||||
rxa->ssql = new SSQL(
|
||||
0, // run
|
||||
rxa->dsp_size, // size
|
||||
rxa->midbuff, // pointer to input buffer
|
||||
@ -532,7 +532,7 @@ RXA* RXA::create_rxa (
|
||||
2000.0); // max freq for f_to_v converter
|
||||
|
||||
// PatchPanel
|
||||
rxa->panel = PANEL::create_panel (
|
||||
rxa->panel = new PANEL(
|
||||
1, // run
|
||||
rxa->dsp_size, // size
|
||||
rxa->midbuff, // pointer to input buffer
|
||||
@ -565,8 +565,8 @@ RXA* RXA::create_rxa (
|
||||
void RXA::destroy_rxa (RXA *rxa)
|
||||
{
|
||||
delete (rxa->rsmpout);
|
||||
PANEL::destroy_panel (rxa->panel);
|
||||
SSQL::destroy_ssql (rxa->ssql);
|
||||
delete (rxa->panel);
|
||||
delete (rxa->ssql);
|
||||
delete (rxa->mpeak);
|
||||
delete (rxa->speak);
|
||||
delete (rxa->cbl);
|
||||
@ -629,8 +629,8 @@ void RXA::flush_rxa (RXA *rxa)
|
||||
rxa->cbl->flush();
|
||||
rxa->speak->flush();
|
||||
rxa->mpeak->flush();
|
||||
SSQL::flush_ssql (rxa->ssql);
|
||||
PANEL::flush_panel (rxa->panel);
|
||||
rxa->ssql->flush();
|
||||
rxa->panel->flush();
|
||||
rxa->rsmpout->flush();
|
||||
}
|
||||
|
||||
@ -668,8 +668,8 @@ void RXA::xrxa (RXA *rxa)
|
||||
rxa->cbl->execute();
|
||||
rxa->speak->execute();
|
||||
rxa->mpeak->execute();
|
||||
SSQL::xssql (rxa->ssql);
|
||||
PANEL::xpanel (rxa->panel);
|
||||
rxa->ssql->execute();
|
||||
rxa->panel->execute();
|
||||
rxa->amsq->execute();
|
||||
rxa->rsmpout->execute();
|
||||
}
|
||||
@ -775,8 +775,8 @@ void RXA::setDSPSamplerate (RXA *rxa, int dsp_rate)
|
||||
rxa->cbl->setSamplerate(rxa->dsp_rate);
|
||||
rxa->speak->setSamplerate(rxa->dsp_rate);
|
||||
rxa->mpeak->setSamplerate(rxa->dsp_rate);
|
||||
SSQL::setSamplerate_ssql (rxa->ssql, rxa->dsp_rate);
|
||||
PANEL::setSamplerate_panel (rxa->panel, rxa->dsp_rate);
|
||||
rxa->ssql->setSamplerate(rxa->dsp_rate);
|
||||
rxa->panel->setSamplerate(rxa->dsp_rate);
|
||||
// output resampler
|
||||
rxa->rsmpout->setBuffers(rxa->midbuff, rxa->outbuff);
|
||||
rxa->rsmpout->setInRate(rxa->dsp_rate);
|
||||
@ -858,10 +858,10 @@ void RXA::setDSPBuffsize (RXA *rxa, int dsp_size)
|
||||
rxa->speak->setSize(rxa->dsp_size);
|
||||
rxa->mpeak->setBuffers(rxa->midbuff, rxa->midbuff);
|
||||
rxa->mpeak->setSize(rxa->dsp_size);
|
||||
SSQL::setBuffers_ssql (rxa->ssql, rxa->midbuff, rxa->midbuff);
|
||||
SSQL::setSize_ssql (rxa->ssql, rxa->dsp_size);
|
||||
PANEL::setBuffers_panel (rxa->panel, rxa->midbuff, rxa->midbuff);
|
||||
PANEL::setSize_panel (rxa->panel, rxa->dsp_size);
|
||||
rxa->ssql->setBuffers(rxa->midbuff, rxa->midbuff);
|
||||
rxa->ssql->setSize(rxa->dsp_size);
|
||||
rxa->panel->setBuffers(rxa->midbuff, rxa->midbuff);
|
||||
rxa->panel->setSize(rxa->dsp_size);
|
||||
// output resampler
|
||||
rxa->rsmpout->setBuffers(rxa->midbuff, rxa->outbuff);
|
||||
rxa->rsmpout->setSize(rxa->dsp_size);
|
||||
|
14
wdsp/TXA.cpp
14
wdsp/TXA.cpp
@ -103,7 +103,7 @@ TXA* TXA::create_txa (
|
||||
txa->dsp_rate, // sample rate
|
||||
2); // mode
|
||||
|
||||
txa->panel = PANEL::create_panel (
|
||||
txa->panel = new PANEL(
|
||||
1, // run
|
||||
txa->dsp_size, // size
|
||||
txa->midbuff, // pointer to input buffer
|
||||
@ -549,7 +549,7 @@ void TXA::destroy_txa (TXA *txa)
|
||||
delete (txa->amsq);
|
||||
delete (txa->micmeter);
|
||||
delete (txa->phrot);
|
||||
PANEL::destroy_panel (txa->panel);
|
||||
delete (txa->panel);
|
||||
delete (txa->gen0);
|
||||
delete (txa->rsmpin);
|
||||
delete[] (txa->midbuff);
|
||||
@ -565,7 +565,7 @@ void TXA::flush_txa (TXA* txa)
|
||||
std::fill(txa->midbuff, txa->midbuff + 2 * txa->dsp_size * 2, 0);
|
||||
txa->rsmpin->flush();
|
||||
txa->gen0->flush();
|
||||
PANEL::flush_panel (txa->panel);
|
||||
txa->panel->flush ();
|
||||
txa->phrot->flush();
|
||||
txa->micmeter->flush ();
|
||||
txa->amsq->flush ();
|
||||
@ -599,7 +599,7 @@ void xtxa (TXA* txa)
|
||||
{
|
||||
txa->rsmpin->execute(); // input resampler
|
||||
txa->gen0->execute(); // input signal generator
|
||||
PANEL::xpanel (txa->panel); // includes MIC gain
|
||||
txa->panel->execute(); // includes MIC gain
|
||||
txa->phrot->execute(); // phase rotator
|
||||
txa->micmeter->execute (); // MIC meter
|
||||
txa->amsq->xcap (); // downward expander capture
|
||||
@ -697,7 +697,7 @@ void TXA::setDSPSamplerate (TXA *txa, int dsp_rate)
|
||||
txa->rsmpin->setOutRate(txa->dsp_rate);
|
||||
// dsp_rate blocks
|
||||
txa->gen0->setSamplerate(txa->dsp_rate);
|
||||
PANEL::setSamplerate_panel (txa->panel, txa->dsp_rate);
|
||||
txa->panel->setSamplerate(txa->dsp_rate);
|
||||
txa->phrot->setSamplerate(txa->dsp_rate);
|
||||
txa->micmeter->setSamplerate (txa->dsp_rate);
|
||||
txa->amsq->setSamplerate (txa->dsp_rate);
|
||||
@ -758,8 +758,8 @@ void TXA::setDSPBuffsize (TXA *txa, int dsp_size)
|
||||
// dsp_size blocks
|
||||
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);
|
||||
txa->panel->setBuffers(txa->midbuff, txa->midbuff);
|
||||
txa->panel->setSize(txa->dsp_size);
|
||||
txa->phrot->setBuffers(txa->midbuff, txa->midbuff);
|
||||
txa->phrot->setSize(txa->dsp_size);
|
||||
txa->micmeter->setBuffers (txa->midbuff);
|
||||
|
@ -66,6 +66,8 @@ public:
|
||||
int enum_gain,
|
||||
double* pgain
|
||||
);
|
||||
METER(const METER&) = delete;
|
||||
METER& operator=(const METER& other) = delete;
|
||||
~METER() = default;
|
||||
|
||||
void flush();
|
||||
|
@ -32,103 +32,94 @@ warren@wpratt.com
|
||||
|
||||
namespace WDSP {
|
||||
|
||||
PANEL* PANEL::create_panel (
|
||||
int run,
|
||||
int size,
|
||||
float* in,
|
||||
float* out,
|
||||
double gain1,
|
||||
double gain2I,
|
||||
double gain2Q,
|
||||
int inselect,
|
||||
int copy
|
||||
)
|
||||
PANEL::PANEL(
|
||||
int _run,
|
||||
int _size,
|
||||
float* _in,
|
||||
float* _out,
|
||||
double _gain1,
|
||||
double _gain2I,
|
||||
double _gain2Q,
|
||||
int _inselect,
|
||||
int _copy
|
||||
) :
|
||||
run(_run),
|
||||
size(_size),
|
||||
in(_in),
|
||||
out(_out),
|
||||
gain1(_gain1),
|
||||
gain2I(_gain2I),
|
||||
gain2Q(_gain2Q),
|
||||
inselect(_inselect),
|
||||
copy(_copy)
|
||||
{
|
||||
PANEL* a = new PANEL;
|
||||
a->run = run;
|
||||
a->size = size;
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
a->gain1 = gain1;
|
||||
a->gain2I = gain2I;
|
||||
a->gain2Q = gain2Q;
|
||||
a->inselect = inselect;
|
||||
a->copy = copy;
|
||||
return a;
|
||||
}
|
||||
|
||||
void PANEL::destroy_panel (PANEL *a)
|
||||
void PANEL::flush()
|
||||
{
|
||||
delete (a);
|
||||
}
|
||||
|
||||
void PANEL::flush_panel (PANEL *)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PANEL::xpanel (PANEL *a)
|
||||
void PANEL::execute()
|
||||
{
|
||||
int i;
|
||||
double I, Q;
|
||||
double gainI = a->gain1 * a->gain2I;
|
||||
double gainQ = a->gain1 * a->gain2Q;
|
||||
double gainI = gain1 * gain2I;
|
||||
double gainQ = gain1 * gain2Q;
|
||||
// inselect is either 0(neither), 1(Q), 2(I), or 3(both)
|
||||
switch (a->copy)
|
||||
switch (copy)
|
||||
{
|
||||
case 0: // no copy
|
||||
for (i = 0; i < a->size; i++)
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
I = a->in[2 * i + 0] * (a->inselect >> 1);
|
||||
Q = a->in[2 * i + 1] * (a->inselect & 1);
|
||||
a->out[2 * i + 0] = gainI * I;
|
||||
a->out[2 * i + 1] = gainQ * Q;
|
||||
I = in[2 * i + 0] * (inselect >> 1);
|
||||
Q = in[2 * i + 1] * (inselect & 1);
|
||||
out[2 * i + 0] = gainI * I;
|
||||
out[2 * i + 1] = gainQ * Q;
|
||||
}
|
||||
break;
|
||||
case 1: // copy I to Q (then Q == I)
|
||||
for (i = 0; i < a->size; i++)
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
I = a->in[2 * i + 0] * (a->inselect >> 1);
|
||||
I = in[2 * i + 0] * (inselect >> 1);
|
||||
Q = I;
|
||||
a->out[2 * i + 0] = gainI * I;
|
||||
a->out[2 * i + 1] = gainQ * Q;
|
||||
out[2 * i + 0] = gainI * I;
|
||||
out[2 * i + 1] = gainQ * Q;
|
||||
}
|
||||
break;
|
||||
case 2: // copy Q to I (then I == Q)
|
||||
for (i = 0; i < a->size; i++)
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
Q = a->in[2 * i + 1] * (a->inselect & 1);
|
||||
Q = in[2 * i + 1] * (inselect & 1);
|
||||
I = Q;
|
||||
a->out[2 * i + 0] = gainI * I;
|
||||
a->out[2 * i + 1] = gainQ * Q;
|
||||
out[2 * i + 0] = gainI * I;
|
||||
out[2 * i + 1] = gainQ * Q;
|
||||
}
|
||||
break;
|
||||
case 3: // reverse (I=>Q and Q=>I)
|
||||
for (i = 0; i < a->size; i++)
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
Q = a->in[2 * i + 0] * (a->inselect >> 1);
|
||||
I = a->in[2 * i + 1] * (a->inselect & 1);
|
||||
a->out[2 * i + 0] = gainI * I;
|
||||
a->out[2 * i + 1] = gainQ * Q;
|
||||
Q = in[2 * i + 0] * (inselect >> 1);
|
||||
I = in[2 * i + 1] * (inselect & 1);
|
||||
out[2 * i + 0] = gainI * I;
|
||||
out[2 * i + 1] = gainQ * Q;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PANEL::setBuffers_panel (PANEL *a, float* in, float* out)
|
||||
void PANEL::setBuffers(float* _in, float* _out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
in = _in;
|
||||
out = _out;
|
||||
}
|
||||
|
||||
void PANEL::setSamplerate_panel (PANEL *, int)
|
||||
void PANEL::setSamplerate(int)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PANEL::setSize_panel (PANEL *a, int size)
|
||||
void PANEL::setSize(int _size)
|
||||
{
|
||||
a->size = size;
|
||||
size = _size;
|
||||
}
|
||||
|
||||
/********************************************************************************************************
|
||||
@ -137,54 +128,54 @@ void PANEL::setSize_panel (PANEL *a, int size)
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
void PANEL::SetPanelRun (RXA& rxa, int run)
|
||||
void PANEL::setRun(int _run)
|
||||
{
|
||||
rxa.panel->run = run;
|
||||
run = _run;
|
||||
}
|
||||
|
||||
void PANEL::SetPanelSelect (RXA& rxa, int select)
|
||||
void PANEL::setSelect(int _select)
|
||||
{
|
||||
rxa.panel->inselect = select;
|
||||
inselect = _select;
|
||||
}
|
||||
|
||||
void PANEL::SetPanelGain1 (RXA& rxa, double gain)
|
||||
void PANEL::setGain1(double _gain)
|
||||
{
|
||||
rxa.panel->gain1 = gain;
|
||||
gain1 = _gain;
|
||||
}
|
||||
|
||||
void PANEL::SetPanelGain2 (RXA& rxa, double gainI, double gainQ)
|
||||
void PANEL::setGain2(double _gainI, double _gainQ)
|
||||
{
|
||||
rxa.panel->gain2I = gainI;
|
||||
rxa.panel->gain2Q = gainQ;
|
||||
gain2I = _gainI;
|
||||
gain2Q = _gainQ;
|
||||
}
|
||||
|
||||
void PANEL::SetPanelPan (RXA& rxa, double pan)
|
||||
void PANEL::setPan(double _pan)
|
||||
{
|
||||
double gain1, gain2;
|
||||
|
||||
if (pan <= 0.5)
|
||||
if (_pan <= 0.5)
|
||||
{
|
||||
gain1 = 1.0;
|
||||
gain2 = sin (pan * PI);
|
||||
gain2 = sin (_pan * PI);
|
||||
}
|
||||
else
|
||||
{
|
||||
gain1 = sin (pan * PI);
|
||||
gain1 = sin (_pan * PI);
|
||||
gain2 = 1.0;
|
||||
}
|
||||
|
||||
rxa.panel->gain2I = gain1;
|
||||
rxa.panel->gain2Q = gain2;
|
||||
gain2I = gain1;
|
||||
gain2Q = gain2;
|
||||
}
|
||||
|
||||
void PANEL::SetPanelCopy (RXA& rxa, int copy)
|
||||
void PANEL::setCopy(int _copy)
|
||||
{
|
||||
rxa.panel->copy = copy;
|
||||
copy = _copy;
|
||||
}
|
||||
|
||||
void PANEL::SetPanelBinaural (RXA& rxa, int bin)
|
||||
void PANEL::setBinaural(int _bin)
|
||||
{
|
||||
rxa.panel->copy = 1 - bin;
|
||||
copy = 1 - _bin;
|
||||
}
|
||||
|
||||
/********************************************************************************************************
|
||||
@ -193,25 +184,14 @@ void PANEL::SetPanelBinaural (RXA& rxa, int bin)
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
void PANEL::SetPanelRun (TXA& txa, int run)
|
||||
void PANEL::setSelectTx(int _select)
|
||||
{
|
||||
txa.panel->run = run;
|
||||
}
|
||||
|
||||
void PANEL::SetPanelGain1 (TXA& txa, double 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->copy = 3;
|
||||
if (_select == 1)
|
||||
copy = 3;
|
||||
else
|
||||
txa.panel->copy = 0;
|
||||
copy = 0;
|
||||
|
||||
txa.panel->inselect = select;
|
||||
inselect = _select;
|
||||
}
|
||||
|
||||
} // namespace WDSP
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
int inselect;
|
||||
int copy;
|
||||
|
||||
static PANEL* create_panel (
|
||||
PANEL(
|
||||
int run,
|
||||
int size,
|
||||
float* in,
|
||||
@ -59,24 +59,25 @@ public:
|
||||
int inselect,
|
||||
int copy
|
||||
);
|
||||
static void destroy_panel (PANEL *a);
|
||||
static void flush_panel (PANEL *a);
|
||||
static void xpanel (PANEL *a);
|
||||
static void setBuffers_panel (PANEL *a, float* in, float* out);
|
||||
static void setSamplerate_panel (PANEL *a, int rate);
|
||||
static void setSize_panel (PANEL *a, int size);
|
||||
PANEL(const PANEL&) = delete;
|
||||
PANEL& operator=(const PANEL& other) = delete;
|
||||
~PANEL() = default;
|
||||
|
||||
void flush();
|
||||
void execute();
|
||||
void setBuffers(float* in, float* out);
|
||||
void setSamplerate(int rate);
|
||||
void setSize(int size);
|
||||
// RXA Properties
|
||||
static void SetPanelRun (RXA& rxa, int run);
|
||||
static void SetPanelSelect (RXA& rxa, int select);
|
||||
static void SetPanelGain1 (RXA& rxa, double gain);
|
||||
static void SetPanelGain2 (RXA& rxa, double gainI, double gainQ);
|
||||
static void SetPanelPan (RXA& rxa, double pan);
|
||||
static void SetPanelCopy (RXA& rxa, int copy);
|
||||
static void SetPanelBinaural (RXA& rxa, int bin);
|
||||
void setRun(int run);
|
||||
void setSelect(int select);
|
||||
void setGain1(double gain);
|
||||
void setGain2(double gainI, double gainQ);
|
||||
void setPan(double pan);
|
||||
void setCopy(int copy);
|
||||
void setBinaural(int bin);
|
||||
// TXA Properties
|
||||
static void SetPanelRun (TXA& txa, int run);
|
||||
static void SetPanelGain1 (TXA& txa, double gain);
|
||||
static void SetPanelSelect (TXA& txa, int select);
|
||||
void setSelectTx(int select);
|
||||
};
|
||||
|
||||
} // namespace WDSP
|
||||
|
311
wdsp/ssql.cpp
311
wdsp/ssql.cpp
@ -117,127 +117,122 @@ void FTOV::execute()
|
||||
|
||||
|
||||
|
||||
void SSQL::compute_ssql_slews(SSQL *a)
|
||||
void SSQL::compute_slews()
|
||||
{
|
||||
int i;
|
||||
double delta, theta;
|
||||
delta = PI / (double)a->ntup;
|
||||
delta = PI / (double) ntup;
|
||||
theta = 0.0;
|
||||
for (i = 0; i <= a->ntup; i++)
|
||||
for (int i = 0; i <= ntup; i++)
|
||||
{
|
||||
a->cup[i] = a->muted_gain + (1.0 - a->muted_gain) * 0.5 * (1.0 - cos(theta));
|
||||
cup[i] = muted_gain + (1.0 - muted_gain) * 0.5 * (1.0 - cos(theta));
|
||||
theta += delta;
|
||||
}
|
||||
delta = PI / (double)a->ntdown;
|
||||
delta = PI / (double)ntdown;
|
||||
theta = 0.0;
|
||||
for (i = 0; i <= a->ntdown; i++)
|
||||
for (int i = 0; i <= ntdown; i++)
|
||||
{
|
||||
a->cdown[i] = a->muted_gain + (1.0 - a->muted_gain) * 0.5 * (1.0 + cos(theta));
|
||||
cdown[i] = muted_gain + (1.0 - muted_gain) * 0.5 * (1.0 + cos(theta));
|
||||
theta += delta;
|
||||
}
|
||||
}
|
||||
|
||||
void SSQL::calc_ssql (SSQL *a)
|
||||
void SSQL::calc()
|
||||
{
|
||||
a->b1 = new float[a->size * 2]; // (float*) malloc0 (a->size * sizeof (complex));
|
||||
a->dcbl = new CBL(1, a->size, a->in, a->b1, 0, a->rate, 0.02);
|
||||
a->ibuff = new float[a->size]; // (float*) malloc0 (a->size * sizeof (float));
|
||||
a->ftovbuff = new float[a->size]; // (float*) malloc0(a->size * sizeof (float));
|
||||
a->cvtr = new FTOV(1, a->size, a->rate, a->ftov_rsize, a->ftov_fmax, a->ibuff, a->ftovbuff);
|
||||
a->lpbuff = new float[a->size]; // (float*) malloc0 (a->size * sizeof (float));
|
||||
a->filt = new DBQLP(1, a->size, a->ftovbuff, a->lpbuff, a->rate, 11.3, 1.0, 1.0, 1);
|
||||
a->wdbuff = new int[a->size]; // (int*) malloc0 (a->size * sizeof (int));
|
||||
a->tr_signal = new int[a->size]; // (int*) malloc0 (a->size * sizeof (int));
|
||||
b1 = new float[size * 2]; // (float*) malloc0 (size * sizeof (complex));
|
||||
dcbl = new CBL(1, size, in, b1, 0, rate, 0.02);
|
||||
ibuff = new float[size]; // (float*) malloc0 (size * sizeof (float));
|
||||
ftovbuff = new float[size]; // (float*) malloc0(size * sizeof (float));
|
||||
cvtr = new FTOV(1, size, rate, ftov_rsize, ftov_fmax, ibuff, ftovbuff);
|
||||
lpbuff = new float[size]; // (float*) malloc0 (size * sizeof (float));
|
||||
filt = new DBQLP(1, size, ftovbuff, lpbuff, rate, 11.3, 1.0, 1.0, 1);
|
||||
wdbuff = new int[size]; // (int*) malloc0 (size * sizeof (int));
|
||||
tr_signal = new int[size]; // (int*) malloc0 (size * sizeof (int));
|
||||
// window detector
|
||||
a->wdmult = exp (-1.0 / (a->rate * a->wdtau));
|
||||
a->wdaverage = 0.0;
|
||||
wdmult = exp (-1.0 / (rate * wdtau));
|
||||
wdaverage = 0.0;
|
||||
// trigger
|
||||
a->tr_voltage = a->tr_thresh;
|
||||
a->mute_mult = 1.0 - exp (-1.0 / (a->rate * a->tr_tau_mute));
|
||||
a->unmute_mult = 1.0 - exp (-1.0 / (a->rate * a->tr_tau_unmute));
|
||||
tr_voltage = tr_thresh;
|
||||
mute_mult = 1.0 - exp (-1.0 / (rate * tr_tau_mute));
|
||||
unmute_mult = 1.0 - exp (-1.0 / (rate * tr_tau_unmute));
|
||||
// level change
|
||||
a->ntup = (int)(a->tup * a->rate);
|
||||
a->ntdown = (int)(a->tdown * a->rate);
|
||||
a->cup = new float[a->ntup + 1]; // (float*) malloc0 ((a->ntup + 1) * sizeof (float));
|
||||
a->cdown = new float[a->ntdown + 1]; // (float*) malloc0 ((a->ntdown + 1) * sizeof (float));
|
||||
compute_ssql_slews (a);
|
||||
ntup = (int)(tup * rate);
|
||||
ntdown = (int)(tdown * rate);
|
||||
cup = new float[ntup + 1]; // (float*) malloc0 ((ntup + 1) * sizeof (float));
|
||||
cdown = new float[ntdown + 1]; // (float*) malloc0 ((ntdown + 1) * sizeof (float));
|
||||
compute_slews();
|
||||
// control
|
||||
a->state = 0;
|
||||
a->count = 0;
|
||||
state = 0;
|
||||
count = 0;
|
||||
}
|
||||
|
||||
void SSQL::decalc_ssql (SSQL *a)
|
||||
void SSQL::decalc()
|
||||
{
|
||||
delete[] (a->tr_signal);
|
||||
delete[] (a->wdbuff);
|
||||
delete (a->filt);
|
||||
delete[] (a->lpbuff);
|
||||
delete (a->cvtr);
|
||||
delete[] (a->ftovbuff);
|
||||
delete[] (a->ibuff);
|
||||
delete (a->dcbl);
|
||||
delete[] (a->b1);
|
||||
delete[] (a->cdown);
|
||||
delete[] (a->cup);
|
||||
delete[] (tr_signal);
|
||||
delete[] (wdbuff);
|
||||
delete (filt);
|
||||
delete[] (lpbuff);
|
||||
delete (cvtr);
|
||||
delete[] (ftovbuff);
|
||||
delete[] (ibuff);
|
||||
delete (dcbl);
|
||||
delete[] (b1);
|
||||
delete[] (cdown);
|
||||
delete[] (cup);
|
||||
}
|
||||
|
||||
SSQL* SSQL::create_ssql (
|
||||
int run,
|
||||
int size,
|
||||
float* in,
|
||||
float* out,
|
||||
int rate,
|
||||
double tup,
|
||||
double tdown,
|
||||
double muted_gain,
|
||||
double tau_mute,
|
||||
double tau_unmute,
|
||||
double wthresh,
|
||||
double tr_thresh,
|
||||
int rsize,
|
||||
double fmax
|
||||
SSQL::SSQL(
|
||||
int _run,
|
||||
int _size,
|
||||
float* _in,
|
||||
float* _out,
|
||||
int _rate,
|
||||
double _tup,
|
||||
double _tdown,
|
||||
double _muted_gain,
|
||||
double _tau_mute,
|
||||
double _tau_unmute,
|
||||
double _wthresh,
|
||||
double _tr_thresh,
|
||||
int _rsize,
|
||||
double _fmax
|
||||
)
|
||||
{
|
||||
SSQL *a = new SSQL;
|
||||
a->run = run;
|
||||
a->size = size;
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
a->rate = rate;
|
||||
a->tup = tup;
|
||||
a->tdown = tdown;
|
||||
a->muted_gain = muted_gain;
|
||||
a->tr_tau_mute = tau_mute;
|
||||
a->tr_tau_unmute = tau_unmute;
|
||||
a->wthresh = wthresh; // PRIMARY SQUELCH THRESHOLD CONTROL
|
||||
a->tr_thresh = tr_thresh; // value between tr_ss_unmute and tr_ss_mute, default = 0.8197
|
||||
a->tr_ss_mute = 1.0;
|
||||
a->tr_ss_unmute = 0.3125;
|
||||
a->wdtau = 0.5;
|
||||
a->ftov_rsize = rsize;
|
||||
a->ftov_fmax = fmax;
|
||||
calc_ssql (a);
|
||||
return a;
|
||||
run = _run;
|
||||
size = _size;
|
||||
in = _in;
|
||||
out = _out;
|
||||
rate = _rate;
|
||||
tup = _tup;
|
||||
tdown = _tdown;
|
||||
muted_gain = _muted_gain;
|
||||
tr_tau_mute = _tau_mute;
|
||||
tr_tau_unmute = _tau_unmute;
|
||||
wthresh = _wthresh; // PRIMARY SQUELCH THRESHOLD CONTROL
|
||||
tr_thresh = _tr_thresh; // value between tr_ss_unmute and tr_ss_mute, default = 0.8197
|
||||
tr_ss_mute = 1.0;
|
||||
tr_ss_unmute = 0.3125;
|
||||
wdtau = 0.5;
|
||||
ftov_rsize = _rsize;
|
||||
ftov_fmax = _fmax;
|
||||
calc();
|
||||
}
|
||||
|
||||
void SSQL::destroy_ssql (SSQL *a)
|
||||
SSQL::~SSQL()
|
||||
{
|
||||
decalc_ssql (a);
|
||||
delete (a);
|
||||
decalc();
|
||||
}
|
||||
|
||||
void SSQL::flush_ssql (SSQL *a)
|
||||
void SSQL::flush()
|
||||
{
|
||||
|
||||
std::fill(a->b1, a->b1 + a->size * 2, 0);
|
||||
a->dcbl->flush();
|
||||
memset (a->ibuff, 0, a->size * sizeof (float));
|
||||
memset (a->ftovbuff, 0, a->size * sizeof (float));
|
||||
a->cvtr->flush();
|
||||
memset (a->lpbuff, 0, a->size * sizeof (float));
|
||||
a->filt->flush();
|
||||
memset (a->wdbuff, 0, a->size * sizeof (int));
|
||||
memset (a->tr_signal, 0, a->size * sizeof (int));
|
||||
std::fill(b1, b1 + size * 2, 0);
|
||||
dcbl->flush();
|
||||
memset (ibuff, 0, size * sizeof (float));
|
||||
memset (ftovbuff, 0, size * sizeof (float));
|
||||
cvtr->flush();
|
||||
memset (lpbuff, 0, size * sizeof (float));
|
||||
filt->flush();
|
||||
memset (wdbuff, 0, size * sizeof (int));
|
||||
memset (tr_signal, 0, size * sizeof (int));
|
||||
}
|
||||
|
||||
enum _ssqlstate
|
||||
@ -248,98 +243,98 @@ enum _ssqlstate
|
||||
DECREASE
|
||||
};
|
||||
|
||||
void SSQL::xssql (SSQL *a)
|
||||
void SSQL::execute()
|
||||
{
|
||||
if (a->run)
|
||||
if (run)
|
||||
{
|
||||
a->dcbl->execute(); // dc block the input signal
|
||||
for (int i = 0; i < a->size; i++) // extract 'I' component
|
||||
a->ibuff[i] = a->b1[2 * i];
|
||||
a->cvtr->execute(); // convert frequency to voltage, ignoring amplitude
|
||||
// WriteAudioWDSP(20.0, a->rate, a->size, a->ftovbuff, 4, 0.99);
|
||||
a->filt->execute(); // low-pass filter
|
||||
// WriteAudioWDSP(20.0, a->rate, a->size, a->lpbuff, 4, 0.99);
|
||||
dcbl->execute(); // dc block the input signal
|
||||
for (int i = 0; i < size; i++) // extract 'I' component
|
||||
ibuff[i] = b1[2 * i];
|
||||
cvtr->execute(); // convert frequency to voltage, ignoring amplitude
|
||||
// WriteAudioWDSP(20.0, rate, size, ftovbuff, 4, 0.99);
|
||||
filt->execute(); // low-pass filter
|
||||
// WriteAudioWDSP(20.0, rate, size, lpbuff, 4, 0.99);
|
||||
// calculate the output of the window detector for each sample
|
||||
for (int i = 0; i < a->size; i++)
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
a->wdaverage = a->wdmult * a->wdaverage + (1.0 - a->wdmult) * a->lpbuff[i];
|
||||
if ((a->lpbuff[i] - a->wdaverage) > a->wthresh || (a->wdaverage - a->lpbuff[i]) > a->wthresh)
|
||||
a->wdbuff[i] = 0; // signal unmute
|
||||
wdaverage = wdmult * wdaverage + (1.0 - wdmult) * lpbuff[i];
|
||||
if ((lpbuff[i] - wdaverage) > wthresh || (wdaverage - lpbuff[i]) > wthresh)
|
||||
wdbuff[i] = 0; // signal unmute
|
||||
else
|
||||
a->wdbuff[i] = 1; // signal mute
|
||||
wdbuff[i] = 1; // signal mute
|
||||
}
|
||||
// calculate the trigger signal for each sample
|
||||
for (int i = 0; i < a->size; i++)
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
if (a->wdbuff[i] == 0)
|
||||
a->tr_voltage += (a->tr_ss_unmute - a->tr_voltage) * a->unmute_mult;
|
||||
if (a->wdbuff[i] == 1)
|
||||
a->tr_voltage += (a->tr_ss_mute - a->tr_voltage) * a->mute_mult;
|
||||
if (a->tr_voltage > a->tr_thresh) a->tr_signal[i] = 0; // muted
|
||||
else a->tr_signal[i] = 1; // unmuted
|
||||
if (wdbuff[i] == 0)
|
||||
tr_voltage += (tr_ss_unmute - tr_voltage) * unmute_mult;
|
||||
if (wdbuff[i] == 1)
|
||||
tr_voltage += (tr_ss_mute - tr_voltage) * mute_mult;
|
||||
if (tr_voltage > tr_thresh) tr_signal[i] = 0; // muted
|
||||
else tr_signal[i] = 1; // unmuted
|
||||
}
|
||||
// execute state machine; calculate audio output
|
||||
for (int i = 0; i < a->size; i++)
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
switch (a->state)
|
||||
switch (state)
|
||||
{
|
||||
case MUTED:
|
||||
if (a->tr_signal[i] == 1)
|
||||
if (tr_signal[i] == 1)
|
||||
{
|
||||
a->state = INCREASE;
|
||||
a->count = a->ntup;
|
||||
state = INCREASE;
|
||||
count = ntup;
|
||||
}
|
||||
a->out[2 * i + 0] = a->muted_gain * a->in[2 * i + 0];
|
||||
a->out[2 * i + 1] = a->muted_gain * a->in[2 * i + 1];
|
||||
out[2 * i + 0] = muted_gain * in[2 * i + 0];
|
||||
out[2 * i + 1] = muted_gain * in[2 * i + 1];
|
||||
break;
|
||||
case INCREASE:
|
||||
a->out[2 * i + 0] = a->in[2 * i + 0] * a->cup[a->ntup - a->count];
|
||||
a->out[2 * i + 1] = a->in[2 * i + 1] * a->cup[a->ntup - a->count];
|
||||
if (a->count-- == 0)
|
||||
a->state = UNMUTED;
|
||||
out[2 * i + 0] = in[2 * i + 0] * cup[ntup - count];
|
||||
out[2 * i + 1] = in[2 * i + 1] * cup[ntup - count];
|
||||
if (count-- == 0)
|
||||
state = UNMUTED;
|
||||
break;
|
||||
case UNMUTED:
|
||||
if (a->tr_signal[i] == 0)
|
||||
if (tr_signal[i] == 0)
|
||||
{
|
||||
a->state = DECREASE;
|
||||
a->count = a->ntdown;
|
||||
state = DECREASE;
|
||||
count = ntdown;
|
||||
}
|
||||
a->out[2 * i + 0] = a->in[2 * i + 0];
|
||||
a->out[2 * i + 1] = a->in[2 * i + 1];
|
||||
out[2 * i + 0] = in[2 * i + 0];
|
||||
out[2 * i + 1] = in[2 * i + 1];
|
||||
break;
|
||||
case DECREASE:
|
||||
a->out[2 * i + 0] = a->in[2 * i + 0] * a->cdown[a->ntdown - a->count];
|
||||
a->out[2 * i + 1] = a->in[2 * i + 1] * a->cdown[a->ntdown - a->count];
|
||||
if (a->count-- == 0)
|
||||
a->state = MUTED;
|
||||
out[2 * i + 0] = in[2 * i + 0] * cdown[ntdown - count];
|
||||
out[2 * i + 1] = in[2 * i + 1] * cdown[ntdown - count];
|
||||
if (count-- == 0)
|
||||
state = MUTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (a->in != a->out)
|
||||
std::copy(a->in, a->in + a->size * 2, a->out);
|
||||
else if (in != out)
|
||||
std::copy(in, in + size * 2, out);
|
||||
}
|
||||
|
||||
void SSQL::setBuffers_ssql (SSQL *a, float* in, float* out)
|
||||
void SSQL::setBuffers(float* _in, float* _out)
|
||||
{
|
||||
decalc_ssql (a);
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
calc_ssql (a);
|
||||
decalc();
|
||||
in = _in;
|
||||
out = _out;
|
||||
calc();
|
||||
}
|
||||
|
||||
void SSQL::setSamplerate_ssql (SSQL *a, int rate)
|
||||
void SSQL::setSamplerate(int _rate)
|
||||
{
|
||||
decalc_ssql (a);
|
||||
a->rate = rate;
|
||||
calc_ssql (a);
|
||||
decalc();
|
||||
rate = _rate;
|
||||
calc();
|
||||
}
|
||||
|
||||
void SSQL::setSize_ssql (SSQL *a, int size)
|
||||
void SSQL::setSize(int _size)
|
||||
{
|
||||
decalc_ssql (a);
|
||||
a->size = size;
|
||||
calc_ssql (a);
|
||||
decalc();
|
||||
size = _size;
|
||||
calc();
|
||||
}
|
||||
|
||||
/********************************************************************************************************
|
||||
@ -348,34 +343,32 @@ void SSQL::setSize_ssql (SSQL *a, int size)
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
void SSQL::SetSSQLRun (RXA& rxa, int run)
|
||||
void SSQL::setRun(int _run)
|
||||
{
|
||||
rxa.ssql->run = run;
|
||||
run = _run;
|
||||
}
|
||||
|
||||
void SSQL::SetSSQLThreshold (RXA& rxa, double threshold)
|
||||
void SSQL::setThreshold(double _threshold)
|
||||
{
|
||||
// 'threshold' should be between 0.0 and 1.0
|
||||
// WU2O testing: 0.16 is a good default for 'threshold'; => 0.08 for 'wthresh'
|
||||
rxa.ssql->wthresh = threshold / 2.0;
|
||||
wthresh = _threshold / 2.0;
|
||||
}
|
||||
|
||||
void SSQL::SetSSQLTauMute (RXA& rxa, double tau_mute)
|
||||
void SSQL::setTauMute(double _tau_mute)
|
||||
{
|
||||
// reasonable (wide) range is 0.1 to 2.0
|
||||
// WU2O testing: 0.1 is good default value
|
||||
SSQL *a = rxa.ssql;
|
||||
a->tr_tau_mute = tau_mute;
|
||||
a->mute_mult = 1.0 - exp (-1.0 / (a->rate * a->tr_tau_mute));
|
||||
tr_tau_mute = _tau_mute;
|
||||
mute_mult = 1.0 - exp (-1.0 / (rate * tr_tau_mute));
|
||||
}
|
||||
|
||||
void SSQL::SetSSQLTauUnMute (RXA& rxa, double tau_unmute)
|
||||
void SSQL::setTauUnMute(double _tau_unmute)
|
||||
{
|
||||
// reasonable (wide) range is 0.1 to 1.0
|
||||
// WU2O testing: 0.1 is good default value
|
||||
SSQL *a = rxa.ssql;
|
||||
a->tr_tau_unmute = tau_unmute;
|
||||
a->unmute_mult = 1.0 - exp (-1.0 / (a->rate * a->tr_tau_unmute));
|
||||
tr_tau_unmute = _tau_unmute;
|
||||
unmute_mult = 1.0 - exp (-1.0 / (rate * tr_tau_unmute));
|
||||
}
|
||||
|
||||
} // namespace WDSP
|
||||
|
@ -117,7 +117,7 @@ public:
|
||||
double unmute_mult; // multiplier for successive voltage calcs when unmuted
|
||||
int* tr_signal; // trigger signal, 0 or 1
|
||||
|
||||
static SSQL* create_ssql (
|
||||
SSQL(
|
||||
int run,
|
||||
int size,
|
||||
float* in,
|
||||
@ -133,22 +133,25 @@ public:
|
||||
int rsize,
|
||||
double fmax
|
||||
);
|
||||
static void destroy_ssql (SSQL *a);
|
||||
static void flush_ssql (SSQL *a);
|
||||
static void xssql (SSQL *a);
|
||||
static void setBuffers_ssql (SSQL *a, float* in, float* out);
|
||||
static void setSamplerate_ssql (SSQL *a, int rate);
|
||||
static void setSize_ssql (SSQL *a, int size);
|
||||
SSQL(const SSQL&) = delete;
|
||||
SSQL& operator=(const SSQL& other) = delete;
|
||||
~SSQL();
|
||||
|
||||
void flush();
|
||||
void execute();
|
||||
void setBuffers(float* in, float* out);
|
||||
void setSamplerate(int rate);
|
||||
void setSize(int size);
|
||||
// RXA Properties
|
||||
static void SetSSQLRun (RXA& rxa, int run);
|
||||
static void SetSSQLThreshold (RXA& rxa, double threshold);
|
||||
static void SetSSQLTauMute (RXA& rxa, double tau_mute);
|
||||
static void SetSSQLTauUnMute (RXA& rxa, double tau_unmute);
|
||||
void setRun(int run);
|
||||
void setThreshold(double threshold);
|
||||
void setTauMute(double tau_mute);
|
||||
void setTauUnMute(double tau_unmute);
|
||||
|
||||
private:
|
||||
static void compute_ssql_slews(SSQL *a);
|
||||
static void calc_ssql (SSQL *a);
|
||||
static void decalc_ssql (SSQL *a);
|
||||
void compute_slews();
|
||||
void calc();
|
||||
void decalc();
|
||||
};
|
||||
|
||||
} // namespace WDSP
|
||||
|
Loading…
Reference in New Issue
Block a user