274 changed files with 6391 additions and 258 deletions
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
project(modfreedv) |
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") |
||||
|
||||
set(modfreedv_SOURCES |
||||
freedvmod.cpp |
||||
freedvmodgui.cpp |
||||
freedvmodplugin.cpp |
||||
freedvmodsettings.cpp |
||||
) |
||||
|
||||
set(modfreedv_HEADERS |
||||
freedvmod.h |
||||
freedvmodgui.h |
||||
freedvmodplugin.h |
||||
freedvmodsettings.h |
||||
) |
||||
|
||||
set(modfreedv_FORMS |
||||
freedvmodgui.ui |
||||
) |
||||
|
||||
include_directories( |
||||
. |
||||
${CMAKE_CURRENT_BINARY_DIR} |
||||
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client |
||||
) |
||||
|
||||
add_definitions(${QT_DEFINITIONS}) |
||||
add_definitions(-DQT_PLUGIN) |
||||
add_definitions(-DQT_SHARED) |
||||
|
||||
qt5_wrap_ui(modfreedv_FORMS_HEADERS ${modfreedv_FORMS}) |
||||
|
||||
add_library(modfreedv SHARED |
||||
${modfreedv_SOURCES} |
||||
${modfreedv_HEADERS_MOC} |
||||
${modfreedv_FORMS_HEADERS} |
||||
) |
||||
|
||||
target_link_libraries(modfreedv |
||||
${QT_LIBRARIES} |
||||
sdrbase |
||||
sdrgui |
||||
swagger |
||||
) |
||||
|
||||
target_link_libraries(modfreedv Qt5::Core Qt5::Widgets) |
||||
|
||||
install(TARGETS modfreedv DESTINATION lib/plugins/channeltx) |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,339 @@
@@ -0,0 +1,339 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2019 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PLUGINS_CHANNELTX_MODFREEDV_FREEDVMOD_H_ |
||||
#define PLUGINS_CHANNELTX_MODFREEDV_FREEDVMOD_H_ |
||||
|
||||
#include <vector> |
||||
#include <iostream> |
||||
#include <fstream> |
||||
|
||||
#include <QMutex> |
||||
#include <QNetworkRequest> |
||||
|
||||
#include "dsp/basebandsamplesource.h" |
||||
#include "channel/channelsourceapi.h" |
||||
#include "dsp/basebandsamplesink.h" |
||||
#include "dsp/ncof.h" |
||||
#include "dsp/interpolator.h" |
||||
#include "util/movingaverage.h" |
||||
#include "dsp/agc.h" |
||||
#include "dsp/fftfilt.h" |
||||
#include "dsp/cwkeyer.h" |
||||
#include "audio/audiofifo.h" |
||||
#include "util/message.h" |
||||
|
||||
#include "freedvmodsettings.h" |
||||
|
||||
class QNetworkAccessManager; |
||||
class QNetworkReply; |
||||
class DeviceSinkAPI; |
||||
class ThreadedBasebandSampleSource; |
||||
class UpChannelizer; |
||||
|
||||
class FreeDVMod : public BasebandSampleSource, public ChannelSourceAPI { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
class MsgConfigureFreeDVMod : public Message { |
||||
MESSAGE_CLASS_DECLARATION |
||||
|
||||
public: |
||||
const FreeDVModSettings& getSettings() const { return m_settings; } |
||||
bool getForce() const { return m_force; } |
||||
|
||||
static MsgConfigureFreeDVMod* create(const FreeDVModSettings& settings, bool force) |
||||
{ |
||||
return new MsgConfigureFreeDVMod(settings, force); |
||||
} |
||||
|
||||
private: |
||||
FreeDVModSettings m_settings; |
||||
bool m_force; |
||||
|
||||
MsgConfigureFreeDVMod(const FreeDVModSettings& settings, bool force) : |
||||
Message(), |
||||
m_settings(settings), |
||||
m_force(force) |
||||
{ } |
||||
}; |
||||
|
||||
class MsgConfigureChannelizer : public Message { |
||||
MESSAGE_CLASS_DECLARATION |
||||
|
||||
public: |
||||
int getSampleRate() const { return m_sampleRate; } |
||||
int getCenterFrequency() const { return m_centerFrequency; } |
||||
|
||||
static MsgConfigureChannelizer* create(int sampleRate, int centerFrequency) |
||||
{ |
||||
return new MsgConfigureChannelizer(sampleRate, centerFrequency); |
||||
} |
||||
|
||||
private: |
||||
int m_sampleRate; |
||||
int m_centerFrequency; |
||||
|
||||
MsgConfigureChannelizer(int sampleRate, int centerFrequency) : |
||||
Message(), |
||||
m_sampleRate(sampleRate), |
||||
m_centerFrequency(centerFrequency) |
||||
{ } |
||||
}; |
||||
|
||||
class MsgConfigureFileSourceName : public Message |
||||
{ |
||||
MESSAGE_CLASS_DECLARATION |
||||
|
||||
public: |
||||
const QString& getFileName() const { return m_fileName; } |
||||
|
||||
static MsgConfigureFileSourceName* create(const QString& fileName) |
||||
{ |
||||
return new MsgConfigureFileSourceName(fileName); |
||||
} |
||||
|
||||
private: |
||||
QString m_fileName; |
||||
|
||||
MsgConfigureFileSourceName(const QString& fileName) : |
||||
Message(), |
||||
m_fileName(fileName) |
||||
{ } |
||||
}; |
||||
|
||||
class MsgConfigureFileSourceSeek : public Message |
||||
{ |
||||
MESSAGE_CLASS_DECLARATION |
||||
|
||||
public: |
||||
int getPercentage() const { return m_seekPercentage; } |
||||
|
||||
static MsgConfigureFileSourceSeek* create(int seekPercentage) |
||||
{ |
||||
return new MsgConfigureFileSourceSeek(seekPercentage); |
||||
} |
||||
|
||||
protected: |
||||
int m_seekPercentage; //!< percentage of seek position from the beginning 0..100
|
||||
|
||||
MsgConfigureFileSourceSeek(int seekPercentage) : |
||||
Message(), |
||||
m_seekPercentage(seekPercentage) |
||||
{ } |
||||
}; |
||||
|
||||
class MsgConfigureFileSourceStreamTiming : public Message { |
||||
MESSAGE_CLASS_DECLARATION |
||||
|
||||
public: |
||||
|
||||
static MsgConfigureFileSourceStreamTiming* create() |
||||
{ |
||||
return new MsgConfigureFileSourceStreamTiming(); |
||||
} |
||||
|
||||
private: |
||||
|
||||
MsgConfigureFileSourceStreamTiming() : |
||||
Message() |
||||
{ } |
||||
}; |
||||
|
||||
class MsgReportFileSourceStreamTiming : public Message |
||||
{ |
||||
MESSAGE_CLASS_DECLARATION |
||||
|
||||
public: |
||||
std::size_t getSamplesCount() const { return m_samplesCount; } |
||||
|
||||
static MsgReportFileSourceStreamTiming* create(std::size_t samplesCount) |
||||
{ |
||||
return new MsgReportFileSourceStreamTiming(samplesCount); |
||||
} |
||||
|
||||
protected: |
||||
std::size_t m_samplesCount; |
||||
|
||||
MsgReportFileSourceStreamTiming(std::size_t samplesCount) : |
||||
Message(), |
||||
m_samplesCount(samplesCount) |
||||
{ } |
||||
}; |
||||
|
||||
class MsgReportFileSourceStreamData : public Message { |
||||
MESSAGE_CLASS_DECLARATION |
||||
|
||||
public: |
||||
int getSampleRate() const { return m_sampleRate; } |
||||
quint32 getRecordLength() const { return m_recordLength; } |
||||
|
||||
static MsgReportFileSourceStreamData* create(int sampleRate, |
||||
quint32 recordLength) |
||||
{ |
||||
return new MsgReportFileSourceStreamData(sampleRate, recordLength); |
||||
} |
||||
|
||||
protected: |
||||
int m_sampleRate; |
||||
quint32 m_recordLength; |
||||
|
||||
MsgReportFileSourceStreamData(int sampleRate, |
||||
quint32 recordLength) : |
||||
Message(), |
||||
m_sampleRate(sampleRate), |
||||
m_recordLength(recordLength) |
||||
{ } |
||||
}; |
||||
|
||||
//=================================================================
|
||||
|
||||
FreeDVMod(DeviceSinkAPI *deviceAPI); |
||||
~FreeDVMod(); |
||||
virtual void destroy() { delete this; } |
||||
|
||||
void setSpectrumSampleSink(BasebandSampleSink* sampleSink) { m_sampleSink = sampleSink; } |
||||
|
||||
virtual void pull(Sample& sample); |
||||
virtual void pullAudio(int nbSamples); |
||||
virtual void start(); |
||||
virtual void stop(); |
||||
virtual bool handleMessage(const Message& cmd); |
||||
|
||||
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; } |
||||
|
||||
virtual QByteArray serialize() const; |
||||
virtual bool deserialize(const QByteArray& data); |
||||
|
||||
virtual int webapiSettingsGet( |
||||
SWGSDRangel::SWGChannelSettings& response, |
||||
QString& errorMessage); |
||||
|
||||
virtual int webapiSettingsPutPatch( |
||||
bool force, |
||||
const QStringList& channelSettingsKeys, |
||||
SWGSDRangel::SWGChannelSettings& response, |
||||
QString& errorMessage); |
||||
|
||||
virtual int webapiReportGet( |
||||
SWGSDRangel::SWGChannelReport& response, |
||||
QString& errorMessage); |
||||
|
||||
uint32_t getAudioSampleRate() const { return m_audioSampleRate; } |
||||
double getMagSq() const { return m_magsq; } |
||||
|
||||
CWKeyer *getCWKeyer() { return &m_cwKeyer; } |
||||
|
||||
static const QString m_channelIdURI; |
||||
static const QString m_channelId; |
||||
|
||||
signals: |
||||
/**
|
||||
* Level changed |
||||
* \param rmsLevel RMS level in range 0.0 - 1.0 |
||||
* \param peakLevel Peak level in range 0.0 - 1.0 |
||||
* \param numSamples Number of audio samples analyzed |
||||
*/ |
||||
void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples); |
||||
|
||||
|
||||
private: |
||||
enum RateState { |
||||
RSInitialFill, |
||||
RSRunning |
||||
}; |
||||
|
||||
DeviceSinkAPI* m_deviceAPI; |
||||
ThreadedBasebandSampleSource* m_threadedChannelizer; |
||||
UpChannelizer* m_channelizer; |
||||
|
||||
int m_basebandSampleRate; |
||||
int m_outputSampleRate; |
||||
int m_inputFrequencyOffset; |
||||
FreeDVModSettings m_settings; |
||||
quint32 m_audioSampleRate; |
||||
|
||||
NCOF m_carrierNco; |
||||
NCOF m_toneNco; |
||||
Complex m_modSample; |
||||
Interpolator m_interpolator; |
||||
Real m_interpolatorDistance; |
||||
Real m_interpolatorDistanceRemain; |
||||
bool m_interpolatorConsumed; |
||||
fftfilt* m_SSBFilter; |
||||
fftfilt* m_DSBFilter; |
||||
Complex* m_SSBFilterBuffer; |
||||
Complex* m_DSBFilterBuffer; |
||||
int m_SSBFilterBufferIndex; |
||||
int m_DSBFilterBufferIndex; |
||||
static const int m_ssbFftLen; |
||||
|
||||
BasebandSampleSink* m_sampleSink; |
||||
SampleVector m_sampleBuffer; |
||||
|
||||
fftfilt::cmplx m_sum; |
||||
int m_undersampleCount; |
||||
int m_sumCount; |
||||
|
||||
double m_magsq; |
||||
MovingAverageUtil<double, double, 16> m_movingAverage; |
||||
|
||||
AudioVector m_audioBuffer; |
||||
uint m_audioBufferFill; |
||||
|
||||
AudioFifo m_audioFifo; |
||||
QMutex m_settingsMutex; |
||||
|
||||
std::ifstream m_ifstream; |
||||
QString m_fileName; |
||||
quint64 m_fileSize; //!< raw file size (bytes)
|
||||
quint32 m_recordLength; //!< record length in seconds computed from file size
|
||||
int m_sampleRate; |
||||
|
||||
quint32 m_levelCalcCount; |
||||
Real m_peakLevel; |
||||
Real m_levelSum; |
||||
CWKeyer m_cwKeyer; |
||||
|
||||
MagAGC m_inAGC; |
||||
int m_agcStepLength; |
||||
|
||||
QNetworkAccessManager *m_networkManager; |
||||
QNetworkRequest m_networkRequest; |
||||
|
||||
static const int m_levelNbSamples; |
||||
|
||||
void applyAudioSampleRate(int sampleRate); |
||||
void applyChannelSettings(int basebandSampleRate, int outputSampleRate, int inputFrequencyOffset, bool force = false); |
||||
void applySettings(const FreeDVModSettings& settings, bool force = false); |
||||
void pullAF(Complex& sample); |
||||
void calculateLevel(Complex& sample); |
||||
void modulateSample(); |
||||
void openFileStream(); |
||||
void seekFileStream(int seekPercentage); |
||||
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const FreeDVModSettings& settings); |
||||
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response); |
||||
void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const FreeDVModSettings& settings, bool force); |
||||
void webapiReverseSendCWSettings(const CWKeyerSettings& settings); |
||||
|
||||
private slots: |
||||
void networkManagerFinished(QNetworkReply *reply); |
||||
}; |
||||
|
||||
|
||||
#endif /* PLUGINS_CHANNELTX_MODFREEDV_FREEDVMOD_H_ */ |
||||
@ -0,0 +1,796 @@
@@ -0,0 +1,796 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2019 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 <QDockWidget> |
||||
#include <QMainWindow> |
||||
#include <QFileDialog> |
||||
#include <QTime> |
||||
#include <QDebug> |
||||
|
||||
#include "freedvmodgui.h" |
||||
|
||||
#include "device/devicesinkapi.h" |
||||
#include "device/deviceuiset.h" |
||||
#include "dsp/spectrumvis.h" |
||||
#include "ui_freedvmodgui.h" |
||||
#include "plugin/pluginapi.h" |
||||
#include "util/simpleserializer.h" |
||||
#include "util/db.h" |
||||
#include "dsp/dspengine.h" |
||||
#include "dsp/dspcommands.h" |
||||
#include "gui/crightclickenabler.h" |
||||
#include "gui/audioselectdialog.h" |
||||
#include "gui/basicchannelsettingsdialog.h" |
||||
#include "mainwindow.h" |
||||
|
||||
FreeDVModGUI* FreeDVModGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx) |
||||
{ |
||||
FreeDVModGUI* gui = new FreeDVModGUI(pluginAPI, deviceUISet, channelTx); |
||||
return gui; |
||||
} |
||||
|
||||
void FreeDVModGUI::destroy() |
||||
{ |
||||
delete this; |
||||
} |
||||
|
||||
void FreeDVModGUI::setName(const QString& name) |
||||
{ |
||||
setObjectName(name); |
||||
} |
||||
|
||||
QString FreeDVModGUI::getName() const |
||||
{ |
||||
return objectName(); |
||||
} |
||||
|
||||
qint64 FreeDVModGUI::getCenterFrequency() const { |
||||
return m_channelMarker.getCenterFrequency(); |
||||
} |
||||
|
||||
void FreeDVModGUI::setCenterFrequency(qint64 centerFrequency) |
||||
{ |
||||
m_channelMarker.setCenterFrequency(centerFrequency); |
||||
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency(); |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::resetToDefaults() |
||||
{ |
||||
m_settings.resetToDefaults(); |
||||
} |
||||
|
||||
QByteArray FreeDVModGUI::serialize() const |
||||
{ |
||||
return m_settings.serialize(); |
||||
} |
||||
|
||||
bool FreeDVModGUI::deserialize(const QByteArray& data) |
||||
{ |
||||
if(m_settings.deserialize(data)) |
||||
{ |
||||
qDebug("FreeDVModGUI::deserialize"); |
||||
displaySettings(); |
||||
applyBandwidths(5 - ui->spanLog2->value(), true); // does applySettings(true)
|
||||
return true; |
||||
} |
||||
else |
||||
{ |
||||
m_settings.resetToDefaults(); |
||||
displaySettings(); |
||||
applyBandwidths(5 - ui->spanLog2->value(), true); // does applySettings(true)
|
||||
return false; |
||||
} |
||||
} |
||||
|
||||
bool FreeDVModGUI::handleMessage(const Message& message) |
||||
{ |
||||
if (FreeDVMod::MsgReportFileSourceStreamData::match(message)) |
||||
{ |
||||
m_recordSampleRate = ((FreeDVMod::MsgReportFileSourceStreamData&)message).getSampleRate(); |
||||
m_recordLength = ((FreeDVMod::MsgReportFileSourceStreamData&)message).getRecordLength(); |
||||
m_samplesCount = 0; |
||||
updateWithStreamData(); |
||||
return true; |
||||
} |
||||
else if (FreeDVMod::MsgReportFileSourceStreamTiming::match(message)) |
||||
{ |
||||
m_samplesCount = ((FreeDVMod::MsgReportFileSourceStreamTiming&)message).getSamplesCount(); |
||||
updateWithStreamTime(); |
||||
return true; |
||||
} |
||||
else if (DSPConfigureAudio::match(message)) |
||||
{ |
||||
qDebug("FreeDVModGUI::handleMessage: DSPConfigureAudio: %d", m_freeDVMod->getAudioSampleRate()); |
||||
applyBandwidths(5 - ui->spanLog2->value()); // will update spectrum details with new sample rate
|
||||
return true; |
||||
} |
||||
else if (FreeDVMod::MsgConfigureFreeDVMod::match(message)) |
||||
{ |
||||
const FreeDVMod::MsgConfigureFreeDVMod& cfg = (FreeDVMod::MsgConfigureFreeDVMod&) message; |
||||
m_settings = cfg.getSettings(); |
||||
blockApplySettings(true); |
||||
displaySettings(); |
||||
blockApplySettings(false); |
||||
return true; |
||||
} |
||||
else if (CWKeyer::MsgConfigureCWKeyer::match(message)) |
||||
{ |
||||
const CWKeyer::MsgConfigureCWKeyer& cfg = (CWKeyer::MsgConfigureCWKeyer&) message; |
||||
ui->cwKeyerGUI->displaySettings(cfg.getSettings()); |
||||
return true; |
||||
} |
||||
else |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
void FreeDVModGUI::channelMarkerChangedByCursor() |
||||
{ |
||||
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency()); |
||||
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency(); |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::channelMarkerUpdate() |
||||
{ |
||||
m_settings.m_rgbColor = m_channelMarker.getColor().rgb(); |
||||
displaySettings(); |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::handleSourceMessages() |
||||
{ |
||||
Message* message; |
||||
|
||||
while ((message = getInputMessageQueue()->pop()) != 0) |
||||
{ |
||||
if (handleMessage(*message)) |
||||
{ |
||||
delete message; |
||||
} |
||||
} |
||||
} |
||||
|
||||
void FreeDVModGUI::on_deltaFrequency_changed(qint64 value) |
||||
{ |
||||
m_channelMarker.setCenterFrequency(value); |
||||
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency(); |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_flipSidebands_clicked(bool checked) |
||||
{ |
||||
(void) checked; |
||||
int bwValue = ui->BW->value(); |
||||
int lcValue = ui->lowCut->value(); |
||||
ui->BW->setValue(-bwValue); |
||||
ui->lowCut->setValue(-lcValue); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_dsb_toggled(bool dsb) |
||||
{ |
||||
ui->flipSidebands->setEnabled(!dsb); |
||||
applyBandwidths(5 - ui->spanLog2->value()); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_audioBinaural_toggled(bool checked) |
||||
{ |
||||
m_settings.m_audioBinaural = checked; |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_audioFlipChannels_toggled(bool checked) |
||||
{ |
||||
m_settings.m_audioFlipChannels = checked; |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_spanLog2_valueChanged(int value) |
||||
{ |
||||
if ((value < 0) || (value > 4)) { |
||||
return; |
||||
} |
||||
|
||||
applyBandwidths(5 - value); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_BW_valueChanged(int value) |
||||
{ |
||||
(void) value; |
||||
applyBandwidths(5 - ui->spanLog2->value()); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_lowCut_valueChanged(int value) |
||||
{ |
||||
(void) value; |
||||
applyBandwidths(5 - ui->spanLog2->value()); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_toneFrequency_valueChanged(int value) |
||||
{ |
||||
ui->toneFrequencyText->setText(QString("%1k").arg(value / 100.0, 0, 'f', 2)); |
||||
m_settings.m_toneFrequency = value * 10.0; |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_volume_valueChanged(int value) |
||||
{ |
||||
ui->volumeText->setText(QString("%1").arg(value / 10.0, 0, 'f', 1)); |
||||
m_settings.m_volumeFactor = value / 10.0; |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_audioMute_toggled(bool checked) |
||||
{ |
||||
m_settings.m_audioMute = checked; |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_playLoop_toggled(bool checked) |
||||
{ |
||||
m_settings.m_playLoop = checked; |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_play_toggled(bool checked) |
||||
{ |
||||
ui->tone->setEnabled(!checked); // release other source inputs
|
||||
ui->morseKeyer->setEnabled(!checked); |
||||
ui->mic->setEnabled(!checked); |
||||
m_settings.m_modAFInput = checked ? FreeDVModSettings::FreeDVModInputFile : FreeDVModSettings::FreeDVModInputNone; |
||||
applySettings(); |
||||
ui->navTimeSlider->setEnabled(!checked); |
||||
m_enableNavTime = !checked; |
||||
} |
||||
|
||||
void FreeDVModGUI::on_tone_toggled(bool checked) |
||||
{ |
||||
ui->play->setEnabled(!checked); // release other source inputs
|
||||
ui->morseKeyer->setEnabled(!checked); |
||||
ui->mic->setEnabled(!checked); |
||||
m_settings.m_modAFInput = checked ? FreeDVModSettings::FreeDVModInputTone : FreeDVModSettings::FreeDVModInputNone; |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_morseKeyer_toggled(bool checked) |
||||
{ |
||||
ui->play->setEnabled(!checked); // release other source inputs
|
||||
ui->tone->setEnabled(!checked); // release other source inputs
|
||||
ui->mic->setEnabled(!checked); |
||||
m_settings.m_modAFInput = checked ? FreeDVModSettings::FreeDVModInputCWTone : FreeDVModSettings::FreeDVModInputNone; |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_mic_toggled(bool checked) |
||||
{ |
||||
ui->play->setEnabled(!checked); // release other source inputs
|
||||
ui->morseKeyer->setEnabled(!checked); |
||||
ui->tone->setEnabled(!checked); // release other source inputs
|
||||
m_settings.m_modAFInput = checked ? FreeDVModSettings::FreeDVModInputAudio : FreeDVModSettings::FreeDVModInputNone; |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_agc_toggled(bool checked) |
||||
{ |
||||
m_settings.m_agc = checked; |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_agcOrder_valueChanged(int value){ |
||||
QString s = QString::number(value / 100.0, 'f', 2); |
||||
ui->agcOrderText->setText(s); |
||||
m_settings.m_agcOrder = value / 100.0; |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_agcTime_valueChanged(int value){ |
||||
QString s = QString::number(FreeDVModSettings::getAGCTimeConstant(value), 'f', 0); |
||||
ui->agcTimeText->setText(s); |
||||
m_settings.m_agcTime = FreeDVModSettings::getAGCTimeConstant(value) * 48; |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_agcThreshold_valueChanged(int value) |
||||
{ |
||||
m_settings.m_agcThreshold = value; // dB
|
||||
displayAGCPowerThreshold(); |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_agcThresholdGate_valueChanged(int value) |
||||
{ |
||||
QString s = QString::number(value, 'f', 0); |
||||
ui->agcThresholdGateText->setText(s); |
||||
m_settings.m_agcThresholdGate = value * 48; |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_agcThresholdDelay_valueChanged(int value) |
||||
{ |
||||
QString s = QString::number(value * 10, 'f', 0); |
||||
ui->agcThresholdDelayText->setText(s); |
||||
m_settings.m_agcThresholdDelay = value * 480; |
||||
applySettings(); |
||||
} |
||||
|
||||
void FreeDVModGUI::on_navTimeSlider_valueChanged(int value) |
||||
{ |
||||
if (m_enableNavTime && ((value >= 0) && (value <= 100))) |
||||
{ |
||||
int t_sec = (m_recordLength * value) / 100; |
||||
QTime t(0, 0, 0, 0); |
||||
t = t.addSecs(t_sec); |
||||
|
||||
FreeDVMod::MsgConfigureFileSourceSeek* message = FreeDVMod::MsgConfigureFileSourceSeek::create(value); |
||||
m_freeDVMod->getInputMessageQueue()->push(message); |
||||
} |
||||
} |
||||
|
||||
void FreeDVModGUI::on_showFileDialog_clicked(bool checked) |
||||
{ |
||||
(void) checked; |
||||
QString fileName = QFileDialog::getOpenFileName(this, |
||||
tr("Open raw audio file"), ".", tr("Raw audio Files (*.raw)"), 0, QFileDialog::DontUseNativeDialog); |
||||
|
||||
if (fileName != "") |
||||
{ |
||||
m_fileName = fileName; |
||||
ui->recordFileText->setText(m_fileName); |
||||
ui->play->setEnabled(true); |
||||
configureFileName(); |
||||
} |
||||
} |
||||
|
||||
void FreeDVModGUI::configureFileName() |
||||
{ |
||||
qDebug() << "FileSourceGui::configureFileName: " << m_fileName.toStdString().c_str(); |
||||
FreeDVMod::MsgConfigureFileSourceName* message = FreeDVMod::MsgConfigureFileSourceName::create(m_fileName); |
||||
m_freeDVMod->getInputMessageQueue()->push(message); |
||||
} |
||||
|
||||
void FreeDVModGUI::onWidgetRolled(QWidget* widget, bool rollDown) |
||||
{ |
||||
(void) widget; |
||||
(void) rollDown; |
||||
} |
||||
|
||||
void FreeDVModGUI::onMenuDialogCalled(const QPoint &p) |
||||
{ |
||||
BasicChannelSettingsDialog dialog(&m_channelMarker, this); |
||||
dialog.setUseReverseAPI(m_settings.m_useReverseAPI); |
||||
dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress); |
||||
dialog.setReverseAPIPort(m_settings.m_reverseAPIPort); |
||||
dialog.setReverseAPIDeviceIndex(m_settings.m_reverseAPIDeviceIndex); |
||||
dialog.setReverseAPIChannelIndex(m_settings.m_reverseAPIChannelIndex); |
||||
|
||||
dialog.move(p); |
||||
dialog.exec(); |
||||
|
||||
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency(); |
||||
m_settings.m_rgbColor = m_channelMarker.getColor().rgb(); |
||||
m_settings.m_title = m_channelMarker.getTitle(); |
||||
m_settings.m_useReverseAPI = dialog.useReverseAPI(); |
||||
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress(); |
||||
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort(); |
||||
m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex(); |
||||
m_settings.m_reverseAPIChannelIndex = dialog.getReverseAPIChannelIndex(); |
||||
|
||||
setWindowTitle(m_settings.m_title); |
||||
setTitleColor(m_settings.m_rgbColor); |
||||
|
||||
applySettings(); |
||||
} |
||||
|
||||
FreeDVModGUI::FreeDVModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx, QWidget* parent) : |
||||
RollupWidget(parent), |
||||
ui(new Ui::FreeDVModGUI), |
||||
m_pluginAPI(pluginAPI), |
||||
m_deviceUISet(deviceUISet), |
||||
m_channelMarker(this), |
||||
m_doApplySettings(true), |
||||
m_spectrumRate(6000), |
||||
m_recordLength(0), |
||||
m_recordSampleRate(48000), |
||||
m_samplesCount(0), |
||||
m_tickCount(0), |
||||
m_enableNavTime(false) |
||||
{ |
||||
ui->setupUi(this); |
||||
setAttribute(Qt::WA_DeleteOnClose, true); |
||||
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); |
||||
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &))); |
||||
|
||||
m_spectrumVis = new SpectrumVis(SDR_TX_SCALEF, ui->glSpectrum); |
||||
m_freeDVMod = (FreeDVMod*) channelTx; |
||||
m_freeDVMod->setSpectrumSampleSink(m_spectrumVis); |
||||
m_freeDVMod->setMessageQueueToGUI(getInputMessageQueue()); |
||||
|
||||
resetToDefaults(); |
||||
|
||||
ui->glSpectrum->setCenterFrequency(m_spectrumRate/2); |
||||
ui->glSpectrum->setSampleRate(m_spectrumRate); |
||||
ui->glSpectrum->setDisplayWaterfall(true); |
||||
ui->glSpectrum->setDisplayMaxHold(true); |
||||
ui->glSpectrum->setSsbSpectrum(true); |
||||
ui->glSpectrum->connectTimer(MainWindow::getInstance()->getMasterTimer()); |
||||
|
||||
connect(&MainWindow::getInstance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); |
||||
|
||||
CRightClickEnabler *audioMuteRightClickEnabler = new CRightClickEnabler(ui->mic); |
||||
connect(audioMuteRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(audioSelect())); |
||||
|
||||
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03))); |
||||
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); |
||||
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999); |
||||
|
||||
m_channelMarker.blockSignals(true); |
||||
m_channelMarker.setColor(Qt::darkCyan); |
||||
m_channelMarker.setBandwidth(m_spectrumRate); |
||||
m_channelMarker.setSidebands(ChannelMarker::usb); |
||||
m_channelMarker.setCenterFrequency(0); |
||||
m_channelMarker.setTitle("FreeDV Modulator"); |
||||
m_channelMarker.blockSignals(false); |
||||
m_channelMarker.setVisible(true); |
||||
|
||||
setTitleColor(m_channelMarker.getColor()); |
||||
|
||||
m_deviceUISet->registerTxChannelInstance(FreeDVMod::m_channelIdURI, this); |
||||
m_deviceUISet->addChannelMarker(&m_channelMarker); |
||||
m_deviceUISet->addRollupWidget(this); |
||||
|
||||
connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(channelMarkerChangedByCursor())); |
||||
|
||||
ui->cwKeyerGUI->setBuddies(m_freeDVMod->getInputMessageQueue(), m_freeDVMod->getCWKeyer()); |
||||
ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum); |
||||
|
||||
m_settings.setChannelMarker(&m_channelMarker); |
||||
m_settings.setSpectrumGUI(ui->spectrumGUI); |
||||
m_settings.setCWKeyerGUI(ui->cwKeyerGUI); |
||||
|
||||
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages())); |
||||
connect(m_freeDVMod, SIGNAL(levelChanged(qreal, qreal, int)), ui->volumeMeter, SLOT(levelChanged(qreal, qreal, int))); |
||||
|
||||
m_iconDSBUSB.addPixmap(QPixmap("://dsb.png"), QIcon::Normal, QIcon::On); |
||||
m_iconDSBUSB.addPixmap(QPixmap("://usb.png"), QIcon::Normal, QIcon::Off); |
||||
m_iconDSBLSB.addPixmap(QPixmap("://dsb.png"), QIcon::Normal, QIcon::On); |
||||
m_iconDSBLSB.addPixmap(QPixmap("://lsb.png"), QIcon::Normal, QIcon::Off); |
||||
|
||||
displaySettings(); |
||||
applyBandwidths(5 - ui->spanLog2->value(), true); // does applySettings(true)
|
||||
} |
||||
|
||||
FreeDVModGUI::~FreeDVModGUI() |
||||
{ |
||||
m_deviceUISet->removeTxChannelInstance(this); |
||||
delete m_freeDVMod; // TODO: check this: when the GUI closes it has to delete the modulator
|
||||
delete m_spectrumVis; |
||||
delete ui; |
||||
} |
||||
|
||||
bool FreeDVModGUI::blockApplySettings(bool block) |
||||
{ |
||||
bool ret = !m_doApplySettings; |
||||
m_doApplySettings = !block; |
||||
return ret; |
||||
} |
||||
|
||||
void FreeDVModGUI::applySettings(bool force) |
||||
{ |
||||
if (m_doApplySettings) |
||||
{ |
||||
FreeDVMod::MsgConfigureChannelizer *msgChan = FreeDVMod::MsgConfigureChannelizer::create( |
||||
48000, m_settings.m_inputFrequencyOffset); |
||||
m_freeDVMod->getInputMessageQueue()->push(msgChan); |
||||
|
||||
FreeDVMod::MsgConfigureFreeDVMod *msg = FreeDVMod::MsgConfigureFreeDVMod::create(m_settings, force); |
||||
m_freeDVMod->getInputMessageQueue()->push(msg); |
||||
} |
||||
} |
||||
|
||||
void FreeDVModGUI::applyBandwidths(int spanLog2, bool force) |
||||
{ |
||||
bool dsb = ui->dsb->isChecked(); |
||||
m_spectrumRate = m_freeDVMod->getAudioSampleRate() / (1<<spanLog2); |
||||
int bw = ui->BW->value(); |
||||
int lw = ui->lowCut->value(); |
||||
int bwMax = m_freeDVMod->getAudioSampleRate() / (100*(1<<spanLog2)); |
||||
int tickInterval = m_spectrumRate / 1200; |
||||
tickInterval = tickInterval == 0 ? 1 : tickInterval; |
||||
|
||||
qDebug() << "FreeDVModGUI::applyBandwidths:" |
||||
<< " dsb: " << dsb |
||||
<< " spanLog2: " << spanLog2 |
||||
<< " m_spectrumRate: " << m_spectrumRate |
||||
<< " bw: " << bw |
||||
<< " lw: " << lw |
||||
<< " bwMax: " << bwMax |
||||
<< " tickInterval: " << tickInterval; |
||||
|
||||
ui->BW->setTickInterval(tickInterval); |
||||
ui->lowCut->setTickInterval(tickInterval); |
||||
|
||||
bw = bw < -bwMax ? -bwMax : bw > bwMax ? bwMax : bw; |
||||
|
||||
if (bw < 0) { |
||||
lw = lw < bw+1 ? bw+1 : lw < 0 ? lw : 0; |
||||
} else if (bw > 0) { |
||||
lw = lw > bw-1 ? bw-1 : lw < 0 ? 0 : lw; |
||||
} else { |
||||
lw = 0; |
||||
} |
||||
|
||||
if (dsb) |
||||
{ |
||||
bw = bw < 0 ? -bw : bw; |
||||
lw = 0; |
||||
} |
||||
|
||||
QString spanStr = QString::number(bwMax/10.0, 'f', 1); |
||||
QString bwStr = QString::number(bw/10.0, 'f', 1); |
||||
QString lwStr = QString::number(lw/10.0, 'f', 1); |
||||
|
||||
if (dsb) |
||||
{ |
||||
ui->BWText->setText(tr("%1%2k").arg(QChar(0xB1, 0x00)).arg(bwStr)); |
||||
ui->spanText->setText(tr("%1%2k").arg(QChar(0xB1, 0x00)).arg(spanStr)); |
||||
ui->scaleMinus->setText("0"); |
||||
ui->scaleCenter->setText(""); |
||||
ui->scalePlus->setText(tr("%1").arg(QChar(0xB1, 0x00))); |
||||
ui->lsbLabel->setText(""); |
||||
ui->usbLabel->setText(""); |
||||
ui->glSpectrum->setCenterFrequency(0); |
||||
ui->glSpectrum->setSampleRate(2*m_spectrumRate); |
||||
ui->glSpectrum->setSsbSpectrum(false); |
||||
ui->glSpectrum->setLsbDisplay(false); |
||||
} |
||||
else |
||||
{ |
||||
ui->BWText->setText(tr("%1k").arg(bwStr)); |
||||
ui->spanText->setText(tr("%1k").arg(spanStr)); |
||||
ui->scaleMinus->setText("-"); |
||||
ui->scaleCenter->setText("0"); |
||||
ui->scalePlus->setText("+"); |
||||
ui->lsbLabel->setText("LSB"); |
||||
ui->usbLabel->setText("USB"); |
||||
ui->glSpectrum->setCenterFrequency(m_spectrumRate/2); |
||||
ui->glSpectrum->setSampleRate(m_spectrumRate); |
||||
ui->glSpectrum->setSsbSpectrum(true); |
||||
ui->glSpectrum->setLsbDisplay(bw < 0); |
||||
} |
||||
|
||||
ui->lowCutText->setText(tr("%1k").arg(lwStr)); |
||||
|
||||
|
||||
ui->BW->blockSignals(true); |
||||
ui->lowCut->blockSignals(true); |
||||
|
||||
ui->BW->setMaximum(bwMax); |
||||
ui->BW->setMinimum(dsb ? 0 : -bwMax); |
||||
ui->BW->setValue(bw); |
||||
|
||||
ui->lowCut->setMaximum(dsb ? 0 : bwMax); |
||||
ui->lowCut->setMinimum(dsb ? 0 : -bwMax); |
||||
ui->lowCut->setValue(lw); |
||||
|
||||
ui->lowCut->blockSignals(false); |
||||
ui->BW->blockSignals(false); |
||||
|
||||
|
||||
m_settings.m_dsb = dsb; |
||||
m_settings.m_spanLog2 = spanLog2; |
||||
m_settings.m_bandwidth = bw * 100; |
||||
m_settings.m_lowCutoff = lw * 100; |
||||
|
||||
applySettings(force); |
||||
|
||||
bool applySettingsWereBlocked = blockApplySettings(true); |
||||
m_channelMarker.setBandwidth(bw * 200); |
||||
m_channelMarker.setSidebands(dsb ? ChannelMarker::dsb : bw < 0 ? ChannelMarker::lsb : ChannelMarker::usb); |
||||
ui->dsb->setIcon(bw < 0 ? m_iconDSBLSB : m_iconDSBUSB); |
||||
if (!dsb) { m_channelMarker.setLowCutoff(lw * 100); } |
||||
blockApplySettings(applySettingsWereBlocked); |
||||
} |
||||
|
||||
void FreeDVModGUI::displaySettings() |
||||
{ |
||||
m_channelMarker.blockSignals(true); |
||||
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset); |
||||
m_channelMarker.setTitle(m_settings.m_title); |
||||
m_channelMarker.setBandwidth(m_settings.m_bandwidth * 2); |
||||
m_channelMarker.setLowCutoff(m_settings.m_lowCutoff); |
||||
|
||||
ui->flipSidebands->setEnabled(!m_settings.m_dsb); |
||||
|
||||
if (m_settings.m_dsb) { |
||||
m_channelMarker.setSidebands(ChannelMarker::dsb); |
||||
} else { |
||||
if (m_settings.m_bandwidth < 0) { |
||||
m_channelMarker.setSidebands(ChannelMarker::lsb); |
||||
ui->dsb->setIcon(m_iconDSBLSB); |
||||
} else { |
||||
m_channelMarker.setSidebands(ChannelMarker::usb); |
||||
ui->dsb->setIcon(m_iconDSBUSB); |
||||
} |
||||
} |
||||
|
||||
m_channelMarker.blockSignals(false); |
||||
m_channelMarker.setColor(m_settings.m_rgbColor); |
||||
|
||||
setTitleColor(m_settings.m_rgbColor); |
||||
setWindowTitle(m_channelMarker.getTitle()); |
||||
|
||||
blockApplySettings(true); |
||||
|
||||
QString s = QString::number(m_settings.m_agcTime / 48, 'f', 0); |
||||
ui->agcTimeText->setText(s); |
||||
ui->agcTime->setValue(FreeDVModSettings::getAGCTimeConstantIndex(m_settings.m_agcTime / 48)); |
||||
displayAGCPowerThreshold(); |
||||
s = QString::number(m_settings.m_agcThresholdGate / 48, 'f', 0); |
||||
ui->agcThresholdGateText->setText(s); |
||||
ui->agcThresholdGate->setValue(m_settings.m_agcThresholdGate / 48); |
||||
s = QString::number(m_settings.m_agcThresholdDelay / 48, 'f', 0); |
||||
ui->agcThresholdDelayText->setText(s); |
||||
ui->agcThresholdDelay->setValue(m_settings.m_agcThresholdDelay / 480); |
||||
s = QString::number(m_settings.m_agcOrder, 'f', 2); |
||||
ui->agcOrderText->setText(s); |
||||
ui->agcOrder->setValue(roundf(m_settings.m_agcOrder * 100.0)); |
||||
|
||||
ui->agc->setChecked(m_settings.m_agc); |
||||
ui->audioBinaural->setChecked(m_settings.m_audioBinaural); |
||||
ui->audioFlipChannels->setChecked(m_settings.m_audioFlipChannels); |
||||
ui->audioMute->setChecked(m_settings.m_audioMute); |
||||
ui->playLoop->setChecked(m_settings.m_playLoop); |
||||
|
||||
// Prevent uncontrolled triggering of applyBandwidths
|
||||
ui->spanLog2->blockSignals(true); |
||||
ui->dsb->blockSignals(true); |
||||
ui->BW->blockSignals(true); |
||||
|
||||
ui->dsb->setChecked(m_settings.m_dsb); |
||||
ui->spanLog2->setValue(5 - m_settings.m_spanLog2); |
||||
|
||||
ui->BW->setValue(roundf(m_settings.m_bandwidth/100.0)); |
||||
s = QString::number(m_settings.m_bandwidth/1000.0, 'f', 1); |
||||
|
||||
if (m_settings.m_dsb) |
||||
{ |
||||
ui->BWText->setText(tr("%1%2k").arg(QChar(0xB1, 0x00)).arg(s)); |
||||
} |
||||
else |
||||
{ |
||||
ui->BWText->setText(tr("%1k").arg(s)); |
||||
} |
||||
|
||||
ui->spanLog2->blockSignals(false); |
||||
ui->dsb->blockSignals(false); |
||||
ui->BW->blockSignals(false); |
||||
|
||||
// The only one of the four signals triggering applyBandwidths will trigger it once only with all other values
|
||||
// set correctly and therefore validate the settings and apply them to dependent widgets
|
||||
ui->lowCut->setValue(m_settings.m_lowCutoff / 100.0); |
||||
ui->lowCutText->setText(tr("%1k").arg(m_settings.m_lowCutoff / 1000.0)); |
||||
|
||||
ui->deltaFrequency->setValue(m_settings.m_inputFrequencyOffset); |
||||
|
||||
ui->toneFrequency->setValue(roundf(m_settings.m_toneFrequency / 10.0)); |
||||
ui->toneFrequencyText->setText(QString("%1k").arg(m_settings.m_toneFrequency / 1000.0, 0, 'f', 2)); |
||||
|
||||
ui->volume->setValue(m_settings.m_volumeFactor * 10.0); |
||||
ui->volumeText->setText(QString("%1").arg(m_settings.m_volumeFactor, 0, 'f', 1)); |
||||
|
||||
ui->tone->setEnabled((m_settings.m_modAFInput == FreeDVModSettings::FreeDVModInputAF::FreeDVModInputTone) |
||||
|| (m_settings.m_modAFInput == FreeDVModSettings::FreeDVModInputAF::FreeDVModInputNone)); |
||||
ui->mic->setEnabled((m_settings.m_modAFInput == FreeDVModSettings::FreeDVModInputAF::FreeDVModInputAudio) |
||||
|| (m_settings.m_modAFInput == FreeDVModSettings::FreeDVModInputAF::FreeDVModInputNone)); |
||||
ui->play->setEnabled((m_settings.m_modAFInput == FreeDVModSettings::FreeDVModInputAF::FreeDVModInputFile) |
||||
|| (m_settings.m_modAFInput == FreeDVModSettings::FreeDVModInputAF::FreeDVModInputNone)); |
||||
ui->morseKeyer->setEnabled((m_settings.m_modAFInput == FreeDVModSettings::FreeDVModInputAF::FreeDVModInputCWTone) |
||||
|| (m_settings.m_modAFInput == FreeDVModSettings::FreeDVModInputAF::FreeDVModInputNone)); |
||||
|
||||
ui->tone->setChecked(m_settings.m_modAFInput == FreeDVModSettings::FreeDVModInputAF::FreeDVModInputTone); |
||||
ui->mic->setChecked(m_settings.m_modAFInput == FreeDVModSettings::FreeDVModInputAF::FreeDVModInputAudio); |
||||
ui->play->setChecked(m_settings.m_modAFInput == FreeDVModSettings::FreeDVModInputAF::FreeDVModInputFile); |
||||
ui->morseKeyer->setChecked(m_settings.m_modAFInput == FreeDVModSettings::FreeDVModInputAF::FreeDVModInputCWTone); |
||||
|
||||
blockApplySettings(false); |
||||
} |
||||
|
||||
void FreeDVModGUI::displayAGCPowerThreshold() |
||||
{ |
||||
if (m_settings.m_agcThreshold == -99) |
||||
{ |
||||
ui->agcThresholdText->setText("---"); |
||||
} |
||||
else |
||||
{ |
||||
QString s = QString::number(m_settings.m_agcThreshold, 'f', 0); |
||||
ui->agcThresholdText->setText(s); |
||||
} |
||||
|
||||
ui->agcThreshold->setValue(m_settings.m_agcThreshold); |
||||
} |
||||
|
||||
void FreeDVModGUI::leaveEvent(QEvent*) |
||||
{ |
||||
m_channelMarker.setHighlighted(false); |
||||
} |
||||
|
||||
void FreeDVModGUI::enterEvent(QEvent*) |
||||
{ |
||||
m_channelMarker.setHighlighted(true); |
||||
} |
||||
|
||||
void FreeDVModGUI::audioSelect() |
||||
{ |
||||
qDebug("FreeDVModGUI::audioSelect"); |
||||
AudioSelectDialog audioSelect(DSPEngine::instance()->getAudioDeviceManager(), m_settings.m_audioDeviceName, true); // true for input
|
||||
audioSelect.exec(); |
||||
|
||||
if (audioSelect.m_selected) |
||||
{ |
||||
m_settings.m_audioDeviceName = audioSelect.m_audioDeviceName; |
||||
applySettings(); |
||||
} |
||||
} |
||||
|
||||
void FreeDVModGUI::tick() |
||||
{ |
||||
double powDb = CalcDb::dbPower(m_freeDVMod->getMagSq()); |
||||
m_channelPowerDbAvg(powDb); |
||||
ui->channelPower->setText(tr("%1 dB").arg(m_channelPowerDbAvg.asDouble(), 0, 'f', 1)); |
||||
|
||||
if (((++m_tickCount & 0xf) == 0) && (m_settings.m_modAFInput == FreeDVModSettings::FreeDVModInputFile)) |
||||
{ |
||||
FreeDVMod::MsgConfigureFileSourceStreamTiming* message = FreeDVMod::MsgConfigureFileSourceStreamTiming::create(); |
||||
m_freeDVMod->getInputMessageQueue()->push(message); |
||||
} |
||||
} |
||||
|
||||
void FreeDVModGUI::updateWithStreamData() |
||||
{ |
||||
QTime recordLength(0, 0, 0, 0); |
||||
recordLength = recordLength.addSecs(m_recordLength); |
||||
QString s_time = recordLength.toString("HH:mm:ss"); |
||||
ui->recordLengthText->setText(s_time); |
||||
updateWithStreamTime(); |
||||
} |
||||
|
||||
void FreeDVModGUI::updateWithStreamTime() |
||||
{ |
||||
int t_sec = 0; |
||||
int t_msec = 0; |
||||
|
||||
if (m_recordSampleRate > 0) |
||||
{ |
||||
t_msec = ((m_samplesCount * 1000) / m_recordSampleRate) % 1000; |
||||
t_sec = m_samplesCount / m_recordSampleRate; |
||||
} |
||||
|
||||
QTime t(0, 0, 0, 0); |
||||
t = t.addSecs(t_sec); |
||||
t = t.addMSecs(t_msec); |
||||
QString s_timems = t.toString("HH:mm:ss.zzz"); |
||||
QString s_time = t.toString("HH:mm:ss"); |
||||
ui->relTimeText->setText(s_timems); |
||||
|
||||
if (!m_enableNavTime) |
||||
{ |
||||
float posRatio = (float) t_sec / (float) m_recordLength; |
||||
ui->navTimeSlider->setValue((int) (posRatio * 100.0)); |
||||
} |
||||
} |
||||
@ -0,0 +1,136 @@
@@ -0,0 +1,136 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2019 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PLUGINS_CHANNELTX_MODFREEDV_FREEDVMODGUI_H_ |
||||
#define PLUGINS_CHANNELTX_MODFREEDV_FREEDVMODGUI_H_ |
||||
|
||||
#include <QIcon> |
||||
|
||||
#include <plugin/plugininstancegui.h> |
||||
#include "gui/rollupwidget.h" |
||||
#include "dsp/channelmarker.h" |
||||
#include "util/movingaverage.h" |
||||
#include "util/messagequeue.h" |
||||
|
||||
#include "freedvmod.h" |
||||
#include "freedvmodsettings.h" |
||||
|
||||
class PluginAPI; |
||||
class DeviceUISet; |
||||
class BasebandSampleSource; |
||||
class SpectrumVis; |
||||
|
||||
namespace Ui { |
||||
class FreeDVModGUI; |
||||
} |
||||
|
||||
class FreeDVModGUI : public RollupWidget, public PluginInstanceGUI { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
static FreeDVModGUI* create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx); |
||||
virtual void destroy(); |
||||
|
||||
void setName(const QString& name); |
||||
QString getName() const; |
||||
virtual qint64 getCenterFrequency() const; |
||||
virtual void setCenterFrequency(qint64 centerFrequency); |
||||
|
||||
void resetToDefaults(); |
||||
QByteArray serialize() const; |
||||
bool deserialize(const QByteArray& data); |
||||
virtual MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } |
||||
virtual bool handleMessage(const Message& message); |
||||
|
||||
public slots: |
||||
void channelMarkerChangedByCursor(); |
||||
|
||||
private: |
||||
Ui::FreeDVModGUI* ui; |
||||
PluginAPI* m_pluginAPI; |
||||
DeviceUISet* m_deviceUISet; |
||||
ChannelMarker m_channelMarker; |
||||
FreeDVModSettings m_settings; |
||||
bool m_doApplySettings; |
||||
int m_spectrumRate; |
||||
|
||||
SpectrumVis* m_spectrumVis; |
||||
FreeDVMod* m_freeDVMod; |
||||
MovingAverageUtil<double, double, 20> m_channelPowerDbAvg; |
||||
|
||||
QString m_fileName; |
||||
quint32 m_recordLength; |
||||
int m_recordSampleRate; |
||||
int m_samplesCount; |
||||
std::size_t m_tickCount; |
||||
bool m_enableNavTime; |
||||
MessageQueue m_inputMessageQueue; |
||||
|
||||
QIcon m_iconDSBUSB; |
||||
QIcon m_iconDSBLSB; |
||||
|
||||
explicit FreeDVModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx, QWidget* parent = 0); |
||||
virtual ~FreeDVModGUI(); |
||||
|
||||
bool blockApplySettings(bool block); |
||||
void applySettings(bool force = false); |
||||
void applyBandwidths(int spanLog2, bool force = false); |
||||
void displaySettings(); |
||||
void displayAGCPowerThreshold(); |
||||
void updateWithStreamData(); |
||||
void updateWithStreamTime(); |
||||
void channelMarkerUpdate(); |
||||
|
||||
void leaveEvent(QEvent*); |
||||
void enterEvent(QEvent*); |
||||
|
||||
private slots: |
||||
void handleSourceMessages(); |
||||
void on_deltaFrequency_changed(qint64 value); |
||||
void on_flipSidebands_clicked(bool checked); |
||||
void on_dsb_toggled(bool checked); |
||||
void on_audioBinaural_toggled(bool checked); |
||||
void on_audioFlipChannels_toggled(bool checked); |
||||
void on_spanLog2_valueChanged(int value); |
||||
void on_BW_valueChanged(int value); |
||||
void on_lowCut_valueChanged(int value); |
||||
void on_volume_valueChanged(int value); |
||||
void on_audioMute_toggled(bool checked); |
||||
void on_tone_toggled(bool checked); |
||||
void on_toneFrequency_valueChanged(int value); |
||||
void on_mic_toggled(bool checked); |
||||
void on_agc_toggled(bool checked); |
||||
void on_agcOrder_valueChanged(int value); |
||||
void on_agcTime_valueChanged(int value); |
||||
void on_agcThreshold_valueChanged(int value); |
||||
void on_agcThresholdGate_valueChanged(int value); |
||||
void on_agcThresholdDelay_valueChanged(int value); |
||||
void on_play_toggled(bool checked); |
||||
void on_playLoop_toggled(bool checked); |
||||
void on_morseKeyer_toggled(bool checked); |
||||
|
||||
void on_navTimeSlider_valueChanged(int value); |
||||
void on_showFileDialog_clicked(bool checked); |
||||
|
||||
void onWidgetRolled(QWidget* widget, bool rollDown); |
||||
void onMenuDialogCalled(const QPoint& p); |
||||
|
||||
void configureFileName(); |
||||
void audioSelect(); |
||||
void tick(); |
||||
}; |
||||
|
||||
#endif /* PLUGINS_CHANNELTX_MODFREEDV_FREEDVMODGUI_H_ */ |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,78 @@
@@ -0,0 +1,78 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2019 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 <QtPlugin> |
||||
#include "plugin/pluginapi.h" |
||||
|
||||
#ifndef SERVER_MODE |
||||
#include "freedvmodgui.h" |
||||
#endif |
||||
#include "freedvmod.h" |
||||
#include "freedvmodplugin.h" |
||||
|
||||
const PluginDescriptor FreeDVModPlugin::m_pluginDescriptor = { |
||||
QString("SSB Modulator"), |
||||
QString("4.5.0"), |
||||
QString("(c) Edouard Griffiths, F4EXB"), |
||||
QString("https://github.com/f4exb/sdrangel"), |
||||
true, |
||||
QString("https://github.com/f4exb/sdrangel") |
||||
}; |
||||
|
||||
FreeDVModPlugin::FreeDVModPlugin(QObject* parent) : |
||||
QObject(parent), |
||||
m_pluginAPI(0) |
||||
{ |
||||
} |
||||
|
||||
const PluginDescriptor& FreeDVModPlugin::getPluginDescriptor() const |
||||
{ |
||||
return m_pluginDescriptor; |
||||
} |
||||
|
||||
void FreeDVModPlugin::initPlugin(PluginAPI* pluginAPI) |
||||
{ |
||||
m_pluginAPI = pluginAPI; |
||||
|
||||
// register FreeDV modulator
|
||||
m_pluginAPI->registerTxChannel(FreeDVMod::m_channelIdURI, FreeDVMod::m_channelId, this); |
||||
} |
||||
|
||||
#ifdef SERVER_MODE |
||||
PluginInstanceGUI* FreeDVModPlugin::createTxChannelGUI( |
||||
DeviceUISet *deviceUISet __attribute__((unused)), |
||||
BasebandSampleSource *txChannel __attribute__((unused))) |
||||
{ |
||||
return 0; |
||||
} |
||||
#else |
||||
PluginInstanceGUI* FreeDVModPlugin::createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel) |
||||
{ |
||||
return FreeDVModGUI::create(m_pluginAPI, deviceUISet, txChannel); |
||||
} |
||||
#endif |
||||
|
||||
BasebandSampleSource* FreeDVModPlugin::createTxChannelBS(DeviceSinkAPI *deviceAPI) |
||||
{ |
||||
return new FreeDVMod(deviceAPI); |
||||
} |
||||
|
||||
ChannelSourceAPI* FreeDVModPlugin::createTxChannelCS(DeviceSinkAPI *deviceAPI) |
||||
{ |
||||
return new FreeDVMod(deviceAPI); |
||||
} |
||||
|
||||
|
||||
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2019 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FREEDVMODPLUGIN_H |
||||
#define INCLUDE_FREEDVMODPLUGIN_H |
||||
|
||||
#include <QObject> |
||||
#include "plugin/plugininterface.h" |
||||
|
||||
class DeviceUISet; |
||||
class BasebandSampleSource; |
||||
|
||||
class FreeDVModPlugin : public QObject, PluginInterface { |
||||
Q_OBJECT |
||||
Q_INTERFACES(PluginInterface) |
||||
Q_PLUGIN_METADATA(IID "sdrangel.channeltx.freedvmod") |
||||
|
||||
public: |
||||
explicit FreeDVModPlugin(QObject* parent = 0); |
||||
|
||||
const PluginDescriptor& getPluginDescriptor() const; |
||||
void initPlugin(PluginAPI* pluginAPI); |
||||
|
||||
virtual PluginInstanceGUI* createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel); |
||||
virtual BasebandSampleSource* createTxChannelBS(DeviceSinkAPI *deviceAPI); |
||||
virtual ChannelSourceAPI* createTxChannelCS(DeviceSinkAPI *deviceAPI); |
||||
|
||||
private: |
||||
static const PluginDescriptor m_pluginDescriptor; |
||||
|
||||
PluginAPI* m_pluginAPI; |
||||
}; |
||||
|
||||
#endif // INCLUDE_FREEDVMODPLUGIN_H
|
||||
@ -0,0 +1,241 @@
@@ -0,0 +1,241 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2019 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 <QColor> |
||||
|
||||
#include "dsp/dspengine.h" |
||||
#include "util/simpleserializer.h" |
||||
#include "settings/serializable.h" |
||||
#include "freedvmodsettings.h" |
||||
|
||||
const int FreeDVModSettings::m_agcTimeConstant[] = { |
||||
1, |
||||
2, |
||||
5, |
||||
10, |
||||
20, |
||||
50, |
||||
100, |
||||
200, |
||||
500, |
||||
990}; |
||||
|
||||
const int FreeDVModSettings::m_nbAGCTimeConstants = 10; |
||||
|
||||
FreeDVModSettings::FreeDVModSettings() : |
||||
m_channelMarker(0), |
||||
m_spectrumGUI(0), |
||||
m_cwKeyerGUI(0) |
||||
{ |
||||
resetToDefaults(); |
||||
} |
||||
|
||||
void FreeDVModSettings::resetToDefaults() |
||||
{ |
||||
m_inputFrequencyOffset = 0; |
||||
m_bandwidth = 3000.0; |
||||
m_lowCutoff = 300.0; |
||||
m_usb = true; |
||||
m_toneFrequency = 1000.0; |
||||
m_volumeFactor = 1.0; |
||||
m_spanLog2 = 3; |
||||
m_audioBinaural = false; |
||||
m_audioFlipChannels = false; |
||||
m_dsb = false; |
||||
m_audioMute = false; |
||||
m_playLoop = false; |
||||
m_agc = false; |
||||
m_agcOrder = 0.2; |
||||
m_agcTime = 9600; |
||||
m_agcThresholdEnable = true; |
||||
m_agcThreshold = -40; // dB
|
||||
m_agcThresholdGate = 192; |
||||
m_agcThresholdDelay = 2400; |
||||
m_rgbColor = QColor(0, 255, 0).rgb(); |
||||
m_title = "FreeDV Modulator"; |
||||
m_modAFInput = FreeDVModInputAF::FreeDVModInputNone; |
||||
m_audioDeviceName = AudioDeviceManager::m_defaultDeviceName; |
||||
m_useReverseAPI = false; |
||||
m_reverseAPIAddress = "127.0.0.1"; |
||||
m_reverseAPIPort = 8888; |
||||
m_reverseAPIDeviceIndex = 0; |
||||
m_reverseAPIChannelIndex = 0; |
||||
} |
||||
|
||||
QByteArray FreeDVModSettings::serialize() const |
||||
{ |
||||
SimpleSerializer s(1); |
||||
|
||||
s.writeS32(1, m_inputFrequencyOffset); |
||||
s.writeS32(2, roundf(m_bandwidth / 100.0)); |
||||
s.writeS32(3, roundf(m_toneFrequency / 10.0)); |
||||
|
||||
if (m_spectrumGUI) { |
||||
s.writeBlob(4, m_spectrumGUI->serialize()); |
||||
} |
||||
|
||||
s.writeU32(5, m_rgbColor); |
||||
|
||||
if (m_cwKeyerGUI) { |
||||
s.writeBlob(6, m_cwKeyerGUI->serialize()); |
||||
} |
||||
|
||||
s.writeS32(7, roundf(m_lowCutoff / 100.0)); |
||||
s.writeS32(8, m_spanLog2); |
||||
s.writeBool(9, m_audioBinaural); |
||||
s.writeBool(10, m_audioFlipChannels); |
||||
s.writeBool(11, m_dsb); |
||||
s.writeBool(12, m_agc); |
||||
s.writeS32(13, getAGCTimeConstantIndex(m_agcTime/48)); |
||||
s.writeS32(14, m_agcThreshold); // dB
|
||||
s.writeS32(15, m_agcThresholdGate / 48); |
||||
s.writeS32(16, m_agcThresholdDelay / 48); |
||||
s.writeS32(17, roundf(m_agcOrder * 100.0)); |
||||
|
||||
if (m_channelMarker) { |
||||
s.writeBlob(18, m_channelMarker->serialize()); |
||||
} |
||||
|
||||
s.writeString(19, m_title); |
||||
s.writeString(20, m_audioDeviceName); |
||||
s.writeS32(21, (int) m_modAFInput); |
||||
s.writeBool(22, m_useReverseAPI); |
||||
s.writeString(23, m_reverseAPIAddress); |
||||
s.writeU32(24, m_reverseAPIPort); |
||||
s.writeU32(25, m_reverseAPIDeviceIndex); |
||||
s.writeU32(26, m_reverseAPIChannelIndex); |
||||
|
||||
return s.final(); |
||||
} |
||||
|
||||
bool FreeDVModSettings::deserialize(const QByteArray& data) |
||||
{ |
||||
SimpleDeserializer d(data); |
||||
|
||||
if(!d.isValid()) |
||||
{ |
||||
resetToDefaults(); |
||||
return false; |
||||
} |
||||
|
||||
if(d.getVersion() == 1) |
||||
{ |
||||
QByteArray bytetmp; |
||||
qint32 tmp; |
||||
uint32_t utmp; |
||||
|
||||
d.readS32(1, &tmp, 0); |
||||
m_inputFrequencyOffset = tmp; |
||||
|
||||
d.readS32(2, &tmp, 30); |
||||
m_bandwidth = tmp * 100.0; |
||||
|
||||
d.readS32(3, &tmp, 100); |
||||
m_toneFrequency = tmp * 10.0; |
||||
|
||||
if (m_spectrumGUI) |
||||
{ |
||||
d.readBlob(4, &bytetmp); |
||||
m_spectrumGUI->deserialize(bytetmp); |
||||
} |
||||
|
||||
d.readU32(5, &m_rgbColor); |
||||
|
||||
if (m_cwKeyerGUI) { |
||||
d.readBlob(6, &bytetmp); |
||||
m_cwKeyerGUI->deserialize(bytetmp); |
||||
} |
||||
|
||||
d.readS32(7, &tmp, 3); |
||||
m_lowCutoff = tmp * 100.0; |
||||
|
||||
d.readS32(8, &m_spanLog2, 3); |
||||
d.readBool(9, &m_audioBinaural, false); |
||||
d.readBool(10, &m_audioFlipChannels, false); |
||||
d.readBool(11, &m_dsb, false); |
||||
d.readBool(12, &m_agc, false); |
||||
d.readS32(13, &tmp, 7); |
||||
m_agcTime = getAGCTimeConstant(tmp) * 48; |
||||
d.readS32(14, &m_agcThreshold, -40); |
||||
d.readS32(15, &tmp, 4); |
||||
m_agcThresholdGate = tmp * 48; |
||||
d.readS32(16, &tmp, 5); |
||||
m_agcThresholdDelay = tmp * 48; |
||||
d.readS32(17, &tmp, 20); |
||||
m_agcOrder = tmp / 100.0; |
||||
|
||||
if (m_channelMarker) { |
||||
d.readBlob(18, &bytetmp); |
||||
m_channelMarker->deserialize(bytetmp); |
||||
} |
||||
|
||||
d.readString(19, &m_title, "FreeDV Modulator"); |
||||
d.readString(20, &m_audioDeviceName, AudioDeviceManager::m_defaultDeviceName); |
||||
|
||||
d.readS32(21, &tmp, 0); |
||||
if ((tmp < 0) || (tmp > (int) FreeDVModInputAF::FreeDVModInputTone)) { |
||||
m_modAFInput = FreeDVModInputNone; |
||||
} else { |
||||
m_modAFInput = (FreeDVModInputAF) tmp; |
||||
} |
||||
|
||||
d.readBool(22, &m_useReverseAPI, false); |
||||
d.readString(23, &m_reverseAPIAddress, "127.0.0.1"); |
||||
d.readU32(24, &utmp, 0); |
||||
|
||||
if ((utmp > 1023) && (utmp < 65535)) { |
||||
m_reverseAPIPort = utmp; |
||||
} else { |
||||
m_reverseAPIPort = 8888; |
||||
} |
||||
|
||||
d.readU32(25, &utmp, 0); |
||||
m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp; |
||||
d.readU32(26, &utmp, 0); |
||||
m_reverseAPIChannelIndex = utmp > 99 ? 99 : utmp; |
||||
|
||||
return true; |
||||
} |
||||
else |
||||
{ |
||||
resetToDefaults(); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
int FreeDVModSettings::getAGCTimeConstant(int index) |
||||
{ |
||||
if (index < 0) { |
||||
return m_agcTimeConstant[0]; |
||||
} else if (index < m_nbAGCTimeConstants) { |
||||
return m_agcTimeConstant[index]; |
||||
} else { |
||||
return m_agcTimeConstant[m_nbAGCTimeConstants-1]; |
||||
} |
||||
} |
||||
|
||||
int FreeDVModSettings::getAGCTimeConstantIndex(int agcTimeConstant) |
||||
{ |
||||
for (int i = 0; i < m_nbAGCTimeConstants; i++) |
||||
{ |
||||
if (agcTimeConstant <= m_agcTimeConstant[i]) |
||||
{ |
||||
return i; |
||||
} |
||||
} |
||||
|
||||
return m_nbAGCTimeConstants-1; |
||||
} |
||||
@ -0,0 +1,88 @@
@@ -0,0 +1,88 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2019 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PLUGINS_CHANNELTX_MODFREEDV_FREEDVMODSETTINGS_H_ |
||||
#define PLUGINS_CHANNELTX_MODFREEDV_FREEDVMODSETTINGS_H_ |
||||
|
||||
#include <QByteArray> |
||||
#include <QString> |
||||
#include <stdint.h> |
||||
|
||||
class Serializable; |
||||
|
||||
struct FreeDVModSettings |
||||
{ |
||||
typedef enum |
||||
{ |
||||
FreeDVModInputNone, |
||||
FreeDVModInputTone, |
||||
FreeDVModInputFile, |
||||
FreeDVModInputAudio, |
||||
FreeDVModInputCWTone |
||||
} FreeDVModInputAF; |
||||
|
||||
static const int m_nbAGCTimeConstants; |
||||
static const int m_agcTimeConstant[]; |
||||
|
||||
qint64 m_inputFrequencyOffset; |
||||
Real m_bandwidth; |
||||
Real m_lowCutoff; |
||||
bool m_usb; |
||||
float m_toneFrequency; |
||||
float m_volumeFactor; |
||||
int m_spanLog2; |
||||
bool m_audioBinaural; |
||||
bool m_audioFlipChannels; |
||||
bool m_dsb; |
||||
bool m_audioMute; |
||||
bool m_playLoop; |
||||
bool m_agc; |
||||
float m_agcOrder; |
||||
int m_agcTime; |
||||
bool m_agcThresholdEnable; |
||||
int m_agcThreshold; |
||||
int m_agcThresholdGate; |
||||
int m_agcThresholdDelay; |
||||
quint32 m_rgbColor; |
||||
|
||||
QString m_title; |
||||
FreeDVModInputAF m_modAFInput; |
||||
QString m_audioDeviceName; |
||||
|
||||
bool m_useReverseAPI; |
||||
QString m_reverseAPIAddress; |
||||
uint16_t m_reverseAPIPort; |
||||
uint16_t m_reverseAPIDeviceIndex; |
||||
uint16_t m_reverseAPIChannelIndex; |
||||
|
||||
Serializable *m_channelMarker; |
||||
Serializable *m_spectrumGUI; |
||||
Serializable *m_cwKeyerGUI; |
||||
|
||||
FreeDVModSettings(); |
||||
void resetToDefaults(); |
||||
void setChannelMarker(Serializable *channelMarker) { m_channelMarker = channelMarker; } |
||||
void setSpectrumGUI(Serializable *spectrumGUI) { m_spectrumGUI = spectrumGUI; } |
||||
void setCWKeyerGUI(Serializable *cwKeyerGUI) { m_cwKeyerGUI = cwKeyerGUI; } |
||||
QByteArray serialize() const; |
||||
bool deserialize(const QByteArray& data); |
||||
|
||||
static int getAGCTimeConstant(int index); |
||||
static int getAGCTimeConstantIndex(int agcTimeConstant); |
||||
}; |
||||
|
||||
|
||||
#endif /* PLUGINS_CHANNELTX_MODFREEDV_FREEDVMODSETTINGS_H_ */ |
||||
@ -0,0 +1,80 @@
@@ -0,0 +1,80 @@
|
||||
FreeDVModSettings: |
||||
description: FreeDVMod |
||||
properties: |
||||
inputFrequencyOffset: |
||||
type: integer |
||||
format: int64 |
||||
bandwidth: |
||||
type: number |
||||
format: float |
||||
lowCutoff: |
||||
type: number |
||||
format: float |
||||
usb: |
||||
type: integer |
||||
toneFrequency: |
||||
type: number |
||||
format: float |
||||
volumeFactor: |
||||
type: number |
||||
format: float |
||||
spanLog2: |
||||
type: integer |
||||
audioBinaural: |
||||
type: integer |
||||
audioFlipChannels: |
||||
type: integer |
||||
dsb: |
||||
type: integer |
||||
audioMute: |
||||
type: integer |
||||
playLoop: |
||||
type: integer |
||||
agc: |
||||
type: integer |
||||
agcOrder: |
||||
type: number |
||||
format: float |
||||
agcTime: |
||||
type: integer |
||||
agcThresholdEnable: |
||||
type: integer |
||||
agcThreshold: |
||||
type: integer |
||||
agcThresholdGate: |
||||
type: integer |
||||
agcThresholdDelay: |
||||
type: integer |
||||
rgbColor: |
||||
type: integer |
||||
title: |
||||
type: string |
||||
audioDeviceName: |
||||
type: string |
||||
modAFInput: |
||||
type: integer |
||||
useReverseAPI: |
||||
description: Synchronize with reverse API (1 for yes, 0 for no) |
||||
type: integer |
||||
reverseAPIAddress: |
||||
type: string |
||||
reverseAPIPort: |
||||
type: integer |
||||
reverseAPIDeviceIndex: |
||||
type: integer |
||||
reverseAPIChannelIndex: |
||||
type: integer |
||||
cwKeyer: |
||||
$ref: "/doc/swagger/include/CWKeyer.yaml#/CWKeyerSettings" |
||||
|
||||
FreeDVModReport: |
||||
description: FreeDVMod |
||||
properties: |
||||
channelPowerDB: |
||||
description: power transmitted in channel (dB) |
||||
type: number |
||||
format: float |
||||
audioSampleRate: |
||||
type: integer |
||||
channelSampleRate: |
||||
type: integer |
||||
@ -0,0 +1,80 @@
@@ -0,0 +1,80 @@
|
||||
FreeDVModSettings: |
||||
description: FreeDVMod |
||||
properties: |
||||
inputFrequencyOffset: |
||||
type: integer |
||||
format: int64 |
||||
bandwidth: |
||||
type: number |
||||
format: float |
||||
lowCutoff: |
||||
type: number |
||||
format: float |
||||
usb: |
||||
type: integer |
||||
toneFrequency: |
||||
type: number |
||||
format: float |
||||
volumeFactor: |
||||
type: number |
||||
format: float |
||||
spanLog2: |
||||
type: integer |
||||
audioBinaural: |
||||
type: integer |
||||
audioFlipChannels: |
||||
type: integer |
||||
dsb: |
||||
type: integer |
||||
audioMute: |
||||
type: integer |
||||
playLoop: |
||||
type: integer |
||||
agc: |
||||
type: integer |
||||
agcOrder: |
||||
type: number |
||||
format: float |
||||
agcTime: |
||||
type: integer |
||||
agcThresholdEnable: |
||||
type: integer |
||||
agcThreshold: |
||||
type: integer |
||||
agcThresholdGate: |
||||
type: integer |
||||
agcThresholdDelay: |
||||
type: integer |
||||
rgbColor: |
||||
type: integer |
||||
title: |
||||
type: string |
||||
audioDeviceName: |
||||
type: string |
||||
modAFInput: |
||||
type: integer |
||||
useReverseAPI: |
||||
description: Synchronize with reverse API (1 for yes, 0 for no) |
||||
type: integer |
||||
reverseAPIAddress: |
||||
type: string |
||||
reverseAPIPort: |
||||
type: integer |
||||
reverseAPIDeviceIndex: |
||||
type: integer |
||||
reverseAPIChannelIndex: |
||||
type: integer |
||||
cwKeyer: |
||||
$ref: "http://localhost:8081/api/swagger/include/CWKeyer.yaml#/CWKeyerSettings" |
||||
|
||||
FreeDVModReport: |
||||
description: FreeDVMod |
||||
properties: |
||||
channelPowerDB: |
||||
description: power transmitted in channel (dB) |
||||
type: number |
||||
format: float |
||||
audioSampleRate: |
||||
type: integer |
||||
channelSampleRate: |
||||
type: integer |
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue