mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-03-25 05:38:39 -04:00
Remote sink: fixed chanel frequency shift calculation and access
This commit is contained in:
parent
102013791e
commit
91089b6809
plugins/channelrx/remotesink
sdrbase/dsp
@ -38,6 +38,7 @@
|
||||
#include "dsp/threadedbasebandsamplesink.h"
|
||||
#include "dsp/downchannelizer.h"
|
||||
#include "dsp/dspcommands.h"
|
||||
#include "dsp/hbfilterchainconverter.h"
|
||||
#include "device/devicesourceapi.h"
|
||||
|
||||
#include "../remotesink/remotesinkthread.h"
|
||||
@ -61,6 +62,7 @@ RemoteSink::RemoteSink(DeviceSourceAPI *deviceAPI) :
|
||||
m_centerFrequency(0),
|
||||
m_frequencyOffset(0),
|
||||
m_sampleRate(48000),
|
||||
m_deviceSampleRate(48000),
|
||||
m_nbBlocksFEC(0),
|
||||
m_txDelay(35),
|
||||
m_dataAddress("127.0.0.1"),
|
||||
@ -273,7 +275,6 @@ bool RemoteSink::handleMessage(const Message& cmd)
|
||||
}
|
||||
|
||||
setTxDelay(m_settings.m_txDelay, m_settings.m_nbFECBlocks);
|
||||
m_frequencyOffset = notif.getFrequencyOffset();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -286,6 +287,8 @@ bool RemoteSink::handleMessage(const Message& cmd)
|
||||
<< " centerFrequency: " << notif.getCenterFrequency();
|
||||
|
||||
setCenterFrequency(notif.getCenterFrequency());
|
||||
m_deviceSampleRate = notif.getSampleRate();
|
||||
calculateFrequencyOffset(); // This is when device sample rate changes
|
||||
|
||||
// Redo the channelizer stuff with the new sample rate to re-synchronize everything
|
||||
m_channelizer->set(m_channelizer->getInputMessageQueue(),
|
||||
@ -322,6 +325,8 @@ bool RemoteSink::handleMessage(const Message& cmd)
|
||||
m_settings.m_log2Decim,
|
||||
m_settings.m_filterChainHash);
|
||||
|
||||
calculateFrequencyOffset(); // This is when decimation or filter chain changes
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -413,6 +418,12 @@ void RemoteSink::validateFilterChainHash(RemoteSinkSettings& settings)
|
||||
settings.m_filterChainHash = settings.m_filterChainHash >= s ? s-1 : settings.m_filterChainHash;
|
||||
}
|
||||
|
||||
void RemoteSink::calculateFrequencyOffset()
|
||||
{
|
||||
double shiftFactor = HBFilterChainConverter::getShiftFactor(m_settings.m_log2Decim, m_settings.m_filterChainHash);
|
||||
m_frequencyOffset = m_deviceSampleRate * shiftFactor;
|
||||
}
|
||||
|
||||
int RemoteSink::webapiSettingsGet(
|
||||
SWGSDRangel::SWGChannelSettings& response,
|
||||
QString& errorMessage)
|
||||
|
@ -120,7 +120,7 @@ public:
|
||||
|
||||
virtual void getIdentifier(QString& id) { id = objectName(); }
|
||||
virtual void getTitle(QString& title) { title = "Remote Sink"; }
|
||||
virtual qint64 getCenterFrequency() const { return 0; }
|
||||
virtual qint64 getCenterFrequency() const { return m_frequencyOffset; }
|
||||
|
||||
virtual QByteArray serialize() const;
|
||||
virtual bool deserialize(const QByteArray& data);
|
||||
@ -173,6 +173,7 @@ private:
|
||||
uint64_t m_centerFrequency;
|
||||
int64_t m_frequencyOffset;
|
||||
uint32_t m_sampleRate;
|
||||
uint32_t m_deviceSampleRate;
|
||||
int m_nbBlocksFEC;
|
||||
int m_txDelay;
|
||||
QString m_dataAddress;
|
||||
@ -182,6 +183,7 @@ private:
|
||||
|
||||
void applySettings(const RemoteSinkSettings& settings, bool force = false);
|
||||
void validateFilterChainHash(RemoteSinkSettings& settings);
|
||||
void calculateFrequencyOffset();
|
||||
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const RemoteSinkSettings& settings);
|
||||
void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const RemoteSinkSettings& settings, bool force);
|
||||
|
||||
|
@ -28,13 +28,10 @@ double HBFilterChainConverter::convertToIndexes(unsigned int log2, unsigned int
|
||||
}
|
||||
|
||||
unsigned int s = 1;
|
||||
unsigned int d = 1;
|
||||
unsigned int u = chainHash;
|
||||
|
||||
for (unsigned int i = 0; i < log2; i++)
|
||||
{
|
||||
for (unsigned int i = 0; i < log2; i++) {
|
||||
s *= 3;
|
||||
d *= 2;
|
||||
}
|
||||
|
||||
u %= s; // scale
|
||||
@ -73,14 +70,11 @@ double HBFilterChainConverter::convertToString(unsigned int log2, unsigned int c
|
||||
}
|
||||
|
||||
unsigned int s = 1;
|
||||
unsigned int d = 1;
|
||||
unsigned int u = chainHash;
|
||||
chainString = "";
|
||||
|
||||
for (unsigned int i = 0; i < log2; i++)
|
||||
{
|
||||
for (unsigned int i = 0; i < log2; i++) {
|
||||
s *= 3;
|
||||
d *= 2;
|
||||
}
|
||||
|
||||
u %= s; // scale
|
||||
@ -115,5 +109,44 @@ double HBFilterChainConverter::convertToString(unsigned int log2, unsigned int c
|
||||
shift_stage *= 2;
|
||||
}
|
||||
|
||||
return shift;
|
||||
}
|
||||
|
||||
double HBFilterChainConverter::getShiftFactor(unsigned int log2, unsigned int chainHash)
|
||||
{
|
||||
if (log2 == 0)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
unsigned int s = 1;
|
||||
unsigned int u = chainHash;
|
||||
|
||||
for (unsigned int i = 0; i < log2; i++) {
|
||||
s *= 3;
|
||||
}
|
||||
|
||||
u %= s; // scale
|
||||
unsigned int ix = log2;
|
||||
double shift = 0.0;
|
||||
double shift_stage = 1.0 / (1<<(log2+1));
|
||||
|
||||
// base3 conversion
|
||||
do
|
||||
{
|
||||
int r = u % 3;
|
||||
shift += (r-1)*shift_stage;
|
||||
shift_stage *= 2;
|
||||
u /= 3;
|
||||
ix--;
|
||||
} while (u);
|
||||
|
||||
// continue shift with leading zeroes. ix has the number of leading zeroes.
|
||||
for (unsigned int i = 0; i < ix; i++)
|
||||
{
|
||||
shift -= shift_stage;
|
||||
shift_stage *= 2;
|
||||
}
|
||||
|
||||
return shift;
|
||||
}
|
@ -34,6 +34,8 @@ public:
|
||||
static double convertToIndexes(unsigned int log2, unsigned int chainHash, std::vector<unsigned int>& chainIndexes);
|
||||
// Same but used only for display giving a string representation of the filter chain
|
||||
static double convertToString(unsigned int log2, unsigned int chainHash, QString& chainString);
|
||||
// Just calculate the frequency shift factor relative to sample rate
|
||||
static double getShiftFactor(unsigned int log2, unsigned int chainHash);
|
||||
};
|
||||
|
||||
#endif // SDRBASE_DSP_HBFILTERCHAINCONVERTER_H
|
Loading…
Reference in New Issue
Block a user