mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-04 16:01:14 -05:00
NFM demod: use specific method to apply channelizer sample rate and frequency offset changes. Separate this data from settings
This commit is contained in:
parent
e39e080cc0
commit
af58d18eac
@ -47,7 +47,8 @@ const int NFMDemod::m_udpBlockSize = 512;
|
||||
NFMDemod::NFMDemod(DeviceSourceAPI *devieAPI) :
|
||||
ChannelSinkAPI(m_channelIdURI),
|
||||
m_deviceAPI(devieAPI),
|
||||
m_absoluteFrequencyOffset(0),
|
||||
m_inputSampleRate(48000),
|
||||
m_inputFrequencyOffset(0),
|
||||
m_ctcssIndex(0),
|
||||
m_sampleCount(0),
|
||||
m_squelchCount(0),
|
||||
@ -324,46 +325,69 @@ bool NFMDemod::handleMessage(const Message& cmd)
|
||||
if (DownChannelizer::MsgChannelizerNotification::match(cmd))
|
||||
{
|
||||
DownChannelizer::MsgChannelizerNotification& notif = (DownChannelizer::MsgChannelizerNotification&) cmd;
|
||||
qDebug() << "NFMDemod::handleMessage: DownChannelizer::MsgChannelizerNotification";
|
||||
|
||||
NFMDemodSettings settings = m_settings;
|
||||
|
||||
settings.m_inputSampleRate = notif.getSampleRate();
|
||||
settings.m_inputFrequencyOffset = notif.getFrequencyOffset();
|
||||
|
||||
applySettings(settings);
|
||||
|
||||
qDebug() << "NFMDemod::handleMessage: DownChannelizer::MsgChannelizerNotification:"
|
||||
<< " m_inputSampleRate: " << settings.m_inputSampleRate
|
||||
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset;
|
||||
applyChannelSettings(notif.getSampleRate(), notif.getFrequencyOffset());
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureChannelizer::match(cmd))
|
||||
{
|
||||
MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
|
||||
qDebug() << "NFMDemod::handleMessage: MsgConfigureChannelizer:"
|
||||
<< " sampleRate: " << cfg.getSampleRate()
|
||||
<< " centerFrequency: " << cfg.getCenterFrequency();
|
||||
|
||||
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
|
||||
cfg.getSampleRate(),
|
||||
cfg.getCenterFrequency());
|
||||
|
||||
qDebug() << "NFMDemod::handleMessage: MsgConfigureChannelizer:"
|
||||
<< " sampleRate: " << cfg.getSampleRate()
|
||||
<< " centerFrequency: " << cfg.getCenterFrequency();
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureNFMDemod::match(cmd))
|
||||
{
|
||||
MsgConfigureNFMDemod& cfg = (MsgConfigureNFMDemod&) cmd;
|
||||
|
||||
NFMDemodSettings settings = cfg.getSettings();
|
||||
qDebug() << "NFMDemod::handleMessage: MsgConfigureNFMDemod";
|
||||
|
||||
m_absoluteFrequencyOffset = settings.m_inputFrequencyOffset;
|
||||
settings.m_inputSampleRate = m_settings.m_inputSampleRate;
|
||||
settings.m_inputFrequencyOffset = m_settings.m_inputFrequencyOffset;
|
||||
applySettings(settings, cfg.getForce());
|
||||
|
||||
qDebug() << "NFMDemod::handleMessage: MsgConfigureNFMDemod:"
|
||||
<< " m_absoluteFrequencyOffset: " << m_absoluteFrequencyOffset
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void NFMDemod::applyChannelSettings(int inputSampleRate, int inputFrequencyOffset)
|
||||
{
|
||||
qDebug() << "NFMDemod::applyChannelSettings:"
|
||||
<< " inputSampleRate: " << inputSampleRate
|
||||
<< " inputFrequencyOffset: " << inputFrequencyOffset;
|
||||
|
||||
if ((inputFrequencyOffset != m_inputFrequencyOffset) ||
|
||||
(inputSampleRate != m_inputSampleRate))
|
||||
{
|
||||
m_nco.setFreq(-inputFrequencyOffset, inputSampleRate);
|
||||
}
|
||||
|
||||
if (inputSampleRate != m_inputSampleRate)
|
||||
{
|
||||
m_settingsMutex.lock();
|
||||
m_interpolator.create(16, inputSampleRate, m_settings.m_rfBandwidth / 2.2);
|
||||
m_interpolatorDistanceRemain = 0;
|
||||
m_interpolatorDistance = (Real) inputSampleRate / (Real) m_settings.m_audioSampleRate;
|
||||
m_settingsMutex.unlock();
|
||||
}
|
||||
|
||||
m_inputSampleRate = inputSampleRate;
|
||||
m_inputFrequencyOffset = inputFrequencyOffset;
|
||||
}
|
||||
|
||||
void NFMDemod::applySettings(const NFMDemodSettings& settings, bool force)
|
||||
{
|
||||
qDebug() << "NFMDemod::applySettings:"
|
||||
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
|
||||
<< " m_rfBandwidth: " << settings.m_rfBandwidth
|
||||
<< " m_afBandwidth: " << settings.m_afBandwidth
|
||||
@ -378,34 +402,15 @@ bool NFMDemod::handleMessage(const Message& cmd)
|
||||
<< " m_copyAudioToUDP: " << settings.m_copyAudioToUDP
|
||||
<< " m_udpAddress: " << settings.m_udpAddress
|
||||
<< " m_udpPort: " << settings.m_udpPort
|
||||
<< " force: " << cfg.getForce();
|
||||
<< " force: " << force;
|
||||
|
||||
applySettings(settings, cfg.getForce());
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void NFMDemod::applySettings(const NFMDemodSettings& settings, bool force)
|
||||
{
|
||||
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) ||
|
||||
(settings.m_inputSampleRate != m_settings.m_inputSampleRate) || force)
|
||||
{
|
||||
m_nco.setFreq(-settings.m_inputFrequencyOffset, settings.m_inputSampleRate);
|
||||
}
|
||||
|
||||
if ((settings.m_inputSampleRate != m_settings.m_inputSampleRate) ||
|
||||
(settings.m_rfBandwidth != m_settings.m_rfBandwidth) ||
|
||||
if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) ||
|
||||
(settings.m_audioSampleRate != m_settings.m_audioSampleRate) || force)
|
||||
{
|
||||
m_settingsMutex.lock();
|
||||
m_interpolator.create(16, settings.m_inputSampleRate, settings.m_rfBandwidth / 2.2);
|
||||
m_interpolator.create(16, m_inputSampleRate, settings.m_rfBandwidth / 2.2);
|
||||
m_interpolatorDistanceRemain = 0;
|
||||
m_interpolatorDistance = (Real) settings.m_inputSampleRate / (Real) settings.m_audioSampleRate;
|
||||
m_interpolatorDistance = (Real) m_inputSampleRate / (Real) settings.m_audioSampleRate;
|
||||
m_settingsMutex.unlock();
|
||||
}
|
||||
|
||||
@ -493,9 +498,7 @@ int NFMDemod::webapiSettingsGet(
|
||||
QString& errorMessage __attribute__((unused)))
|
||||
{
|
||||
response.setNfmDemodSettings(new SWGSDRangel::SWGNFMDemodSettings());
|
||||
NFMDemodSettings settings = m_settings;
|
||||
settings.m_inputFrequencyOffset = m_absoluteFrequencyOffset;
|
||||
webapiFormatChannelSettings(response, settings);
|
||||
webapiFormatChannelSettings(response, m_settings);
|
||||
return 200;
|
||||
}
|
||||
|
||||
@ -537,9 +540,6 @@ int NFMDemod::webapiSettingsPutPatch(
|
||||
settings.m_inputFrequencyOffset = response.getNfmDemodSettings()->getInputFrequencyOffset();
|
||||
frequencyOffsetChanged = true;
|
||||
}
|
||||
// if (channelSettingsKeys.contains("inputSampleRate")) {
|
||||
// settings.m_inputSampleRate = response.getNfmDemodSettings()->getInputSampleRate();
|
||||
// }
|
||||
if (channelSettingsKeys.contains("rfBandwidth")) {
|
||||
settings.m_rfBandwidth = response.getNfmDemodSettings()->getRfBandwidth();
|
||||
}
|
||||
@ -597,7 +597,6 @@ void NFMDemod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& resp
|
||||
response.getNfmDemodSettings()->setDeltaSquelch(settings.m_deltaSquelch ? 1 : 0);
|
||||
response.getNfmDemodSettings()->setFmDeviation(settings.m_fmDeviation);
|
||||
response.getNfmDemodSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
|
||||
response.getNfmDemodSettings()->setInputSampleRate(settings.m_inputSampleRate);
|
||||
response.getNfmDemodSettings()->setRfBandwidth(settings.m_rfBandwidth);
|
||||
response.getNfmDemodSettings()->setRgbColor(settings.m_rgbColor);
|
||||
response.getNfmDemodSettings()->setSquelch(settings.m_squelch);
|
||||
|
@ -117,7 +117,6 @@ public:
|
||||
virtual void stop();
|
||||
virtual bool handleMessage(const Message& cmd);
|
||||
|
||||
virtual int getDeltaFrequency() const { return m_absoluteFrequencyOffset; }
|
||||
virtual void getIdentifier(QString& id) { id = objectName(); }
|
||||
virtual void getTitle(QString& title) { title = m_settings.m_title; }
|
||||
virtual qint64 getCenterFrequency() const { return m_settings.m_inputFrequencyOffset; }
|
||||
@ -171,8 +170,9 @@ private:
|
||||
ThreadedBasebandSampleSink* m_threadedChannelizer;
|
||||
DownChannelizer* m_channelizer;
|
||||
|
||||
int m_inputSampleRate;
|
||||
int m_inputFrequencyOffset;
|
||||
NFMDemodSettings m_settings;
|
||||
int m_absoluteFrequencyOffset;
|
||||
|
||||
NCO m_nco;
|
||||
Interpolator m_interpolator;
|
||||
@ -220,6 +220,7 @@ private:
|
||||
static const int m_udpBlockSize;
|
||||
|
||||
// void apply(bool force = false);
|
||||
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset);
|
||||
void applySettings(const NFMDemodSettings& settings, bool force = false);
|
||||
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const NFMDemodSettings& settings);
|
||||
};
|
||||
|
@ -38,7 +38,6 @@ NFMDemodSettings::NFMDemodSettings() :
|
||||
|
||||
void NFMDemodSettings::resetToDefaults()
|
||||
{
|
||||
m_inputSampleRate = 96000;
|
||||
m_inputFrequencyOffset = 0;
|
||||
m_rfBandwidth = 12500;
|
||||
m_afBandwidth = 3000;
|
||||
|
@ -27,7 +27,6 @@ struct NFMDemodSettings
|
||||
static const int m_rfBW[];
|
||||
static const int m_fmDev[];
|
||||
|
||||
int m_inputSampleRate;
|
||||
int64_t m_inputFrequencyOffset;
|
||||
Real m_rfBandwidth;
|
||||
Real m_afBandwidth;
|
||||
|
@ -145,7 +145,7 @@ def main():
|
||||
settings["NFMDemodSettings"]["udpAddress"] = address_port[0]
|
||||
settings["NFMDemodSettings"]["copyAudioToUDP"] = 1
|
||||
|
||||
r = callAPI(deviceset_url + "/channel/0/settings", "PATCH", None, settings, "Change NFM mod")
|
||||
r = callAPI(deviceset_url + "/channel/0/settings", "PATCH", None, settings, "Change NFM demod")
|
||||
if r is None:
|
||||
exit(-1)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user