mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 06:45:37 +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);
|
||||
|
||||
BlackCore::registerMetadata();
|
||||
|
||||
BlackCore::CApplication a("sampleafvclient", CApplicationInfo::Sample);
|
||||
|
||||
CAfvMapReader *afvMapReader = new CAfvMapReader(&a);
|
||||
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);
|
||||
|
||||
voiceClient->start(QThread::TimeCriticalPriority);
|
||||
|
||||
QObject::connect(&qa, &QCoreApplication::aboutToQuit, [voiceClient]()
|
||||
{
|
||||
voiceClient->quitAndWait();
|
||||
@@ -56,8 +54,8 @@ int main(int argc, char *argv[])
|
||||
QQmlApplicationEngine engine;
|
||||
QQmlContext *ctxt = engine.rootContext();
|
||||
ctxt->setContextProperty("afvMapReader", afvMapReader);
|
||||
ctxt->setContextProperty("voiceClient", voiceClientBridge);
|
||||
ctxt->setContextProperty("userName", defaultUserName);
|
||||
ctxt->setContextProperty("voiceClient", voiceClientBridge);
|
||||
ctxt->setContextProperty("userName", defaultUserName);
|
||||
|
||||
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||
return a.exec();
|
||||
|
||||
@@ -30,7 +30,9 @@ namespace BlackCore
|
||||
CAudioOutputBuffer::CAudioOutputBuffer(ISampleProvider *sampleProvider, QObject *parent) :
|
||||
QIODevice(parent),
|
||||
m_sampleProvider(sampleProvider)
|
||||
{ }
|
||||
{
|
||||
this->setObjectName("CAudioOutputBuffer");
|
||||
}
|
||||
|
||||
qint64 CAudioOutputBuffer::readData(char *data, qint64 maxlen)
|
||||
{
|
||||
@@ -42,7 +44,7 @@ namespace BlackCore
|
||||
|
||||
for (float sample : buffer)
|
||||
{
|
||||
float absSample = qAbs(sample);
|
||||
const float absSample = qAbs(sample);
|
||||
if (absSample > m_maxSampleOutput) { m_maxSampleOutput = absSample; }
|
||||
}
|
||||
|
||||
@@ -80,7 +82,9 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
Output::Output(QObject *parent) : QObject(parent)
|
||||
{ }
|
||||
{
|
||||
this->setObjectName("COutput");
|
||||
}
|
||||
|
||||
void Output::start(const CAudioDeviceInfo &outputDevice, ISampleProvider *sampleProvider)
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace BlackCore
|
||||
|
||||
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_mixer->addMixerInput(voiceInput);
|
||||
}
|
||||
|
||||
@@ -83,9 +83,8 @@ namespace BlackCore
|
||||
|
||||
private:
|
||||
uint m_frequencyHz = 122800000;
|
||||
bool m_mute = false;
|
||||
|
||||
const double m_clickGain = 1.0;
|
||||
bool m_mute = false;
|
||||
const double m_clickGain = 1.0;
|
||||
const double m_blockToneGain = 0.10;
|
||||
|
||||
quint16 m_id;
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace BlackCore
|
||||
|
||||
const QUuid m_networkVersion = QUuid("3a5ddc6d-cf5d-4319-bd0e-d184f772db80");
|
||||
|
||||
//Data
|
||||
// Data
|
||||
CClientConnectionData m_connection;
|
||||
|
||||
// Voice server
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace BlackCore
|
||||
protected:
|
||||
CCoreFacadeConfig::ContextMode m_mode; //!< How context is used
|
||||
qint64 m_contextId; //!< unique identifer, avoid redirection rountrips
|
||||
bool m_debugEnabled = false; //!< debug messages enabled
|
||||
bool m_debugEnabled = false; //!< debug messages enabled
|
||||
|
||||
//! Constructor
|
||||
IContext(CCoreFacadeConfig::ContextMode mode, QObject *parent) :
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace BlackGui
|
||||
CLoadIndicator::CLoadIndicator(int width, int height, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
this->setObjectName("CLoadIndicator");
|
||||
this->resize(width, height);
|
||||
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
this->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
@@ -28,7 +28,9 @@ namespace BlackInput
|
||||
m_deviceName(QString::fromWCharArray(pdidInstance->tszInstanceName)),
|
||||
m_productName(QString::fromWCharArray(pdidInstance->tszProductName)),
|
||||
m_directInput(directInputPtr)
|
||||
{}
|
||||
{
|
||||
this->setObjectName("CJoystickDevice");
|
||||
}
|
||||
|
||||
bool CJoystickDevice::init(HWND helperWindow)
|
||||
{
|
||||
@@ -378,24 +380,25 @@ namespace BlackInput
|
||||
//
|
||||
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)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_DEVICECHANGE:
|
||||
{
|
||||
if (wParam == DBT_DEVICEARRIVAL)
|
||||
{
|
||||
DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
|
||||
if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
||||
if (wParam == DBT_DEVICEARRIVAL)
|
||||
{
|
||||
joystickWindows->enumJoystickDevices();
|
||||
// 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)
|
||||
{
|
||||
joystickWindows->enumJoystickDevices();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
@@ -406,7 +409,7 @@ namespace BlackInput
|
||||
CJoystickWindows *obj = static_cast<CJoystickWindows *>(pContext);
|
||||
|
||||
/* ignore XInput devices here, keep going. */
|
||||
//if (isXInputDevice( &pdidInstance->guidProduct )) return DIENUM_CONTINUE;
|
||||
// if (isXInputDevice(&pdidInstance->guidProduct)) return DIENUM_CONTINUE;
|
||||
|
||||
if (! obj->isJoystickAlreadyAdded(pdidInstance))
|
||||
{
|
||||
@@ -418,9 +421,9 @@ namespace BlackInput
|
||||
|
||||
bool operator == (const CJoystickDevice &lhs, const CJoystickDevice &rhs)
|
||||
{
|
||||
return lhs.m_guidDevice == rhs.m_guidDevice &&
|
||||
return lhs.m_guidDevice == rhs.m_guidDevice &&
|
||||
lhs.m_guidProduct == rhs.m_guidProduct &&
|
||||
lhs.m_deviceName == rhs.m_deviceName &&
|
||||
lhs.m_deviceName == rhs.m_deviceName &&
|
||||
lhs.m_productName == rhs.m_productName;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,13 @@ namespace BlackMisc
|
||||
void CFileDeleter::addFileForDeletion(const QString &file)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (files.isEmpty()) { return; }
|
||||
this->m_fileNames.append(files);
|
||||
m_fileNames.append(files);
|
||||
}
|
||||
|
||||
CFileDeleter::~CFileDeleter()
|
||||
@@ -49,14 +49,15 @@ namespace BlackMisc
|
||||
QObject(parent)
|
||||
{
|
||||
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
|
||||
this->m_fileDeleter.addFileForDeletion(file);
|
||||
m_fileDeleter.addFileForDeletion(file);
|
||||
m_timerId = startTimer(deleteAfterMs);
|
||||
}
|
||||
|
||||
void CTimedFileDeleter::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
Q_UNUSED(event)
|
||||
if (m_timerId > 0) { this->killTimer(m_timerId); }
|
||||
m_timerId = -1;
|
||||
m_fileDeleter.deleteFiles();
|
||||
|
||||
@@ -30,14 +30,17 @@ namespace BlackSound
|
||||
//! Dtor
|
||||
~COpusDecoder();
|
||||
|
||||
//! Frame count
|
||||
int frameCount(int bufferSize);
|
||||
|
||||
//! Decode
|
||||
QVector<qint16> decode(const QByteArray opusData, int dataLength, int *decodedLength);
|
||||
|
||||
//! Reset
|
||||
void resetState();
|
||||
|
||||
private:
|
||||
OpusDecoder *opusDecoder;
|
||||
OpusDecoder *opusDecoder = nullptr;
|
||||
int m_sampleRate;
|
||||
int m_channels;
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ namespace BlackSound
|
||||
void setPeakingEq(float sampleRate, float centreFrequency, float q, float dbGain);
|
||||
void setHighPassFilter(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 peakingEQ(float sampleRate, float centreFrequency, float q, float dbGain);
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace BlackSound
|
||||
|
||||
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);
|
||||
// if (len != 0) qDebug() << "Reading" << count << "samples." << m_audioBuffer.size() << "currently in the buffer.";
|
||||
m_audioBuffer.remove(0, len);
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace BlackSound
|
||||
class BLACKSOUND_EXPORT CMixingSampleProvider : public ISampleProvider
|
||||
{
|
||||
public:
|
||||
//! Ctor mixing provider
|
||||
CMixingSampleProvider(QObject *parent = nullptr) : ISampleProvider(parent) {}
|
||||
|
||||
//! Add a provider
|
||||
|
||||
@@ -16,25 +16,26 @@ namespace BlackSound
|
||||
{
|
||||
int CPinkNoiseGenerator::readSamples(QVector<float> &samples, qint64 count)
|
||||
{
|
||||
const int c = static_cast<int>(count);
|
||||
samples.clear();
|
||||
samples.fill(0, count);
|
||||
samples.fill(0, c);
|
||||
|
||||
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;
|
||||
pinkNoiseBuffer[1] = 0.99332 * pinkNoiseBuffer[1] + white * 0.0750759;
|
||||
pinkNoiseBuffer[2] = 0.96900 * pinkNoiseBuffer[2] + white * 0.1538520;
|
||||
pinkNoiseBuffer[3] = 0.86650 * pinkNoiseBuffer[3] + white * 0.3104856;
|
||||
pinkNoiseBuffer[4] = 0.55000 * pinkNoiseBuffer[4] + white * 0.5329522;
|
||||
pinkNoiseBuffer[5] = -0.7616 * pinkNoiseBuffer[5] - white * 0.0168980;
|
||||
double pink = pinkNoiseBuffer[0] + pinkNoiseBuffer[1] + pinkNoiseBuffer[2] + pinkNoiseBuffer[3] + pinkNoiseBuffer[4] + pinkNoiseBuffer[5] + pinkNoiseBuffer[6] + white * 0.5362;
|
||||
pinkNoiseBuffer[6] = white * 0.115926;
|
||||
double sampleValue = (m_gain * (pink / 5));
|
||||
m_pinkNoiseBuffer[0] = 0.99886 * m_pinkNoiseBuffer[0] + white * 0.0555179;
|
||||
m_pinkNoiseBuffer[1] = 0.99332 * m_pinkNoiseBuffer[1] + white * 0.0750759;
|
||||
m_pinkNoiseBuffer[2] = 0.96900 * m_pinkNoiseBuffer[2] + white * 0.1538520;
|
||||
m_pinkNoiseBuffer[3] = 0.86650 * m_pinkNoiseBuffer[3] + white * 0.3104856;
|
||||
m_pinkNoiseBuffer[4] = 0.55000 * m_pinkNoiseBuffer[4] + white * 0.5329522;
|
||||
m_pinkNoiseBuffer[5] = -0.7616 * m_pinkNoiseBuffer[5] - white * 0.0168980;
|
||||
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;
|
||||
m_pinkNoiseBuffer[6] = white * 0.115926;
|
||||
const float sampleValue = static_cast<float>(m_gain * (pink / 5));
|
||||
samples[sampleCount] = sampleValue;
|
||||
}
|
||||
return count;
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace BlackSound
|
||||
void setGain(double gain) { m_gain = gain; }
|
||||
|
||||
private:
|
||||
QRandomGenerator random;
|
||||
std::array<double, 7> pinkNoiseBuffer = {{0}};
|
||||
QRandomGenerator m_random;
|
||||
std::array<double, 7> m_pinkNoiseBuffer = {{0}};
|
||||
double m_gain = 0.0;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace BlackSound
|
||||
{
|
||||
namespace SampleProvider
|
||||
{
|
||||
|
||||
//! CResourceSound shared data
|
||||
struct CResourceSoundData : public QSharedData
|
||||
{
|
||||
|
||||
@@ -48,8 +48,7 @@ namespace BlackSound
|
||||
|
||||
CResourceSound m_resourceSound;
|
||||
qint64 m_position = 0;
|
||||
// const int m_tempBufferSize = 9600; //9600 = 200ms
|
||||
const int m_tempBufferSize = 24000; //24000 = 500ms (avoid "
|
||||
const int m_tempBufferSize = 24000; //24000 = 500ms (avoid buffer overflow), m_tempBufferSize = 9600; //9600 = 200ms
|
||||
QVector<float> m_tempBuffer;
|
||||
bool m_isFinished = false;
|
||||
};
|
||||
|
||||
@@ -16,7 +16,9 @@ namespace BlackSound
|
||||
CSawToothGenerator::CSawToothGenerator(double frequency, QObject *parent) :
|
||||
ISampleProvider(parent),
|
||||
m_frequency(frequency)
|
||||
{}
|
||||
{
|
||||
this->setObjectName("CSawToothGenerator");
|
||||
}
|
||||
|
||||
int CSawToothGenerator::readSamples(QVector<float> &samples, qint64 count)
|
||||
{
|
||||
|
||||
@@ -37,10 +37,10 @@ namespace BlackSound
|
||||
void setGain(double gain) { m_gain = gain; }
|
||||
|
||||
private:
|
||||
double m_gain = 0.0;
|
||||
double m_frequency = 0.0;
|
||||
double m_gain = 0.0;
|
||||
double m_frequency = 0.0;
|
||||
double m_sampleRate = 48000;
|
||||
int m_nSample = 0;
|
||||
int m_nSample = 0;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user