Ref T730, style

* set object name
* use m_XYZ member name
This commit is contained in:
Klaus Basan
2019-10-07 17:33:52 +02:00
committed by Mat Sutcliffe
parent c604ced11c
commit 857e3581b0
19 changed files with 64 additions and 54 deletions

View File

@@ -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);
voiceClient->start(QThread::TimeCriticalPriority); // background thread
CAfvClientBridge *voiceClientBridge = new CAfvClientBridge(voiceClient, &qa);
voiceClient->start(QThread::TimeCriticalPriority);
QObject::connect(&qa, &QCoreApplication::aboutToQuit, [voiceClient]()
{
voiceClient->quitAndWait();

View File

@@ -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)
{

View File

@@ -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);
}

View File

@@ -84,7 +84,6 @@ namespace BlackCore
private:
uint m_frequencyHz = 122800000;
bool m_mute = false;
const double m_clickGain = 1.0;
const double m_blockToneGain = 0.10;

View File

@@ -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);

View File

@@ -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)
{
@@ -388,6 +390,7 @@ namespace BlackInput
{
if (wParam == DBT_DEVICEARRIVAL)
{
// 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)
{

View File

@@ -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();

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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

View File

@@ -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;
}
}
}

View File

@@ -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;
};
}

View File

@@ -24,7 +24,6 @@ namespace BlackSound
{
namespace SampleProvider
{
//! CResourceSound shared data
struct CResourceSoundData : public QSharedData
{

View File

@@ -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;
};

View File

@@ -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)
{