mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-09-04 06:07:49 -04:00
Remote sink: fixed chanel frequency shift calculation and access
This commit is contained in:
parent
102013791e
commit
91089b6809
@ -38,6 +38,7 @@
|
|||||||
#include "dsp/threadedbasebandsamplesink.h"
|
#include "dsp/threadedbasebandsamplesink.h"
|
||||||
#include "dsp/downchannelizer.h"
|
#include "dsp/downchannelizer.h"
|
||||||
#include "dsp/dspcommands.h"
|
#include "dsp/dspcommands.h"
|
||||||
|
#include "dsp/hbfilterchainconverter.h"
|
||||||
#include "device/devicesourceapi.h"
|
#include "device/devicesourceapi.h"
|
||||||
|
|
||||||
#include "../remotesink/remotesinkthread.h"
|
#include "../remotesink/remotesinkthread.h"
|
||||||
@ -61,6 +62,7 @@ RemoteSink::RemoteSink(DeviceSourceAPI *deviceAPI) :
|
|||||||
m_centerFrequency(0),
|
m_centerFrequency(0),
|
||||||
m_frequencyOffset(0),
|
m_frequencyOffset(0),
|
||||||
m_sampleRate(48000),
|
m_sampleRate(48000),
|
||||||
|
m_deviceSampleRate(48000),
|
||||||
m_nbBlocksFEC(0),
|
m_nbBlocksFEC(0),
|
||||||
m_txDelay(35),
|
m_txDelay(35),
|
||||||
m_dataAddress("127.0.0.1"),
|
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);
|
setTxDelay(m_settings.m_txDelay, m_settings.m_nbFECBlocks);
|
||||||
m_frequencyOffset = notif.getFrequencyOffset();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -286,6 +287,8 @@ bool RemoteSink::handleMessage(const Message& cmd)
|
|||||||
<< " centerFrequency: " << notif.getCenterFrequency();
|
<< " centerFrequency: " << notif.getCenterFrequency();
|
||||||
|
|
||||||
setCenterFrequency(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
|
// Redo the channelizer stuff with the new sample rate to re-synchronize everything
|
||||||
m_channelizer->set(m_channelizer->getInputMessageQueue(),
|
m_channelizer->set(m_channelizer->getInputMessageQueue(),
|
||||||
@ -322,6 +325,8 @@ bool RemoteSink::handleMessage(const Message& cmd)
|
|||||||
m_settings.m_log2Decim,
|
m_settings.m_log2Decim,
|
||||||
m_settings.m_filterChainHash);
|
m_settings.m_filterChainHash);
|
||||||
|
|
||||||
|
calculateFrequencyOffset(); // This is when decimation or filter chain changes
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -413,6 +418,12 @@ void RemoteSink::validateFilterChainHash(RemoteSinkSettings& settings)
|
|||||||
settings.m_filterChainHash = settings.m_filterChainHash >= s ? s-1 : settings.m_filterChainHash;
|
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(
|
int RemoteSink::webapiSettingsGet(
|
||||||
SWGSDRangel::SWGChannelSettings& response,
|
SWGSDRangel::SWGChannelSettings& response,
|
||||||
QString& errorMessage)
|
QString& errorMessage)
|
||||||
|
@ -120,7 +120,7 @@ public:
|
|||||||
|
|
||||||
virtual void getIdentifier(QString& id) { id = objectName(); }
|
virtual void getIdentifier(QString& id) { id = objectName(); }
|
||||||
virtual void getTitle(QString& title) { title = "Remote Sink"; }
|
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 QByteArray serialize() const;
|
||||||
virtual bool deserialize(const QByteArray& data);
|
virtual bool deserialize(const QByteArray& data);
|
||||||
@ -173,6 +173,7 @@ private:
|
|||||||
uint64_t m_centerFrequency;
|
uint64_t m_centerFrequency;
|
||||||
int64_t m_frequencyOffset;
|
int64_t m_frequencyOffset;
|
||||||
uint32_t m_sampleRate;
|
uint32_t m_sampleRate;
|
||||||
|
uint32_t m_deviceSampleRate;
|
||||||
int m_nbBlocksFEC;
|
int m_nbBlocksFEC;
|
||||||
int m_txDelay;
|
int m_txDelay;
|
||||||
QString m_dataAddress;
|
QString m_dataAddress;
|
||||||
@ -182,6 +183,7 @@ private:
|
|||||||
|
|
||||||
void applySettings(const RemoteSinkSettings& settings, bool force = false);
|
void applySettings(const RemoteSinkSettings& settings, bool force = false);
|
||||||
void validateFilterChainHash(RemoteSinkSettings& settings);
|
void validateFilterChainHash(RemoteSinkSettings& settings);
|
||||||
|
void calculateFrequencyOffset();
|
||||||
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const RemoteSinkSettings& settings);
|
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const RemoteSinkSettings& settings);
|
||||||
void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const RemoteSinkSettings& settings, bool force);
|
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 s = 1;
|
||||||
unsigned int d = 1;
|
|
||||||
unsigned int u = chainHash;
|
unsigned int u = chainHash;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < log2; i++)
|
for (unsigned int i = 0; i < log2; i++) {
|
||||||
{
|
|
||||||
s *= 3;
|
s *= 3;
|
||||||
d *= 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u %= s; // scale
|
u %= s; // scale
|
||||||
@ -73,14 +70,11 @@ double HBFilterChainConverter::convertToString(unsigned int log2, unsigned int c
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int s = 1;
|
unsigned int s = 1;
|
||||||
unsigned int d = 1;
|
|
||||||
unsigned int u = chainHash;
|
unsigned int u = chainHash;
|
||||||
chainString = "";
|
chainString = "";
|
||||||
|
|
||||||
for (unsigned int i = 0; i < log2; i++)
|
for (unsigned int i = 0; i < log2; i++) {
|
||||||
{
|
|
||||||
s *= 3;
|
s *= 3;
|
||||||
d *= 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u %= s; // scale
|
u %= s; // scale
|
||||||
@ -117,3 +111,42 @@ double HBFilterChainConverter::convertToString(unsigned int log2, unsigned int c
|
|||||||
|
|
||||||
return shift;
|
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);
|
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
|
// 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);
|
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
|
#endif // SDRBASE_DSP_HBFILTERCHAINCONVERTER_H
|
Loading…
x
Reference in New Issue
Block a user