1 /***************************************************************************
2 * Copyright (C) 2010 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 #ifndef AUDIOSPECTRUM_H
12 #define AUDIOSPECTRUM_H
18 #include "abstractaudioscopewidget.h"
19 #include "ui_audiospectrum_ui.h"
20 #include "tools/kiss_fftr.h"
22 class AudioSpectrum_UI;
23 class AudioSpectrum : public AbstractAudioScopeWidget {
27 AudioSpectrum(QWidget *parent = 0);
30 // Implemented virtual methods
31 QString widgetName() const;
33 static const QString directions[]; // Mainly for debug output
34 enum RescaleDirection { North, Northeast, East, Southeast };
35 enum RescaleDimension { Min_dB, Max_dB, Max_Hz };
39 ///// Implemented methods /////
41 QImage renderHUD(uint accelerationFactor);
42 QImage renderAudioScope(uint accelerationFactor, const QVector<int16_t> audioFrame, const int freq, const int num_channels, const int num_samples);
43 QImage renderBackground(uint accelerationFactor);
44 bool isHUDDependingOnInput() const;
45 bool isScopeDependingOnInput() const;
46 bool isBackgroundDependingOnInput() const;
47 virtual void readConfig();
50 void mouseMoveEvent(QMouseEvent *event);
51 void mousePressEvent(QMouseEvent *event);
52 void mouseReleaseEvent(QMouseEvent *event);
55 Ui::AudioSpectrum_UI *ui;
57 QHash<QString, QVector<float> > m_windowFunctions;
61 // Contains the plot only; m_scopeRect contains text and widgets as well
62 QRect m_innerScopeRect;
64 /** Lower bound for the dB value to display */
66 /** Upper bound (max: 0) */
69 /** Maximum frequency (depends on the sampling rate)
70 Stored for the HUD painter */
72 /** The user has chosen a custom frequency. */
76 ///// Movement detection /////
77 const int m_rescaleMinDist;
78 const float m_rescaleVerticalThreshold;
81 bool m_rescalePropertiesLocked;
82 bool m_rescaleFirstRescaleDone;
84 Qt::KeyboardModifiers m_rescaleModifiers;
85 AudioSpectrum::RescaleDirection m_rescaleClockDirection;
86 QPoint m_rescaleStartPoint;
92 void slotResetMaxFreq();
96 #endif // AUDIOSPECTRUM_H