mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T730, style
This commit is contained in:
committed by
Mat Sutcliffe
parent
c1470f6069
commit
bde7baf84d
@@ -61,15 +61,16 @@ namespace BlackCore
|
||||
static constexpr int SampleCountPerEvent = 4800;
|
||||
QAudioFormat m_outputFormat;
|
||||
double m_maxSampleOutput = 0;
|
||||
int m_sampleCount = 0;
|
||||
const double m_maxDb = 0;
|
||||
const double m_minDb = -40;
|
||||
int m_sampleCount = 0;
|
||||
const double m_maxDb = 0;
|
||||
const double m_minDb = -40;
|
||||
};
|
||||
|
||||
//! Output
|
||||
class Output : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
Output(QObject *parent = nullptr);
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace BlackCore
|
||||
outputSampleProvider->setVolume(m_outputVolume);
|
||||
|
||||
m_output->start(outputDevice.isNull() ? QAudioDeviceInfo::defaultOutputDevice() : outputDevice, outputSampleProvider);
|
||||
m_input->start(inputDevice.isNull() ? QAudioDeviceInfo::defaultInputDevice() : inputDevice);
|
||||
m_input->start(inputDevice.isNull() ? QAudioDeviceInfo::defaultInputDevice() : inputDevice);
|
||||
|
||||
m_startDateTimeUtc = QDateTime::currentDateTimeUtc();
|
||||
m_connection->setReceiveAudio(true);
|
||||
@@ -226,7 +226,7 @@ namespace BlackCore
|
||||
|
||||
void CAfvClient::updateComFrequency(CComSystem::ComUnit comUnit, const CFrequency &comFrequency)
|
||||
{
|
||||
const int freqHz = static_cast<int>(comFrequency.valueInteger(CFrequencyUnit::Hz()));
|
||||
const quint16 freqHz = static_cast<quint16>(comFrequency.valueInteger(CFrequencyUnit::Hz()));
|
||||
this->updateComFrequency(comUnitToTransceiverId(comUnit), freqHz);
|
||||
}
|
||||
|
||||
@@ -494,13 +494,13 @@ namespace BlackCore
|
||||
this->updateComFrequency(CComSystem::Com1, com1);
|
||||
this->updateComFrequency(CComSystem::Com2, com2);
|
||||
|
||||
const bool tx1 = com1.isTransmitEnabled();
|
||||
const bool rec1 = com1.isReceiveEnabled();
|
||||
const bool tx2 = com2.isTransmitEnabled();
|
||||
const bool rec2 = com2.isReceiveEnabled();
|
||||
const bool tx1 = com1.isTransmitEnabled();
|
||||
const bool rx1 = com1.isReceiveEnabled();
|
||||
const bool tx2 = com2.isTransmitEnabled();
|
||||
const bool rx2 = com2.isReceiveEnabled();
|
||||
|
||||
this->enableComUnit(CComSystem::Com1, tx1 || rec1);
|
||||
this->enableComUnit(CComSystem::Com2, tx2 || rec2);
|
||||
this->enableComUnit(CComSystem::Com1, tx1 || rx1);
|
||||
this->enableComUnit(CComSystem::Com2, tx2 || rx2);
|
||||
this->setTransmittingComUnit(CComSystem::Com1);
|
||||
this->setTransmittingComUnit(CComSystem::Com2);
|
||||
|
||||
|
||||
@@ -58,8 +58,8 @@ namespace BlackCore
|
||||
CIdentifiable(this),
|
||||
m_voiceClient(("https://voice1.vatsim.uk"))
|
||||
{
|
||||
|
||||
this->setVoiceOutputVolume(m_audioSettings.getThreadLocal().getOutVolume());
|
||||
const CSettings as = m_audioSettings.getThreadLocal();
|
||||
this->setVoiceOutputVolume(as.getOutVolume());
|
||||
m_selcalPlayer = new CSelcalPlayer(QAudioDeviceInfo::defaultOutputDevice(), this);
|
||||
|
||||
connect(&m_voiceClient, &CAfvClient::ptt, this, &CContextAudio::ptt);
|
||||
|
||||
@@ -196,10 +196,10 @@ namespace BlackGui
|
||||
const bool com2Tx = com2Enabled && client->isTransmittingdComUnit(CComSystem::Com2);
|
||||
|
||||
// we do not have receiving
|
||||
const bool com1Rec = com1Enabled;
|
||||
const bool com2Rec = com2Enabled;
|
||||
const bool com1Rx = com1Enabled;
|
||||
const bool com2Rx = com2Enabled;
|
||||
|
||||
this->setTransmitReceiveInUi(com1Tx, com1Rec, com2Tx, com2Rec);
|
||||
this->setTransmitReceiveInUi(com1Tx, com1Rx, com2Tx, com2Rx);
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::reloadSettings()
|
||||
|
||||
@@ -106,7 +106,6 @@ namespace BlackGui
|
||||
BlackMisc::Audio::CAudioDeviceInfo getSelectedInputDevice() const;
|
||||
BlackMisc::Audio::CAudioDeviceInfo getSelectedOutputDevice() const;
|
||||
|
||||
|
||||
//! Transmit and receive state @{
|
||||
void setTransmitReceiveInUi(bool tx1, bool rec1, bool tx2, bool rec2);
|
||||
void setTransmitReceiveInUiFromVoiceClient();
|
||||
|
||||
@@ -31,14 +31,16 @@ namespace BlackSound
|
||||
//! Ctor
|
||||
CBufferedWaveProvider(const QAudioFormat &format, QObject *parent = nullptr);
|
||||
|
||||
//! Add samples
|
||||
void addSamples(const QVector<qint16> &samples);
|
||||
|
||||
//! ISampleProvider::readSamples
|
||||
virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
|
||||
|
||||
//! Bytes from buffer
|
||||
int getBufferedBytes() const { return m_audioBuffer.size(); }
|
||||
|
||||
|
||||
//! Clear the buffer
|
||||
void clearBuffer();
|
||||
|
||||
private:
|
||||
|
||||
@@ -20,18 +20,22 @@ namespace BlackSound
|
||||
{
|
||||
namespace SampleProvider
|
||||
{
|
||||
//! Mixer
|
||||
class BLACKSOUND_EXPORT CMixingSampleProvider : public ISampleProvider
|
||||
{
|
||||
public:
|
||||
CMixingSampleProvider(QObject *parent = nullptr) : ISampleProvider(parent) {}
|
||||
|
||||
//! Add a provider
|
||||
void addMixerInput(ISampleProvider *provider) { m_sources.append(provider); }
|
||||
|
||||
//! \copydoc ISampleProvider::readSamples
|
||||
virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
|
||||
|
||||
private:
|
||||
QVector<ISampleProvider *> m_sources;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -21,17 +21,17 @@ namespace BlackSound
|
||||
int CSawToothGenerator::readSamples(QVector<qint16> &samples, qint64 count)
|
||||
{
|
||||
samples.clear();
|
||||
samples.fill(0, count);
|
||||
samples.fill(0, static_cast<int>(count));
|
||||
|
||||
for (int sampleCount = 0; sampleCount < count; sampleCount++)
|
||||
{
|
||||
double multiple = 2 * m_frequency / m_sampleRate;
|
||||
double sampleSaw = std::fmod((m_nSample * multiple), 2) - 1;
|
||||
double sampleValue = m_gain * sampleSaw;
|
||||
samples[sampleCount] = sampleValue * 32768;
|
||||
samples[sampleCount] = static_cast<qint16>(qRound(sampleValue * 32768));
|
||||
m_nSample++;
|
||||
}
|
||||
return static_cast<int>(count);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -27,10 +27,13 @@ namespace BlackSound
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
CSawToothGenerator(double frequency, QObject *parent = nullptr);
|
||||
|
||||
//! \copydoc ISampleProvider::readSamples
|
||||
virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
|
||||
|
||||
//! Set the gain
|
||||
void setGain(double gain) { m_gain = gain; }
|
||||
|
||||
private:
|
||||
@@ -39,7 +42,7 @@ namespace BlackSound
|
||||
double m_sampleRate = 48000;
|
||||
int m_nSample = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -22,27 +22,32 @@ namespace BlackSound
|
||||
{
|
||||
namespace SampleProvider
|
||||
{
|
||||
//! Compressor effect
|
||||
class BLACKSOUND_EXPORT CSimpleCompressorEffect : public ISampleProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
CSimpleCompressorEffect(ISampleProvider *source, QObject *parent = nullptr);
|
||||
|
||||
//! \copydoc ISampleProvider::readSamples
|
||||
virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
|
||||
|
||||
//! Enable
|
||||
void setEnabled(bool enabled);
|
||||
|
||||
//! Set gain
|
||||
void setMakeUpGain(double gain);
|
||||
|
||||
private:
|
||||
|
||||
QTimer m_timer;
|
||||
ISampleProvider *m_sourceStream;
|
||||
ISampleProvider *m_sourceStream = nullptr;
|
||||
bool m_enabled = true;
|
||||
chunkware_simple::SimpleComp m_simpleCompressor;
|
||||
const int channels = 1;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user