mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-28 11:45:40 +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>
|
#include <QDebug>
|
||||||
|
|
||||||
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackSound::SampleProvider;
|
using namespace BlackSound::SampleProvider;
|
||||||
|
|
||||||
namespace BlackCore
|
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)
|
for (CallsignSampleProvider *voiceInput : m_voiceInputs)
|
||||||
{
|
{
|
||||||
voiceInput->clear();
|
voiceInput->clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_frequency = frequency;
|
m_frequencyHz = frequencyHz;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CReceiverSampleProvider::activeCallsigns() const
|
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 p->inUse() == true;
|
||||||
});
|
}));
|
||||||
return numberOfCallsigns;
|
return numberOfCallsigns;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CReceiverSampleProvider::volume() const
|
|
||||||
{
|
|
||||||
return 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CReceiverSampleProvider::getMute() const
|
|
||||||
{
|
|
||||||
return m_mute;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CReceiverSampleProvider::setMute(bool value)
|
void CReceiverSampleProvider::setMute(bool value)
|
||||||
{
|
{
|
||||||
m_mute = value;
|
m_mute = value;
|
||||||
@@ -107,13 +98,17 @@ namespace BlackCore
|
|||||||
|
|
||||||
if (m_doClickWhenAppropriate && numberOfInUseInputs == 0)
|
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);
|
CResourceSoundSampleProvider *resourceSound = new CResourceSoundSampleProvider(Samples::instance().click(), m_mixer);
|
||||||
m_mixer->addMixerInput(resourceSound);
|
m_mixer->addMixerInput(resourceSound);
|
||||||
qDebug() << "Click...";
|
qDebug() << "Click...";
|
||||||
m_doClickWhenAppropriate = false;
|
m_doClickWhenAppropriate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numberOfInUseInputs != lastNumberOfInUseInputs)
|
if (numberOfInUseInputs != m_lastNumberOfInUseInputs)
|
||||||
{
|
{
|
||||||
QStringList receivingCallsigns;
|
QStringList receivingCallsigns;
|
||||||
for (const CallsignSampleProvider *voiceInput : m_voiceInputs)
|
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 };
|
TransceiverReceivingCallsignsChangedArgs args = { m_id, receivingCallsigns };
|
||||||
emit receivingCallsignsChanged(args);
|
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);
|
return m_mixer->readSamples(samples, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CReceiverSampleProvider::addOpusSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio)
|
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;
|
return;
|
||||||
|
|
||||||
CallsignSampleProvider *voiceInput = nullptr;
|
CallsignSampleProvider *voiceInput = nullptr;
|
||||||
@@ -172,7 +168,7 @@ namespace BlackCore
|
|||||||
void CReceiverSampleProvider::addSilentSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio)
|
void CReceiverSampleProvider::addSilentSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio)
|
||||||
{
|
{
|
||||||
Q_UNUSED(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;
|
return;
|
||||||
|
|
||||||
CallsignSampleProvider *voiceInput = nullptr;
|
CallsignSampleProvider *voiceInput = nullptr;
|
||||||
@@ -202,10 +198,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CReceiverSampleProvider::getReceivingCallsigns() const
|
|
||||||
{
|
|
||||||
return m_receivingCallsigns;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
#include "blacksound/sampleprovider/sampleprovider.h"
|
#include "blacksound/sampleprovider/sampleprovider.h"
|
||||||
#include "blacksound/sampleprovider/mixingsampleprovider.h"
|
#include "blacksound/sampleprovider/mixingsampleprovider.h"
|
||||||
|
|
||||||
|
#include "blackmisc/aviation/callsignset.h"
|
||||||
|
#include "blackmisc/audio/audiosettings.h"
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
@@ -40,41 +42,59 @@ namespace BlackCore
|
|||||||
CReceiverSampleProvider(const QAudioFormat &audioFormat, quint16 id, int voiceInputNumber, QObject *parent = nullptr);
|
CReceiverSampleProvider(const QAudioFormat &audioFormat, quint16 id, int voiceInputNumber, QObject *parent = nullptr);
|
||||||
|
|
||||||
void setBypassEffects(bool value);
|
void setBypassEffects(bool value);
|
||||||
void setFrequency(const uint &frequency);
|
void setFrequency(const uint &frequencyHz);
|
||||||
|
|
||||||
|
//! Number of active callsign
|
||||||
int activeCallsigns() const;
|
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);
|
void setMute(bool value);
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
//! \copydoc BlackSound::SampleProvider::ISampleProvider::readSamples
|
||||||
virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
|
virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
|
||||||
|
|
||||||
void addOpusSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio);
|
void addOpusSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio);
|
||||||
void addSilentSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio);
|
void addSilentSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio);
|
||||||
|
|
||||||
quint16 getId() const { return m_id; }
|
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:
|
signals:
|
||||||
|
//! Receving callsigns have changed
|
||||||
void receivingCallsignsChanged(const TransceiverReceivingCallsignsChangedArgs &args);
|
void receivingCallsignsChanged(const TransceiverReceivingCallsignsChangedArgs &args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint m_frequency = 122800;
|
uint m_frequencyHz = 122800000;
|
||||||
bool m_mute = false;
|
bool m_mute = false;
|
||||||
|
|
||||||
const float m_clickGain = 1.0f;
|
const double m_clickGain = 1.0;
|
||||||
const double m_blockToneGain = 0.10f;
|
const double m_blockToneGain = 0.10;
|
||||||
|
|
||||||
quint16 m_id;
|
quint16 m_id;
|
||||||
|
BlackMisc::CSettingReadOnly<BlackMisc::Audio::TSettings> m_audioSettings { this };
|
||||||
|
|
||||||
// TODO VolumeSampleProvider volume;
|
// TODO VolumeSampleProvider volume;
|
||||||
BlackSound::SampleProvider::CMixingSampleProvider *m_mixer = nullptr;
|
BlackSound::SampleProvider::CMixingSampleProvider *m_mixer = nullptr;
|
||||||
// TODO SignalGenerator blockTone;
|
// TODO SignalGenerator blockTone;
|
||||||
QVector<CallsignSampleProvider *> m_voiceInputs;
|
QVector<CallsignSampleProvider *> m_voiceInputs;
|
||||||
QString m_receivingCallsigns;
|
|
||||||
|
QString m_receivingCallsignsString;
|
||||||
|
BlackMisc::Aviation::CCallsignSet m_receivingCallsigns;
|
||||||
|
|
||||||
bool m_doClickWhenAppropriate = false;
|
bool m_doClickWhenAppropriate = false;
|
||||||
int lastNumberOfInUseInputs = 0;
|
int m_lastNumberOfInUseInputs = 0;
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
QString CSoundcardSampleProvider::getReceivingCallsigns(quint16 transceiverID)
|
QString CSoundcardSampleProvider::getReceivingCallsigns(quint16 transceiverID)
|
||||||
{
|
{
|
||||||
return m_receiverInputs.at(transceiverID)->getReceivingCallsigns();
|
return m_receiverInputs.at(transceiverID)->getReceivingCallsignsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -479,8 +479,8 @@ namespace BlackCore
|
|||||||
const QAudioDeviceInfo &CAfvClient::getOutputDevice() const
|
const QAudioDeviceInfo &CAfvClient::getOutputDevice() const
|
||||||
{
|
{
|
||||||
if (m_output) { return m_output->device(); }
|
if (m_output) { return m_output->device(); }
|
||||||
static const QAudioDeviceInfo null = QAudioDeviceInfo();
|
static const QAudioDeviceInfo nullDevice = QAudioDeviceInfo();
|
||||||
return null;
|
return nullDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAfvClient::ConnectionStatus CAfvClient::getConnectionStatus() const
|
CAfvClient::ConnectionStatus CAfvClient::getConnectionStatus() const
|
||||||
|
|||||||
@@ -139,7 +139,8 @@ namespace BlackCore
|
|||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Callsigns have been changed
|
//! Receiving callsigns have been changed
|
||||||
|
//! \remark callsigns I do receive
|
||||||
void receivingCallsignsChanged(const Audio::TransceiverReceivingCallsignsChangedArgs &args);
|
void receivingCallsignsChanged(const Audio::TransceiverReceivingCallsignsChangedArgs &args);
|
||||||
|
|
||||||
//! Connection status has been changed
|
//! Connection status has been changed
|
||||||
|
|||||||
@@ -21,6 +21,16 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
CCallsignSet::CCallsignSet() { }
|
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)
|
CCallsignSet::CCallsignSet(const CCallsign &callsign)
|
||||||
{
|
{
|
||||||
if (callsign.isEmpty()) { return; }
|
if (callsign.isEmpty()) { return; }
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "blackmisc/sequence.h"
|
#include "blackmisc/sequence.h"
|
||||||
|
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
|
#include <QStringList>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
@@ -30,9 +31,12 @@ namespace BlackMisc
|
|||||||
using CCollection::CCollection;
|
using CCollection::CCollection;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Default constructor.
|
//! Default constructor
|
||||||
CCallsignSet();
|
CCallsignSet();
|
||||||
|
|
||||||
|
//! By string list
|
||||||
|
CCallsignSet(const QStringList &callsigns);
|
||||||
|
|
||||||
//! Construct from single callsign
|
//! Construct from single callsign
|
||||||
CCallsignSet(const CCallsign &callsign);
|
CCallsignSet(const CCallsign &callsign);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user