mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 18:35:35 +08:00
Implement VolumeSampleProvider to gain in and output
fixup! Implement VolumeSampleProvider to gain in and output
This commit is contained in:
committed by
Mat Sutcliffe
parent
8b1fb1baca
commit
8d1eea25b1
@@ -122,9 +122,10 @@ namespace BlackCore
|
||||
|
||||
soundcardSampleProvider = new SoundcardSampleProvider(c_sampleRate, transceiverIDs, this);
|
||||
connect(soundcardSampleProvider, &SoundcardSampleProvider::receivingCallsignsChanged, this, &AFVClient::receivingCallsignsChanged);
|
||||
// TODO outputSampleProvider = new VolumeSampleProvider(soundcardSampleProvider);
|
||||
outputSampleProvider = new VolumeSampleProvider(soundcardSampleProvider, this);
|
||||
outputSampleProvider->setVolume(m_outputVolume);
|
||||
|
||||
m_output->start(outputDevice, soundcardSampleProvider);
|
||||
m_output->start(outputDevice, outputSampleProvider);
|
||||
m_input->start(inputDevice);
|
||||
|
||||
m_startDateTimeUtc = QDateTime::currentDateTimeUtc();
|
||||
@@ -140,7 +141,8 @@ namespace BlackCore
|
||||
|
||||
soundcardSampleProvider = new SoundcardSampleProvider(c_sampleRate, { 0, 1 }, this);
|
||||
connect(soundcardSampleProvider, &SoundcardSampleProvider::receivingCallsignsChanged, this, &AFVClient::receivingCallsignsChanged);
|
||||
// TODO outputSampleProvider = new VolumeSampleProvider(soundcardSampleProvider);
|
||||
outputSampleProvider = new VolumeSampleProvider(soundcardSampleProvider, this);
|
||||
outputSampleProvider->setVolume(m_outputVolume);
|
||||
|
||||
QAudioDeviceInfo inputDevice = QAudioDeviceInfo::defaultInputDevice();
|
||||
for (const auto &device : QAudioDeviceInfo::availableDevices(QAudio::AudioInput))
|
||||
@@ -162,7 +164,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
m_output->start(outputDevice, soundcardSampleProvider);
|
||||
m_output->start(outputDevice, outputSampleProvider);
|
||||
m_input->start(inputDevice);
|
||||
|
||||
m_startDateTimeUtc = QDateTime::currentDateTimeUtc();
|
||||
@@ -296,12 +298,12 @@ namespace BlackCore
|
||||
qDebug() << "PTT:" << active;
|
||||
}
|
||||
|
||||
void AFVClient::setInputVolumeDb(float value)
|
||||
void AFVClient::setInputVolumeDb(double value)
|
||||
{
|
||||
if (value > 18) { value = 18; }
|
||||
if (value < -18) { value = -18; }
|
||||
m_inputVolumeDb = value;
|
||||
// TODO input.Volume = (float)System.Math.Pow(10, value / 20);
|
||||
m_input->setVolume(qPow(10, value / 20));
|
||||
}
|
||||
|
||||
void AFVClient::opusDataAvailable(const OpusDataAvailableArgs &args)
|
||||
@@ -404,17 +406,20 @@ namespace BlackCore
|
||||
updateTransceivers();
|
||||
}
|
||||
|
||||
float AFVClient::getOutputVolume() const
|
||||
float AFVClient::getOutputVolumeDb() const
|
||||
{
|
||||
return m_outputVolume;
|
||||
}
|
||||
|
||||
void AFVClient::setOutputVolume(float outputVolume)
|
||||
void AFVClient::setOutputVolumeDb(double outputVolume)
|
||||
{
|
||||
if (outputVolume > 18) { m_outputVolume = 18; }
|
||||
if (outputVolume < -60) { m_outputVolume = -60; }
|
||||
// m_outputVolume = (float)System.Math.Pow(10, value / 20);
|
||||
// TODO outputSampleProvider.Volume = outputVolume;
|
||||
m_outputVolume = qPow(10, m_outputVolume / 20);
|
||||
if (outputSampleProvider)
|
||||
{
|
||||
outputSampleProvider->setVolume(outputVolume);
|
||||
}
|
||||
}
|
||||
|
||||
AFVClient::ConnectionStatus AFVClient::getConnectionStatus() const
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
|
||||
#include "blackcore/context/contextownaircraft.h"
|
||||
#include "blacksound/sampleprovider/volumesampleprovider.h"
|
||||
|
||||
#include <QAudioDeviceInfo>
|
||||
#include <QDateTime>
|
||||
@@ -89,15 +90,15 @@ namespace BlackCore
|
||||
|
||||
Q_INVOKABLE void setLoopBack(bool on) { m_loopbackOn = on; }
|
||||
|
||||
float inputVolumeDb() const
|
||||
double inputVolumeDb() const
|
||||
{
|
||||
return m_inputVolumeDb;
|
||||
}
|
||||
|
||||
void setInputVolumeDb(float value);
|
||||
void setInputVolumeDb(double value);
|
||||
|
||||
float getOutputVolume() const;
|
||||
void setOutputVolume(float outputVolume);
|
||||
float getOutputVolumeDb() const;
|
||||
void setOutputVolumeDb(double outputVolume);
|
||||
|
||||
float getInputVolumePeakVU() const { return m_inputVolumeStream.PeakVU; }
|
||||
float getOutputVolumePeakVU() const { return m_outputVolumeStream.PeakVU; }
|
||||
@@ -136,7 +137,7 @@ namespace BlackCore
|
||||
Audio::Output *m_output = nullptr;
|
||||
|
||||
Audio::SoundcardSampleProvider *soundcardSampleProvider = nullptr;
|
||||
// TODO VolumeSampleProvider outputSampleProvider;
|
||||
VolumeSampleProvider *outputSampleProvider = nullptr;
|
||||
|
||||
bool m_transmit = false;
|
||||
bool m_transmitHistory = false;
|
||||
@@ -145,8 +146,8 @@ namespace BlackCore
|
||||
bool m_isStarted = false;
|
||||
QDateTime m_startDateTimeUtc;
|
||||
|
||||
float m_inputVolumeDb;
|
||||
float m_outputVolume = 1;
|
||||
double m_inputVolumeDb;
|
||||
double m_outputVolume = 1.0;
|
||||
|
||||
double m_maxDbReadingInPTTInterval = -100;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user