UtiLite
0.3.1
A lite utilities library
|
#include <USpectrogram.h>
Public Slots | |
void | clear () |
void | push (const std::vector< float > &frame) |
void | push (const QVector< float > &frame) |
void | setSamplingRate (int fs) |
Public Member Functions | |
USpectrogram (QWidget *parent=0) | |
USpectrogram (int fs, QWidget *parent=0) | |
void | setData (const QList< QVector< float > > &data) |
USpectrogram is a QWidget to show a spectrogram. Add frames (squared magnitude values) incrementally using Qt signals/slots.
Example:
#include "utilite/USpectrogram.h" #include <QApplication> int main(int argc, char * argv[]) { QApplication app(argc, argv); USpectrogram spectrogram; // Get audio frames and compute the FFTs, // compute the squared magnitude (im*im + re*re) of the FFTs, then // add the frequency frames to the spectrogram. std::vector<float> frame1, frame2, frame3, frame4; //... spectrogram.push(frame1); spectrogram.push(frame2); spectrogram.push(frame3); spectrogram.push(frame4); spectrogram.push(frameXXXX); //... spectrogram.show(); app.exec(); return 0; }
USpectrogram::USpectrogram | ( | QWidget * | parent = 0 | ) |
Constructor 1.
USpectrogram::USpectrogram | ( | int | fs, |
QWidget * | parent = 0 |
||
) |
Constructor 2. Set the sampling frequency of the frames (used to show values in Hz).
void USpectrogram::clear | ( | ) | [slot] |
Clear the spectrogram.
void USpectrogram::push | ( | const std::vector< float > & | frame | ) | [slot] |
Push a new frame. It must be the same size of the previous added frames. If not, a clear() is required.
void USpectrogram::push | ( | const QVector< float > & | frame | ) | [slot] |
For convenience, push a new frame. It must be the same size of the previous added frames. If not, a clear() is required.
void USpectrogram::setData | ( | const QList< QVector< float > > & | data | ) |
Set all frames. If you want to incrementally add frames, use slot push().
void USpectrogram::setSamplingRate | ( | int | fs | ) | [slot] |
Set sampling rate (to display frequencies in Hz).