mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 12:55:31 +08:00
Ref T730, style
* set object name * use m_XYZ member name
This commit is contained in:
committed by
Mat Sutcliffe
parent
c604ced11c
commit
857e3581b0
@@ -29,17 +29,15 @@ int main(int argc, char *argv[])
|
|||||||
QGuiApplication qa(argc, argv);
|
QGuiApplication qa(argc, argv);
|
||||||
|
|
||||||
BlackCore::registerMetadata();
|
BlackCore::registerMetadata();
|
||||||
|
|
||||||
BlackCore::CApplication a("sampleafvclient", CApplicationInfo::Sample);
|
BlackCore::CApplication a("sampleafvclient", CApplicationInfo::Sample);
|
||||||
|
|
||||||
CAfvMapReader *afvMapReader = new CAfvMapReader(&a);
|
CAfvMapReader *afvMapReader = new CAfvMapReader(&a);
|
||||||
afvMapReader->updateFromMap();
|
afvMapReader->updateFromMap();
|
||||||
|
|
||||||
CAfvClient *voiceClient = new CAfvClient("https://voice1.vatsim.uk", &qa);
|
CAfvClient *voiceClient = new CAfvClient("https://voice1.vatsim.uk", &qa);
|
||||||
|
voiceClient->start(QThread::TimeCriticalPriority); // background thread
|
||||||
CAfvClientBridge *voiceClientBridge = new CAfvClientBridge(voiceClient, &qa);
|
CAfvClientBridge *voiceClientBridge = new CAfvClientBridge(voiceClient, &qa);
|
||||||
|
|
||||||
voiceClient->start(QThread::TimeCriticalPriority);
|
|
||||||
|
|
||||||
QObject::connect(&qa, &QCoreApplication::aboutToQuit, [voiceClient]()
|
QObject::connect(&qa, &QCoreApplication::aboutToQuit, [voiceClient]()
|
||||||
{
|
{
|
||||||
voiceClient->quitAndWait();
|
voiceClient->quitAndWait();
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ namespace BlackCore
|
|||||||
CAudioOutputBuffer::CAudioOutputBuffer(ISampleProvider *sampleProvider, QObject *parent) :
|
CAudioOutputBuffer::CAudioOutputBuffer(ISampleProvider *sampleProvider, QObject *parent) :
|
||||||
QIODevice(parent),
|
QIODevice(parent),
|
||||||
m_sampleProvider(sampleProvider)
|
m_sampleProvider(sampleProvider)
|
||||||
{ }
|
{
|
||||||
|
this->setObjectName("CAudioOutputBuffer");
|
||||||
|
}
|
||||||
|
|
||||||
qint64 CAudioOutputBuffer::readData(char *data, qint64 maxlen)
|
qint64 CAudioOutputBuffer::readData(char *data, qint64 maxlen)
|
||||||
{
|
{
|
||||||
@@ -42,7 +44,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
for (float sample : buffer)
|
for (float sample : buffer)
|
||||||
{
|
{
|
||||||
float absSample = qAbs(sample);
|
const float absSample = qAbs(sample);
|
||||||
if (absSample > m_maxSampleOutput) { m_maxSampleOutput = absSample; }
|
if (absSample > m_maxSampleOutput) { m_maxSampleOutput = absSample; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +82,9 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
Output::Output(QObject *parent) : QObject(parent)
|
Output::Output(QObject *parent) : QObject(parent)
|
||||||
{ }
|
{
|
||||||
|
this->setObjectName("COutput");
|
||||||
|
}
|
||||||
|
|
||||||
void Output::start(const CAudioDeviceInfo &outputDevice, ISampleProvider *sampleProvider)
|
void Output::start(const CAudioDeviceInfo &outputDevice, ISampleProvider *sampleProvider)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
for (int i = 0; i < voiceInputNumber; i++)
|
for (int i = 0; i < voiceInputNumber; i++)
|
||||||
{
|
{
|
||||||
auto voiceInput = new CallsignSampleProvider(audioFormat, this, m_mixer);
|
const auto voiceInput = new CallsignSampleProvider(audioFormat, this, m_mixer);
|
||||||
m_voiceInputs.push_back(voiceInput);
|
m_voiceInputs.push_back(voiceInput);
|
||||||
m_mixer->addMixerInput(voiceInput);
|
m_mixer->addMixerInput(voiceInput);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ namespace BlackCore
|
|||||||
private:
|
private:
|
||||||
uint m_frequencyHz = 122800000;
|
uint m_frequencyHz = 122800000;
|
||||||
bool m_mute = false;
|
bool m_mute = false;
|
||||||
|
|
||||||
const double m_clickGain = 1.0;
|
const double m_clickGain = 1.0;
|
||||||
const double m_blockToneGain = 0.10;
|
const double m_blockToneGain = 0.10;
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
const QUuid m_networkVersion = QUuid("3a5ddc6d-cf5d-4319-bd0e-d184f772db80");
|
const QUuid m_networkVersion = QUuid("3a5ddc6d-cf5d-4319-bd0e-d184f772db80");
|
||||||
|
|
||||||
//Data
|
// Data
|
||||||
CClientConnectionData m_connection;
|
CClientConnectionData m_connection;
|
||||||
|
|
||||||
// Voice server
|
// Voice server
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ namespace BlackGui
|
|||||||
CLoadIndicator::CLoadIndicator(int width, int height, QWidget *parent)
|
CLoadIndicator::CLoadIndicator(int width, int height, QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
|
this->setObjectName("CLoadIndicator");
|
||||||
this->resize(width, height);
|
this->resize(width, height);
|
||||||
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
this->setFocusPolicy(Qt::NoFocus);
|
this->setFocusPolicy(Qt::NoFocus);
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ namespace BlackInput
|
|||||||
m_deviceName(QString::fromWCharArray(pdidInstance->tszInstanceName)),
|
m_deviceName(QString::fromWCharArray(pdidInstance->tszInstanceName)),
|
||||||
m_productName(QString::fromWCharArray(pdidInstance->tszProductName)),
|
m_productName(QString::fromWCharArray(pdidInstance->tszProductName)),
|
||||||
m_directInput(directInputPtr)
|
m_directInput(directInputPtr)
|
||||||
{}
|
{
|
||||||
|
this->setObjectName("CJoystickDevice");
|
||||||
|
}
|
||||||
|
|
||||||
bool CJoystickDevice::init(HWND helperWindow)
|
bool CJoystickDevice::init(HWND helperWindow)
|
||||||
{
|
{
|
||||||
@@ -378,7 +380,7 @@ namespace BlackInput
|
|||||||
//
|
//
|
||||||
LRESULT CALLBACK CJoystickWindows::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK CJoystickWindows::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
CJoystickWindows* joystickWindows = static_cast<CJoystickWindows*>(GetProp(hWnd, L"CJoystickWindows"));
|
CJoystickWindows *joystickWindows = static_cast<CJoystickWindows *>(GetProp(hWnd, L"CJoystickWindows"));
|
||||||
|
|
||||||
if (joystickWindows)
|
if (joystickWindows)
|
||||||
{
|
{
|
||||||
@@ -388,7 +390,8 @@ namespace BlackInput
|
|||||||
{
|
{
|
||||||
if (wParam == DBT_DEVICEARRIVAL)
|
if (wParam == DBT_DEVICEARRIVAL)
|
||||||
{
|
{
|
||||||
DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
|
// DEV_BROADCAST_HDR *dbh = reinterpret_cast<DEV_BROADCAST_HDR *>(lParam); ???
|
||||||
|
DEV_BROADCAST_HDR *dbh = (DEV_BROADCAST_HDR *) lParam;
|
||||||
if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
||||||
{
|
{
|
||||||
joystickWindows->enumJoystickDevices();
|
joystickWindows->enumJoystickDevices();
|
||||||
@@ -406,7 +409,7 @@ namespace BlackInput
|
|||||||
CJoystickWindows *obj = static_cast<CJoystickWindows *>(pContext);
|
CJoystickWindows *obj = static_cast<CJoystickWindows *>(pContext);
|
||||||
|
|
||||||
/* ignore XInput devices here, keep going. */
|
/* ignore XInput devices here, keep going. */
|
||||||
//if (isXInputDevice( &pdidInstance->guidProduct )) return DIENUM_CONTINUE;
|
// if (isXInputDevice(&pdidInstance->guidProduct)) return DIENUM_CONTINUE;
|
||||||
|
|
||||||
if (! obj->isJoystickAlreadyAdded(pdidInstance))
|
if (! obj->isJoystickAlreadyAdded(pdidInstance))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ namespace BlackMisc
|
|||||||
void CFileDeleter::addFileForDeletion(const QString &file)
|
void CFileDeleter::addFileForDeletion(const QString &file)
|
||||||
{
|
{
|
||||||
if (file.isEmpty()) { return; }
|
if (file.isEmpty()) { return; }
|
||||||
if (!this->m_fileNames.contains(file)) this->m_fileNames.append(file);
|
if (!m_fileNames.contains(file)) m_fileNames.append(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFileDeleter::addFilesForDeletion(const QStringList &files)
|
void CFileDeleter::addFilesForDeletion(const QStringList &files)
|
||||||
{
|
{
|
||||||
if (files.isEmpty()) { return; }
|
if (files.isEmpty()) { return; }
|
||||||
this->m_fileNames.append(files);
|
m_fileNames.append(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
CFileDeleter::~CFileDeleter()
|
CFileDeleter::~CFileDeleter()
|
||||||
@@ -49,14 +49,15 @@ namespace BlackMisc
|
|||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(!file.isEmpty(), Q_FUNC_INFO, "No file name");
|
Q_ASSERT_X(!file.isEmpty(), Q_FUNC_INFO, "No file name");
|
||||||
|
this->setObjectName("CTimedFileDeleter");
|
||||||
if (deleteAfterMs < 100) { deleteAfterMs = 100; } // makes sure timer is started properly
|
if (deleteAfterMs < 100) { deleteAfterMs = 100; } // makes sure timer is started properly
|
||||||
this->m_fileDeleter.addFileForDeletion(file);
|
m_fileDeleter.addFileForDeletion(file);
|
||||||
m_timerId = startTimer(deleteAfterMs);
|
m_timerId = startTimer(deleteAfterMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTimedFileDeleter::timerEvent(QTimerEvent *event)
|
void CTimedFileDeleter::timerEvent(QTimerEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event)
|
||||||
if (m_timerId > 0) { this->killTimer(m_timerId); }
|
if (m_timerId > 0) { this->killTimer(m_timerId); }
|
||||||
m_timerId = -1;
|
m_timerId = -1;
|
||||||
m_fileDeleter.deleteFiles();
|
m_fileDeleter.deleteFiles();
|
||||||
|
|||||||
@@ -30,14 +30,17 @@ namespace BlackSound
|
|||||||
//! Dtor
|
//! Dtor
|
||||||
~COpusDecoder();
|
~COpusDecoder();
|
||||||
|
|
||||||
|
//! Frame count
|
||||||
int frameCount(int bufferSize);
|
int frameCount(int bufferSize);
|
||||||
|
|
||||||
|
//! Decode
|
||||||
QVector<qint16> decode(const QByteArray opusData, int dataLength, int *decodedLength);
|
QVector<qint16> decode(const QByteArray opusData, int dataLength, int *decodedLength);
|
||||||
|
|
||||||
|
//! Reset
|
||||||
void resetState();
|
void resetState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OpusDecoder *opusDecoder;
|
OpusDecoder *opusDecoder = nullptr;
|
||||||
int m_sampleRate;
|
int m_sampleRate;
|
||||||
int m_channels;
|
int m_channels;
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ namespace BlackSound
|
|||||||
void setPeakingEq(float sampleRate, float centreFrequency, float q, float dbGain);
|
void setPeakingEq(float sampleRate, float centreFrequency, float q, float dbGain);
|
||||||
void setHighPassFilter(float sampleRate, float cutoffFrequency, float q);
|
void setHighPassFilter(float sampleRate, float cutoffFrequency, float q);
|
||||||
|
|
||||||
|
|
||||||
static BiQuadFilter lowPassFilter(float sampleRate, float cutoffFrequency, float q);
|
static BiQuadFilter lowPassFilter(float sampleRate, float cutoffFrequency, float q);
|
||||||
static BiQuadFilter highPassFilter(float sampleRate, float cutoffFrequency, float q);
|
static BiQuadFilter highPassFilter(float sampleRate, float cutoffFrequency, float q);
|
||||||
static BiQuadFilter peakingEQ(float sampleRate, float centreFrequency, float q, float dbGain);
|
static BiQuadFilter peakingEQ(float sampleRate, float centreFrequency, float q, float dbGain);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace BlackSound
|
|||||||
|
|
||||||
int CBufferedWaveProvider::readSamples(QVector<float> &samples, qint64 count)
|
int CBufferedWaveProvider::readSamples(QVector<float> &samples, qint64 count)
|
||||||
{
|
{
|
||||||
qint64 len = qMin(count, static_cast<qint64>(m_audioBuffer.size()));
|
const int len = static_cast<int>(qMin(count, static_cast<qint64>(m_audioBuffer.size())));
|
||||||
samples = m_audioBuffer.mid(0, len);
|
samples = m_audioBuffer.mid(0, len);
|
||||||
// if (len != 0) qDebug() << "Reading" << count << "samples." << m_audioBuffer.size() << "currently in the buffer.";
|
// if (len != 0) qDebug() << "Reading" << count << "samples." << m_audioBuffer.size() << "currently in the buffer.";
|
||||||
m_audioBuffer.remove(0, len);
|
m_audioBuffer.remove(0, len);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace BlackSound
|
|||||||
class BLACKSOUND_EXPORT CMixingSampleProvider : public ISampleProvider
|
class BLACKSOUND_EXPORT CMixingSampleProvider : public ISampleProvider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//! Ctor mixing provider
|
||||||
CMixingSampleProvider(QObject *parent = nullptr) : ISampleProvider(parent) {}
|
CMixingSampleProvider(QObject *parent = nullptr) : ISampleProvider(parent) {}
|
||||||
|
|
||||||
//! Add a provider
|
//! Add a provider
|
||||||
|
|||||||
@@ -16,25 +16,26 @@ namespace BlackSound
|
|||||||
{
|
{
|
||||||
int CPinkNoiseGenerator::readSamples(QVector<float> &samples, qint64 count)
|
int CPinkNoiseGenerator::readSamples(QVector<float> &samples, qint64 count)
|
||||||
{
|
{
|
||||||
|
const int c = static_cast<int>(count);
|
||||||
samples.clear();
|
samples.clear();
|
||||||
samples.fill(0, count);
|
samples.fill(0, c);
|
||||||
|
|
||||||
for (int sampleCount = 0; sampleCount < count; sampleCount++)
|
for (int sampleCount = 0; sampleCount < count; sampleCount++)
|
||||||
{
|
{
|
||||||
double white = 2 * random.generateDouble() - 1;
|
double white = 2 * m_random.generateDouble() - 1;
|
||||||
|
|
||||||
pinkNoiseBuffer[0] = 0.99886 * pinkNoiseBuffer[0] + white * 0.0555179;
|
m_pinkNoiseBuffer[0] = 0.99886 * m_pinkNoiseBuffer[0] + white * 0.0555179;
|
||||||
pinkNoiseBuffer[1] = 0.99332 * pinkNoiseBuffer[1] + white * 0.0750759;
|
m_pinkNoiseBuffer[1] = 0.99332 * m_pinkNoiseBuffer[1] + white * 0.0750759;
|
||||||
pinkNoiseBuffer[2] = 0.96900 * pinkNoiseBuffer[2] + white * 0.1538520;
|
m_pinkNoiseBuffer[2] = 0.96900 * m_pinkNoiseBuffer[2] + white * 0.1538520;
|
||||||
pinkNoiseBuffer[3] = 0.86650 * pinkNoiseBuffer[3] + white * 0.3104856;
|
m_pinkNoiseBuffer[3] = 0.86650 * m_pinkNoiseBuffer[3] + white * 0.3104856;
|
||||||
pinkNoiseBuffer[4] = 0.55000 * pinkNoiseBuffer[4] + white * 0.5329522;
|
m_pinkNoiseBuffer[4] = 0.55000 * m_pinkNoiseBuffer[4] + white * 0.5329522;
|
||||||
pinkNoiseBuffer[5] = -0.7616 * pinkNoiseBuffer[5] - white * 0.0168980;
|
m_pinkNoiseBuffer[5] = -0.7616 * m_pinkNoiseBuffer[5] - white * 0.0168980;
|
||||||
double pink = pinkNoiseBuffer[0] + pinkNoiseBuffer[1] + pinkNoiseBuffer[2] + pinkNoiseBuffer[3] + pinkNoiseBuffer[4] + pinkNoiseBuffer[5] + pinkNoiseBuffer[6] + white * 0.5362;
|
double pink = m_pinkNoiseBuffer[0] + m_pinkNoiseBuffer[1] + m_pinkNoiseBuffer[2] + m_pinkNoiseBuffer[3] + m_pinkNoiseBuffer[4] + m_pinkNoiseBuffer[5] + m_pinkNoiseBuffer[6] + white * 0.5362;
|
||||||
pinkNoiseBuffer[6] = white * 0.115926;
|
m_pinkNoiseBuffer[6] = white * 0.115926;
|
||||||
double sampleValue = (m_gain * (pink / 5));
|
const float sampleValue = static_cast<float>(m_gain * (pink / 5));
|
||||||
samples[sampleCount] = sampleValue;
|
samples[sampleCount] = sampleValue;
|
||||||
}
|
}
|
||||||
return count;
|
return c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ namespace BlackSound
|
|||||||
void setGain(double gain) { m_gain = gain; }
|
void setGain(double gain) { m_gain = gain; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QRandomGenerator random;
|
QRandomGenerator m_random;
|
||||||
std::array<double, 7> pinkNoiseBuffer = {{0}};
|
std::array<double, 7> m_pinkNoiseBuffer = {{0}};
|
||||||
double m_gain = 0.0;
|
double m_gain = 0.0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ namespace BlackSound
|
|||||||
{
|
{
|
||||||
namespace SampleProvider
|
namespace SampleProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
//! CResourceSound shared data
|
//! CResourceSound shared data
|
||||||
struct CResourceSoundData : public QSharedData
|
struct CResourceSoundData : public QSharedData
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,8 +48,7 @@ namespace BlackSound
|
|||||||
|
|
||||||
CResourceSound m_resourceSound;
|
CResourceSound m_resourceSound;
|
||||||
qint64 m_position = 0;
|
qint64 m_position = 0;
|
||||||
// const int m_tempBufferSize = 9600; //9600 = 200ms
|
const int m_tempBufferSize = 24000; //24000 = 500ms (avoid buffer overflow), m_tempBufferSize = 9600; //9600 = 200ms
|
||||||
const int m_tempBufferSize = 24000; //24000 = 500ms (avoid "
|
|
||||||
QVector<float> m_tempBuffer;
|
QVector<float> m_tempBuffer;
|
||||||
bool m_isFinished = false;
|
bool m_isFinished = false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ namespace BlackSound
|
|||||||
CSawToothGenerator::CSawToothGenerator(double frequency, QObject *parent) :
|
CSawToothGenerator::CSawToothGenerator(double frequency, QObject *parent) :
|
||||||
ISampleProvider(parent),
|
ISampleProvider(parent),
|
||||||
m_frequency(frequency)
|
m_frequency(frequency)
|
||||||
{}
|
{
|
||||||
|
this->setObjectName("CSawToothGenerator");
|
||||||
|
}
|
||||||
|
|
||||||
int CSawToothGenerator::readSamples(QVector<float> &samples, qint64 count)
|
int CSawToothGenerator::readSamples(QVector<float> &samples, qint64 count)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user