8 namespace swift::sound::sample_provider
15 m_timer =
new QTimer(
this);
18 m_simpleCompressor.setAttack(5.0);
19 m_simpleCompressor.setRelease(10.0);
20 m_simpleCompressor.setSampleRate(48000.0);
21 m_simpleCompressor.setThresh(16.0);
22 m_simpleCompressor.setRatio(6.0);
23 m_simpleCompressor.setMakeUpGain(16.0);
29 int samplesRead = m_sourceStream->
readSamples(samples, count);
33 for (
int sample = 0; sample < samplesRead; sample += m_channels)
35 double in1 = samples.at(sample);
36 double in2 = (m_channels == 1) ? 0 : samples.at(sample + 1);
37 m_simpleCompressor.process(in1, in2);
38 samples[sample] =
static_cast<float>(in1);
39 if (m_channels > 1) { samples[sample + 1] =
static_cast<float>(in2); }
51 if (channels < 1) { channels = 1; }
52 else if (channels > 2) { channels = 2; }
53 m_channels = channels;
void setChannels(int channels)
Set channels 1 or 2.
void setEnabled(bool enabled)
Enable.
CSimpleCompressorEffect(ISampleProvider *source, QObject *parent=nullptr)
Ctor.
void setMakeUpGain(double gain)
Set gain.
int readSamples(QVector< float > &samples, qint64 count)
Read samples.
Sample provider interface.
virtual int readSamples(QVector< float > &samples, qint64 count)=0
Read samples.
void setObjectName(QAnyStringView name)