20 #include <QMutexLocker> 21 #include <QNetworkAccessManager> 22 #include <QNetworkReply> 57 m_deviceAPI(deviceAPI),
58 m_basebandSampleRate(384000),
59 m_outputSampleRate(384000),
60 m_inputFrequencyOffset(0),
63 m_settingsMutex(QMutex::Recursive),
167 double magsq = ci.real() * ci.real() + ci.imag() * ci.imag();
305 qDebug() <<
"WFMMod::handleMessage: MsgChannelizerNotification";
314 qDebug() <<
"WFMMod::handleMessage: MsgConfigureChannelizer:" 327 qDebug() <<
"NFWFMMod::handleMessage: MsgConfigureWFMMod";
352 std::size_t samplesCount;
381 qDebug() <<
"WFMMod::handleMessage: DSPConfigureAudio:" 382 <<
" sampleRate: " << sampleRate;
413 qDebug() <<
"WFMMod::openFileStream: " <<
m_fileName.toStdString().c_str()
429 seekPoint *=
sizeof(
Real);
437 qDebug(
"WFMMod::applyAudioSampleRate: %d", sampleRate);
451 qDebug() <<
"WFMMod::applyChannelSettings:" 452 <<
" basebandSampleRate: " << basebandSampleRate
453 <<
" outputSampleRate: " << outputSampleRate
454 <<
" inputFrequencyOffset: " << inputFrequencyOffset;
487 qDebug() <<
"WFMMod::applySettings:" 503 <<
" force: " << force;
505 QList<QString> reverseAPIKeys;
508 reverseAPIKeys.append(
"inputFrequencyOffset");
511 reverseAPIKeys.append(
"fmDeviation");
514 reverseAPIKeys.append(
"volumeFactor");
517 reverseAPIKeys.append(
"channelMute");
520 reverseAPIKeys.append(
"playLoop");
523 reverseAPIKeys.append(
"modAFInput");
528 reverseAPIKeys.append(
"afBandwidth");
539 reverseAPIKeys.append(
"rfBandwidth");
549 reverseAPIKeys.append(
"toneFrequency");
557 reverseAPIKeys.append(
"audioDeviceName");
605 QString& errorMessage)
616 const QStringList& channelSettingsKeys,
618 QString& errorMessage)
622 bool channelizerChange =
false;
624 if (channelSettingsKeys.contains(
"channelMute")) {
627 if (channelSettingsKeys.contains(
"inputFrequencyOffset"))
630 channelizerChange =
true;
632 if (channelSettingsKeys.contains(
"modAFInput")) {
635 if (channelSettingsKeys.contains(
"playLoop")) {
638 if (channelSettingsKeys.contains(
"rfBandwidth")) {
640 channelizerChange =
true;
642 if (channelSettingsKeys.contains(
"afBandwidth")) {
645 if (channelSettingsKeys.contains(
"rgbColor")) {
648 if (channelSettingsKeys.contains(
"title")) {
651 if (channelSettingsKeys.contains(
"toneFrequency")) {
654 if (channelSettingsKeys.contains(
"volumeFactor")) {
657 if (channelSettingsKeys.contains(
"fmDeviation")) {
660 if (channelSettingsKeys.contains(
"useReverseAPI")) {
663 if (channelSettingsKeys.contains(
"reverseAPIAddress")) {
666 if (channelSettingsKeys.contains(
"reverseAPIPort")) {
669 if (channelSettingsKeys.contains(
"reverseAPIDeviceIndex")) {
672 if (channelSettingsKeys.contains(
"reverseAPIChannelIndex")) {
676 if (channelSettingsKeys.contains(
"cwKeyer"))
692 if (channelizerChange)
715 QString& errorMessage)
790 if (channelSettingsKeys.contains(
"channelMute") || force) {
793 if (channelSettingsKeys.contains(
"inputFrequencyOffset") || force) {
796 if (channelSettingsKeys.contains(
"modAFInput") || force) {
799 if (channelSettingsKeys.contains(
"playLoop") || force) {
802 if (channelSettingsKeys.contains(
"rfBandwidth") || force) {
805 if (channelSettingsKeys.contains(
"afBandwidth") || force) {
808 if (channelSettingsKeys.contains(
"rgbColor") || force) {
811 if (channelSettingsKeys.contains(
"title") || force) {
814 if (channelSettingsKeys.contains(
"toneFrequency") || force) {
817 if (channelSettingsKeys.contains(
"volumeFactor") || force) {
820 if (channelSettingsKeys.contains(
"fmDeviation")) {
823 if (channelSettingsKeys.contains(
"audioDeviceName") || force) {
835 QString channelSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
841 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
843 QBuffer *buffer=
new QBuffer();
844 buffer->open((QBuffer::ReadWrite));
845 buffer->write(swgChannelSettings->
asJson().toUtf8());
851 delete swgChannelSettings;
866 QString channelSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
872 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
874 QBuffer *buffer=
new QBuffer();
875 buffer->open((QBuffer::ReadWrite));
876 buffer->write(swgChannelSettings->
asJson().toUtf8());
882 delete swgChannelSettings;
887 QNetworkReply::NetworkError replyError = reply->error();
891 qWarning() <<
"WFMMod::networkManagerFinished:" 892 <<
" error(" << (int) replyError
893 <<
"): " << replyError
894 <<
": " << reply->errorString();
898 QString answer = reply->readAll();
900 qDebug(
"WFMMod::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
ThreadedBasebandSampleSource * m_threadedChannelizer
void setOriginatorChannelIndex(qint32 originator_channel_index)
qint32 getReverseApiDeviceIndex()
static const int m_levelNbSamples
void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples)
UpChannelizer * m_channelizer
Complex nextIQ()
Return next complex sample.
void push(Message *message, bool emitSignal=true)
Push message onto queue.
Fixed< IntType, IntBits > cos(Fixed< IntType, IntBits > const &x)
uint16_t m_reverseAPIChannelIndex
void removeChannelSourceAPI(ChannelAPI *channelAPI, int streamIndex=0)
static double dbPower(double magsq, double floor=1e-12)
QNetworkAccessManager * m_networkManager
QString * getAudioDeviceName()
int getInputSampleRate(int inputDeviceIndex=-1)
QString * getReverseApiAddress()
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
bool interpolate(Real *distance, const Complex &next, Complex *result)
fftfilt::cmplx * m_rfFilterBuffer
void setRfBandwidth(float rf_bandwidth)
int getDeviceSetIndex() const
void applyChannelSettings(int basebandSampleRate, int outputSampleRate, int inputFrequencyOffset, bool force=false)
void setWfmModSettings(SWGWFMModSettings *wfm_mod_settings)
void calculateLevel(const Real &sample)
void seekFileStream(int seekPercentage)
void removeChannelSource(ThreadedBasebandSampleSource *sink, int streamIndex=0)
Remove a channel source (Tx)
int runFilt(const cmplx &in, cmplx **out)
qint32 getReverseApiPort()
bool m_interpolatorConsumed
Real m_interpolatorDistance
virtual void pullAudio(int nbSamples)
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
WFMModInputAF m_modAFInput
static MsgReportFileSourceStreamData * create(int sampleRate, quint32 recordLength)
void pullAF(Complex &sample)
WFMMod(DeviceAPI *deviceAPI)
void setChannelType(QString *channel_type)
void addChannelSource(ThreadedBasebandSampleSource *sink, int streamIndex=0)
Add a channel source (Tx)
void setChannelMute(qint32 channel_mute)
void setOriginatorDeviceSetIndex(qint32 originator_device_set_index)
AudioVector m_audioBuffer
static const QString m_channelIdURI
std::complex< float > cmplx
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void addAudioSource(AudioFifo *audioFifo, MessageQueue *sampleSourceMessageQueue, int inputDeviceIndex=-1)
Add an audio source.
void setUseReverseApi(qint32 use_reverse_api)
virtual void pull(Sample &sample)
quint64 m_fileSize
raw file size (bytes)
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
void setPhase(Real phase)
static const QString m_channelId
bool deserialize(const QByteArray &data)
SWGCWKeyerSettings * getCwKeyer()
void setReverseApiPort(qint32 reverse_api_port)
int getBasebandSampleRate() const
#define MESSAGE_CLASS_DEFINITION(Name, BaseClass)
bool getFadeSample(bool on, float &sample)
void setInputFrequencyOffset(qint64 input_frequency_offset)
void create_filter(float f1, float f2)
void setPlayLoop(qint32 play_loop)
static DSPEngine * instance()
CWSmoother & getCWSmoother()
static MsgReportFileSourceStreamTiming * create(std::size_t samplesCount)
int m_rfFilterBufferIndex
void setWfmModReport(SWGWFMModReport *wfm_mod_report)
QNetworkRequest m_networkRequest
void setAudioDeviceName(QString *audio_device_name)
Fixed< IntType, IntBits > sin(Fixed< IntType, IntBits > const &x)
QString m_audioDeviceName
This is the audio device you get the audio samples from.
void setCwKeyer(SWGCWKeyerSettings *cw_keyer)
static bool match(const Message *message)
void setChannelPowerDb(float channel_power_db)
void setFreq(Real freq, Real sampleRate)
virtual bool handleMessage(const Message &cmd)
Processing of a message. Returns true if message has actually been processed.
quint32 m_audioSampleRate
void applySettings(const WFMModSettings &settings, bool force=false)
Fixed< IntType, IntBits > sqrt(Fixed< IntType, IntBits > const &x)
SWGWFMModReport * getWfmModReport()
void setDirection(qint32 direction)
uint32_t read(quint8 *data, uint32_t numSamples)
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
virtual QByteArray serialize() const
virtual int webapiReportGet(SWGSDRangel::SWGChannelReport &response, QString &errorMessage)
virtual QString asJson() override
virtual int webapiSettingsGet(SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
static void webapiFormatChannelSettings(SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings, const CWKeyerSettings &cwKeyerSettings)
MovingAverageUtil< double, double, 16 > m_movingAverage
AudioDeviceManager * getAudioDeviceManager()
SWGWFMModSettings * getWfmModSettings()
qint64 getFrequencyOffset() const
void setReverseApiAddress(QString *reverse_api_address)
QByteArray serialize() const
uint16_t m_reverseAPIPort
static const int m_rfFilterFFTLength
MessageQueue * getMessageQueueToGUI()
static void webapiSettingsPutPatch(const QStringList &channelSettingsKeys, CWKeyerSettings &cwKeyerSettings, SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings)
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
qint64 getInputFrequencyOffset()
void setChannelSampleRate(qint32 channel_sample_rate)
void networkManagerFinished(QNetworkReply *reply)
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport &response)
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
void setFreq(Real freq, Real sampleRate)
virtual int webapiSettingsPutPatch(bool force, const QStringList &channelSettingsKeys, SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
Real m_interpolatorDistanceRemain
void setAudioSampleRate(qint32 audio_sample_rate)
int getInputDeviceIndex(const QString &deviceName) const
void setFmDeviation(float fm_deviation)
int getSampleRate() const
quint32 m_recordLength
record length in seconds computed from file size
void addChannelSourceAPI(ChannelAPI *channelAPI, int streamIndex=0)
void applyAudioSampleRate(int sampleRate)
QString m_reverseAPIAddress
void setAfBandwidth(float af_bandwidth)
qint32 getUseReverseApi()
WFMModSettings m_settings
Interpolator m_interpolator
const CWKeyerSettings & getSettings() const
int getIndexInDeviceSet() const
Real next()
Return next real sample.
qint32 getReverseApiChannelIndex()
std::complex< Real > Complex
float m_modPhasor
baseband modulator phasor
void webapiReverseSendCWSettings(const CWKeyerSettings &settings)
void setToneFrequency(float tone_frequency)
void setModAfInput(qint32 mod_af_input)
void setSampleRate(int sampleRate)
qint64 m_inputFrequencyOffset
int m_inputFrequencyOffset
uint16_t m_reverseAPIDeviceIndex
virtual bool deserialize(const QByteArray &data)
T max(const T &x, const T &y)
void setVolumeFactor(float volume_factor)
void removeAudioSource(AudioFifo *audioFifo)
Remove an audio source.
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const WFMModSettings &settings)
void setTitle(QString *title)
void webapiReverseSendSettings(QList< QString > &channelSettingsKeys, const WFMModSettings &settings, bool force)
void setRgbColor(qint32 rgb_color)
void configure(MessageQueue *messageQueue, int sampleRate, int centerFrequency)