mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-03 09:44:01 -05:00
Amendments to WDSP. WDSP Receiver: create/delete WDSP RXA
This commit is contained in:
parent
8ce840dd17
commit
d0391e3516
@ -19,7 +19,8 @@ set(wdsprx_HEADERS
|
|||||||
)
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
|
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
|
||||||
|
${CMAKE_SOURCE_DIR}/wdsp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT SERVER_MODE)
|
if(NOT SERVER_MODE)
|
||||||
|
@ -25,11 +25,14 @@
|
|||||||
#include "util/db.h"
|
#include "util/db.h"
|
||||||
#include "util/messagequeue.h"
|
#include "util/messagequeue.h"
|
||||||
#include "maincore.h"
|
#include "maincore.h"
|
||||||
|
#include "RXA.hpp"
|
||||||
|
|
||||||
#include "wdsprxsink.h"
|
#include "wdsprxsink.h"
|
||||||
|
|
||||||
const int WDSPRxSink::m_ssbFftLen = 2048;
|
const int WDSPRxSink::m_ssbFftLen = 2048;
|
||||||
const int WDSPRxSink::m_agcTarget = 3276; // 32768/10 -10 dB amplitude => -20 dB power: center of normal signal
|
const int WDSPRxSink::m_agcTarget = 3276; // 32768/10 -10 dB amplitude => -20 dB power: center of normal signal
|
||||||
|
const int WDSPRxSink::m_wdspSampleRate = 48000;
|
||||||
|
const int WDSPRxSink::m_wdspBufSize = 512;
|
||||||
|
|
||||||
WDSPRxSink::WDSPRxSink() :
|
WDSPRxSink::WDSPRxSink() :
|
||||||
m_audioBinaual(false),
|
m_audioBinaual(false),
|
||||||
@ -69,6 +72,12 @@ WDSPRxSink::WDSPRxSink() :
|
|||||||
m_magsqPeak = 0.0;
|
m_magsqPeak = 0.0;
|
||||||
m_magsqCount = 0;
|
m_magsqCount = 0;
|
||||||
|
|
||||||
|
m_rxa = WDSP::RXA::create_rxa(
|
||||||
|
m_wdspSampleRate, // input samplerate
|
||||||
|
m_wdspSampleRate, // output samplerate
|
||||||
|
m_wdspSampleRate, // sample rate for mainstream dsp processing (dsp)
|
||||||
|
m_wdspBufSize // number complex samples processed per buffer in mainstream dsp processing
|
||||||
|
);
|
||||||
SSBFilter = new fftfilt(m_LowCutoff / m_audioSampleRate, m_Bandwidth / m_audioSampleRate, m_ssbFftLen);
|
SSBFilter = new fftfilt(m_LowCutoff / m_audioSampleRate, m_Bandwidth / m_audioSampleRate, m_ssbFftLen);
|
||||||
DSBFilter = new fftfilt((2.0f * m_Bandwidth) / m_audioSampleRate, 2 * m_ssbFftLen);
|
DSBFilter = new fftfilt((2.0f * m_Bandwidth) / m_audioSampleRate, 2 * m_ssbFftLen);
|
||||||
|
|
||||||
@ -81,6 +90,7 @@ WDSPRxSink::WDSPRxSink() :
|
|||||||
|
|
||||||
WDSPRxSink::~WDSPRxSink()
|
WDSPRxSink::~WDSPRxSink()
|
||||||
{
|
{
|
||||||
|
WDSP::RXA::destroy_rxa(m_rxa);
|
||||||
delete SSBFilter;
|
delete SSBFilter;
|
||||||
delete DSBFilter;
|
delete DSBFilter;
|
||||||
}
|
}
|
||||||
@ -289,7 +299,7 @@ void WDSPRxSink::applyChannelSettings(int channelSampleRate, int channelFrequenc
|
|||||||
Real interpolatorBandwidth = (m_Bandwidth * 1.5f) > channelSampleRate ? channelSampleRate : (m_Bandwidth * 1.5f);
|
Real interpolatorBandwidth = (m_Bandwidth * 1.5f) > channelSampleRate ? channelSampleRate : (m_Bandwidth * 1.5f);
|
||||||
m_interpolator.create(16, channelSampleRate, interpolatorBandwidth, 2.0f);
|
m_interpolator.create(16, channelSampleRate, interpolatorBandwidth, 2.0f);
|
||||||
m_interpolatorDistanceRemain = 0;
|
m_interpolatorDistanceRemain = 0;
|
||||||
m_interpolatorDistance = (Real) channelSampleRate / (Real) m_audioSampleRate;
|
m_interpolatorDistance = (Real) channelSampleRate / (Real) m_wdspSampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_channelSampleRate = channelSampleRate;
|
m_channelSampleRate = channelSampleRate;
|
||||||
@ -303,7 +313,9 @@ void WDSPRxSink::applyAudioSampleRate(int sampleRate)
|
|||||||
Real interpolatorBandwidth = (m_Bandwidth * 1.5f) > m_channelSampleRate ? m_channelSampleRate : (m_Bandwidth * 1.5f);
|
Real interpolatorBandwidth = (m_Bandwidth * 1.5f) > m_channelSampleRate ? m_channelSampleRate : (m_Bandwidth * 1.5f);
|
||||||
m_interpolator.create(16, m_channelSampleRate, interpolatorBandwidth, 2.0f);
|
m_interpolator.create(16, m_channelSampleRate, interpolatorBandwidth, 2.0f);
|
||||||
m_interpolatorDistanceRemain = 0;
|
m_interpolatorDistanceRemain = 0;
|
||||||
m_interpolatorDistance = (Real) m_channelSampleRate / (Real) sampleRate;
|
m_interpolatorDistance = (Real) m_channelSampleRate / (Real) m_wdspSampleRate;
|
||||||
|
|
||||||
|
WDSP::RXA::setOutputSamplerate(m_rxa, sampleRate);
|
||||||
|
|
||||||
SSBFilter->create_filter(m_LowCutoff / (float) sampleRate, m_Bandwidth / (float) sampleRate, m_settings.m_filterBank[m_settings.m_filterIndex].m_fftWindow);
|
SSBFilter->create_filter(m_LowCutoff / (float) sampleRate, m_Bandwidth / (float) sampleRate, m_settings.m_filterBank[m_settings.m_filterIndex].m_fftWindow);
|
||||||
DSBFilter->create_dsb_filter(m_Bandwidth / (float) sampleRate, m_settings.m_filterBank[m_settings.m_filterIndex].m_fftWindow);
|
DSBFilter->create_dsb_filter(m_Bandwidth / (float) sampleRate, m_settings.m_filterBank[m_settings.m_filterIndex].m_fftWindow);
|
||||||
|
@ -34,6 +34,10 @@
|
|||||||
class SpectrumVis;
|
class SpectrumVis;
|
||||||
class ChannelAPI;
|
class ChannelAPI;
|
||||||
|
|
||||||
|
namespace WDSP {
|
||||||
|
class RXA;
|
||||||
|
}
|
||||||
|
|
||||||
class WDSPRxSink : public ChannelSampleSink {
|
class WDSPRxSink : public ChannelSampleSink {
|
||||||
public:
|
public:
|
||||||
WDSPRxSink();
|
WDSPRxSink();
|
||||||
@ -132,9 +136,12 @@ private:
|
|||||||
|
|
||||||
QVector<qint16> m_demodBuffer;
|
QVector<qint16> m_demodBuffer;
|
||||||
int m_demodBufferFill;
|
int m_demodBufferFill;
|
||||||
|
WDSP::RXA *m_rxa;
|
||||||
|
|
||||||
static const int m_ssbFftLen;
|
static const int m_ssbFftLen;
|
||||||
static const int m_agcTarget;
|
static const int m_agcTarget;
|
||||||
|
static const int m_wdspSampleRate;
|
||||||
|
static const int m_wdspBufSize;
|
||||||
|
|
||||||
void processOneSample(Complex &ci);
|
void processOneSample(Complex &ci);
|
||||||
};
|
};
|
||||||
|
58
wdsp/RXA.cpp
58
wdsp/RXA.cpp
@ -58,24 +58,26 @@ namespace WDSP {
|
|||||||
RXA* RXA::create_rxa (
|
RXA* RXA::create_rxa (
|
||||||
int in_rate, // input samplerate
|
int in_rate, // input samplerate
|
||||||
int out_rate, // output samplerate
|
int out_rate, // output samplerate
|
||||||
int in_size, // input buffsize (complex samples) in a fexchange() operation
|
|
||||||
int dsp_rate, // sample rate for mainstream dsp processing
|
int dsp_rate, // sample rate for mainstream dsp processing
|
||||||
int dsp_size, // number complex samples processed per buffer in mainstream dsp processing
|
int dsp_size // number complex samples processed per buffer in mainstream dsp processing
|
||||||
int dsp_insize, // size (complex samples) of the output of the r1 (input) buffer
|
|
||||||
int dsp_outsize, // size (complex samples) of the input of the r2 (output) buffer
|
|
||||||
int out_size // output buffsize (complex samples) in a fexchange() operation
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
RXA* rxa = new RXA;
|
RXA* rxa = new RXA;
|
||||||
|
|
||||||
rxa->in_rate = in_rate;
|
rxa->in_rate = in_rate;
|
||||||
rxa->out_rate = out_rate;
|
rxa->out_rate = out_rate;
|
||||||
rxa->in_size = in_size;
|
|
||||||
rxa->dsp_rate = dsp_rate;
|
rxa->dsp_rate = dsp_rate;
|
||||||
rxa->dsp_size = dsp_size;
|
rxa->dsp_size = dsp_size;
|
||||||
rxa->dsp_insize = dsp_insize;
|
|
||||||
rxa->dsp_outsize = dsp_outsize;
|
if (in_rate >= dsp_rate)
|
||||||
rxa->out_size = out_size;
|
rxa->dsp_insize = dsp_size * (in_rate / dsp_rate);
|
||||||
|
else
|
||||||
|
rxa->dsp_insize = dsp_size / (dsp_rate / in_rate);
|
||||||
|
|
||||||
|
if (out_rate >= dsp_rate)
|
||||||
|
rxa->dsp_outsize = dsp_size * (out_rate / dsp_rate);
|
||||||
|
else
|
||||||
|
rxa->dsp_outsize = dsp_size / (dsp_rate / out_rate);
|
||||||
|
|
||||||
rxa->mode = RXA_LSB;
|
rxa->mode = RXA_LSB;
|
||||||
rxa->inbuff = new double[1 * rxa->dsp_insize * 2]; // (double *) malloc0 (1 * ch.dsp_insize * sizeof (complex));
|
rxa->inbuff = new double[1 * rxa->dsp_insize * 2]; // (double *) malloc0 (1 * ch.dsp_insize * sizeof (complex));
|
||||||
@ -645,10 +647,13 @@ void RXA::xrxa (RXA *rxa)
|
|||||||
RESAMPLE::xresample (rxa->rsmpout.p);
|
RESAMPLE::xresample (rxa->rsmpout.p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RXA::setInputSamplerate (RXA *rxa, int dsp_insize, int in_rate)
|
void RXA::setInputSamplerate (RXA *rxa, int in_rate)
|
||||||
{
|
{
|
||||||
rxa->csDSP.lock();
|
rxa->csDSP.lock();
|
||||||
rxa->dsp_insize = dsp_insize;
|
if (in_rate >= rxa->dsp_rate)
|
||||||
|
rxa->dsp_insize = rxa->dsp_size * (in_rate / rxa->dsp_rate);
|
||||||
|
else
|
||||||
|
rxa->dsp_insize = rxa->dsp_size / (rxa->dsp_rate / in_rate);
|
||||||
rxa->in_rate = in_rate;
|
rxa->in_rate = in_rate;
|
||||||
// buffers
|
// buffers
|
||||||
delete[] (rxa->inbuff);
|
delete[] (rxa->inbuff);
|
||||||
@ -665,10 +670,13 @@ void RXA::setInputSamplerate (RXA *rxa, int dsp_insize, int in_rate)
|
|||||||
rxa->csDSP.unlock();
|
rxa->csDSP.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RXA::setOutputSamplerate (RXA *rxa, int dsp_outsize, int out_rate)
|
void RXA::setOutputSamplerate (RXA *rxa, int out_rate)
|
||||||
{
|
{
|
||||||
rxa->csDSP.lock();
|
rxa->csDSP.lock();
|
||||||
rxa->dsp_outsize = dsp_outsize;
|
if (out_rate >= rxa->dsp_rate)
|
||||||
|
rxa->dsp_outsize = rxa->dsp_size * (out_rate / rxa->dsp_rate);
|
||||||
|
else
|
||||||
|
rxa->dsp_outsize = rxa->dsp_size / (rxa->dsp_rate / out_rate);
|
||||||
rxa->out_rate = out_rate;
|
rxa->out_rate = out_rate;
|
||||||
// buffers
|
// buffers
|
||||||
delete[] (rxa->outbuff);
|
delete[] (rxa->outbuff);
|
||||||
@ -680,11 +688,17 @@ void RXA::setOutputSamplerate (RXA *rxa, int dsp_outsize, int out_rate)
|
|||||||
rxa->csDSP.unlock();
|
rxa->csDSP.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RXA::setDSPSamplerate (RXA *rxa, int dsp_insize, int dsp_outsize, int dsp_rate)
|
void RXA::setDSPSamplerate (RXA *rxa, int dsp_rate)
|
||||||
{
|
{
|
||||||
rxa->csDSP.lock();
|
rxa->csDSP.lock();
|
||||||
rxa->dsp_insize = dsp_insize;
|
if (rxa->in_rate >= dsp_rate)
|
||||||
rxa->dsp_outsize = dsp_outsize;
|
rxa->dsp_insize = rxa->dsp_size * (rxa->in_rate / dsp_rate);
|
||||||
|
else
|
||||||
|
rxa->dsp_insize = rxa->dsp_size / (dsp_rate / rxa->in_rate);
|
||||||
|
if (rxa->out_rate >= dsp_rate)
|
||||||
|
rxa->dsp_outsize = rxa->dsp_size * (rxa->out_rate / dsp_rate);
|
||||||
|
else
|
||||||
|
rxa->dsp_outsize = rxa->dsp_size / (dsp_rate / rxa->out_rate);
|
||||||
rxa->dsp_rate = dsp_rate;
|
rxa->dsp_rate = dsp_rate;
|
||||||
// buffers
|
// buffers
|
||||||
delete[] (rxa->inbuff);
|
delete[] (rxa->inbuff);
|
||||||
@ -731,12 +745,18 @@ void RXA::setDSPSamplerate (RXA *rxa, int dsp_insize, int dsp_outsize, int dsp_r
|
|||||||
rxa->csDSP.unlock();
|
rxa->csDSP.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RXA::setDSPBuffsize (RXA *rxa, int dsp_insize, int dsp_size, int dsp_outsize)
|
void RXA::setDSPBuffsize (RXA *rxa, int dsp_size)
|
||||||
{
|
{
|
||||||
rxa->csDSP.lock();
|
rxa->csDSP.lock();
|
||||||
rxa->dsp_insize = dsp_insize;
|
if (rxa->in_rate >= rxa->dsp_rate)
|
||||||
|
rxa->dsp_insize = dsp_size * (rxa->in_rate / rxa->dsp_rate);
|
||||||
|
else
|
||||||
|
rxa->dsp_insize = dsp_size / (rxa->dsp_rate / rxa->in_rate);
|
||||||
|
if (rxa->out_rate >= rxa->dsp_rate)
|
||||||
|
rxa->dsp_outsize = dsp_size * (rxa->out_rate / rxa->dsp_rate);
|
||||||
|
else
|
||||||
|
rxa->dsp_outsize = dsp_size / (rxa->dsp_rate / rxa->out_rate);
|
||||||
rxa->dsp_size = dsp_size;
|
rxa->dsp_size = dsp_size;
|
||||||
rxa->dsp_outsize = dsp_outsize;
|
|
||||||
// buffers
|
// buffers
|
||||||
delete[](rxa->inbuff);
|
delete[](rxa->inbuff);
|
||||||
rxa->inbuff = new double[1 * rxa->dsp_insize * 2]; // (double *)malloc0(1 * rxa->dsp_insize * sizeof(complex));
|
rxa->inbuff = new double[1 * rxa->dsp_insize * 2]; // (double *)malloc0(1 * rxa->dsp_insize * sizeof(complex));
|
||||||
|
26
wdsp/RXA.hpp
26
wdsp/RXA.hpp
@ -95,9 +95,6 @@ public:
|
|||||||
RXA_METERTYPE_LAST
|
RXA_METERTYPE_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
double* inbuff;
|
|
||||||
double* outbuff;
|
|
||||||
double* midbuff;
|
|
||||||
int mode;
|
int mode;
|
||||||
double meter[RXA_METERTYPE_LAST];
|
double meter[RXA_METERTYPE_LAST];
|
||||||
QRecursiveMutex* pmtupdate[RXA_METERTYPE_LAST];
|
QRecursiveMutex* pmtupdate[RXA_METERTYPE_LAST];
|
||||||
@ -209,20 +206,20 @@ public:
|
|||||||
static RXA* create_rxa (
|
static RXA* create_rxa (
|
||||||
int in_rate, // input samplerate
|
int in_rate, // input samplerate
|
||||||
int out_rate, // output samplerate
|
int out_rate, // output samplerate
|
||||||
int in_size, // input buffsize (complex samples) in a fexchange() operation
|
|
||||||
int dsp_rate, // sample rate for mainstream dsp processing
|
int dsp_rate, // sample rate for mainstream dsp processing
|
||||||
int dsp_size, // number complex samples processed per buffer in mainstream dsp processing
|
int dsp_size // number complex samples processed per buffer in mainstream dsp processing
|
||||||
int dsp_insize, // size (complex samples) of the output of the r1 (input) buffer
|
|
||||||
int dsp_outsize, // size (complex samples) of the input of the r2 (output) buffer
|
|
||||||
int out_size // output buffsize (complex samples) in a fexchange() operation
|
|
||||||
);
|
);
|
||||||
static void destroy_rxa (RXA *rxa);
|
static void destroy_rxa (RXA *rxa);
|
||||||
static void flush_rxa (RXA *rxa);
|
static void flush_rxa (RXA *rxa);
|
||||||
static void xrxa (RXA *rxa);
|
static void xrxa (RXA *rxa);
|
||||||
static void setInputSamplerate (RXA *rxa, int dsp_insize, int in_rate);
|
int get_insize() const { return dsp_insize; }
|
||||||
static void setOutputSamplerate (RXA *rxa, int dsp_outsize, int out_rate);
|
int get_outsize() const { return dsp_outsize; }
|
||||||
static void setDSPSamplerate (RXA *rxa, int dsp_insize, int dsp_outsize, int dsp_rate);
|
double *get_inbuff() { return inbuff; }
|
||||||
static void setDSPBuffsize (RXA *rxa, int dsp_insize, int dsp_size, int dsp_outsize);
|
double *get_outbuff() { return outbuff; }
|
||||||
|
static void setInputSamplerate (RXA *rxa, int in_rate);
|
||||||
|
static void setOutputSamplerate (RXA *rxa, int out_rate);
|
||||||
|
static void setDSPSamplerate (RXA *rxa, int dsp_rate);
|
||||||
|
static void setDSPBuffsize (RXA *rxa, int dsp_size);
|
||||||
|
|
||||||
// RXA Properties
|
// RXA Properties
|
||||||
static void SetMode (RXA& rxa, int mode);
|
static void SetMode (RXA& rxa, int mode);
|
||||||
@ -236,6 +233,11 @@ public:
|
|||||||
static void SetPassband (RXA& rxa, double f_low, double f_high);
|
static void SetPassband (RXA& rxa, double f_low, double f_high);
|
||||||
static void SetNC (RXA& rxa, int nc);
|
static void SetNC (RXA& rxa, int nc);
|
||||||
static void SetMP (RXA& rxa, int mp);
|
static void SetMP (RXA& rxa, int mp);
|
||||||
|
|
||||||
|
private:
|
||||||
|
double* inbuff;
|
||||||
|
double* midbuff;
|
||||||
|
double* outbuff;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace WDSP
|
} // namespace WDSP
|
||||||
|
70
wdsp/TXA.cpp
70
wdsp/TXA.cpp
@ -54,24 +54,26 @@ namespace WDSP {
|
|||||||
TXA* TXA::create_txa (
|
TXA* TXA::create_txa (
|
||||||
int in_rate, // input samplerate
|
int in_rate, // input samplerate
|
||||||
int out_rate, // output samplerate
|
int out_rate, // output samplerate
|
||||||
int in_size, // input buffsize (complex samples) in a fexchange() operation
|
|
||||||
int dsp_rate, // sample rate for mainstream dsp processing
|
int dsp_rate, // sample rate for mainstream dsp processing
|
||||||
int dsp_size, // number complex samples processed per buffer in mainstream dsp processing
|
int dsp_size // number complex samples processed per buffer in mainstream dsp processing
|
||||||
int dsp_insize, // size (complex samples) of the output of the r1 (input) buffer
|
|
||||||
int dsp_outsize, // size (complex samples) of the input of the r2 (output) buffer
|
|
||||||
int out_size // output buffsize (complex samples) in a fexchange() operation
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
TXA *txa = new TXA;
|
TXA *txa = new TXA;
|
||||||
|
|
||||||
txa->in_rate = in_rate;
|
txa->in_rate = in_rate;
|
||||||
txa->out_rate = out_rate;
|
txa->out_rate = out_rate;
|
||||||
txa->in_size = in_size;
|
|
||||||
txa->dsp_rate = dsp_rate;
|
txa->dsp_rate = dsp_rate;
|
||||||
txa->dsp_size = dsp_size;
|
txa->dsp_size = dsp_size;
|
||||||
txa->dsp_insize = dsp_insize;
|
|
||||||
txa->dsp_outsize = dsp_outsize;
|
if (in_rate >= dsp_rate)
|
||||||
txa->out_size = out_size;
|
txa->dsp_insize = dsp_size * (in_rate / dsp_rate);
|
||||||
|
else
|
||||||
|
txa->dsp_insize = dsp_size / (dsp_rate / in_rate);
|
||||||
|
|
||||||
|
if (out_rate >= dsp_rate)
|
||||||
|
txa->dsp_outsize = dsp_size * (out_rate / dsp_rate);
|
||||||
|
else
|
||||||
|
txa->dsp_outsize = dsp_size / (dsp_rate / out_rate);
|
||||||
|
|
||||||
txa->mode = TXA_LSB;
|
txa->mode = TXA_LSB;
|
||||||
txa->f_low = -5000.0;
|
txa->f_low = -5000.0;
|
||||||
@ -561,7 +563,7 @@ void TXA::destroy_txa (TXA *txa)
|
|||||||
delete txa;
|
delete txa;
|
||||||
}
|
}
|
||||||
|
|
||||||
void flush_txa (TXA* txa)
|
void TXA::flush_txa (TXA* txa)
|
||||||
{
|
{
|
||||||
memset (txa->inbuff, 0, 1 * txa->dsp_insize * sizeof (dcomplex));
|
memset (txa->inbuff, 0, 1 * txa->dsp_insize * sizeof (dcomplex));
|
||||||
memset (txa->outbuff, 0, 1 * txa->dsp_outsize * sizeof (dcomplex));
|
memset (txa->outbuff, 0, 1 * txa->dsp_outsize * sizeof (dcomplex));
|
||||||
@ -635,10 +637,15 @@ void xtxa (TXA* txa)
|
|||||||
// print_peak_env ("env_exception.txt", txa->dsp_outsize, txa->outbuff, 0.7);
|
// print_peak_env ("env_exception.txt", txa->dsp_outsize, txa->outbuff, 0.7);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TXA::setInputSamplerate (TXA *txa, int dsp_insize, int in_rate)
|
void TXA::setInputSamplerate (TXA *txa, int in_rate)
|
||||||
{
|
{
|
||||||
txa->csDSP.lock();
|
txa->csDSP.lock();
|
||||||
txa->dsp_insize = dsp_insize;
|
|
||||||
|
if (in_rate >= txa->dsp_rate)
|
||||||
|
txa->dsp_insize = txa->dsp_size * (in_rate / txa->dsp_rate);
|
||||||
|
else
|
||||||
|
txa->dsp_insize = txa->dsp_size / (txa->dsp_rate / in_rate);
|
||||||
|
|
||||||
txa->in_rate = in_rate;
|
txa->in_rate = in_rate;
|
||||||
// buffers
|
// buffers
|
||||||
delete[] (txa->inbuff);
|
delete[] (txa->inbuff);
|
||||||
@ -651,10 +658,15 @@ void TXA::setInputSamplerate (TXA *txa, int dsp_insize, int in_rate)
|
|||||||
txa->csDSP.unlock();
|
txa->csDSP.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TXA::setOutputSamplerate (TXA* txa, int dsp_outsize, int out_rate)
|
void TXA::setOutputSamplerate (TXA* txa, int out_rate)
|
||||||
{
|
{
|
||||||
txa->csDSP.lock();
|
txa->csDSP.lock();
|
||||||
txa->dsp_outsize = dsp_outsize;
|
|
||||||
|
if (out_rate >= txa->dsp_rate)
|
||||||
|
txa->dsp_outsize = txa->dsp_size * (out_rate / txa->dsp_rate);
|
||||||
|
else
|
||||||
|
txa->dsp_outsize = txa->dsp_size / (txa->dsp_rate / out_rate);
|
||||||
|
|
||||||
txa->out_rate = out_rate;
|
txa->out_rate = out_rate;
|
||||||
// buffers
|
// buffers
|
||||||
delete[] (txa->outbuff);
|
delete[] (txa->outbuff);
|
||||||
@ -672,11 +684,20 @@ void TXA::setOutputSamplerate (TXA* txa, int dsp_outsize, int out_rate)
|
|||||||
txa->csDSP.unlock();
|
txa->csDSP.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TXA::setDSPSamplerate (TXA *txa, int dsp_insize, int dsp_outsize, int dsp_rate)
|
void TXA::setDSPSamplerate (TXA *txa, int dsp_rate)
|
||||||
{
|
{
|
||||||
txa->csDSP.lock();
|
txa->csDSP.lock();
|
||||||
txa->dsp_insize = dsp_insize;
|
|
||||||
txa->dsp_outsize = dsp_outsize;
|
if (txa->in_rate >= dsp_rate)
|
||||||
|
txa->dsp_insize = txa->dsp_size * (txa->in_rate / dsp_rate);
|
||||||
|
else
|
||||||
|
txa->dsp_insize = txa->dsp_size / (dsp_rate / txa->in_rate);
|
||||||
|
|
||||||
|
if (txa->out_rate >= dsp_rate)
|
||||||
|
txa->dsp_outsize = txa->dsp_size * (txa->out_rate / dsp_rate);
|
||||||
|
else
|
||||||
|
txa->dsp_outsize = txa->dsp_size / (dsp_rate / txa->out_rate);
|
||||||
|
|
||||||
txa->dsp_rate = dsp_rate;
|
txa->dsp_rate = dsp_rate;
|
||||||
// buffers
|
// buffers
|
||||||
delete[] (txa->inbuff);
|
delete[] (txa->inbuff);
|
||||||
@ -725,12 +746,21 @@ void TXA::setDSPSamplerate (TXA *txa, int dsp_insize, int dsp_outsize, int dsp_r
|
|||||||
txa->csDSP.unlock();
|
txa->csDSP.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TXA::setDSPBuffsize (TXA *txa, int dsp_insize, int dsp_size, int dsp_outsize)
|
void TXA::setDSPBuffsize (TXA *txa, int dsp_size)
|
||||||
{
|
{
|
||||||
txa->csDSP.lock();
|
txa->csDSP.lock();
|
||||||
txa->dsp_insize = dsp_insize;
|
|
||||||
|
if (txa->in_rate >= txa->dsp_rate)
|
||||||
|
txa->dsp_insize = dsp_size * (txa->in_rate / txa->dsp_rate);
|
||||||
|
else
|
||||||
|
txa->dsp_insize = dsp_size / (txa->dsp_rate / txa->in_rate);
|
||||||
|
|
||||||
|
if (txa->out_rate >= txa->dsp_rate)
|
||||||
|
txa->dsp_outsize = dsp_size * (txa->out_rate / txa->dsp_rate);
|
||||||
|
else
|
||||||
|
txa->dsp_outsize = dsp_size / (txa->dsp_rate / txa->out_rate);
|
||||||
|
|
||||||
txa->dsp_size = dsp_size;
|
txa->dsp_size = dsp_size;
|
||||||
txa->dsp_outsize = dsp_outsize;
|
|
||||||
// buffers
|
// buffers
|
||||||
delete[] (txa->inbuff);
|
delete[] (txa->inbuff);
|
||||||
txa->inbuff = new double[1 * txa->dsp_insize * 2]; // (double *)malloc0(1 * txa->dsp_insize * sizeof(complex));
|
txa->inbuff = new double[1 * txa->dsp_insize * 2]; // (double *)malloc0(1 * txa->dsp_insize * sizeof(complex));
|
||||||
|
24
wdsp/TXA.hpp
24
wdsp/TXA.hpp
@ -124,9 +124,6 @@ public:
|
|||||||
TXA_METERTYPE_LAST
|
TXA_METERTYPE_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
double* inbuff;
|
|
||||||
double* outbuff;
|
|
||||||
double* midbuff;
|
|
||||||
int mode;
|
int mode;
|
||||||
double f_low;
|
double f_low;
|
||||||
double f_high;
|
double f_high;
|
||||||
@ -223,20 +220,20 @@ public:
|
|||||||
static TXA* create_txa (
|
static TXA* create_txa (
|
||||||
int in_rate, // input samplerate
|
int in_rate, // input samplerate
|
||||||
int out_rate, // output samplerate
|
int out_rate, // output samplerate
|
||||||
int in_size, // input buffsize (complex samples) in a fexchange() operation
|
|
||||||
int dsp_rate, // sample rate for mainstream dsp processing
|
int dsp_rate, // sample rate for mainstream dsp processing
|
||||||
int dsp_size, // number complex samples processed per buffer in mainstream dsp processing
|
int dsp_size // number complex samples processed per buffer in mainstream dsp processing
|
||||||
int dsp_insize, // size (complex samples) of the output of the r1 (input) buffer
|
|
||||||
int dsp_outsize, // size (complex samples) of the input of the r2 (output) buffer
|
|
||||||
int out_size // output buffsize (complex samples) in a fexchange() operation
|
|
||||||
);
|
);
|
||||||
static void destroy_txa (TXA *txa);
|
static void destroy_txa (TXA *txa);
|
||||||
static void flush_txa (TXA *txa);
|
static void flush_txa (TXA *txa);
|
||||||
static void xtxa (TXA *txa);
|
static void xtxa (TXA *txa);
|
||||||
static void setInputSamplerate (TXA *txa, int dsp_insize, int in_rate);
|
int get_insize() const { return dsp_insize; }
|
||||||
static void setOutputSamplerate (TXA *txa, int dsp_outsize, int out_rate);
|
int get_outsize() const { return dsp_outsize; }
|
||||||
static void setDSPSamplerate (TXA *txa, int dsp_insize, int dsp_outsize, int dsp_rate);
|
double *get_inbuff() { return inbuff; }
|
||||||
static void setDSPBuffsize (TXA *txa, int dsp_insize, int dsp_size, int dsp_outsize);
|
double *get_outbuff() { return outbuff; }
|
||||||
|
static void setInputSamplerate (TXA *txa, int in_rate);
|
||||||
|
static void setOutputSamplerate (TXA *txa, int out_rate);
|
||||||
|
static void setDSPSamplerate (TXA *txa, int dsp_rate);
|
||||||
|
static void setDSPBuffsize (TXA *txa, int dsp_size);
|
||||||
|
|
||||||
// TXA Properties
|
// TXA Properties
|
||||||
static void SetMode (TXA& txa, int mode);
|
static void SetMode (TXA& txa, int mode);
|
||||||
@ -251,6 +248,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static void ResCheck (TXA& txa);
|
static void ResCheck (TXA& txa);
|
||||||
|
double* inbuff;
|
||||||
|
double* midbuff;
|
||||||
|
double* outbuff;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace WDSP
|
} // namespace WDSP
|
||||||
|
@ -39,12 +39,10 @@ class WDSP_API Unit
|
|||||||
public:
|
public:
|
||||||
int in_rate; // input samplerate
|
int in_rate; // input samplerate
|
||||||
int out_rate; // output samplerate
|
int out_rate; // output samplerate
|
||||||
int in_size; // input buffsize (complex samples) in a fexchange() operation
|
|
||||||
int dsp_rate; // sample rate for mainstream dsp processing
|
int dsp_rate; // sample rate for mainstream dsp processing
|
||||||
int dsp_size; // number complex samples processed per buffer in mainstream dsp processing
|
int dsp_size; // number complex samples processed per buffer in mainstream dsp processing
|
||||||
int dsp_insize; // size (complex samples) of the output of the r1 (input) buffer
|
int dsp_insize; // size (complex samples) of the input buffer
|
||||||
int dsp_outsize; // size (complex samples) of the input of the r2 (output) buffer
|
int dsp_outsize; // size (complex samples) of the output buffer
|
||||||
int out_size; // output buffsize (complex samples) in a fexchange() operation
|
|
||||||
QRecursiveMutex csDSP; // used to block dsp while parameters are updated or buffers flushed
|
QRecursiveMutex csDSP; // used to block dsp while parameters are updated or buffers flushed
|
||||||
QRecursiveMutex csEXCH; // used to block fexchange() while parameters are updated or buffers flushed
|
QRecursiveMutex csEXCH; // used to block fexchange() while parameters are updated or buffers flushed
|
||||||
int state; // 0 for unit OFF; 1 for unit ON
|
int state; // 0 for unit OFF; 1 for unit ON
|
||||||
|
Loading…
Reference in New Issue
Block a user