mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-16 13:21:50 -05:00
WFM Moduletor
This commit is contained in:
parent
d09f0d2ede
commit
95a8eb9856
@ -249,8 +249,6 @@ void NFMMod::stop()
|
|||||||
|
|
||||||
bool NFMMod::handleMessage(const Message& cmd)
|
bool NFMMod::handleMessage(const Message& cmd)
|
||||||
{
|
{
|
||||||
qDebug() << "NFMMod::handleMessage";
|
|
||||||
|
|
||||||
if (UpChannelizer::MsgChannelizerNotification::match(cmd))
|
if (UpChannelizer::MsgChannelizerNotification::match(cmd))
|
||||||
{
|
{
|
||||||
UpChannelizer::MsgChannelizerNotification& notif = (UpChannelizer::MsgChannelizerNotification&) cmd;
|
UpChannelizer::MsgChannelizerNotification& notif = (UpChannelizer::MsgChannelizerNotification&) cmd;
|
||||||
|
@ -96,30 +96,23 @@ void WFMMod::configure(MessageQueue* messageQueue,
|
|||||||
|
|
||||||
void WFMMod::pull(Sample& sample)
|
void WFMMod::pull(Sample& sample)
|
||||||
{
|
{
|
||||||
Complex ci;
|
Complex ci, ri;
|
||||||
Real t;
|
Real t;
|
||||||
|
|
||||||
m_settingsMutex.lock();
|
m_settingsMutex.lock();
|
||||||
|
|
||||||
if (m_interpolatorDistance > 1.0f) // decimate
|
if (m_interpolator.interpolate(&m_interpolatorDistanceRemain, m_modSample, &ri))
|
||||||
{
|
{
|
||||||
modulateSample();
|
pullAF(m_modSample);
|
||||||
|
calculateLevel(m_modSample.real());
|
||||||
while (!m_interpolator.decimate(&m_interpolatorDistanceRemain, m_modSample, &ci))
|
|
||||||
{
|
|
||||||
modulateSample();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (m_interpolator.interpolate(&m_interpolatorDistanceRemain, m_modSample, &ci))
|
|
||||||
{
|
|
||||||
modulateSample();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_interpolatorDistanceRemain += m_interpolatorDistance;
|
m_interpolatorDistanceRemain += m_interpolatorDistance;
|
||||||
|
|
||||||
|
m_modPhasor += (m_running.m_fmDeviation / (float) m_running.m_outputSampleRate) * ri.real() * M_PI_2;
|
||||||
|
ci.real(cos(m_modPhasor) * 32678.0f);
|
||||||
|
ci.imag(sin(m_modPhasor) * 32678.0f);
|
||||||
|
|
||||||
ci *= m_carrierNco.nextIQ(); // shift to carrier frequency
|
ci *= m_carrierNco.nextIQ(); // shift to carrier frequency
|
||||||
|
|
||||||
m_settingsMutex.unlock();
|
m_settingsMutex.unlock();
|
||||||
@ -133,27 +126,15 @@ void WFMMod::pull(Sample& sample)
|
|||||||
sample.m_imag = (FixReal) ci.imag();
|
sample.m_imag = (FixReal) ci.imag();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WFMMod::modulateSample()
|
void WFMMod::pullAF(Complex& sample)
|
||||||
{
|
|
||||||
Real t;
|
|
||||||
|
|
||||||
pullAF(t);
|
|
||||||
calculateLevel(t);
|
|
||||||
|
|
||||||
// 378 = 302 * 1.25; 302 = number of filter taps (established experimentally)
|
|
||||||
m_modPhasor += (m_running.m_fmDeviation / (float) m_running.m_audioSampleRate) * m_bandpass.filter(t) * (M_PI / 378.0f);
|
|
||||||
m_modSample.real(cos(m_modPhasor) * 32678.0f);
|
|
||||||
m_modSample.imag(sin(m_modPhasor) * 32678.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WFMMod::pullAF(Real& sample)
|
|
||||||
{
|
{
|
||||||
int16_t audioSample[2];
|
int16_t audioSample[2];
|
||||||
|
|
||||||
switch (m_afInput)
|
switch (m_afInput)
|
||||||
{
|
{
|
||||||
case WFMModInputTone:
|
case WFMModInputTone:
|
||||||
sample = m_toneNco.next();
|
sample.real(m_toneNco.next());
|
||||||
|
sample.imag(0.0f);
|
||||||
break;
|
break;
|
||||||
case WFMModInputFile:
|
case WFMModInputFile:
|
||||||
// sox f4exb_call.wav --encoding float --endian little f4exb_call.raw
|
// sox f4exb_call.wav --encoding float --endian little f4exb_call.raw
|
||||||
@ -171,22 +152,32 @@ void WFMMod::pullAF(Real& sample)
|
|||||||
|
|
||||||
if (m_ifstream.eof())
|
if (m_ifstream.eof())
|
||||||
{
|
{
|
||||||
sample = 0.0f;
|
sample.real(0.0f);
|
||||||
|
sample.imag(0.0f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_ifstream.read(reinterpret_cast<char*>(&sample), sizeof(Real));
|
Real s;
|
||||||
sample *= m_running.m_volumeFactor;
|
m_ifstream.read(reinterpret_cast<char*>(&s), sizeof(Real));
|
||||||
|
m_lowpass.filter(s);
|
||||||
|
sample.real(s * m_running.m_volumeFactor);
|
||||||
|
sample.imag(0.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sample = 0.0f;
|
sample.real(0.0f);
|
||||||
|
sample.imag(0.0f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WFMModInputAudio:
|
case WFMModInputAudio:
|
||||||
|
{
|
||||||
|
Real s = (audioSample[0] + audioSample[1]) / 65536.0f;
|
||||||
|
m_lowpass.filter(s);
|
||||||
m_audioFifo.read(reinterpret_cast<quint8*>(audioSample), 1, 10);
|
m_audioFifo.read(reinterpret_cast<quint8*>(audioSample), 1, 10);
|
||||||
sample = ((audioSample[0] + audioSample[1]) / 65536.0f) * m_running.m_volumeFactor;
|
sample.real(s * m_running.m_volumeFactor);
|
||||||
|
sample.imag(0.0f);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case WFMModInputCWTone:
|
case WFMModInputCWTone:
|
||||||
Real fadeFactor;
|
Real fadeFactor;
|
||||||
@ -194,24 +185,28 @@ void WFMMod::pullAF(Real& sample)
|
|||||||
if (m_cwKeyer.getSample())
|
if (m_cwKeyer.getSample())
|
||||||
{
|
{
|
||||||
m_cwSmoother.getFadeSample(true, fadeFactor);
|
m_cwSmoother.getFadeSample(true, fadeFactor);
|
||||||
sample = m_toneNco.next() * fadeFactor;
|
sample.real(m_toneNco.next() * fadeFactor);
|
||||||
|
sample.imag(0.0f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_cwSmoother.getFadeSample(false, fadeFactor))
|
if (m_cwSmoother.getFadeSample(false, fadeFactor))
|
||||||
{
|
{
|
||||||
sample = m_toneNco.next() * fadeFactor;
|
sample.real(m_toneNco.next() * fadeFactor);
|
||||||
|
sample.imag(0.0f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sample = 0.0f;
|
sample.real(0.0f);
|
||||||
|
sample.imag(0.0f);
|
||||||
m_toneNco.setPhase(0);
|
m_toneNco.setPhase(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WFMModInputNone:
|
case WFMModInputNone:
|
||||||
default:
|
default:
|
||||||
sample = 0.0f;
|
sample.real(0.0f);
|
||||||
|
sample.imag(0.0f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -249,8 +244,6 @@ void WFMMod::stop()
|
|||||||
|
|
||||||
bool WFMMod::handleMessage(const Message& cmd)
|
bool WFMMod::handleMessage(const Message& cmd)
|
||||||
{
|
{
|
||||||
qDebug() << "WFMMod::handleMessage";
|
|
||||||
|
|
||||||
if (UpChannelizer::MsgChannelizerNotification::match(cmd))
|
if (UpChannelizer::MsgChannelizerNotification::match(cmd))
|
||||||
{
|
{
|
||||||
UpChannelizer::MsgChannelizerNotification& notif = (UpChannelizer::MsgChannelizerNotification&) cmd;
|
UpChannelizer::MsgChannelizerNotification& notif = (UpChannelizer::MsgChannelizerNotification&) cmd;
|
||||||
@ -353,7 +346,7 @@ void WFMMod::apply()
|
|||||||
m_interpolatorDistanceRemain = 0;
|
m_interpolatorDistanceRemain = 0;
|
||||||
m_interpolatorConsumed = false;
|
m_interpolatorConsumed = false;
|
||||||
m_interpolatorDistance = (Real) m_config.m_audioSampleRate / (Real) m_config.m_outputSampleRate;
|
m_interpolatorDistance = (Real) m_config.m_audioSampleRate / (Real) m_config.m_outputSampleRate;
|
||||||
m_interpolator.create(48, m_config.m_audioSampleRate, m_config.m_rfBandwidth / 2.2, 3.0);
|
m_interpolator.create(48, m_config.m_audioSampleRate, m_config.m_rfBandwidth, 3.0);
|
||||||
m_settingsMutex.unlock();
|
m_settingsMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,8 +354,7 @@ void WFMMod::apply()
|
|||||||
(m_config.m_audioSampleRate != m_running.m_audioSampleRate))
|
(m_config.m_audioSampleRate != m_running.m_audioSampleRate))
|
||||||
{
|
{
|
||||||
m_settingsMutex.lock();
|
m_settingsMutex.lock();
|
||||||
m_lowpass.create(301, m_config.m_audioSampleRate, 250.0);
|
m_lowpass.create(101, m_config.m_audioSampleRate, m_config.m_afBandwidth);
|
||||||
m_bandpass.create(301, m_config.m_audioSampleRate, 300.0, m_config.m_afBandwidth);
|
|
||||||
m_settingsMutex.unlock();
|
m_settingsMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +298,6 @@ private:
|
|||||||
Real m_interpolatorDistanceRemain;
|
Real m_interpolatorDistanceRemain;
|
||||||
bool m_interpolatorConsumed;
|
bool m_interpolatorConsumed;
|
||||||
Lowpass<Real> m_lowpass;
|
Lowpass<Real> m_lowpass;
|
||||||
Bandpass<Real> m_bandpass;
|
|
||||||
|
|
||||||
Real m_magsq;
|
Real m_magsq;
|
||||||
MovingAverage<Real> m_movingAverage;
|
MovingAverage<Real> m_movingAverage;
|
||||||
@ -326,9 +325,8 @@ private:
|
|||||||
static const int m_levelNbSamples;
|
static const int m_levelNbSamples;
|
||||||
|
|
||||||
void apply();
|
void apply();
|
||||||
void pullAF(Real& sample);
|
void pullAF(Complex& sample);
|
||||||
void calculateLevel(Real& sample);
|
void calculateLevel(Real& sample);
|
||||||
void modulateSample();
|
|
||||||
void openFileStream();
|
void openFileStream();
|
||||||
void seekFileStream(int seekPercentage);
|
void seekFileStream(int seekPercentage);
|
||||||
};
|
};
|
||||||
|
@ -436,7 +436,7 @@ void WFMModGUI::applySettings()
|
|||||||
m_wfmMod->configure(m_wfmMod->getInputMessageQueue(),
|
m_wfmMod->configure(m_wfmMod->getInputMessageQueue(),
|
||||||
m_rfBW[ui->rfBW->currentIndex()],
|
m_rfBW[ui->rfBW->currentIndex()],
|
||||||
ui->afBW->value() * 1000.0,
|
ui->afBW->value() * 1000.0,
|
||||||
ui->fmDev->value() * 100.0f, // value is in '100 Hz
|
ui->fmDev->value() * 1000.0f, // value is in '100 Hz
|
||||||
ui->toneFrequency->value() * 10.0f,
|
ui->toneFrequency->value() * 10.0f,
|
||||||
ui->volume->value() / 10.0f,
|
ui->volume->value() / 10.0f,
|
||||||
ui->audioMute->isChecked(),
|
ui->audioMute->isChecked(),
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
<enum>Qt::StrongFocus</enum>
|
<enum>Qt::StrongFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>NFM Modulator</string>
|
<string>WFM Modulator</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="settingsContainer" native="true">
|
<widget class="QWidget" name="settingsContainer" native="true">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
@ -243,7 +243,7 @@
|
|||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<number>3</number>
|
<number>8</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -259,7 +259,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>3k</string>
|
<string>8k</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
Loading…
Reference in New Issue
Block a user