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 ***************************************************************************/
12 #ifndef AUDIOSPECTRUM_H
13 #define AUDIOSPECTRUM_H
16 //#define DEBUG_AUDIOSPEC
18 // Show overmodulation
19 #define DETECT_OVERMODULATION
25 #include "abstractaudioscopewidget.h"
26 #include "ui_audiospectrum_ui.h"
27 #include "lib/external/kiss_fft/tools/kiss_fftr.h"
28 #include "lib/audio/fftTools.h"
30 class AudioSpectrum_UI;
33 \brief Displays a spectral power distribution of audio samples.
34 The frequency distribution is calculated by means of a Fast Fourier Transformation.
35 For more information see Wikipedia:FFT and the code comments.
37 \todo Currently only supports one channel. Add support for multiple channels.
39 class AudioSpectrum : public AbstractAudioScopeWidget {
43 explicit AudioSpectrum(QWidget *parent = 0);
46 // Implemented virtual methods
47 QString widgetName() const;
51 ///// Implemented methods /////
53 QImage renderHUD(uint accelerationFactor);
54 QImage renderAudioScope(uint accelerationFactor, const QVector<int16_t> audioFrame, const int freq, const int num_channels, const int num_samples, const int newData);
55 QImage renderBackground(uint accelerationFactor);
56 bool isHUDDependingOnInput() const;
57 bool isScopeDependingOnInput() const;
58 bool isBackgroundDependingOnInput() const;
59 virtual void readConfig();
62 virtual void handleMouseDrag(const QPoint &movement, const RescaleDirection rescaleDirection, const Qt::KeyboardModifiers rescaleModifiers);
65 Ui::AudioSpectrum_UI *ui;
68 QAction *m_aTrackMouse;
72 QVector<float> m_lastFFT;
73 QSemaphore m_lastFFTLock;
75 QVector<float> m_peaks;
76 QVector<float> m_peakMap;
78 /** Contains the plot only; m_scopeRect contains text and widgets as well */
79 QRect m_innerScopeRect;
81 /** Lower bound for the dB value to display */
83 /** Upper bound (max: 0) */
86 /** Maximum frequency (limited by the sampling rate if determined automatically).
87 Stored for the painters. */
89 /** The user has chosen a custom frequency. */
94 #ifdef DEBUG_AUDIOSPEC
101 void slotResetMaxFreq();
105 #endif // AUDIOSPECTRUM_H