spectrograph.h Example File
multimedia/spectrum/app/spectrograph.h
#ifndef SPECTROGRAPH_H
#define SPECTROGRAPH_H
#include "frequencyspectrum.h"
#include <QWidget>
class Spectrograph : public QWidget
{
Q_OBJECT
public:
explicit Spectrograph(QWidget *parent = 0);
~Spectrograph();
void setParams(int numBars, qreal lowFreq, qreal highFreq);
void timerEvent(QTimerEvent *event) override;
void paintEvent(QPaintEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
signals:
void infoMessage(const QString &message, int intervalMs);
public slots:
void reset();
void spectrumChanged(const FrequencySpectrum &spectrum);
private:
int barIndex(qreal frequency) const;
QPair<qreal, qreal> barRange(int barIndex) const;
void updateBars();
void selectBar(int index);
private:
struct Bar {
Bar() : value(0.0), clipped(false) { }
qreal value;
bool clipped;
};
QVector<Bar> m_bars;
int m_barSelected;
int m_timerId;
qreal m_lowFreq;
qreal m_highFreq;
FrequencySpectrum m_spectrum;
};
#endif // SPECTROGRAPH_H