mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 18:25: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
@@ -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