File indexing completed on 2025-01-05 04:25:41
0001 /**************************************************************************************** 0002 * Copyright (c) 2017 Malte Veerman <malte.veerman@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Pulic License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef BLOCKWORKER_H 0018 #define BLOCKWORKER_H 0019 0020 #include "AnalyzerWorker.h" 0021 0022 #include <QElapsedTimer> 0023 #include <QMutex> 0024 #include <QTime> 0025 #include <QVector> 0026 0027 0028 class BlockWorker : public Analyzer::Worker 0029 { 0030 friend class BlockRenderer; 0031 0032 Q_OBJECT 0033 0034 public: 0035 BlockWorker( int rows, int columns, qreal step, bool showFadebars ); 0036 0037 void setStep( qreal step ) { m_step = step; } 0038 void setRows( int rows ); 0039 void setColumns( int columns ); 0040 void setRefreshRate( qreal refreshRate ) { m_refreshTime = std::floor( 1000.0 / refreshRate ); } 0041 void setShowFadebars( bool showFadebars ) { m_showFadebars = showFadebars; } 0042 0043 Q_SIGNALS: 0044 void finished(); 0045 0046 protected: 0047 void analyze() override; 0048 0049 private: 0050 struct Fadebar 0051 { 0052 int y; 0053 qreal intensity; 0054 Fadebar() 0055 { 0056 y = 0; 0057 intensity = 0.0; 0058 } 0059 Fadebar( int y, qreal intensity ) 0060 { 0061 this->y = y; 0062 this->intensity = intensity; 0063 } 0064 }; 0065 mutable QMutex m_mutex; //used to lock m_store and m_fadebars 0066 QVector<double> m_store; //current bar heights 0067 QVector<double> m_yscale; 0068 QVector<QList<Fadebar> > m_fadebars; 0069 qreal m_step; 0070 int m_rows; 0071 int m_columns; 0072 int m_refreshTime; 0073 bool m_showFadebars; 0074 QElapsedTimer m_lastUpdate; 0075 }; 0076 0077 #endif //BLOCKWORKER_H