Ref T730, style

This commit is contained in:
Klaus Basan
2019-09-29 15:37:59 +02:00
committed by Mat Sutcliffe
parent c1470f6069
commit bde7baf84d
10 changed files with 44 additions and 30 deletions

View File

@@ -61,15 +61,16 @@ namespace BlackCore
static constexpr int SampleCountPerEvent = 4800; static constexpr int SampleCountPerEvent = 4800;
QAudioFormat m_outputFormat; QAudioFormat m_outputFormat;
double m_maxSampleOutput = 0; double m_maxSampleOutput = 0;
int m_sampleCount = 0; int m_sampleCount = 0;
const double m_maxDb = 0; const double m_maxDb = 0;
const double m_minDb = -40; const double m_minDb = -40;
}; };
//! Output //! Output
class Output : public QObject class Output : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
//! Ctor //! Ctor
Output(QObject *parent = nullptr); Output(QObject *parent = nullptr);

View File

@@ -142,7 +142,7 @@ namespace BlackCore
outputSampleProvider->setVolume(m_outputVolume); outputSampleProvider->setVolume(m_outputVolume);
m_output->start(outputDevice.isNull() ? QAudioDeviceInfo::defaultOutputDevice() : outputDevice, outputSampleProvider); 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_startDateTimeUtc = QDateTime::currentDateTimeUtc();
m_connection->setReceiveAudio(true); m_connection->setReceiveAudio(true);
@@ -226,7 +226,7 @@ namespace BlackCore
void CAfvClient::updateComFrequency(CComSystem::ComUnit comUnit, const CFrequency &comFrequency) 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); this->updateComFrequency(comUnitToTransceiverId(comUnit), freqHz);
} }
@@ -494,13 +494,13 @@ namespace BlackCore
this->updateComFrequency(CComSystem::Com1, com1); this->updateComFrequency(CComSystem::Com1, com1);
this->updateComFrequency(CComSystem::Com2, com2); this->updateComFrequency(CComSystem::Com2, com2);
const bool tx1 = com1.isTransmitEnabled(); const bool tx1 = com1.isTransmitEnabled();
const bool rec1 = com1.isReceiveEnabled(); const bool rx1 = com1.isReceiveEnabled();
const bool tx2 = com2.isTransmitEnabled(); const bool tx2 = com2.isTransmitEnabled();
const bool rec2 = com2.isReceiveEnabled(); const bool rx2 = com2.isReceiveEnabled();
this->enableComUnit(CComSystem::Com1, tx1 || rec1); this->enableComUnit(CComSystem::Com1, tx1 || rx1);
this->enableComUnit(CComSystem::Com2, tx2 || rec2); this->enableComUnit(CComSystem::Com2, tx2 || rx2);
this->setTransmittingComUnit(CComSystem::Com1); this->setTransmittingComUnit(CComSystem::Com1);
this->setTransmittingComUnit(CComSystem::Com2); this->setTransmittingComUnit(CComSystem::Com2);

View File

@@ -58,8 +58,8 @@ namespace BlackCore
CIdentifiable(this), CIdentifiable(this),
m_voiceClient(("https://voice1.vatsim.uk")) m_voiceClient(("https://voice1.vatsim.uk"))
{ {
const CSettings as = m_audioSettings.getThreadLocal();
this->setVoiceOutputVolume(m_audioSettings.getThreadLocal().getOutVolume()); this->setVoiceOutputVolume(as.getOutVolume());
m_selcalPlayer = new CSelcalPlayer(QAudioDeviceInfo::defaultOutputDevice(), this); m_selcalPlayer = new CSelcalPlayer(QAudioDeviceInfo::defaultOutputDevice(), this);
connect(&m_voiceClient, &CAfvClient::ptt, this, &CContextAudio::ptt); connect(&m_voiceClient, &CAfvClient::ptt, this, &CContextAudio::ptt);

View File

@@ -196,10 +196,10 @@ namespace BlackGui
const bool com2Tx = com2Enabled && client->isTransmittingdComUnit(CComSystem::Com2); const bool com2Tx = com2Enabled && client->isTransmittingdComUnit(CComSystem::Com2);
// we do not have receiving // we do not have receiving
const bool com1Rec = com1Enabled; const bool com1Rx = com1Enabled;
const bool com2Rec = com2Enabled; const bool com2Rx = com2Enabled;
this->setTransmitReceiveInUi(com1Tx, com1Rec, com2Tx, com2Rec); this->setTransmitReceiveInUi(com1Tx, com1Rx, com2Tx, com2Rx);
} }
void CAudioDeviceVolumeSetupComponent::reloadSettings() void CAudioDeviceVolumeSetupComponent::reloadSettings()

View File

@@ -106,7 +106,6 @@ namespace BlackGui
BlackMisc::Audio::CAudioDeviceInfo getSelectedInputDevice() const; BlackMisc::Audio::CAudioDeviceInfo getSelectedInputDevice() const;
BlackMisc::Audio::CAudioDeviceInfo getSelectedOutputDevice() const; BlackMisc::Audio::CAudioDeviceInfo getSelectedOutputDevice() const;
//! Transmit and receive state @{ //! Transmit and receive state @{
void setTransmitReceiveInUi(bool tx1, bool rec1, bool tx2, bool rec2); void setTransmitReceiveInUi(bool tx1, bool rec1, bool tx2, bool rec2);
void setTransmitReceiveInUiFromVoiceClient(); void setTransmitReceiveInUiFromVoiceClient();

View File

@@ -31,14 +31,16 @@ namespace BlackSound
//! Ctor //! Ctor
CBufferedWaveProvider(const QAudioFormat &format, QObject *parent = nullptr); CBufferedWaveProvider(const QAudioFormat &format, QObject *parent = nullptr);
//! Add samples
void addSamples(const QVector<qint16> &samples); void addSamples(const QVector<qint16> &samples);
//! ISampleProvider::readSamples //! ISampleProvider::readSamples
virtual int readSamples(QVector<qint16> &samples, qint64 count) override; virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
//! Bytes from buffer
int getBufferedBytes() const { return m_audioBuffer.size(); } int getBufferedBytes() const { return m_audioBuffer.size(); }
//! Clear the buffer
void clearBuffer(); void clearBuffer();
private: private:

View File

@@ -20,18 +20,22 @@ namespace BlackSound
{ {
namespace SampleProvider namespace SampleProvider
{ {
//! Mixer
class BLACKSOUND_EXPORT CMixingSampleProvider : public ISampleProvider class BLACKSOUND_EXPORT CMixingSampleProvider : public ISampleProvider
{ {
public: public:
CMixingSampleProvider(QObject *parent = nullptr) : ISampleProvider(parent) {} CMixingSampleProvider(QObject *parent = nullptr) : ISampleProvider(parent) {}
//! Add a provider
void addMixerInput(ISampleProvider *provider) { m_sources.append(provider); } void addMixerInput(ISampleProvider *provider) { m_sources.append(provider); }
//! \copydoc ISampleProvider::readSamples
virtual int readSamples(QVector<qint16> &samples, qint64 count) override; virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
private: private:
QVector<ISampleProvider *> m_sources; QVector<ISampleProvider *> m_sources;
}; };
} } // ns
} } // ns
#endif // guard #endif // guard

View File

@@ -21,17 +21,17 @@ namespace BlackSound
int CSawToothGenerator::readSamples(QVector<qint16> &samples, qint64 count) int CSawToothGenerator::readSamples(QVector<qint16> &samples, qint64 count)
{ {
samples.clear(); samples.clear();
samples.fill(0, count); samples.fill(0, static_cast<int>(count));
for (int sampleCount = 0; sampleCount < count; sampleCount++) for (int sampleCount = 0; sampleCount < count; sampleCount++)
{ {
double multiple = 2 * m_frequency / m_sampleRate; double multiple = 2 * m_frequency / m_sampleRate;
double sampleSaw = std::fmod((m_nSample * multiple), 2) - 1; double sampleSaw = std::fmod((m_nSample * multiple), 2) - 1;
double sampleValue = m_gain * sampleSaw; double sampleValue = m_gain * sampleSaw;
samples[sampleCount] = sampleValue * 32768; samples[sampleCount] = static_cast<qint16>(qRound(sampleValue * 32768));
m_nSample++; m_nSample++;
} }
return static_cast<int>(count); return static_cast<int>(count);
} }
} } // ns
} } // ns

View File

@@ -27,10 +27,13 @@ namespace BlackSound
Q_OBJECT Q_OBJECT
public: public:
//! Ctor
CSawToothGenerator(double frequency, QObject *parent = nullptr); CSawToothGenerator(double frequency, QObject *parent = nullptr);
//! \copydoc ISampleProvider::readSamples
virtual int readSamples(QVector<qint16> &samples, qint64 count) override; virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
//! Set the gain
void setGain(double gain) { m_gain = gain; } void setGain(double gain) { m_gain = gain; }
private: private:
@@ -39,7 +42,7 @@ namespace BlackSound
double m_sampleRate = 48000; double m_sampleRate = 48000;
int m_nSample = 0; int m_nSample = 0;
}; };
} } // ns
} } // ns
#endif // guard #endif // guard

View File

@@ -22,27 +22,32 @@ namespace BlackSound
{ {
namespace SampleProvider namespace SampleProvider
{ {
//! Compressor effect
class BLACKSOUND_EXPORT CSimpleCompressorEffect : public ISampleProvider class BLACKSOUND_EXPORT CSimpleCompressorEffect : public ISampleProvider
{ {
Q_OBJECT Q_OBJECT
public: public:
//! Ctor
CSimpleCompressorEffect(ISampleProvider *source, QObject *parent = nullptr); CSimpleCompressorEffect(ISampleProvider *source, QObject *parent = nullptr);
//! \copydoc ISampleProvider::readSamples
virtual int readSamples(QVector<qint16> &samples, qint64 count) override; virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
//! Enable
void setEnabled(bool enabled); void setEnabled(bool enabled);
//! Set gain
void setMakeUpGain(double gain); void setMakeUpGain(double gain);
private: private:
QTimer m_timer; QTimer m_timer;
ISampleProvider *m_sourceStream; ISampleProvider *m_sourceStream = nullptr;
bool m_enabled = true; bool m_enabled = true;
chunkware_simple::SimpleComp m_simpleCompressor; chunkware_simple::SimpleComp m_simpleCompressor;
const int channels = 1; const int channels = 1;
}; };
} } // ns
} } // ns
#endif // guard #endif // guard