11using namespace swift::config;
13using namespace swift::sound::sample_provider;
15namespace swift::core::afv::audio
21 const QString on = QStringLiteral(
"%1 sample rate: %2, transceivers: %3")
27 m_waveFormat.setSampleRate(sampleRate);
28 m_waveFormat.setChannelCount(1);
29 m_waveFormat.setSampleFormat(QAudioFormat::Int16);
30 static_assert(Q_BYTE_ORDER == Q_LITTLE_ENDIAN);
33 m_receiverIDs = transceiverIDs;
35 constexpr int voiceInputNumber = 4;
36 for (quint16 transceiverID : transceiverIDs)
41 m_receiverInputs.push_back(transceiverInput);
42 m_receiverIDs.push_back(transceiverID);
43 m_mixer->addMixerInput(transceiverInput);
51 receiverInput->setBypassEffects(value);
63 txTransceiversFiltered.
erase(
64 std::ranges::remove_if(txTransceiversFiltered,
67 txTransceiversFiltered.
end());
72 return p->
getId() == txTransceiver.id;
75 if (it != m_receiverInputs.end())
86 receiverInput->setMute(
false);
93 return m_mixer->readSamples(samples, count);
101 rxTransceiversFilteredAndSorted.
erase(
102 std::ranges::remove_if(rxTransceiversFilteredAndSorted,
105 rxTransceiversFilteredAndSorted.
end());
107 std::ranges::sort(rxTransceiversFilteredAndSorted,
112 if (!rxTransceiversFilteredAndSorted.
isEmpty())
114 bool audioPlayed =
false;
116 for (
const auto rxTransceiver : rxTransceiversFilteredAndSorted)
118 if (!handledTransceiverIDs.
contains(rxTransceiver.id))
120 handledTransceiverIDs.
push_back(rxTransceiver.id);
124 return p->
getId() == rxTransceiver.id;
127 if (it != m_receiverInputs.end())
143 receiverInput->
addOpusSamples(audioDto, rxTransceiver.frequency, rxTransceiver.distanceRatio);
148 receiverInput->
addSilentSamples(audioDto, rxTransceiver.frequency, rxTransceiver.distanceRatio);
154 receiverInput->logVoiceInputs(QStringLiteral(
"Transceiver %1 ").arg(rxTransceiver.id), 1500);
166 return p->
getId() == radioTransceiver.id;
169 if (it != m_receiverInputs.end())
171 (*it)->setFrequency(radioTransceiver.frequencyHz);
177 const quint16 transceiverID = receiverInput->getId();
178 const bool contains = std::ranges::any_of(
179 radioTransceivers, [transceiverID](
const auto &tx) {
return transceiverID == tx.id; });
182 receiverInput->setFrequency(0);
189 return m_receiverInputs.
at(transceiverID)->getReceivingCallsignsString();
194 auto receiverInput = std::ranges::find_if(
195 m_receiverInputs, [&](
const auto receiver) {
return receiver->getId() == transceiverID; });
196 if (receiverInput == m_receiverInputs.end())
200 return (*receiverInput)->setGainRatio(gainRatio);
205 return m_receiverInputs.at(transceiverID)->getReceivingCallsigns();
static bool isLocalDeveloperDebugBuild()
Local build for developers.
void addSilentSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio)
Add samples.
void receivingCallsignsChanged(const TransceiverReceivingCallsignsChangedArgs &args)
Receving callsigns have changed.
bool getMute() const
Mute.
void addOpusSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio)
Add samples.
int readSamples(QVector< float > &samples, qint64 count)
Read samples.
bool setGainRatioForTransceiver(quint16 transceiverID, double gainRatio)
Setting gain for specified receiver.
void setBypassEffects(bool value)
Bypass effects.
swift::misc::aviation::CCallsignSet getReceivingCallsigns(quint16 transceiverID) const
Receiving callsign as single string.
void receivingCallsignsChanged(const TransceiverReceivingCallsignsChangedArgs &args)
Changed callsigns.
void updateRadioTransceivers(const QVector< TransceiverDto > &radioTransceivers)
Update all tranceivers.
QString getReceivingCallsignsString(quint16 transceiverID) const
Receiving callsign as single string.
void pttUpdate(bool active, const QVector< TxTransceiverDto > &txTransceivers)
Update PTT.
CSoundcardSampleProvider(int sampleRate, const QVector< quint16 > &transceiverIDs, QObject *parent=nullptr)
Ctor.
void addOpusSamples(const IAudioDto &audioDto, const QVector< RxTransceiverDto > &rxTransceivers)
Add OPUS samples.
Value object for a set of callsigns.
ISampleProvider(QObject *parent=nullptr)
Ctor.
Free functions in swift::misc.
QString classNameShort(const QObject *object)
Class name as from QMetaObject::className without namespace.
bool contains(const AT &value) const const
QList< T >::iterator end()
QList< T >::iterator erase(QList< T >::const_iterator begin, QList< T >::const_iterator end)
bool isEmpty() const const
void push_back(QList< T >::parameter_type value)
qsizetype size() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
void setObjectName(QAnyStringView name)
QString arg(Args &&... args) const const
const QChar at(qsizetype position) const const
float distanceRatio
Properties.
Transmit transceiver DTO.