1 /***************************************************************************
2 * Copyright (C) 2012 by Simon Andreas Eugster (simon.eu@gmail.com) *
3 * This file is part of kdenlive. See www.kdenlive.org. *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 ***************************************************************************/
11 #include "audioCorrelationInfo.h"
14 AudioCorrelationInfo::AudioCorrelationInfo(int mainSize, int subSize) :
19 m_correlationVector = new int64_t[m_mainSize+m_subSize+1];
22 AudioCorrelationInfo::~AudioCorrelationInfo()
24 delete[] m_correlationVector;
27 int AudioCorrelationInfo::size() const
29 return m_mainSize+m_subSize+1;
32 void AudioCorrelationInfo::setMax(int64_t max)
37 int64_t AudioCorrelationInfo::max() const
42 for (int i = 0; i < width; ++i) {
43 if (m_correlationVector[i] > max) {
44 max = m_correlationVector[i];
53 int AudioCorrelationInfo::maxIndex() const
59 for (int i = 0; i < width; ++i) {
60 if (m_correlationVector[i] > max) {
61 max = m_correlationVector[i];
69 int64_t* AudioCorrelationInfo::correlationVector()
71 return m_correlationVector;
74 QImage AudioCorrelationInfo::toImage(int height) const
77 int64_t maxVal = max();
79 QImage img(width, height, QImage::Format_ARGB32);
80 img.fill(qRgb(255,255,255));
87 for (int x = 0; x < width; x++) {
88 val = m_correlationVector[x]/double(maxVal)*img.height();
89 for (int y = img.height()-1; y > img.height() - val - 1; y--) {
90 img.setPixel(x, y, qRgb(50, 50, 50));