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
24 #include "abstractaudioscopewidget.h"
25 #include "ui_audiospectrum_ui.h"
26 #include "lib/external/kiss_fft/tools/kiss_fftr.h"
27 #include "lib/audio/fftTools.h"
29 class AudioSpectrum_UI;
32 \brief Displays a spectral power distribution of audio samples.
33 The frequency distribution is calculated by means of a Fast Fourier Transformation.
34 For more information see Wikipedia:FFT and the code comments.
36 \todo Currently only supports one channel. Add support for multiple channels.
38 class AudioSpectrum : public AbstractAudioScopeWidget {
42 explicit AudioSpectrum(QWidget *parent = 0);
45 // Implemented virtual methods
46 QString widgetName() const;
50 ///// Implemented methods /////
52 QImage renderHUD(uint accelerationFactor);
53 QImage renderAudioScope(uint accelerationFactor, const QVector<int16_t> &audioFrame, const int freq, const int num_channels, const int num_samples, const int newData);
54 QImage renderBackground(uint accelerationFactor);
55 bool isHUDDependingOnInput() const;
56 bool isScopeDependingOnInput() const;
57 bool isBackgroundDependingOnInput() const;
58 virtual void readConfig();
61 virtual void handleMouseDrag(const QPoint &movement, const RescaleDirection rescaleDirection, const Qt::KeyboardModifiers rescaleModifiers);
64 Ui::AudioSpectrum_UI *ui;
67 QAction *m_aTrackMouse;
71 QVector<float> m_lastFFT;
72 QSemaphore m_lastFFTLock;
74 QVector<float> m_peaks;
75 QVector<float> m_peakMap;
77 /** Contains the plot only; m_scopeRect contains text and widgets as well */
78 QRect m_innerScopeRect;
80 /** Lower bound for the dB value to display */
82 /** Upper bound (max: 0) */
85 /** Maximum frequency (limited by the sampling rate if determined automatically).
86 Stored for the painters. */
88 /** The user has chosen a custom frequency. */
93 #ifdef DEBUG_AUDIOSPEC
100 void slotResetMaxFreq();
104 #endif // AUDIOSPECTRUM_H