mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
[AFV] misc style issues:
* object name * simple style fixes * some renamings * comments
This commit is contained in:
committed by
Mat Sutcliffe
parent
c1622951b3
commit
7d51bedc3e
@@ -6,8 +6,6 @@
|
||||
* or distributed except according to the terms contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#include "callsignsampleprovider.h"
|
||||
#include "callsigndelaycache.h"
|
||||
|
||||
@@ -15,6 +13,7 @@
|
||||
#include "blacksound/sampleprovider/samples.h"
|
||||
#include "blacksound/audioutilities.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/metadatautils.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
|
||||
#include <QtMath>
|
||||
@@ -30,15 +29,18 @@ namespace BlackCore
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
CallsignSampleProvider::CallsignSampleProvider(const QAudioFormat &audioFormat, const CReceiverSampleProvider *receiver, QObject *parent) :
|
||||
CCallsignSampleProvider::CCallsignSampleProvider(const QAudioFormat &audioFormat, const CReceiverSampleProvider *receiver, QObject *parent) :
|
||||
ISampleProvider(parent),
|
||||
m_audioFormat(audioFormat),
|
||||
m_receiver(receiver),
|
||||
m_decoder(audioFormat.sampleRate(), 1)
|
||||
{
|
||||
Q_ASSERT(audioFormat.channelCount() == 1);
|
||||
Q_ASSERT(receiver);
|
||||
|
||||
const QString on = QStringLiteral("%1").arg(classNameShort(this));
|
||||
this->setObjectName(on);
|
||||
|
||||
this->setObjectName("CallsignSampleProvider");
|
||||
m_mixer = new CMixingSampleProvider(this);
|
||||
m_crackleSoundProvider = new CResourceSoundSampleProvider(Samples::instance().crackle(), m_mixer);
|
||||
m_crackleSoundProvider->setLooping(true);
|
||||
@@ -57,23 +59,23 @@ namespace BlackCore
|
||||
m_simpleCompressorEffect->setMakeUpGain(-5.5);
|
||||
|
||||
// Create the voice EQ
|
||||
m_voiceEq = new CEqualizerSampleProvider(m_simpleCompressorEffect, EqualizerPresets::VHFEmulation, m_mixer);
|
||||
m_voiceEqualizer = new CEqualizerSampleProvider(m_simpleCompressorEffect, EqualizerPresets::VHFEmulation, m_mixer);
|
||||
|
||||
m_mixer->addMixerInput(m_whiteNoise);
|
||||
m_mixer->addMixerInput(m_acBusNoise);
|
||||
m_mixer->addMixerInput(m_hfWhiteNoise);
|
||||
m_mixer->addMixerInput(m_voiceEq);
|
||||
m_mixer->addMixerInput(m_voiceEqualizer);
|
||||
|
||||
m_timer = new QTimer(this);
|
||||
m_timer->setObjectName(this->objectName() + "m_timer");
|
||||
m_timer->setObjectName(this->objectName() + ":m_timer");
|
||||
|
||||
m_timer->setInterval(100);
|
||||
connect(m_timer, &QTimer::timeout, this, &CallsignSampleProvider::timerElapsed);
|
||||
connect(m_timer, &QTimer::timeout, this, &CCallsignSampleProvider::timerElapsed);
|
||||
}
|
||||
|
||||
int CallsignSampleProvider::readSamples(QVector<float> &samples, qint64 count)
|
||||
int CCallsignSampleProvider::readSamples(QVector<float> &samples, qint64 count)
|
||||
{
|
||||
int noOfSamples = m_mixer->readSamples(samples, count);
|
||||
const int noOfSamples = m_mixer->readSamples(samples, count);
|
||||
|
||||
if (m_inUse && m_lastPacketLatch && m_audioInput->getBufferedBytes() == 0)
|
||||
{
|
||||
@@ -91,7 +93,7 @@ namespace BlackCore
|
||||
return noOfSamples;
|
||||
}
|
||||
|
||||
void CallsignSampleProvider::timerElapsed()
|
||||
void CCallsignSampleProvider::timerElapsed()
|
||||
{
|
||||
if (m_inUse && m_audioInput->getBufferedBytes() == 0 && m_lastSamplesAddedUtc.msecsTo(QDateTime::currentDateTimeUtc()) > m_idleTimeoutMs)
|
||||
{
|
||||
@@ -99,7 +101,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void CallsignSampleProvider::active(const QString &callsign, const QString &aircraftType)
|
||||
void CCallsignSampleProvider::active(const QString &callsign, const QString &aircraftType)
|
||||
{
|
||||
m_callsign = callsign;
|
||||
CallsignDelayCache::instance().initialise(callsign);
|
||||
@@ -109,17 +111,17 @@ namespace BlackCore
|
||||
setEffects();
|
||||
m_underflow = false;
|
||||
|
||||
int delayMs = CallsignDelayCache::instance().get(callsign);
|
||||
const int delayMs = CallsignDelayCache::instance().get(callsign);
|
||||
if (verbose()) { CLogMessage(this).debug(u"[%1] [Delay %2ms]") << m_callsign << delayMs; }
|
||||
if (delayMs > 0)
|
||||
{
|
||||
int phaseDelayLength = (m_audioFormat.sampleRate() / 1000) * delayMs;
|
||||
QVector<float> phaseDelay(phaseDelayLength * 2, 0);
|
||||
const int phaseDelayLength = (m_audioFormat.sampleRate() / 1000) * delayMs;
|
||||
const QVector<float> phaseDelay(phaseDelayLength * 2, 0);
|
||||
m_audioInput->addSamples(phaseDelay);
|
||||
}
|
||||
}
|
||||
|
||||
void CallsignSampleProvider::activeSilent(const QString &callsign, const QString &aircraftType)
|
||||
void CCallsignSampleProvider::activeSilent(const QString &callsign, const QString &aircraftType)
|
||||
{
|
||||
m_callsign = callsign;
|
||||
CallsignDelayCache::instance().initialise(callsign);
|
||||
@@ -130,18 +132,18 @@ namespace BlackCore
|
||||
m_underflow = true;
|
||||
}
|
||||
|
||||
void CallsignSampleProvider::clear()
|
||||
void CCallsignSampleProvider::clear()
|
||||
{
|
||||
idle();
|
||||
m_audioInput->clearBuffer();
|
||||
}
|
||||
|
||||
void CallsignSampleProvider::addOpusSamples(const IAudioDto &audioDto, float distanceRatio)
|
||||
void CCallsignSampleProvider::addOpusSamples(const IAudioDto &audioDto, float distanceRatio)
|
||||
{
|
||||
m_distanceRatio = distanceRatio;
|
||||
setEffects();
|
||||
|
||||
QVector<qint16> audio = decodeOpus(audioDto.audio);
|
||||
const QVector<qint16> audio = decodeOpus(audioDto.audio);
|
||||
m_audioInput->addSamples(BlackSound::convertFromShortToFloat(audio));
|
||||
m_lastPacketLatch = audioDto.lastPacket;
|
||||
if (audioDto.lastPacket && !m_underflow) { CallsignDelayCache::instance().success(m_callsign); }
|
||||
@@ -149,7 +151,7 @@ namespace BlackCore
|
||||
if (!m_timer->isActive()) { m_timer->start(); }
|
||||
}
|
||||
|
||||
void CallsignSampleProvider::addSilentSamples(const IAudioDto &audioDto)
|
||||
void CCallsignSampleProvider::addSilentSamples(const IAudioDto &audioDto)
|
||||
{
|
||||
// Disable all audio effects
|
||||
setEffects(true);
|
||||
@@ -161,7 +163,7 @@ namespace BlackCore
|
||||
if (!m_timer->isActive()) { m_timer->start(); }
|
||||
}
|
||||
|
||||
void CallsignSampleProvider::idle()
|
||||
void CCallsignSampleProvider::idle()
|
||||
{
|
||||
m_timer->stop();
|
||||
m_inUse = false;
|
||||
@@ -170,14 +172,14 @@ namespace BlackCore
|
||||
m_type.clear();
|
||||
}
|
||||
|
||||
QVector<qint16> CallsignSampleProvider::decodeOpus(const QByteArray &opusData)
|
||||
QVector<qint16> CCallsignSampleProvider::decodeOpus(const QByteArray &opusData)
|
||||
{
|
||||
int decodedLength = 0;
|
||||
QVector<qint16> decoded = m_decoder.decode(opusData, opusData.size(), &decodedLength);
|
||||
const QVector<qint16> decoded = m_decoder.decode(opusData, opusData.size(), &decodedLength);
|
||||
return decoded;
|
||||
}
|
||||
|
||||
void CallsignSampleProvider::setEffects(bool noEffects)
|
||||
void CCallsignSampleProvider::setEffects(bool noEffects)
|
||||
{
|
||||
if (noEffects || m_bypassEffects || !m_inUse)
|
||||
{
|
||||
@@ -186,7 +188,7 @@ namespace BlackCore
|
||||
m_hfWhiteNoise->setGain(0.0);
|
||||
m_acBusNoise->setGain(0.0);
|
||||
m_simpleCompressorEffect->setEnabled(false);
|
||||
m_voiceEq->setBypassEffects(true);
|
||||
m_voiceEqualizer->setBypassEffects(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -201,8 +203,8 @@ namespace BlackCore
|
||||
m_hfWhiteNoise->setGain(m_hfWhiteNoiseGainMin);
|
||||
m_acBusNoise->setGain(m_acBusGainMin + 0.001f);
|
||||
m_simpleCompressorEffect->setEnabled(true);
|
||||
m_voiceEq->setBypassEffects(false);
|
||||
m_voiceEq->setOutputGain(0.38);
|
||||
m_voiceEqualizer->setBypassEffects(false);
|
||||
m_voiceEqualizer->setOutputGain(0.38);
|
||||
m_whiteNoise->setGain(0.0);
|
||||
}
|
||||
else
|
||||
@@ -216,13 +218,13 @@ namespace BlackCore
|
||||
m_whiteNoise->setGain(m_whiteNoiseGainMin);
|
||||
m_acBusNoise->setGain(m_acBusGainMin);
|
||||
m_simpleCompressorEffect->setEnabled(true);
|
||||
m_voiceEq->setBypassEffects(false);
|
||||
m_voiceEq->setOutputGain(1.0 - crackleFactor * 3.7);
|
||||
m_voiceEqualizer->setBypassEffects(false);
|
||||
m_voiceEqualizer->setOutputGain(1.0 - crackleFactor * 3.7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CallsignSampleProvider::setBypassEffects(bool bypassEffects)
|
||||
void CCallsignSampleProvider::setBypassEffects(bool bypassEffects)
|
||||
{
|
||||
m_bypassEffects = bypassEffects;
|
||||
setEffects();
|
||||
|
||||
@@ -35,14 +35,14 @@ namespace BlackCore
|
||||
{
|
||||
class CReceiverSampleProvider;
|
||||
|
||||
//! Callsign provide
|
||||
class CallsignSampleProvider : public BlackSound::SampleProvider::ISampleProvider
|
||||
//! Callsign provider
|
||||
class CCallsignSampleProvider : public BlackSound::SampleProvider::ISampleProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
CallsignSampleProvider(const QAudioFormat &audioFormat, const BlackCore::Afv::Audio::CReceiverSampleProvider *receiver, QObject *parent = nullptr);
|
||||
CCallsignSampleProvider(const QAudioFormat &audioFormat, const BlackCore::Afv::Audio::CReceiverSampleProvider *receiver, QObject *parent = nullptr);
|
||||
|
||||
//! Read samples
|
||||
int readSamples(QVector<float> &samples, qint64 count) override;
|
||||
@@ -93,15 +93,15 @@ namespace BlackCore
|
||||
|
||||
bool m_bypassEffects = false;
|
||||
float m_distanceRatio = 1.0;
|
||||
const CReceiverSampleProvider *m_receiver = nullptr;
|
||||
BlackSound::SampleProvider::CMixingSampleProvider *m_mixer = nullptr;
|
||||
BlackSound::SampleProvider::CResourceSoundSampleProvider *m_crackleSoundProvider = nullptr;
|
||||
BlackSound::SampleProvider::CResourceSoundSampleProvider *m_whiteNoise = nullptr;
|
||||
BlackSound::SampleProvider::CResourceSoundSampleProvider *m_hfWhiteNoise = nullptr;
|
||||
BlackSound::SampleProvider::CSawToothGenerator *m_acBusNoise = nullptr;
|
||||
const CReceiverSampleProvider *m_receiver = nullptr;
|
||||
BlackSound::SampleProvider::CMixingSampleProvider *m_mixer = nullptr;
|
||||
BlackSound::SampleProvider::CResourceSoundSampleProvider *m_crackleSoundProvider = nullptr;
|
||||
BlackSound::SampleProvider::CResourceSoundSampleProvider *m_whiteNoise = nullptr;
|
||||
BlackSound::SampleProvider::CResourceSoundSampleProvider *m_hfWhiteNoise = nullptr;
|
||||
BlackSound::SampleProvider::CSawToothGenerator *m_acBusNoise = nullptr;
|
||||
BlackSound::SampleProvider::CSimpleCompressorEffect *m_simpleCompressorEffect = nullptr;
|
||||
BlackSound::SampleProvider::CEqualizerSampleProvider *m_voiceEq = nullptr;
|
||||
BlackSound::SampleProvider::CBufferedWaveProvider *m_audioInput = nullptr;
|
||||
BlackSound::SampleProvider::CEqualizerSampleProvider *m_voiceEqualizer = nullptr;
|
||||
BlackSound::SampleProvider::CBufferedWaveProvider *m_audioInput = nullptr;
|
||||
QTimer *m_timer = nullptr;
|
||||
|
||||
BlackSound::Codecs::COpusDecoder m_decoder;
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
* or distributed except according to the terms contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#include "output.h"
|
||||
#include "blacksound/audioutilities.h"
|
||||
#include "blackmisc/metadatautils.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/verify.h"
|
||||
|
||||
@@ -32,7 +31,9 @@ namespace BlackCore
|
||||
QIODevice(parent),
|
||||
m_sampleProvider(sampleProvider)
|
||||
{
|
||||
this->setObjectName("CAudioOutputBuffer");
|
||||
Q_ASSERT_X(sampleProvider, Q_FUNC_INFO, "need sample provide");
|
||||
const QString on = QStringLiteral("%1 for %2").arg(classNameShort(this), sampleProvider->objectName());
|
||||
this->setObjectName(on);
|
||||
}
|
||||
|
||||
qint64 CAudioOutputBuffer::readData(char *data, qint64 maxlen)
|
||||
@@ -43,7 +44,7 @@ namespace BlackCore
|
||||
QVector<float> buffer;
|
||||
m_sampleProvider->readSamples(buffer, count);
|
||||
|
||||
for (float sample : buffer)
|
||||
for (float sample : as_const(buffer))
|
||||
{
|
||||
const float absSample = qAbs(sample);
|
||||
if (absSample > m_maxSampleOutput) { m_maxSampleOutput = absSample; }
|
||||
@@ -54,14 +55,14 @@ namespace BlackCore
|
||||
{
|
||||
OutputVolumeStreamArgs outputVolumeStreamArgs;
|
||||
outputVolumeStreamArgs.PeakRaw = m_maxSampleOutput / 1.0;
|
||||
outputVolumeStreamArgs.PeakDb = static_cast<float>(20 * std::log10(outputVolumeStreamArgs.PeakRaw));
|
||||
outputVolumeStreamArgs.PeakDb = static_cast<float>(20 * std::log10(outputVolumeStreamArgs.PeakRaw));
|
||||
const double db = qBound(m_minDb, outputVolumeStreamArgs.PeakDb, m_maxDb);
|
||||
double ratio = (db - m_minDb) / (m_maxDb - m_minDb);
|
||||
if (ratio < 0.30) { ratio = 0.0; }
|
||||
if (ratio > 1.0) { ratio = 1.0; }
|
||||
outputVolumeStreamArgs.PeakVU = ratio;
|
||||
emit outputVolumeStream(outputVolumeStreamArgs);
|
||||
m_sampleCount = 0;
|
||||
m_sampleCount = 0;
|
||||
m_maxSampleOutput = 0;
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ namespace BlackCore
|
||||
|
||||
COutput::COutput(QObject *parent) : QObject(parent)
|
||||
{
|
||||
this->setObjectName("COutput");
|
||||
this->setObjectName(classNameShort(this));
|
||||
}
|
||||
|
||||
void COutput::start(const CAudioDeviceInfo &outputDevice, ISampleProvider *sampleProvider)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "receiversampleprovider.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/metadatautils.h"
|
||||
#include "blacksound/sampleprovider/resourcesoundsampleprovider.h"
|
||||
#include "blacksound/sampleprovider/samples.h"
|
||||
|
||||
@@ -36,11 +37,13 @@ namespace BlackCore
|
||||
ISampleProvider(parent),
|
||||
m_id(id)
|
||||
{
|
||||
m_mixer = new CMixingSampleProvider(this);
|
||||
const QString on = QStringLiteral("%1 id: %2").arg(classNameShort(this)).arg(id);
|
||||
this->setObjectName(on);
|
||||
|
||||
m_mixer = new CMixingSampleProvider(this);
|
||||
for (int i = 0; i < voiceInputNumber; i++)
|
||||
{
|
||||
const auto voiceInput = new CallsignSampleProvider(audioFormat, this, m_mixer);
|
||||
const auto voiceInput = new CCallsignSampleProvider(audioFormat, this, m_mixer);
|
||||
m_voiceInputs.push_back(voiceInput);
|
||||
m_mixer->addMixerInput(voiceInput);
|
||||
}
|
||||
@@ -52,7 +55,7 @@ namespace BlackCore
|
||||
|
||||
void CReceiverSampleProvider::setBypassEffects(bool value)
|
||||
{
|
||||
for (CallsignSampleProvider *voiceInput : m_voiceInputs)
|
||||
for (CCallsignSampleProvider *voiceInput : m_voiceInputs)
|
||||
{
|
||||
voiceInput->setBypassEffects(value);
|
||||
}
|
||||
@@ -62,7 +65,7 @@ namespace BlackCore
|
||||
{
|
||||
if (frequencyHz != m_frequencyHz)
|
||||
{
|
||||
for (CallsignSampleProvider *voiceInput : m_voiceInputs)
|
||||
for (CCallsignSampleProvider *voiceInput : m_voiceInputs)
|
||||
{
|
||||
voiceInput->clear();
|
||||
}
|
||||
@@ -72,7 +75,7 @@ namespace BlackCore
|
||||
|
||||
int CReceiverSampleProvider::activeCallsigns() const
|
||||
{
|
||||
const int numberOfCallsigns = static_cast<int>(std::count_if(m_voiceInputs.begin(), m_voiceInputs.end(), [](const CallsignSampleProvider * p)
|
||||
const int numberOfCallsigns = static_cast<int>(std::count_if(m_voiceInputs.begin(), m_voiceInputs.end(), [](const CCallsignSampleProvider * p)
|
||||
{
|
||||
return p->inUse() == true;
|
||||
}));
|
||||
@@ -84,7 +87,7 @@ namespace BlackCore
|
||||
m_mute = value;
|
||||
if (value)
|
||||
{
|
||||
for (CallsignSampleProvider *voiceInput : m_voiceInputs)
|
||||
for (CCallsignSampleProvider *voiceInput : m_voiceInputs)
|
||||
{
|
||||
voiceInput->clear();
|
||||
}
|
||||
@@ -108,14 +111,14 @@ namespace BlackCore
|
||||
{
|
||||
CResourceSoundSampleProvider *resourceSound = new CResourceSoundSampleProvider(Samples::instance().click(), m_mixer);
|
||||
m_mixer->addMixerInput(resourceSound);
|
||||
// CLogMessage(this).debug(u"AFV Click...");
|
||||
m_doClickWhenAppropriate = false;
|
||||
// CLogMessage(this).debug(u"AFV Click...");
|
||||
}
|
||||
|
||||
if (numberOfInUseInputs != m_lastNumberOfInUseInputs)
|
||||
{
|
||||
QStringList receivingCallsigns;
|
||||
for (const CallsignSampleProvider *voiceInput : m_voiceInputs)
|
||||
for (const CCallsignSampleProvider *voiceInput : m_voiceInputs)
|
||||
{
|
||||
const QString callsign = voiceInput->callsign();
|
||||
if (! callsign.isEmpty())
|
||||
@@ -136,9 +139,9 @@ namespace BlackCore
|
||||
void CReceiverSampleProvider::addOpusSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio)
|
||||
{
|
||||
if (m_frequencyHz != frequency) { return; } // Lag in the backend means we get the tail end of a transmission
|
||||
CallsignSampleProvider *voiceInput = nullptr;
|
||||
CCallsignSampleProvider *voiceInput = nullptr;
|
||||
|
||||
auto it = std::find_if(m_voiceInputs.begin(), m_voiceInputs.end(), [audioDto](const CallsignSampleProvider * p)
|
||||
auto it = std::find_if(m_voiceInputs.begin(), m_voiceInputs.end(), [audioDto](const CCallsignSampleProvider * p)
|
||||
{
|
||||
return p->callsign() == audioDto.callsign;
|
||||
});
|
||||
@@ -150,7 +153,7 @@ namespace BlackCore
|
||||
|
||||
if (! voiceInput)
|
||||
{
|
||||
it = std::find_if(m_voiceInputs.begin(), m_voiceInputs.end(), [](const CallsignSampleProvider * p) { return p->inUse() == false; });
|
||||
it = std::find_if(m_voiceInputs.begin(), m_voiceInputs.end(), [](const CCallsignSampleProvider * p) { return p->inUse() == false; });
|
||||
if (it != m_voiceInputs.end())
|
||||
{
|
||||
voiceInput = *it;
|
||||
@@ -173,8 +176,8 @@ namespace BlackCore
|
||||
Q_UNUSED(distanceRatio)
|
||||
if (m_frequencyHz != frequency) { return; } // Lag in the backend means we get the tail end of a transmission
|
||||
|
||||
CallsignSampleProvider *voiceInput = nullptr;
|
||||
auto it = std::find_if(m_voiceInputs.begin(), m_voiceInputs.end(), [audioDto](const CallsignSampleProvider * p)
|
||||
CCallsignSampleProvider *voiceInput = nullptr;
|
||||
auto it = std::find_if(m_voiceInputs.begin(), m_voiceInputs.end(), [audioDto](const CCallsignSampleProvider * p)
|
||||
{
|
||||
return p->callsign() == audioDto.callsign;
|
||||
});
|
||||
@@ -186,7 +189,7 @@ namespace BlackCore
|
||||
|
||||
if (!voiceInput)
|
||||
{
|
||||
it = std::find_if(m_voiceInputs.begin(), m_voiceInputs.end(), [](const CallsignSampleProvider * p) { return p->inUse() == false; });
|
||||
it = std::find_if(m_voiceInputs.begin(), m_voiceInputs.end(), [](const CCallsignSampleProvider * p) { return p->inUse() == false; });
|
||||
if (it != m_voiceInputs.end())
|
||||
{
|
||||
voiceInput = *it;
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace BlackCore
|
||||
BlackSound::SampleProvider::CVolumeSampleProvider *m_volume = nullptr;
|
||||
BlackSound::SampleProvider::CMixingSampleProvider *m_mixer = nullptr;
|
||||
BlackSound::SampleProvider::CSinusGenerator *m_blockTone = nullptr;
|
||||
QVector<CallsignSampleProvider *> m_voiceInputs;
|
||||
QVector<CCallsignSampleProvider *> m_voiceInputs;
|
||||
|
||||
QString m_receivingCallsignsString;
|
||||
BlackMisc::Aviation::CCallsignSet m_receivingCallsigns;
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
* or distributed except according to the terms contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#include "soundcardsampleprovider.h"
|
||||
#include "blackmisc/metadatautils.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackSound::SampleProvider;
|
||||
|
||||
namespace BlackCore
|
||||
@@ -22,6 +22,9 @@ namespace BlackCore
|
||||
ISampleProvider(parent),
|
||||
m_mixer(new CMixingSampleProvider())
|
||||
{
|
||||
const QString on = QStringLiteral("%1 sample rate: %2, transceivers: %3").arg(classNameShort(this)).arg(sampleRate).arg(transceiverIDs.size());
|
||||
this->setObjectName(on);
|
||||
|
||||
m_waveFormat.setSampleRate(sampleRate);
|
||||
m_waveFormat.setChannelCount(1);
|
||||
m_waveFormat.setSampleSize(16);
|
||||
@@ -32,9 +35,10 @@ namespace BlackCore
|
||||
m_mixer = new CMixingSampleProvider(this);
|
||||
m_receiverIDs = transceiverIDs;
|
||||
|
||||
constexpr int voiceInputNumber = 4; // number of CallsignSampleProviders
|
||||
for (quint16 transceiverID : transceiverIDs)
|
||||
{
|
||||
CReceiverSampleProvider *transceiverInput = new CReceiverSampleProvider(m_waveFormat, transceiverID, 4, m_mixer);
|
||||
CReceiverSampleProvider *transceiverInput = new CReceiverSampleProvider(m_waveFormat, transceiverID, voiceInputNumber, m_mixer);
|
||||
connect(transceiverInput, &CReceiverSampleProvider::receivingCallsignsChanged, this, &CSoundcardSampleProvider::receivingCallsignsChanged);
|
||||
m_receiverInputs.push_back(transceiverInput);
|
||||
m_receiverIDs.push_back(transceiverID);
|
||||
@@ -111,7 +115,7 @@ namespace BlackCore
|
||||
QVector<quint16> handledTransceiverIDs;
|
||||
for (int i = 0; i < rxTransceiversFilteredAndSorted.size(); i++)
|
||||
{
|
||||
RxTransceiverDto rxTransceiver = rxTransceiversFilteredAndSorted[i];
|
||||
const RxTransceiverDto rxTransceiver = rxTransceiversFilteredAndSorted[i];
|
||||
if (!handledTransceiverIDs.contains(rxTransceiver.id))
|
||||
{
|
||||
handledTransceiverIDs.push_back(rxTransceiver.id);
|
||||
@@ -121,12 +125,13 @@ namespace BlackCore
|
||||
{
|
||||
return p->getId() == rxTransceiver.id;
|
||||
});
|
||||
|
||||
if (it != m_receiverInputs.end())
|
||||
{
|
||||
receiverInput = *it;
|
||||
}
|
||||
|
||||
if (! receiverInput) { continue; }
|
||||
if (!receiverInput) { continue; }
|
||||
if (receiverInput->getMute()) { continue; }
|
||||
|
||||
if (!audioPlayed)
|
||||
@@ -160,9 +165,9 @@ namespace BlackCore
|
||||
|
||||
for (CReceiverSampleProvider *receiverInput : m_receiverInputs)
|
||||
{
|
||||
quint16 transceiverID = receiverInput->getId();
|
||||
bool contains = std::any_of(radioTransceivers.begin(), radioTransceivers.end(), [&](const auto & tx) { return transceiverID == tx.id; });
|
||||
if (! contains)
|
||||
const quint16 transceiverID = receiverInput->getId();
|
||||
const bool contains = std::any_of(radioTransceivers.cbegin(), radioTransceivers.cend(), [ transceiverID ](const auto &tx) { return transceiverID == tx.id; });
|
||||
if (!contains)
|
||||
{
|
||||
receiverInput->setFrequency(0);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include "cryptodtoserializer.h"
|
||||
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
namespace Afv
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace BlackCore
|
||||
info.m_index = index;
|
||||
++index;
|
||||
info.m_function = function;
|
||||
info.m_action = action;
|
||||
info.m_action = action;
|
||||
info.m_receiver = receiver;
|
||||
m_boundActions.push_back(info);
|
||||
return info.m_index;
|
||||
|
||||
Reference in New Issue
Block a user