1 #include "audioCorrelationInfo.h"
4 AudioCorrelationInfo::AudioCorrelationInfo(int mainSize, int subSize) :
9 m_correlationVector = new int64_t[m_mainSize+m_subSize+1];
12 AudioCorrelationInfo::~AudioCorrelationInfo()
14 delete m_correlationVector;
17 int AudioCorrelationInfo::size() const
19 return m_mainSize+m_subSize+1;
22 void AudioCorrelationInfo::setMax(int64_t max)
27 int64_t AudioCorrelationInfo::max() const
33 for (int i = 0; i < width; i++) {
34 if (m_correlationVector[i] > max) {
35 max = m_correlationVector[i];
44 int AudioCorrelationInfo::maxIndex() const
50 for (int i = 0; i < width; i++) {
51 if (m_correlationVector[i] > max) {
52 max = m_correlationVector[i];
60 int64_t* AudioCorrelationInfo::correlationVector()
62 return m_correlationVector;
65 QImage AudioCorrelationInfo::toImage(int height) const
68 int64_t maxVal = max();
70 QImage img(width, height, QImage::Format_ARGB32);
71 img.fill(qRgb(255,255,255));
75 for (int x = 0; x < width; x++) {
76 val = m_correlationVector[x]/double(maxVal)*img.height();
77 for (int y = img.height()-1; y > img.height() - val - 1; y--) {
78 img.setPixel(x, y, qRgb(50, 50, 50));