mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
Ref T730, style
This commit is contained in:
committed by
Mat Sutcliffe
parent
c1470f6069
commit
bde7baf84d
@@ -31,14 +31,16 @@ namespace BlackSound
|
||||
//! Ctor
|
||||
CBufferedWaveProvider(const QAudioFormat &format, QObject *parent = nullptr);
|
||||
|
||||
//! Add samples
|
||||
void addSamples(const QVector<qint16> &samples);
|
||||
|
||||
//! ISampleProvider::readSamples
|
||||
virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
|
||||
|
||||
//! Bytes from buffer
|
||||
int getBufferedBytes() const { return m_audioBuffer.size(); }
|
||||
|
||||
|
||||
//! Clear the buffer
|
||||
void clearBuffer();
|
||||
|
||||
private:
|
||||
|
||||
@@ -20,18 +20,22 @@ namespace BlackSound
|
||||
{
|
||||
namespace SampleProvider
|
||||
{
|
||||
//! Mixer
|
||||
class BLACKSOUND_EXPORT CMixingSampleProvider : public ISampleProvider
|
||||
{
|
||||
public:
|
||||
CMixingSampleProvider(QObject *parent = nullptr) : ISampleProvider(parent) {}
|
||||
|
||||
//! Add a provider
|
||||
void addMixerInput(ISampleProvider *provider) { m_sources.append(provider); }
|
||||
|
||||
//! \copydoc ISampleProvider::readSamples
|
||||
virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
|
||||
|
||||
private:
|
||||
QVector<ISampleProvider *> m_sources;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -21,17 +21,17 @@ namespace BlackSound
|
||||
int CSawToothGenerator::readSamples(QVector<qint16> &samples, qint64 count)
|
||||
{
|
||||
samples.clear();
|
||||
samples.fill(0, count);
|
||||
samples.fill(0, static_cast<int>(count));
|
||||
|
||||
for (int sampleCount = 0; sampleCount < count; sampleCount++)
|
||||
{
|
||||
double multiple = 2 * m_frequency / m_sampleRate;
|
||||
double sampleSaw = std::fmod((m_nSample * multiple), 2) - 1;
|
||||
double sampleValue = m_gain * sampleSaw;
|
||||
samples[sampleCount] = sampleValue * 32768;
|
||||
samples[sampleCount] = static_cast<qint16>(qRound(sampleValue * 32768));
|
||||
m_nSample++;
|
||||
}
|
||||
return static_cast<int>(count);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -27,10 +27,13 @@ namespace BlackSound
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
CSawToothGenerator(double frequency, QObject *parent = nullptr);
|
||||
|
||||
//! \copydoc ISampleProvider::readSamples
|
||||
virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
|
||||
|
||||
//! Set the gain
|
||||
void setGain(double gain) { m_gain = gain; }
|
||||
|
||||
private:
|
||||
@@ -39,7 +42,7 @@ namespace BlackSound
|
||||
double m_sampleRate = 48000;
|
||||
int m_nSample = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -22,27 +22,32 @@ namespace BlackSound
|
||||
{
|
||||
namespace SampleProvider
|
||||
{
|
||||
//! Compressor effect
|
||||
class BLACKSOUND_EXPORT CSimpleCompressorEffect : public ISampleProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
CSimpleCompressorEffect(ISampleProvider *source, QObject *parent = nullptr);
|
||||
|
||||
//! \copydoc ISampleProvider::readSamples
|
||||
virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
|
||||
|
||||
//! Enable
|
||||
void setEnabled(bool enabled);
|
||||
|
||||
//! Set gain
|
||||
void setMakeUpGain(double gain);
|
||||
|
||||
private:
|
||||
|
||||
QTimer m_timer;
|
||||
ISampleProvider *m_sourceStream;
|
||||
ISampleProvider *m_sourceStream = nullptr;
|
||||
bool m_enabled = true;
|
||||
chunkware_simple::SimpleComp m_simpleCompressor;
|
||||
const int channels = 1;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user