Ref T730, style

This commit is contained in:
Klaus Basan
2019-09-27 22:53:11 +02:00
committed by Mat Sutcliffe
parent cd58108bfe
commit 6a9109bf8f
13 changed files with 153 additions and 131 deletions

View File

@@ -32,8 +32,10 @@ namespace BlackSound
//! Noise generator
CPinkNoiseGenerator(QObject *parent = nullptr) : ISampleProvider(parent) {}
//! Read samples
virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
//! Gain
void setGain(double gain) { m_gain = gain; }
private:

View File

@@ -19,7 +19,7 @@ namespace BlackSound
{
CResourceSound::CResourceSound(const QString &audioFileName)
{
m_wavFile = new WavFile;
m_wavFile = new CWavFile();
m_wavFile->open(audioFileName);
if (m_wavFile->fileFormat().sampleType() == QAudioFormat::Float)
{
@@ -30,10 +30,5 @@ namespace BlackSound
m_samples = convertBytesTo16BitPCM(m_wavFile->audioData());
}
}
const QVector<qint16> &CResourceSound::audioData()
{
return m_samples;
}
}
}
} // ns
} // ns

View File

@@ -28,13 +28,14 @@ namespace BlackSound
//! Sound of audio file
CResourceSound(const QString &audioFileName);
const QVector<qint16> &audioData();
//! Audio data
const QVector<qint16> &audioData() const { return m_samples; }
private:
Wav::WavFile *m_wavFile = nullptr;
Wav::WavFile *m_wavFile = nullptr;
QVector<qint16> m_samples;
};
}
}
} // ns
} // ns
#endif // guard

View File

@@ -24,11 +24,11 @@ namespace BlackSound
const qint64 samplesToCopy = qMin(availableSamples, count);
samples.clear();
samples.fill(0, samplesToCopy);
samples.fill(0, static_cast<int>(samplesToCopy));
for (int i = 0; i < samplesToCopy; i++)
{
m_tempBuffer[i] = m_resourceSound.audioData().at(m_position + i);
m_tempBuffer[i] = m_resourceSound.audioData().at(static_cast<int>(m_position) + i);
}
if (!qFuzzyCompare(m_gain, 1.0))
@@ -54,5 +54,5 @@ namespace BlackSound
return static_cast<int>(samplesToCopy);
}
}
}
} // ns
} // ns

View File

@@ -26,21 +26,30 @@ namespace BlackSound
//! Ctor
CResourceSoundSampleProvider(const CResourceSound &resourceSound, QObject *parent = nullptr);
//! copydoc ISampleProvider::readSamples
virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
//! copydoc ISampleProvider::isFinished
virtual bool isFinished() const override { return m_isFinished; }
//! Looping @{
bool looping() const { return m_looping; }
void setLooping(bool looping) { m_looping = looping; }
// @}
//! Gain @{
double gain() const { return m_gain; }
void setGain(double gain) { m_gain = gain; }
//! @}
//! Temp buffer @{
QVector<qint16> getTempBuffer() const { return m_tempBuffer; }
void setTempBuffer(const QVector<qint16> &value) { m_tempBuffer = value; }
//! @}
private:
double m_gain = 1.0;
bool m_looping = false;
double m_gain = 1.0;
bool m_looping = false;
CResourceSound m_resourceSound;
qint64 m_position = 0;
@@ -48,7 +57,7 @@ namespace BlackSound
QVector<qint16> m_tempBuffer;
bool m_isFinished = false;
};
}
}
} // ns
} // ns
#endif // guard

View File

@@ -21,20 +21,24 @@ namespace BlackSound
class BLACKSOUND_EXPORT Samples
{
public:
//! Singleton
static Samples &instance();
//! Various samples (sounds) @{
CResourceSound crackle() const;
CResourceSound click() const;
CResourceSound whiteNoise() const;
//! @}
private:
//! Ctor
Samples();
CResourceSound m_crackle;
CResourceSound m_click;
CResourceSound m_whiteNoise;
};
}
}
} // ns
} // ns
#endif // SAMPLES_H
#endif // guard