2016-11-29 17:58:41 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <QTime>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QMutexLocker>
|
2017-10-12 15:26:33 -04:00
|
|
|
|
2017-12-10 14:27:08 -05:00
|
|
|
#include "SWGChannelSettings.h"
|
|
|
|
#include "SWGCWKeyerSettings.h"
|
2018-03-18 15:17:11 -04:00
|
|
|
#include "SWGChannelReport.h"
|
|
|
|
#include "SWGNFMModReport.h"
|
2017-12-10 14:27:08 -05:00
|
|
|
|
2016-11-29 17:58:41 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <complex.h>
|
2016-12-01 20:00:53 -05:00
|
|
|
#include <algorithm>
|
2017-10-12 15:26:33 -04:00
|
|
|
|
2018-02-14 14:11:36 -05:00
|
|
|
#include "dsp/upchannelizer.h"
|
2016-11-29 17:58:41 -05:00
|
|
|
#include "dsp/dspengine.h"
|
2018-02-14 14:11:36 -05:00
|
|
|
#include "dsp/dspcommands.h"
|
2017-10-12 15:26:33 -04:00
|
|
|
#include "device/devicesinkapi.h"
|
2017-10-12 15:51:25 -04:00
|
|
|
#include "dsp/threadedbasebandsamplesource.h"
|
2018-03-18 15:17:11 -04:00
|
|
|
#include "util/db.h"
|
2017-10-12 15:26:33 -04:00
|
|
|
|
2016-11-29 17:58:41 -05:00
|
|
|
#include "nfmmod.h"
|
|
|
|
|
|
|
|
MESSAGE_CLASS_DEFINITION(NFMMod::MsgConfigureNFMMod, Message)
|
2017-10-12 14:33:16 -04:00
|
|
|
MESSAGE_CLASS_DEFINITION(NFMMod::MsgConfigureChannelizer, Message)
|
2016-11-29 17:58:41 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(NFMMod::MsgConfigureFileSourceName, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(NFMMod::MsgConfigureFileSourceSeek, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(NFMMod::MsgConfigureFileSourceStreamTiming, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(NFMMod::MsgReportFileSourceStreamData, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(NFMMod::MsgReportFileSourceStreamTiming, Message)
|
|
|
|
|
2017-11-22 19:19:32 -05:00
|
|
|
const QString NFMMod::m_channelIdURI = "sdrangel.channeltx.modnfm";
|
|
|
|
const QString NFMMod::m_channelId = "NFMMod";
|
2016-12-01 20:00:53 -05:00
|
|
|
const int NFMMod::m_levelNbSamples = 480; // every 10ms
|
2016-11-29 17:58:41 -05:00
|
|
|
|
2017-10-12 15:26:33 -04:00
|
|
|
NFMMod::NFMMod(DeviceSinkAPI *deviceAPI) :
|
2017-12-20 17:57:06 -05:00
|
|
|
ChannelSourceAPI(m_channelIdURI),
|
2017-10-12 15:26:33 -04:00
|
|
|
m_deviceAPI(deviceAPI),
|
2017-12-29 18:18:51 -05:00
|
|
|
m_basebandSampleRate(48000),
|
|
|
|
m_outputSampleRate(48000),
|
|
|
|
m_inputFrequencyOffset(0),
|
2016-11-30 07:39:25 -05:00
|
|
|
m_modPhasor(0.0f),
|
2017-08-24 18:02:49 -04:00
|
|
|
m_audioFifo(4800),
|
2016-11-29 17:58:41 -05:00
|
|
|
m_settingsMutex(QMutex::Recursive),
|
|
|
|
m_fileSize(0),
|
|
|
|
m_recordLength(0),
|
|
|
|
m_sampleRate(48000),
|
2016-12-01 20:00:53 -05:00
|
|
|
m_levelCalcCount(0),
|
|
|
|
m_peakLevel(0.0f),
|
2017-05-25 14:13:34 -04:00
|
|
|
m_levelSum(0.0f)
|
2016-11-29 17:58:41 -05:00
|
|
|
{
|
2017-11-22 19:19:32 -05:00
|
|
|
setObjectName(m_channelId);
|
2016-11-29 17:58:41 -05:00
|
|
|
|
2016-12-25 19:39:34 -05:00
|
|
|
m_audioBuffer.resize(1<<14);
|
|
|
|
m_audioBufferFill = 0;
|
2016-11-29 17:58:41 -05:00
|
|
|
|
|
|
|
m_magsq = 0.0;
|
|
|
|
|
2018-03-25 05:50:34 -04:00
|
|
|
DSPEngine::instance()->getAudioDeviceManager()->addAudioSource(&m_audioFifo, getInputMessageQueue());
|
2018-03-29 09:42:20 -04:00
|
|
|
m_audioSampleRate = DSPEngine::instance()->getAudioDeviceManager()->getInputSampleRate();
|
|
|
|
|
2018-03-31 09:06:35 -04:00
|
|
|
m_lowpass.create(301, m_audioSampleRate, 250.0);
|
2018-03-29 09:42:20 -04:00
|
|
|
m_toneNco.setFreq(1000.0, m_audioSampleRate);
|
|
|
|
m_ctcssNco.setFreq(88.5, m_audioSampleRate);
|
2016-12-11 16:47:42 -05:00
|
|
|
|
|
|
|
// CW keyer
|
2018-03-29 09:42:20 -04:00
|
|
|
m_cwKeyer.setSampleRate(m_audioSampleRate);
|
2016-12-11 16:47:42 -05:00
|
|
|
m_cwKeyer.setWPM(13);
|
2017-12-10 14:27:08 -05:00
|
|
|
m_cwKeyer.setMode(CWKeyerSettings::CWNone);
|
2017-10-12 14:16:37 -04:00
|
|
|
|
2018-03-16 05:26:49 -04:00
|
|
|
applyChannelSettings(m_basebandSampleRate, m_outputSampleRate, m_inputFrequencyOffset, true);
|
|
|
|
applySettings(m_settings, true);
|
|
|
|
|
2017-10-12 15:51:25 -04:00
|
|
|
m_channelizer = new UpChannelizer(this);
|
|
|
|
m_threadedChannelizer = new ThreadedBasebandSampleSource(m_channelizer, this);
|
|
|
|
m_deviceAPI->addThreadedSource(m_threadedChannelizer);
|
2017-11-19 13:33:20 -05:00
|
|
|
m_deviceAPI->addChannelAPI(this);
|
2016-11-29 17:58:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
NFMMod::~NFMMod()
|
|
|
|
{
|
2018-03-23 22:36:49 -04:00
|
|
|
DSPEngine::instance()->getAudioDeviceManager()->removeAudioSource(&m_audioFifo);
|
2017-11-19 13:33:20 -05:00
|
|
|
m_deviceAPI->removeChannelAPI(this);
|
2017-10-12 15:51:25 -04:00
|
|
|
m_deviceAPI->removeThreadedSource(m_threadedChannelizer);
|
|
|
|
delete m_threadedChannelizer;
|
|
|
|
delete m_channelizer;
|
2016-11-29 17:58:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void NFMMod::pull(Sample& sample)
|
|
|
|
{
|
2017-10-12 14:16:37 -04:00
|
|
|
if (m_settings.m_channelMute)
|
2016-12-20 10:38:27 -05:00
|
|
|
{
|
|
|
|
sample.m_real = 0.0f;
|
|
|
|
sample.m_imag = 0.0f;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-11-29 17:58:41 -05:00
|
|
|
Complex ci;
|
|
|
|
|
|
|
|
m_settingsMutex.lock();
|
|
|
|
|
|
|
|
if (m_interpolatorDistance > 1.0f) // decimate
|
|
|
|
{
|
2016-11-30 07:39:25 -05:00
|
|
|
modulateSample();
|
2016-11-29 17:58:41 -05:00
|
|
|
|
|
|
|
while (!m_interpolator.decimate(&m_interpolatorDistanceRemain, m_modSample, &ci))
|
|
|
|
{
|
2016-11-30 07:39:25 -05:00
|
|
|
modulateSample();
|
2016-11-29 17:58:41 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m_interpolator.interpolate(&m_interpolatorDistanceRemain, m_modSample, &ci))
|
|
|
|
{
|
2016-11-30 07:39:25 -05:00
|
|
|
modulateSample();
|
2016-11-29 17:58:41 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_interpolatorDistanceRemain += m_interpolatorDistance;
|
|
|
|
|
|
|
|
ci *= m_carrierNco.nextIQ(); // shift to carrier frequency
|
|
|
|
|
|
|
|
m_settingsMutex.unlock();
|
|
|
|
|
2018-01-21 04:57:04 -05:00
|
|
|
double magsq = ci.real() * ci.real() + ci.imag() * ci.imag();
|
2018-01-22 02:46:05 -05:00
|
|
|
magsq /= (SDR_TX_SCALED*SDR_TX_SCALED);
|
2018-02-03 04:33:02 -05:00
|
|
|
m_movingAverage(magsq);
|
|
|
|
m_magsq = m_movingAverage.asDouble();
|
2016-11-29 17:58:41 -05:00
|
|
|
|
|
|
|
sample.m_real = (FixReal) ci.real();
|
|
|
|
sample.m_imag = (FixReal) ci.imag();
|
|
|
|
}
|
|
|
|
|
2016-12-25 19:39:34 -05:00
|
|
|
void NFMMod::pullAudio(int nbSamples)
|
|
|
|
{
|
2018-03-29 09:42:20 -04:00
|
|
|
unsigned int nbSamplesAudio = nbSamples * ((Real) m_audioSampleRate / (Real) m_basebandSampleRate);
|
2016-12-25 20:15:24 -05:00
|
|
|
|
|
|
|
if (nbSamplesAudio > m_audioBuffer.size())
|
2016-12-25 19:39:34 -05:00
|
|
|
{
|
2016-12-25 20:15:24 -05:00
|
|
|
m_audioBuffer.resize(nbSamplesAudio);
|
2016-12-25 19:39:34 -05:00
|
|
|
}
|
|
|
|
|
2018-09-12 09:30:53 -04:00
|
|
|
m_audioFifo.read(reinterpret_cast<quint8*>(&m_audioBuffer[0]), nbSamplesAudio);
|
2016-12-25 19:39:34 -05:00
|
|
|
m_audioBufferFill = 0;
|
|
|
|
}
|
|
|
|
|
2016-11-30 07:39:25 -05:00
|
|
|
void NFMMod::modulateSample()
|
|
|
|
{
|
|
|
|
Real t;
|
|
|
|
|
|
|
|
pullAF(t);
|
2016-12-01 20:00:53 -05:00
|
|
|
calculateLevel(t);
|
2016-12-25 20:15:24 -05:00
|
|
|
m_audioBufferFill++;
|
2016-11-30 07:39:25 -05:00
|
|
|
|
2017-10-12 14:16:37 -04:00
|
|
|
if (m_settings.m_ctcssOn)
|
2016-12-18 20:41:48 -05:00
|
|
|
{
|
2018-03-29 09:42:20 -04:00
|
|
|
m_modPhasor += (m_settings.m_fmDeviation / (float) m_audioSampleRate) * (0.85f * m_bandpass.filter(t) + 0.15f * 378.0f * m_ctcssNco.next()) * (M_PI / 378.0f);
|
2016-12-18 20:41:48 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// 378 = 302 * 1.25; 302 = number of filter taps (established experimentally)
|
2018-03-29 09:42:20 -04:00
|
|
|
m_modPhasor += (m_settings.m_fmDeviation / (float) m_audioSampleRate) * m_bandpass.filter(t) * (M_PI / 378.0f);
|
2016-12-18 20:41:48 -05:00
|
|
|
}
|
|
|
|
|
2018-01-22 02:46:05 -05:00
|
|
|
m_modSample.real(cos(m_modPhasor) * 0.891235351562f * SDR_TX_SCALEF); // -1 dB
|
|
|
|
m_modSample.imag(sin(m_modPhasor) * 0.891235351562f * SDR_TX_SCALEF);
|
2016-11-30 07:39:25 -05:00
|
|
|
}
|
|
|
|
|
2016-11-29 17:58:41 -05:00
|
|
|
void NFMMod::pullAF(Real& sample)
|
|
|
|
{
|
2017-12-12 12:56:24 -05:00
|
|
|
switch (m_settings.m_modAFInput)
|
2016-11-29 17:58:41 -05:00
|
|
|
{
|
2018-03-03 19:47:51 -05:00
|
|
|
case NFMModSettings::NFMModInputTone:
|
2016-11-29 17:58:41 -05:00
|
|
|
sample = m_toneNco.next();
|
|
|
|
break;
|
2018-03-03 19:47:51 -05:00
|
|
|
case NFMModSettings::NFMModInputFile:
|
2016-11-29 17:58:41 -05:00
|
|
|
// sox f4exb_call.wav --encoding float --endian little f4exb_call.raw
|
|
|
|
// ffplay -f f32le -ar 48k -ac 1 f4exb_call.raw
|
|
|
|
if (m_ifstream.is_open())
|
|
|
|
{
|
|
|
|
if (m_ifstream.eof())
|
|
|
|
{
|
2017-10-12 14:16:37 -04:00
|
|
|
if (m_settings.m_playLoop)
|
2016-11-29 17:58:41 -05:00
|
|
|
{
|
|
|
|
m_ifstream.clear();
|
|
|
|
m_ifstream.seekg(0, std::ios::beg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_ifstream.eof())
|
|
|
|
{
|
|
|
|
sample = 0.0f;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_ifstream.read(reinterpret_cast<char*>(&sample), sizeof(Real));
|
2017-10-12 14:16:37 -04:00
|
|
|
sample *= m_settings.m_volumeFactor;
|
2016-11-29 17:58:41 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sample = 0.0f;
|
|
|
|
}
|
|
|
|
break;
|
2018-03-03 19:47:51 -05:00
|
|
|
case NFMModSettings::NFMModInputAudio:
|
2017-10-12 14:16:37 -04:00
|
|
|
sample = ((m_audioBuffer[m_audioBufferFill].l + m_audioBuffer[m_audioBufferFill].r) / 65536.0f) * m_settings.m_volumeFactor;
|
2016-11-29 17:58:41 -05:00
|
|
|
break;
|
2018-03-03 19:47:51 -05:00
|
|
|
case NFMModSettings::NFMModInputCWTone:
|
2016-12-14 17:59:25 -05:00
|
|
|
Real fadeFactor;
|
|
|
|
|
2016-12-11 16:47:42 -05:00
|
|
|
if (m_cwKeyer.getSample())
|
|
|
|
{
|
2017-10-20 23:27:05 -04:00
|
|
|
m_cwKeyer.getCWSmoother().getFadeSample(true, fadeFactor);
|
2016-12-14 17:59:25 -05:00
|
|
|
sample = m_toneNco.next() * fadeFactor;
|
2016-12-11 16:47:42 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-20 23:27:05 -04:00
|
|
|
if (m_cwKeyer.getCWSmoother().getFadeSample(false, fadeFactor))
|
2016-12-14 17:59:25 -05:00
|
|
|
{
|
|
|
|
sample = m_toneNco.next() * fadeFactor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sample = 0.0f;
|
|
|
|
m_toneNco.setPhase(0);
|
|
|
|
}
|
2016-12-11 16:47:42 -05:00
|
|
|
}
|
|
|
|
break;
|
2018-03-03 19:47:51 -05:00
|
|
|
case NFMModSettings::NFMModInputNone:
|
2016-11-29 17:58:41 -05:00
|
|
|
default:
|
|
|
|
sample = 0.0f;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-01 20:00:53 -05:00
|
|
|
void NFMMod::calculateLevel(Real& sample)
|
|
|
|
{
|
|
|
|
if (m_levelCalcCount < m_levelNbSamples)
|
|
|
|
{
|
|
|
|
m_peakLevel = std::max(std::fabs(m_peakLevel), sample);
|
|
|
|
m_levelSum += sample * sample;
|
|
|
|
m_levelCalcCount++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qreal rmsLevel = sqrt(m_levelSum / m_levelNbSamples);
|
|
|
|
//qDebug("NFMMod::calculateLevel: %f %f", rmsLevel, m_peakLevel);
|
|
|
|
emit levelChanged(rmsLevel, m_peakLevel, m_levelNbSamples);
|
|
|
|
m_peakLevel = 0.0f;
|
|
|
|
m_levelSum = 0.0f;
|
|
|
|
m_levelCalcCount = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-29 17:58:41 -05:00
|
|
|
void NFMMod::start()
|
|
|
|
{
|
2017-12-29 18:18:51 -05:00
|
|
|
qDebug() << "NFMMod::start: m_outputSampleRate: " << m_outputSampleRate
|
|
|
|
<< " m_inputFrequencyOffset: " << m_inputFrequencyOffset;
|
2016-11-29 17:58:41 -05:00
|
|
|
|
|
|
|
m_audioFifo.clear();
|
2018-01-08 19:10:49 -05:00
|
|
|
applyChannelSettings(m_basebandSampleRate, m_outputSampleRate, m_inputFrequencyOffset, true);
|
2016-11-29 17:58:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void NFMMod::stop()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NFMMod::handleMessage(const Message& cmd)
|
|
|
|
{
|
|
|
|
if (UpChannelizer::MsgChannelizerNotification::match(cmd))
|
|
|
|
{
|
|
|
|
UpChannelizer::MsgChannelizerNotification& notif = (UpChannelizer::MsgChannelizerNotification&) cmd;
|
2017-12-29 18:18:51 -05:00
|
|
|
qDebug() << "NFMMod::handleMessage: UpChannelizer::MsgChannelizerNotification";
|
2016-11-29 17:58:41 -05:00
|
|
|
|
2017-12-29 18:18:51 -05:00
|
|
|
applyChannelSettings(notif.getBasebandSampleRate(), notif.getSampleRate(), notif.getFrequencyOffset());
|
2016-11-29 17:58:41 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-10-12 14:33:16 -04:00
|
|
|
else if (MsgConfigureChannelizer::match(cmd))
|
|
|
|
{
|
|
|
|
MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
|
2017-12-29 18:18:51 -05:00
|
|
|
qDebug() << "NFMMod::handleMessage: MsgConfigureChannelizer:"
|
|
|
|
<< " getSampleRate: " << cfg.getSampleRate()
|
|
|
|
<< " getCenterFrequency: " << cfg.getCenterFrequency();
|
2017-10-12 14:33:16 -04:00
|
|
|
|
2017-10-12 15:51:25 -04:00
|
|
|
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
|
|
|
|
cfg.getSampleRate(),
|
|
|
|
cfg.getCenterFrequency());
|
2017-10-12 14:33:16 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-10-12 14:16:37 -04:00
|
|
|
else if (MsgConfigureNFMMod::match(cmd))
|
|
|
|
{
|
|
|
|
MsgConfigureNFMMod& cfg = (MsgConfigureNFMMod&) cmd;
|
2017-12-29 18:18:51 -05:00
|
|
|
qDebug() << "NFMMod::handleMessage: MsgConfigureNFMMod";
|
2017-10-12 14:16:37 -04:00
|
|
|
|
2017-12-29 18:18:51 -05:00
|
|
|
applySettings(cfg.getSettings(), cfg.getForce());
|
2017-10-12 14:16:37 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-11-29 17:58:41 -05:00
|
|
|
else if (MsgConfigureFileSourceName::match(cmd))
|
|
|
|
{
|
|
|
|
MsgConfigureFileSourceName& conf = (MsgConfigureFileSourceName&) cmd;
|
|
|
|
m_fileName = conf.getFileName();
|
|
|
|
openFileStream();
|
2017-12-12 09:58:04 -05:00
|
|
|
qDebug() << "NFMMod::handleMessage: MsgConfigureFileSourceName:"
|
|
|
|
<< " m_fileName: " << m_fileName;
|
2016-11-29 17:58:41 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgConfigureFileSourceSeek::match(cmd))
|
|
|
|
{
|
|
|
|
MsgConfigureFileSourceSeek& conf = (MsgConfigureFileSourceSeek&) cmd;
|
|
|
|
int seekPercentage = conf.getPercentage();
|
|
|
|
seekFileStream(seekPercentage);
|
2017-12-12 09:58:04 -05:00
|
|
|
qDebug() << "NFMMod::handleMessage: MsgConfigureFileSourceSeek:"
|
|
|
|
<< " seekPercentage: " << seekPercentage;
|
2016-11-29 17:58:41 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgConfigureFileSourceStreamTiming::match(cmd))
|
|
|
|
{
|
|
|
|
std::size_t samplesCount;
|
|
|
|
|
|
|
|
if (m_ifstream.eof()) {
|
|
|
|
samplesCount = m_fileSize / sizeof(Real);
|
|
|
|
} else {
|
|
|
|
samplesCount = m_ifstream.tellg() / sizeof(Real);
|
|
|
|
}
|
|
|
|
|
|
|
|
MsgReportFileSourceStreamTiming *report;
|
|
|
|
report = MsgReportFileSourceStreamTiming::create(samplesCount);
|
2017-09-28 02:33:05 -04:00
|
|
|
getMessageQueueToGUI()->push(report);
|
2016-11-29 17:58:41 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2018-03-29 09:42:20 -04:00
|
|
|
else if (DSPConfigureAudio::match(cmd))
|
|
|
|
{
|
|
|
|
DSPConfigureAudio& cfg = (DSPConfigureAudio&) cmd;
|
|
|
|
uint32_t sampleRate = cfg.getSampleRate();
|
|
|
|
|
|
|
|
qDebug() << "NFMMod::handleMessage: DSPConfigureAudio:"
|
|
|
|
<< " sampleRate: " << sampleRate;
|
|
|
|
|
|
|
|
if (sampleRate != m_audioSampleRate) {
|
|
|
|
applyAudioSampleRate(sampleRate);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2018-02-14 14:11:36 -05:00
|
|
|
else if (DSPSignalNotification::match(cmd))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2016-11-29 17:58:41 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void NFMMod::openFileStream()
|
|
|
|
{
|
|
|
|
if (m_ifstream.is_open()) {
|
|
|
|
m_ifstream.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_ifstream.open(m_fileName.toStdString().c_str(), std::ios::binary | std::ios::ate);
|
|
|
|
m_fileSize = m_ifstream.tellg();
|
|
|
|
m_ifstream.seekg(0,std::ios_base::beg);
|
|
|
|
|
|
|
|
m_sampleRate = 48000; // fixed rate
|
|
|
|
m_recordLength = m_fileSize / (sizeof(Real) * m_sampleRate);
|
|
|
|
|
2016-11-29 18:55:35 -05:00
|
|
|
qDebug() << "NFMMod::openFileStream: " << m_fileName.toStdString().c_str()
|
2016-11-29 17:58:41 -05:00
|
|
|
<< " fileSize: " << m_fileSize << "bytes"
|
|
|
|
<< " length: " << m_recordLength << " seconds";
|
|
|
|
|
|
|
|
MsgReportFileSourceStreamData *report;
|
|
|
|
report = MsgReportFileSourceStreamData::create(m_sampleRate, m_recordLength);
|
2017-09-28 02:33:05 -04:00
|
|
|
getMessageQueueToGUI()->push(report);
|
2016-11-29 17:58:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void NFMMod::seekFileStream(int seekPercentage)
|
|
|
|
{
|
|
|
|
QMutexLocker mutexLocker(&m_settingsMutex);
|
|
|
|
|
|
|
|
if (m_ifstream.is_open())
|
|
|
|
{
|
|
|
|
int seekPoint = ((m_recordLength * seekPercentage) / 100) * m_sampleRate;
|
|
|
|
seekPoint *= sizeof(Real);
|
|
|
|
m_ifstream.clear();
|
|
|
|
m_ifstream.seekg(seekPoint, std::ios::beg);
|
|
|
|
}
|
|
|
|
}
|
2017-10-12 14:16:37 -04:00
|
|
|
|
2018-03-29 09:42:20 -04:00
|
|
|
void NFMMod::applyAudioSampleRate(int sampleRate)
|
|
|
|
{
|
|
|
|
qDebug("NFMMod::applyAudioSampleRate: %d", sampleRate);
|
|
|
|
|
|
|
|
MsgConfigureChannelizer* channelConfigMsg = MsgConfigureChannelizer::create(
|
|
|
|
sampleRate, m_settings.m_inputFrequencyOffset);
|
|
|
|
m_inputMessageQueue.push(channelConfigMsg);
|
|
|
|
|
|
|
|
m_settingsMutex.lock();
|
|
|
|
|
|
|
|
m_interpolatorDistanceRemain = 0;
|
|
|
|
m_interpolatorConsumed = false;
|
|
|
|
m_interpolatorDistance = (Real) sampleRate / (Real) m_outputSampleRate;
|
|
|
|
m_interpolator.create(48, sampleRate, m_settings.m_rfBandwidth / 2.2, 3.0);
|
|
|
|
m_lowpass.create(301, sampleRate, 250.0);
|
|
|
|
m_bandpass.create(301, sampleRate, 300.0, m_settings.m_afBandwidth);
|
|
|
|
m_toneNco.setFreq(m_settings.m_toneFrequency, sampleRate);
|
|
|
|
m_ctcssNco.setFreq(NFMModSettings::getCTCSSFreq(m_settings.m_ctcssIndex), sampleRate);
|
|
|
|
m_cwKeyer.setSampleRate(sampleRate);
|
|
|
|
|
|
|
|
m_settingsMutex.unlock();
|
|
|
|
|
|
|
|
m_audioSampleRate = sampleRate;
|
|
|
|
}
|
|
|
|
|
2018-01-08 19:10:49 -05:00
|
|
|
void NFMMod::applyChannelSettings(int basebandSampleRate, int outputSampleRate, int inputFrequencyOffset, bool force)
|
2017-10-12 14:16:37 -04:00
|
|
|
{
|
2017-12-29 18:18:51 -05:00
|
|
|
qDebug() << "NFMMod::applyChannelSettings:"
|
|
|
|
<< " basebandSampleRate: " << basebandSampleRate
|
|
|
|
<< " outputSampleRate: " << outputSampleRate
|
|
|
|
<< " inputFrequencyOffset: " << inputFrequencyOffset;
|
|
|
|
|
|
|
|
if ((inputFrequencyOffset != m_inputFrequencyOffset) ||
|
2018-01-08 19:10:49 -05:00
|
|
|
(outputSampleRate != m_outputSampleRate) || force)
|
2017-10-12 14:16:37 -04:00
|
|
|
{
|
|
|
|
m_settingsMutex.lock();
|
2018-01-02 04:32:00 -05:00
|
|
|
m_carrierNco.setFreq(inputFrequencyOffset, outputSampleRate);
|
2017-12-29 18:18:51 -05:00
|
|
|
m_settingsMutex.unlock();
|
|
|
|
}
|
|
|
|
|
2018-01-08 19:10:49 -05:00
|
|
|
if ((outputSampleRate != m_outputSampleRate) || force)
|
2017-12-29 18:18:51 -05:00
|
|
|
{
|
|
|
|
m_settingsMutex.lock();
|
|
|
|
m_interpolatorDistanceRemain = 0;
|
|
|
|
m_interpolatorConsumed = false;
|
2018-03-29 09:42:20 -04:00
|
|
|
m_interpolatorDistance = (Real) m_audioSampleRate / (Real) outputSampleRate;
|
|
|
|
m_interpolator.create(48, m_audioSampleRate, m_settings.m_rfBandwidth / 2.2, 3.0);
|
2017-10-12 14:16:37 -04:00
|
|
|
m_settingsMutex.unlock();
|
|
|
|
}
|
|
|
|
|
2017-12-29 18:18:51 -05:00
|
|
|
m_basebandSampleRate = basebandSampleRate;
|
|
|
|
m_outputSampleRate = outputSampleRate;
|
|
|
|
m_inputFrequencyOffset = inputFrequencyOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NFMMod::applySettings(const NFMModSettings& settings, bool force)
|
|
|
|
{
|
|
|
|
qDebug() << "NFMMod::applySettings:"
|
|
|
|
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
|
|
|
|
<< " m_rfBandwidth: " << settings.m_rfBandwidth
|
|
|
|
<< " m_afBandwidth: " << settings.m_afBandwidth
|
|
|
|
<< " m_fmDeviation: " << settings.m_fmDeviation
|
|
|
|
<< " m_volumeFactor: " << settings.m_volumeFactor
|
|
|
|
<< " m_toneFrequency: " << settings.m_toneFrequency
|
|
|
|
<< " m_ctcssIndex: " << settings.m_ctcssIndex
|
|
|
|
<< " m_ctcssOn: " << settings.m_ctcssOn
|
|
|
|
<< " m_channelMute: " << settings.m_channelMute
|
|
|
|
<< " m_playLoop: " << settings.m_playLoop
|
|
|
|
<< " m_modAFInout " << settings.m_modAFInput
|
2018-03-29 09:42:20 -04:00
|
|
|
<< " m_audioDeviceName: " << settings.m_audioDeviceName
|
2017-12-29 18:18:51 -05:00
|
|
|
<< " force: " << force;
|
|
|
|
|
2018-03-29 09:42:20 -04:00
|
|
|
if((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force)
|
2017-10-12 14:16:37 -04:00
|
|
|
{
|
|
|
|
m_settingsMutex.lock();
|
|
|
|
m_interpolatorDistanceRemain = 0;
|
|
|
|
m_interpolatorConsumed = false;
|
2018-03-29 09:42:20 -04:00
|
|
|
m_interpolatorDistance = (Real) m_audioSampleRate / (Real) m_outputSampleRate;
|
|
|
|
m_interpolator.create(48, m_audioSampleRate, settings.m_rfBandwidth / 2.2, 3.0);
|
2017-10-12 14:16:37 -04:00
|
|
|
m_settingsMutex.unlock();
|
|
|
|
}
|
|
|
|
|
2018-03-29 09:42:20 -04:00
|
|
|
if ((settings.m_afBandwidth != m_settings.m_afBandwidth) || force)
|
2017-10-12 14:16:37 -04:00
|
|
|
{
|
|
|
|
m_settingsMutex.lock();
|
2018-03-29 09:42:20 -04:00
|
|
|
m_lowpass.create(301, m_audioSampleRate, 250.0);
|
|
|
|
m_bandpass.create(301, m_audioSampleRate, 300.0, settings.m_afBandwidth);
|
2017-10-12 14:16:37 -04:00
|
|
|
m_settingsMutex.unlock();
|
|
|
|
}
|
|
|
|
|
2018-03-29 09:42:20 -04:00
|
|
|
if ((settings.m_toneFrequency != m_settings.m_toneFrequency) || force)
|
2017-10-12 14:16:37 -04:00
|
|
|
{
|
|
|
|
m_settingsMutex.lock();
|
2018-03-29 09:42:20 -04:00
|
|
|
m_toneNco.setFreq(settings.m_toneFrequency, m_audioSampleRate);
|
2017-10-12 14:16:37 -04:00
|
|
|
m_settingsMutex.unlock();
|
|
|
|
}
|
|
|
|
|
2018-03-29 09:42:20 -04:00
|
|
|
if ((settings.m_ctcssIndex != m_settings.m_ctcssIndex) || force)
|
2017-10-12 14:16:37 -04:00
|
|
|
{
|
2018-03-29 09:42:20 -04:00
|
|
|
m_settingsMutex.lock();
|
|
|
|
m_ctcssNco.setFreq(NFMModSettings::getCTCSSFreq(settings.m_ctcssIndex), m_audioSampleRate);
|
|
|
|
m_settingsMutex.unlock();
|
2017-10-12 14:16:37 -04:00
|
|
|
}
|
|
|
|
|
2018-03-29 09:42:20 -04:00
|
|
|
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)
|
2017-10-12 14:16:37 -04:00
|
|
|
{
|
2018-03-29 09:42:20 -04:00
|
|
|
AudioDeviceManager *audioDeviceManager = DSPEngine::instance()->getAudioDeviceManager();
|
|
|
|
int audioDeviceIndex = audioDeviceManager->getInputDeviceIndex(settings.m_audioDeviceName);
|
|
|
|
audioDeviceManager->addAudioSource(&m_audioFifo, getInputMessageQueue(), audioDeviceIndex);
|
|
|
|
uint32_t audioSampleRate = audioDeviceManager->getInputSampleRate(audioDeviceIndex);
|
|
|
|
|
|
|
|
if (m_audioSampleRate != audioSampleRate) {
|
|
|
|
applyAudioSampleRate(audioSampleRate);
|
|
|
|
}
|
2017-10-12 14:16:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
m_settings = settings;
|
|
|
|
}
|
|
|
|
|
2017-12-17 17:15:42 -05:00
|
|
|
QByteArray NFMMod::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NFMMod::deserialize(const QByteArray& data)
|
|
|
|
{
|
2017-12-27 21:29:26 -05:00
|
|
|
bool success = true;
|
|
|
|
|
|
|
|
if (!m_settings.deserialize(data))
|
2017-12-17 17:15:42 -05:00
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
2017-12-27 21:29:26 -05:00
|
|
|
success = false;
|
2017-12-17 17:15:42 -05:00
|
|
|
}
|
2017-12-27 21:29:26 -05:00
|
|
|
|
|
|
|
MsgConfigureChannelizer *msgChan = MsgConfigureChannelizer::create(
|
|
|
|
48000, m_settings.m_inputFrequencyOffset);
|
|
|
|
m_inputMessageQueue.push(msgChan);
|
|
|
|
|
|
|
|
MsgConfigureNFMMod *msg = MsgConfigureNFMMod::create(m_settings, true);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
|
|
|
|
return success;
|
2017-12-17 17:15:42 -05:00
|
|
|
}
|
|
|
|
|
2017-12-10 14:27:08 -05:00
|
|
|
int NFMMod::webapiSettingsGet(
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
2018-11-12 18:45:03 -05:00
|
|
|
QString& errorMessage)
|
2017-12-10 14:27:08 -05:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) errorMessage;
|
2017-12-10 14:27:08 -05:00
|
|
|
response.setNfmModSettings(new SWGSDRangel::SWGNFMModSettings());
|
2018-02-21 07:50:50 -05:00
|
|
|
response.getNfmModSettings()->init();
|
2018-02-14 14:11:36 -05:00
|
|
|
webapiFormatChannelSettings(response, m_settings);
|
2017-12-10 14:27:08 -05:00
|
|
|
return 200;
|
|
|
|
}
|
2017-12-11 12:18:47 -05:00
|
|
|
|
|
|
|
int NFMMod::webapiSettingsPutPatch(
|
|
|
|
bool force,
|
2017-12-23 21:27:07 -05:00
|
|
|
const QStringList& channelSettingsKeys,
|
2017-12-11 12:18:47 -05:00
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
2018-11-12 18:45:03 -05:00
|
|
|
QString& errorMessage)
|
2017-12-11 12:18:47 -05:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) errorMessage;
|
2018-08-08 03:17:25 -04:00
|
|
|
NFMModSettings settings = m_settings;
|
2017-12-27 05:10:47 -05:00
|
|
|
bool frequencyOffsetChanged = false;
|
2017-12-23 22:19:44 -05:00
|
|
|
|
|
|
|
// for (int i = 0; i < channelSettingsKeys.size(); i++) {
|
|
|
|
// qDebug("NFMMod::webapiSettingsPutPatch: settingKey: %s", qPrintable(channelSettingsKeys.at(i)));
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (channelSettingsKeys.contains("afBandwidth")) {
|
|
|
|
settings.m_afBandwidth = response.getNfmModSettings()->getAfBandwidth();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("channelMute")) {
|
|
|
|
settings.m_channelMute = response.getNfmModSettings()->getChannelMute() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("ctcssIndex")) {
|
|
|
|
settings.m_ctcssIndex = response.getNfmModSettings()->getCtcssIndex();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("ctcssOn")) {
|
|
|
|
settings.m_ctcssOn = response.getNfmModSettings()->getCtcssOn() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("fmDeviation")) {
|
|
|
|
settings.m_fmDeviation = response.getNfmModSettings()->getFmDeviation();
|
|
|
|
}
|
2017-12-27 05:10:47 -05:00
|
|
|
if (channelSettingsKeys.contains("inputFrequencyOffset"))
|
|
|
|
{
|
2017-12-23 22:19:44 -05:00
|
|
|
settings.m_inputFrequencyOffset = response.getNfmModSettings()->getInputFrequencyOffset();
|
2017-12-27 05:10:47 -05:00
|
|
|
frequencyOffsetChanged = true;
|
2017-12-23 22:19:44 -05:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("modAFInput")) {
|
|
|
|
settings.m_modAFInput = (NFMModSettings::NFMModInputAF) response.getNfmModSettings()->getModAfInput();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("playLoop")) {
|
|
|
|
settings.m_playLoop = response.getNfmModSettings()->getPlayLoop() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rfBandwidth")) {
|
|
|
|
settings.m_rfBandwidth = response.getNfmModSettings()->getRfBandwidth();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rgbColor")) {
|
|
|
|
settings.m_rgbColor = response.getNfmModSettings()->getRgbColor();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("title")) {
|
|
|
|
settings.m_title = *response.getNfmModSettings()->getTitle();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("toneFrequency")) {
|
|
|
|
settings.m_toneFrequency = response.getNfmModSettings()->getToneFrequency();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("volumeFactor")) {
|
|
|
|
settings.m_volumeFactor = response.getNfmModSettings()->getVolumeFactor();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (channelSettingsKeys.contains("cwKeyer"))
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getNfmModSettings()->getCwKeyer();
|
|
|
|
CWKeyerSettings cwKeyerSettings = m_cwKeyer.getSettings();
|
|
|
|
|
|
|
|
if (channelSettingsKeys.contains("cwKeyer.loop")) {
|
|
|
|
cwKeyerSettings.m_loop = apiCwKeyerSettings->getLoop() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("cwKeyer.mode")) {
|
|
|
|
cwKeyerSettings.m_mode = (CWKeyerSettings::CWMode) apiCwKeyerSettings->getMode();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("cwKeyer.text")) {
|
|
|
|
cwKeyerSettings.m_text = *apiCwKeyerSettings->getText();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("cwKeyer.sampleRate")) {
|
|
|
|
cwKeyerSettings.m_sampleRate = apiCwKeyerSettings->getSampleRate();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("cwKeyer.wpm")) {
|
|
|
|
cwKeyerSettings.m_wpm = apiCwKeyerSettings->getWpm();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_cwKeyer.setLoop(cwKeyerSettings.m_loop);
|
|
|
|
m_cwKeyer.setMode(cwKeyerSettings.m_mode);
|
|
|
|
m_cwKeyer.setSampleRate(cwKeyerSettings.m_sampleRate);
|
|
|
|
m_cwKeyer.setText(cwKeyerSettings.m_text);
|
|
|
|
m_cwKeyer.setWPM(cwKeyerSettings.m_wpm);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
|
|
|
CWKeyer::MsgConfigureCWKeyer *msgCwKeyer = CWKeyer::MsgConfigureCWKeyer::create(cwKeyerSettings, force);
|
|
|
|
m_guiMessageQueue->push(msgCwKeyer);
|
|
|
|
}
|
|
|
|
}
|
2017-12-11 12:18:47 -05:00
|
|
|
|
2017-12-27 05:10:47 -05:00
|
|
|
if (frequencyOffsetChanged)
|
|
|
|
{
|
|
|
|
NFMMod::MsgConfigureChannelizer *msgChan = NFMMod::MsgConfigureChannelizer::create(
|
2018-04-05 18:54:18 -04:00
|
|
|
m_audioSampleRate, settings.m_inputFrequencyOffset);
|
2017-12-27 05:10:47 -05:00
|
|
|
m_inputMessageQueue.push(msgChan);
|
|
|
|
}
|
|
|
|
|
2017-12-11 12:18:47 -05:00
|
|
|
MsgConfigureNFMMod *msg = MsgConfigureNFMMod::create(settings, force);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
|
|
|
MsgConfigureNFMMod *msgToGUI = MsgConfigureNFMMod::create(settings, force);
|
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
|
2018-02-14 14:11:36 -05:00
|
|
|
webapiFormatChannelSettings(response, settings);
|
|
|
|
|
2017-12-11 12:18:47 -05:00
|
|
|
return 200;
|
|
|
|
}
|
2018-02-14 14:11:36 -05:00
|
|
|
|
2018-03-18 15:17:11 -04:00
|
|
|
int NFMMod::webapiReportGet(
|
|
|
|
SWGSDRangel::SWGChannelReport& response,
|
2018-11-12 18:45:03 -05:00
|
|
|
QString& errorMessage)
|
2018-03-18 15:17:11 -04:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) errorMessage;
|
2018-03-18 15:17:11 -04:00
|
|
|
response.setNfmModReport(new SWGSDRangel::SWGNFMModReport());
|
|
|
|
response.getNfmModReport()->init();
|
|
|
|
webapiFormatChannelReport(response);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2018-02-14 14:11:36 -05:00
|
|
|
void NFMMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const NFMModSettings& settings)
|
|
|
|
{
|
2018-02-14 17:39:23 -05:00
|
|
|
response.getNfmModSettings()->setAfBandwidth(settings.m_afBandwidth);
|
|
|
|
response.getNfmModSettings()->setChannelMute(settings.m_channelMute ? 1 : 0);
|
|
|
|
response.getNfmModSettings()->setCtcssIndex(settings.m_ctcssIndex);
|
|
|
|
response.getNfmModSettings()->setCtcssOn(settings.m_ctcssOn ? 1 : 0);
|
|
|
|
response.getNfmModSettings()->setFmDeviation(settings.m_fmDeviation);
|
|
|
|
response.getNfmModSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
|
|
|
|
response.getNfmModSettings()->setModAfInput((int) settings.m_modAFInput);
|
|
|
|
response.getNfmModSettings()->setPlayLoop(settings.m_playLoop ? 1 : 0);
|
|
|
|
response.getNfmModSettings()->setRfBandwidth(settings.m_rfBandwidth);
|
|
|
|
response.getNfmModSettings()->setRgbColor(settings.m_rgbColor);
|
2018-02-14 14:11:36 -05:00
|
|
|
|
|
|
|
if (response.getNfmModSettings()->getTitle()) {
|
2018-02-14 17:39:23 -05:00
|
|
|
*response.getNfmModSettings()->getTitle() = settings.m_title;
|
2018-02-14 14:11:36 -05:00
|
|
|
} else {
|
|
|
|
response.getNfmModSettings()->setTitle(new QString(settings.m_title));
|
|
|
|
}
|
|
|
|
|
2018-02-14 17:39:23 -05:00
|
|
|
response.getNfmModSettings()->setToneFrequency(settings.m_toneFrequency);
|
|
|
|
response.getNfmModSettings()->setVolumeFactor(settings.m_volumeFactor);
|
2018-02-14 14:11:36 -05:00
|
|
|
|
|
|
|
if (!response.getNfmModSettings()->getCwKeyer()) {
|
|
|
|
response.getNfmModSettings()->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings);
|
|
|
|
}
|
|
|
|
|
|
|
|
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getNfmModSettings()->getCwKeyer();
|
|
|
|
const CWKeyerSettings& cwKeyerSettings = m_cwKeyer.getSettings();
|
|
|
|
apiCwKeyerSettings->setLoop(cwKeyerSettings.m_loop ? 1 : 0);
|
|
|
|
apiCwKeyerSettings->setMode((int) cwKeyerSettings.m_mode);
|
|
|
|
apiCwKeyerSettings->setSampleRate(cwKeyerSettings.m_sampleRate);
|
|
|
|
|
|
|
|
if (apiCwKeyerSettings->getText()) {
|
|
|
|
*apiCwKeyerSettings->getText() = cwKeyerSettings.m_text;
|
|
|
|
} else {
|
|
|
|
apiCwKeyerSettings->setText(new QString(cwKeyerSettings.m_text));
|
|
|
|
}
|
|
|
|
|
2018-04-05 18:54:18 -04:00
|
|
|
if (response.getNfmModSettings()->getAudioDeviceName()) {
|
|
|
|
*response.getNfmModSettings()->getAudioDeviceName() = settings.m_audioDeviceName;
|
2018-03-29 09:42:20 -04:00
|
|
|
} else {
|
2018-04-05 18:54:18 -04:00
|
|
|
response.getNfmModSettings()->setAudioDeviceName(new QString(settings.m_audioDeviceName));
|
2018-03-29 09:42:20 -04:00
|
|
|
}
|
|
|
|
|
2018-02-14 14:11:36 -05:00
|
|
|
apiCwKeyerSettings->setWpm(cwKeyerSettings.m_wpm);
|
|
|
|
}
|
2018-03-18 15:17:11 -04:00
|
|
|
|
|
|
|
void NFMMod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
|
|
|
|
{
|
|
|
|
response.getNfmModReport()->setChannelPowerDb(CalcDb::dbPower(getMagSq()));
|
2018-03-29 09:42:20 -04:00
|
|
|
response.getNfmModReport()->setAudioSampleRate(m_audioSampleRate);
|
|
|
|
response.getNfmModReport()->setChannelSampleRate(m_outputSampleRate);
|
2018-03-18 15:17:11 -04:00
|
|
|
}
|