mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-09-03 13:47:50 -04:00
WFM modulator: use settings in modulator (1)
This commit is contained in:
parent
024814e997
commit
e76c95f7a2
@ -26,6 +26,7 @@
|
|||||||
#include "wfmmod.h"
|
#include "wfmmod.h"
|
||||||
|
|
||||||
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureWFMMod, Message)
|
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureWFMMod, Message)
|
||||||
|
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureWFMModPrivate, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureFileSourceName, Message)
|
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureFileSourceName, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureFileSourceSeek, Message)
|
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureFileSourceSeek, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureAFInput, Message)
|
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureAFInput, Message)
|
||||||
@ -103,7 +104,7 @@ void WFMMod::configure(MessageQueue* messageQueue,
|
|||||||
bool channelMute,
|
bool channelMute,
|
||||||
bool playLoop)
|
bool playLoop)
|
||||||
{
|
{
|
||||||
Message* cmd = MsgConfigureWFMMod::create(rfBandwidth, afBandwidth, fmDeviation, toneFrequency, volumeFactor, channelMute, playLoop);
|
Message* cmd = MsgConfigureWFMModPrivate::create(rfBandwidth, afBandwidth, fmDeviation, toneFrequency, volumeFactor, channelMute, playLoop);
|
||||||
messageQueue->push(cmd);
|
messageQueue->push(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,9 +309,9 @@ bool WFMMod::handleMessage(const Message& cmd)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (MsgConfigureWFMMod::match(cmd))
|
else if (MsgConfigureWFMModPrivate::match(cmd))
|
||||||
{
|
{
|
||||||
MsgConfigureWFMMod& cfg = (MsgConfigureWFMMod&) cmd;
|
MsgConfigureWFMModPrivate& cfg = (MsgConfigureWFMModPrivate&) cmd;
|
||||||
|
|
||||||
m_config.m_rfBandwidth = cfg.getRFBandwidth();
|
m_config.m_rfBandwidth = cfg.getRFBandwidth();
|
||||||
m_config.m_afBandwidth = cfg.getAFBandwidth();
|
m_config.m_afBandwidth = cfg.getAFBandwidth();
|
||||||
@ -478,3 +479,61 @@ void WFMMod::seekFileStream(int seekPercentage)
|
|||||||
m_ifstream.seekg(seekPoint, std::ios::beg);
|
m_ifstream.seekg(seekPoint, std::ios::beg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WFMMod::applySettings(const WFMModSettings& settings, bool force)
|
||||||
|
{
|
||||||
|
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) ||
|
||||||
|
(settings.m_outputSampleRate != m_settings.m_outputSampleRate))
|
||||||
|
{
|
||||||
|
m_settingsMutex.lock();
|
||||||
|
m_carrierNco.setFreq(settings.m_inputFrequencyOffset, settings.m_outputSampleRate);
|
||||||
|
m_settingsMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
if((settings.m_outputSampleRate != m_settings.m_outputSampleRate) ||
|
||||||
|
(settings.m_audioSampleRate != m_settings.m_audioSampleRate) ||
|
||||||
|
(settings.m_afBandwidth != m_settings.m_afBandwidth) || force)
|
||||||
|
{
|
||||||
|
m_settingsMutex.lock();
|
||||||
|
m_interpolatorDistanceRemain = 0;
|
||||||
|
m_interpolatorConsumed = false;
|
||||||
|
m_interpolatorDistance = (Real) settings.m_audioSampleRate / (Real) settings.m_outputSampleRate;
|
||||||
|
m_interpolator.create(48, settings.m_audioSampleRate, settings.m_rfBandwidth / 2.2, 3.0);
|
||||||
|
m_settingsMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) ||
|
||||||
|
(settings.m_outputSampleRate != m_settings.m_outputSampleRate) || force)
|
||||||
|
{
|
||||||
|
m_settingsMutex.lock();
|
||||||
|
Real lowCut = -(settings.m_rfBandwidth / 2.0) / settings.m_outputSampleRate;
|
||||||
|
Real hiCut = (settings.m_rfBandwidth / 2.0) / settings.m_outputSampleRate;
|
||||||
|
m_rfFilter->create_filter(lowCut, hiCut);
|
||||||
|
m_settingsMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((settings.m_toneFrequency != m_settings.m_toneFrequency) ||
|
||||||
|
(settings.m_audioSampleRate != m_settings.m_audioSampleRate) || force)
|
||||||
|
{
|
||||||
|
m_settingsMutex.lock();
|
||||||
|
m_toneNco.setFreq(settings.m_toneFrequency, settings.m_audioSampleRate);
|
||||||
|
m_settingsMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((settings.m_toneFrequency != m_settings.m_toneFrequency) ||
|
||||||
|
(settings.m_outputSampleRate != m_settings.m_outputSampleRate) || force)
|
||||||
|
{
|
||||||
|
m_settingsMutex.lock();
|
||||||
|
m_toneNcoRF.setFreq(settings.m_toneFrequency, settings.m_outputSampleRate);
|
||||||
|
m_settingsMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((settings.m_outputSampleRate != m_settings.m_outputSampleRate) || force)
|
||||||
|
{
|
||||||
|
m_cwKeyer.setSampleRate(settings.m_outputSampleRate);
|
||||||
|
m_cwSmoother.setNbFadeSamples(settings.m_outputSampleRate / 250); // 4 ms
|
||||||
|
m_cwKeyer.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_settings = settings;
|
||||||
|
}
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
#include "audio/audiofifo.h"
|
#include "audio/audiofifo.h"
|
||||||
#include "util/message.h"
|
#include "util/message.h"
|
||||||
|
|
||||||
|
#include "wfmmodsettings.h"
|
||||||
|
|
||||||
class WFMMod : public BasebandSampleSource {
|
class WFMMod : public BasebandSampleSource {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -46,6 +48,29 @@ public:
|
|||||||
WFMModInputCWTone
|
WFMModInputCWTone
|
||||||
} WFMModInputAF;
|
} WFMModInputAF;
|
||||||
|
|
||||||
|
class MsgConfigureWFMMod : public Message {
|
||||||
|
MESSAGE_CLASS_DECLARATION
|
||||||
|
|
||||||
|
public:
|
||||||
|
const WFMModSettings& getSettings() const { return m_settings; }
|
||||||
|
bool getForce() const { return m_force; }
|
||||||
|
|
||||||
|
static MsgConfigureWFMMod* create(const WFMModSettings& settings, bool force)
|
||||||
|
{
|
||||||
|
return new MsgConfigureWFMMod(settings, force);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
WFMModSettings m_settings;
|
||||||
|
bool m_force;
|
||||||
|
|
||||||
|
MsgConfigureWFMMod(const WFMModSettings& settings, bool force) :
|
||||||
|
Message(),
|
||||||
|
m_settings(settings),
|
||||||
|
m_force(force)
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
class MsgConfigureFileSourceName : public Message
|
class MsgConfigureFileSourceName : public Message
|
||||||
{
|
{
|
||||||
MESSAGE_CLASS_DECLARATION
|
MESSAGE_CLASS_DECLARATION
|
||||||
@ -207,7 +232,7 @@ signals:
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class MsgConfigureWFMMod : public Message
|
class MsgConfigureWFMModPrivate : public Message
|
||||||
{
|
{
|
||||||
MESSAGE_CLASS_DECLARATION
|
MESSAGE_CLASS_DECLARATION
|
||||||
|
|
||||||
@ -220,7 +245,7 @@ private:
|
|||||||
bool getChannelMute() const { return m_channelMute; }
|
bool getChannelMute() const { return m_channelMute; }
|
||||||
bool getPlayLoop() const { return m_playLoop; }
|
bool getPlayLoop() const { return m_playLoop; }
|
||||||
|
|
||||||
static MsgConfigureWFMMod* create(Real rfBandwidth,
|
static MsgConfigureWFMModPrivate* create(Real rfBandwidth,
|
||||||
Real afBandwidth,
|
Real afBandwidth,
|
||||||
float fmDeviation,
|
float fmDeviation,
|
||||||
float toneFrequency,
|
float toneFrequency,
|
||||||
@ -228,7 +253,7 @@ private:
|
|||||||
bool channelMute,
|
bool channelMute,
|
||||||
bool playLoop)
|
bool playLoop)
|
||||||
{
|
{
|
||||||
return new MsgConfigureWFMMod(rfBandwidth,
|
return new MsgConfigureWFMModPrivate(rfBandwidth,
|
||||||
afBandwidth,
|
afBandwidth,
|
||||||
fmDeviation,
|
fmDeviation,
|
||||||
toneFrequency,
|
toneFrequency,
|
||||||
@ -246,7 +271,7 @@ private:
|
|||||||
bool m_channelMute;
|
bool m_channelMute;
|
||||||
bool m_playLoop;
|
bool m_playLoop;
|
||||||
|
|
||||||
MsgConfigureWFMMod(Real rfBandwidth,
|
MsgConfigureWFMModPrivate(Real rfBandwidth,
|
||||||
Real afBandwidth,
|
Real afBandwidth,
|
||||||
float fmDeviation,
|
float fmDeviation,
|
||||||
float toneFrequency,
|
float toneFrequency,
|
||||||
@ -303,6 +328,7 @@ private:
|
|||||||
|
|
||||||
Config m_config;
|
Config m_config;
|
||||||
Config m_running;
|
Config m_running;
|
||||||
|
WFMModSettings m_settings;
|
||||||
|
|
||||||
NCO m_carrierNco;
|
NCO m_carrierNco;
|
||||||
NCOF m_toneNco;
|
NCOF m_toneNco;
|
||||||
@ -345,6 +371,7 @@ private:
|
|||||||
static const int m_levelNbSamples;
|
static const int m_levelNbSamples;
|
||||||
|
|
||||||
void apply();
|
void apply();
|
||||||
|
void applySettings(const WFMModSettings& settings, bool force = false);
|
||||||
void pullAF(Complex& sample);
|
void pullAF(Complex& sample);
|
||||||
void calculateLevel(const Real& sample);
|
void calculateLevel(const Real& sample);
|
||||||
void openFileStream();
|
void openFileStream();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user