mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
Ref T730, callsign set used for received callsigns
This commit is contained in:
committed by
Mat Sutcliffe
parent
5a19bbdb5e
commit
7c89234f8c
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackSound::SampleProvider;
|
||||
|
||||
namespace BlackCore
|
||||
@@ -48,37 +49,27 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void CReceiverSampleProvider::setFrequency(const uint &frequency)
|
||||
void CReceiverSampleProvider::setFrequency(const uint &frequencyHz)
|
||||
{
|
||||
if (frequency != m_frequency)
|
||||
if (frequencyHz != m_frequencyHz)
|
||||
{
|
||||
for (CallsignSampleProvider *voiceInput : m_voiceInputs)
|
||||
{
|
||||
voiceInput->clear();
|
||||
}
|
||||
}
|
||||
m_frequency = frequency;
|
||||
m_frequencyHz = frequencyHz;
|
||||
}
|
||||
|
||||
int CReceiverSampleProvider::activeCallsigns() const
|
||||
{
|
||||
const int numberOfCallsigns = 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 CallsignSampleProvider * p)
|
||||
{
|
||||
return p->inUse() == true;
|
||||
});
|
||||
}));
|
||||
return numberOfCallsigns;
|
||||
}
|
||||
|
||||
float CReceiverSampleProvider::volume() const
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
bool CReceiverSampleProvider::getMute() const
|
||||
{
|
||||
return m_mute;
|
||||
}
|
||||
|
||||
void CReceiverSampleProvider::setMute(bool value)
|
||||
{
|
||||
m_mute = value;
|
||||
@@ -107,13 +98,17 @@ namespace BlackCore
|
||||
|
||||
if (m_doClickWhenAppropriate && numberOfInUseInputs == 0)
|
||||
{
|
||||
const bool doClick = m_audioSettings.get().pttClickDown();
|
||||
Q_UNUSED(doClick)
|
||||
//! \todo consider the settings
|
||||
|
||||
CResourceSoundSampleProvider *resourceSound = new CResourceSoundSampleProvider(Samples::instance().click(), m_mixer);
|
||||
m_mixer->addMixerInput(resourceSound);
|
||||
qDebug() << "Click...";
|
||||
m_doClickWhenAppropriate = false;
|
||||
}
|
||||
|
||||
if (numberOfInUseInputs != lastNumberOfInUseInputs)
|
||||
if (numberOfInUseInputs != m_lastNumberOfInUseInputs)
|
||||
{
|
||||
QStringList receivingCallsigns;
|
||||
for (const CallsignSampleProvider *voiceInput : m_voiceInputs)
|
||||
@@ -125,19 +120,20 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
m_receivingCallsigns = receivingCallsigns.join(',');
|
||||
m_receivingCallsignsString = receivingCallsigns.join(',');
|
||||
m_receivingCallsigns = CCallsignSet(receivingCallsigns);
|
||||
TransceiverReceivingCallsignsChangedArgs args = { m_id, receivingCallsigns };
|
||||
emit receivingCallsignsChanged(args);
|
||||
}
|
||||
lastNumberOfInUseInputs = numberOfInUseInputs;
|
||||
m_lastNumberOfInUseInputs = numberOfInUseInputs;
|
||||
|
||||
// return volume.Read(buffer, offset, count);
|
||||
// return volume.Read(buffer, offset, count);
|
||||
return m_mixer->readSamples(samples, count);
|
||||
}
|
||||
|
||||
void CReceiverSampleProvider::addOpusSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio)
|
||||
{
|
||||
if (m_frequency != frequency) //Lag in the backend means we get the tail end of a transmission
|
||||
if (m_frequencyHz != frequency) //Lag in the backend means we get the tail end of a transmission
|
||||
return;
|
||||
|
||||
CallsignSampleProvider *voiceInput = nullptr;
|
||||
@@ -172,7 +168,7 @@ namespace BlackCore
|
||||
void CReceiverSampleProvider::addSilentSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio)
|
||||
{
|
||||
Q_UNUSED(distanceRatio);
|
||||
if (m_frequency != frequency) //Lag in the backend means we get the tail end of a transmission
|
||||
if (m_frequencyHz != frequency) //Lag in the backend means we get the tail end of a transmission
|
||||
return;
|
||||
|
||||
CallsignSampleProvider *voiceInput = nullptr;
|
||||
@@ -202,10 +198,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
QString CReceiverSampleProvider::getReceivingCallsigns() const
|
||||
{
|
||||
return m_receivingCallsigns;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // ns
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "blacksound/sampleprovider/sampleprovider.h"
|
||||
#include "blacksound/sampleprovider/mixingsampleprovider.h"
|
||||
|
||||
#include "blackmisc/aviation/callsignset.h"
|
||||
#include "blackmisc/audio/audiosettings.h"
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace BlackCore
|
||||
@@ -40,41 +42,59 @@ namespace BlackCore
|
||||
CReceiverSampleProvider(const QAudioFormat &audioFormat, quint16 id, int voiceInputNumber, QObject *parent = nullptr);
|
||||
|
||||
void setBypassEffects(bool value);
|
||||
void setFrequency(const uint &frequency);
|
||||
void setFrequency(const uint &frequencyHz);
|
||||
|
||||
//! Number of active callsign
|
||||
int activeCallsigns() const;
|
||||
float volume() const;
|
||||
|
||||
bool getMute() const;
|
||||
//! Volume
|
||||
double volume() const { return 1.0; }
|
||||
|
||||
//! Mute @{
|
||||
bool getMute() const { return m_mute; }
|
||||
void setMute(bool value);
|
||||
//! @}
|
||||
|
||||
//! \copydoc BlackSound::SampleProvider::ISampleProvider::readSamples
|
||||
virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
|
||||
|
||||
void addOpusSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio);
|
||||
void addSilentSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio);
|
||||
|
||||
quint16 getId() const { return m_id; }
|
||||
QString getReceivingCallsigns() const;
|
||||
|
||||
//! Receiving callsigns as string
|
||||
//! \remark those callsigns are transmitting and "I do receive them"
|
||||
const QString &getReceivingCallsignsString() const { return m_receivingCallsignsString; }
|
||||
|
||||
//! Receiving callsigns
|
||||
//! \remark those callsigns are transmitting and "I do receive them"
|
||||
const BlackMisc::Aviation::CCallsignSet &getReceivingCallsigns() { return m_receivingCallsigns; }
|
||||
|
||||
signals:
|
||||
//! Receving callsigns have changed
|
||||
void receivingCallsignsChanged(const TransceiverReceivingCallsignsChangedArgs &args);
|
||||
|
||||
private:
|
||||
uint m_frequency = 122800;
|
||||
uint m_frequencyHz = 122800000;
|
||||
bool m_mute = false;
|
||||
|
||||
const float m_clickGain = 1.0f;
|
||||
const double m_blockToneGain = 0.10f;
|
||||
const double m_clickGain = 1.0;
|
||||
const double m_blockToneGain = 0.10;
|
||||
|
||||
quint16 m_id;
|
||||
BlackMisc::CSettingReadOnly<BlackMisc::Audio::TSettings> m_audioSettings { this };
|
||||
|
||||
// TODO VolumeSampleProvider volume;
|
||||
BlackSound::SampleProvider::CMixingSampleProvider *m_mixer = nullptr;
|
||||
// TODO SignalGenerator blockTone;
|
||||
QVector<CallsignSampleProvider *> m_voiceInputs;
|
||||
QString m_receivingCallsigns;
|
||||
|
||||
QString m_receivingCallsignsString;
|
||||
BlackMisc::Aviation::CCallsignSet m_receivingCallsigns;
|
||||
|
||||
bool m_doClickWhenAppropriate = false;
|
||||
int lastNumberOfInUseInputs = 0;
|
||||
int m_lastNumberOfInUseInputs = 0;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace BlackCore
|
||||
|
||||
QString CSoundcardSampleProvider::getReceivingCallsigns(quint16 transceiverID)
|
||||
{
|
||||
return m_receiverInputs.at(transceiverID)->getReceivingCallsigns();
|
||||
return m_receiverInputs.at(transceiverID)->getReceivingCallsignsString();
|
||||
}
|
||||
|
||||
} // ns
|
||||
|
||||
@@ -479,8 +479,8 @@ namespace BlackCore
|
||||
const QAudioDeviceInfo &CAfvClient::getOutputDevice() const
|
||||
{
|
||||
if (m_output) { return m_output->device(); }
|
||||
static const QAudioDeviceInfo null = QAudioDeviceInfo();
|
||||
return null;
|
||||
static const QAudioDeviceInfo nullDevice = QAudioDeviceInfo();
|
||||
return nullDevice;
|
||||
}
|
||||
|
||||
CAfvClient::ConnectionStatus CAfvClient::getConnectionStatus() const
|
||||
|
||||
@@ -139,7 +139,8 @@ namespace BlackCore
|
||||
//! @}
|
||||
|
||||
signals:
|
||||
//! Callsigns have been changed
|
||||
//! Receiving callsigns have been changed
|
||||
//! \remark callsigns I do receive
|
||||
void receivingCallsignsChanged(const Audio::TransceiverReceivingCallsignsChangedArgs &args);
|
||||
|
||||
//! Connection status has been changed
|
||||
|
||||
@@ -21,6 +21,16 @@ namespace BlackMisc
|
||||
{
|
||||
CCallsignSet::CCallsignSet() { }
|
||||
|
||||
CCallsignSet::CCallsignSet(const QStringList &callsigns)
|
||||
{
|
||||
for (const QString &c : callsigns)
|
||||
{
|
||||
if (c.isEmpty()) { continue; }
|
||||
const CCallsign cs(c);
|
||||
this->push_back(cs);
|
||||
}
|
||||
}
|
||||
|
||||
CCallsignSet::CCallsignSet(const CCallsign &callsign)
|
||||
{
|
||||
if (callsign.isEmpty()) { return; }
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "blackmisc/sequence.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QStringList>
|
||||
#include <tuple>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -30,9 +31,12 @@ namespace BlackMisc
|
||||
using CCollection::CCollection;
|
||||
|
||||
public:
|
||||
//! Default constructor.
|
||||
//! Default constructor
|
||||
CCallsignSet();
|
||||
|
||||
//! By string list
|
||||
CCallsignSet(const QStringList &callsigns);
|
||||
|
||||
//! Construct from single callsign
|
||||
CCallsignSet(const CCallsign &callsign);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user