diff --git a/src/blackcore/afv/audio/output.h b/src/blackcore/afv/audio/output.h index 6a1aa0ac7..95c364a33 100644 --- a/src/blackcore/afv/audio/output.h +++ b/src/blackcore/afv/audio/output.h @@ -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); diff --git a/src/blackcore/afv/clients/afvclient.cpp b/src/blackcore/afv/clients/afvclient.cpp index 22cee26bb..ee6a9a838 100644 --- a/src/blackcore/afv/clients/afvclient.cpp +++ b/src/blackcore/afv/clients/afvclient.cpp @@ -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(comFrequency.valueInteger(CFrequencyUnit::Hz())); + const quint16 freqHz = static_cast(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); diff --git a/src/blackcore/context/contextaudioimpl.cpp b/src/blackcore/context/contextaudioimpl.cpp index 2092fb171..3cc2e838f 100644 --- a/src/blackcore/context/contextaudioimpl.cpp +++ b/src/blackcore/context/contextaudioimpl.cpp @@ -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); diff --git a/src/blackgui/components/audiodevicevolumesetupcomponent.cpp b/src/blackgui/components/audiodevicevolumesetupcomponent.cpp index 81724ee31..16bac70f1 100644 --- a/src/blackgui/components/audiodevicevolumesetupcomponent.cpp +++ b/src/blackgui/components/audiodevicevolumesetupcomponent.cpp @@ -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() diff --git a/src/blackgui/components/audiodevicevolumesetupcomponent.h b/src/blackgui/components/audiodevicevolumesetupcomponent.h index 456d6ec3b..26c99e5a7 100644 --- a/src/blackgui/components/audiodevicevolumesetupcomponent.h +++ b/src/blackgui/components/audiodevicevolumesetupcomponent.h @@ -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(); diff --git a/src/blacksound/sampleprovider/bufferedwaveprovider.h b/src/blacksound/sampleprovider/bufferedwaveprovider.h index 30bbc26c4..149e70bdf 100644 --- a/src/blacksound/sampleprovider/bufferedwaveprovider.h +++ b/src/blacksound/sampleprovider/bufferedwaveprovider.h @@ -31,14 +31,16 @@ namespace BlackSound //! Ctor CBufferedWaveProvider(const QAudioFormat &format, QObject *parent = nullptr); + //! Add samples void addSamples(const QVector &samples); //! ISampleProvider::readSamples virtual int readSamples(QVector &samples, qint64 count) override; + //! Bytes from buffer int getBufferedBytes() const { return m_audioBuffer.size(); } - + //! Clear the buffer void clearBuffer(); private: diff --git a/src/blacksound/sampleprovider/mixingsampleprovider.h b/src/blacksound/sampleprovider/mixingsampleprovider.h index 5705807f9..250a23c9f 100644 --- a/src/blacksound/sampleprovider/mixingsampleprovider.h +++ b/src/blacksound/sampleprovider/mixingsampleprovider.h @@ -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 &samples, qint64 count) override; private: QVector m_sources; }; - } -} + } // ns +} // ns #endif // guard diff --git a/src/blacksound/sampleprovider/sawtoothgenerator.cpp b/src/blacksound/sampleprovider/sawtoothgenerator.cpp index 66eaa72d2..d77decd93 100644 --- a/src/blacksound/sampleprovider/sawtoothgenerator.cpp +++ b/src/blacksound/sampleprovider/sawtoothgenerator.cpp @@ -21,17 +21,17 @@ namespace BlackSound int CSawToothGenerator::readSamples(QVector &samples, qint64 count) { samples.clear(); - samples.fill(0, count); + samples.fill(0, static_cast(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(qRound(sampleValue * 32768)); m_nSample++; } return static_cast(count); } - } -} + } // ns +} // ns diff --git a/src/blacksound/sampleprovider/sawtoothgenerator.h b/src/blacksound/sampleprovider/sawtoothgenerator.h index cd04a3161..09f0fbc73 100644 --- a/src/blacksound/sampleprovider/sawtoothgenerator.h +++ b/src/blacksound/sampleprovider/sawtoothgenerator.h @@ -27,10 +27,13 @@ namespace BlackSound Q_OBJECT public: + //! Ctor CSawToothGenerator(double frequency, QObject *parent = nullptr); + //! \copydoc ISampleProvider::readSamples virtual int readSamples(QVector &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 diff --git a/src/blacksound/sampleprovider/simplecompressoreffect.h b/src/blacksound/sampleprovider/simplecompressoreffect.h index 821689df1..0166c12d7 100644 --- a/src/blacksound/sampleprovider/simplecompressoreffect.h +++ b/src/blacksound/sampleprovider/simplecompressoreffect.h @@ -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 &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