-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add simple spectrogram display
- Loading branch information
1 parent
da00299
commit 88db8e7
Showing
11 changed files
with
598 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#------------------------------------------------- | ||
# | ||
# Project created by QtCreator 2020-08-21T15:05:39.404Z | ||
# | ||
#------------------------------------------------- | ||
|
||
QT += widgets | ||
|
||
QT -= gui | ||
|
||
TARGET = Spectrogram | ||
TEMPLATE = lib | ||
|
||
DEFINES += SPECTROGRAM_LIBRARY | ||
|
||
CONFIG += c++11 plugin | ||
CONFIG -= debug_and_release_target | ||
|
||
# The following define makes your compiler emit warnings if you use | ||
# any feature of Qt which has been marked as deprecated (the exact warnings | ||
# depend on your compiler). Please consult the documentation of the | ||
# deprecated API in order to know how to port your code away from it. | ||
DEFINES += QT_DEPRECATED_WARNINGS | ||
|
||
# You can also make your code fail to compile if you use deprecated APIs. | ||
# In order to do so, uncomment the following line. | ||
# You can also select to disable deprecated APIs only up to a certain version of Qt. | ||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 | ||
|
||
SOURCES += spectrogram.cpp spectrogramwidget.cpp spectrogramcontrols.cpp | ||
|
||
HEADERS += spectrogram.h spectrogramwidget.h spectrogramcontrols.h | ||
|
||
FORMS += spectrogramcontrols.ui | ||
|
||
DISTFILES += | ||
|
||
RESOURCES += | ||
|
||
LIBS += -L$$OUT_PWD/../../../hobbits-core/ -lhobbits-core | ||
|
||
INCLUDEPATH += $$PWD/../../../hobbits-core | ||
DEPENDPATH += $$PWD/../../../hobbits-core | ||
|
||
win32-msvc* { | ||
requires(exists($$OUT_PWD/../../../../windows/libfftw3.h)) | ||
requires(exists($$OUT_PWD/../../../../windows/libfftw3-3.lib)) | ||
LIBS += -L$$OUT_PWD/../../../../windows -llibfftw3-3 | ||
INCLUDEPATH += $$OUT_PWD/../../../../windows | ||
DEPENDPATH += $$OUT_PWD/../../../../windows | ||
|
||
DEFINES += FFTW_AUTOCORRELATION | ||
} | ||
win32-g++ { | ||
requires(exists($$OUT_PWD/../../../../windows/libfftw3.h)) | ||
requires(exists($$OUT_PWD/../../../../windows/libfftw3-3.dll)) | ||
LIBS += -L$$OUT_PWD/../../../../windows -lfftw3-3 | ||
INCLUDEPATH += $$OUT_PWD/../../../../windows | ||
DEPENDPATH += $$OUT_PWD/../../../../windows | ||
|
||
DEFINES += FFTW_AUTOCORRELATION | ||
} | ||
unix { | ||
requires(packagesExist(fftw3)) | ||
mac { | ||
INCLUDEPATH += /usr/local/include | ||
LIBS += -L/usr/local/lib | ||
} | ||
LIBS += -lfftw3 | ||
DEFINES += FFTW_AUTOCORRELATION | ||
} | ||
|
||
unix:!mac { | ||
QMAKE_LFLAGS_RPATH= | ||
QMAKE_LFLAGS += "-Wl,-rpath,'$$ORIGIN/../../lib:$$ORIGIN'" | ||
} | ||
|
||
mac { | ||
QMAKE_LFLAGS_RPATH= | ||
QMAKE_LFLAGS += "-Wl,-rpath,'@executable_path/../Frameworks'" | ||
} | ||
|
||
unix { | ||
target.path = $$(HOME)/.local/share/hobbits/plugins/displays | ||
INSTALLS += target | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "spectrogram.h" | ||
|
||
Spectrogram::Spectrogram() : | ||
m_displayWidget(nullptr), | ||
m_controlsWidget(nullptr) | ||
{ | ||
|
||
} | ||
|
||
DisplayInterface* Spectrogram::createDefaultDisplay() | ||
{ | ||
return new Spectrogram(); | ||
} | ||
|
||
QString Spectrogram::getName() | ||
{ | ||
return "Spectrogram"; | ||
} | ||
|
||
QWidget* Spectrogram::getDisplayWidget(QSharedPointer<DisplayHandle> displayHandle) | ||
{ | ||
initialize(displayHandle); | ||
return m_displayWidget; | ||
} | ||
|
||
QWidget* Spectrogram::getControlsWidget(QSharedPointer<DisplayHandle> displayHandle) | ||
{ | ||
initialize(displayHandle); | ||
return m_controlsWidget; | ||
} | ||
|
||
void Spectrogram::initialize(QSharedPointer<DisplayHandle> displayHandle) | ||
{ | ||
if (!m_displayWidget) { | ||
m_displayWidget = new SpectrogramWidget(displayHandle, this); | ||
m_controlsWidget = new SpectrogramControls(); | ||
|
||
connect(m_controlsWidget, &SpectrogramControls::wordSizeSet, | ||
m_displayWidget, &SpectrogramWidget::setWordSize); | ||
connect(m_controlsWidget, &SpectrogramControls::strideSet, | ||
m_displayWidget, &SpectrogramWidget::setStride); | ||
connect(m_controlsWidget, &SpectrogramControls::fftFactorSet, | ||
m_displayWidget, &SpectrogramWidget::setFftSizeFactor); | ||
|
||
m_controlsWidget->sendCurrentValues(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef SPECTROGRAM_H | ||
#define SPECTROGRAM_H | ||
|
||
#include "displayinterface.h" | ||
#include "spectrogramcontrols.h" | ||
#include "spectrogramwidget.h" | ||
|
||
class Spectrogram : public QObject, DisplayInterface | ||
{ | ||
Q_OBJECT | ||
Q_PLUGIN_METADATA(IID "hobbits.DisplayInterface.Spectrogram") | ||
Q_INTERFACES(DisplayInterface) | ||
|
||
public: | ||
Spectrogram(); | ||
|
||
DisplayInterface* createDefaultDisplay(); | ||
|
||
QString getName(); | ||
|
||
QWidget* getDisplayWidget(QSharedPointer<DisplayHandle> displayHandle); | ||
QWidget* getControlsWidget(QSharedPointer<DisplayHandle> displayHandle); | ||
|
||
private: | ||
void initialize(QSharedPointer<DisplayHandle> displayHandle); | ||
SpectrogramWidget* m_displayWidget; | ||
SpectrogramControls* m_controlsWidget; | ||
}; | ||
|
||
#endif // SPECTROGRAM_H |
37 changes: 37 additions & 0 deletions
37
src/hobbits-plugins/displays/Spectrogram/spectrogramcontrols.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "spectrogramcontrols.h" | ||
#include "ui_spectrogramcontrols.h" | ||
|
||
|
||
SpectrogramControls::SpectrogramControls() : | ||
ui(new Ui::SpectrogramControls()) | ||
{ | ||
ui->setupUi(this); | ||
calculateFftSize(); | ||
|
||
connect(ui->sb_wordSize, SIGNAL(valueChanged(int)), this, SIGNAL(wordSizeSet(int))); | ||
} | ||
|
||
void SpectrogramControls::sendCurrentValues() | ||
{ | ||
emit wordSizeSet(ui->sb_wordSize->value()); | ||
emit strideSet(ui->sb_stride->value()); | ||
emit fftFactorSet(ui->sb_fftFactor->value()); | ||
} | ||
|
||
void SpectrogramControls::on_sb_stride_valueChanged(int val) | ||
{ | ||
calculateFftSize(); | ||
emit strideSet(val); | ||
} | ||
|
||
void SpectrogramControls::on_sb_fftFactor_valueChanged(int val) | ||
{ | ||
calculateFftSize(); | ||
emit fftFactorSet(val); | ||
} | ||
|
||
void SpectrogramControls::calculateFftSize() | ||
{ | ||
int fftSize = ui->sb_stride->value() * ui->sb_fftFactor->value(); | ||
ui->lb_fftSize->setText(QString("FFT Size: %1").arg(fftSize)); | ||
} |
34 changes: 34 additions & 0 deletions
34
src/hobbits-plugins/displays/Spectrogram/spectrogramcontrols.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef SPECTROGRAMCONTROLS_H | ||
#define SPECTROGRAMCONTROLS_H | ||
|
||
#include <QWidget> | ||
|
||
namespace Ui | ||
{ | ||
class SpectrogramControls; | ||
} | ||
|
||
class SpectrogramControls : public QWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
SpectrogramControls(); | ||
void sendCurrentValues(); | ||
|
||
signals: | ||
void wordSizeSet(int); | ||
void strideSet(int); | ||
void fftFactorSet(int); | ||
|
||
private slots: | ||
void on_sb_stride_valueChanged(int val); | ||
void on_sb_fftFactor_valueChanged(int val); | ||
|
||
void calculateFftSize(); | ||
|
||
private: | ||
Ui::SpectrogramControls *ui; | ||
}; | ||
|
||
#endif // SPECTROGRAMCONTROLS_H |
108 changes: 108 additions & 0 deletions
108
src/hobbits-plugins/displays/Spectrogram/spectrogramcontrols.ui
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>SpectrogramControls</class> | ||
<widget class="QWidget" name="SpectrogramControls"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>798</width> | ||
<height>56</height> | ||
</rect> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<widget class="QLabel" name="label"> | ||
<property name="text"> | ||
<string>Word Size:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QSpinBox" name="sb_wordSize"> | ||
<property name="minimum"> | ||
<number>1</number> | ||
</property> | ||
<property name="maximum"> | ||
<number>64</number> | ||
</property> | ||
<property name="value"> | ||
<number>16</number> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QLabel" name="label_2"> | ||
<property name="text"> | ||
<string>Stride:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QSpinBox" name="sb_stride"> | ||
<property name="minimum"> | ||
<number>64</number> | ||
</property> | ||
<property name="maximum"> | ||
<number>131072</number> | ||
</property> | ||
<property name="singleStep"> | ||
<number>256</number> | ||
</property> | ||
<property name="value"> | ||
<number>512</number> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QLabel" name="label_3"> | ||
<property name="text"> | ||
<string>FFT Size Factor:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QSpinBox" name="sb_fftFactor"> | ||
<property name="suffix"> | ||
<string>x</string> | ||
</property> | ||
<property name="minimum"> | ||
<number>1</number> | ||
</property> | ||
<property name="maximum"> | ||
<number>16</number> | ||
</property> | ||
<property name="value"> | ||
<number>4</number> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QLabel" name="lb_fftSize"> | ||
<property name="text"> | ||
<string>FFT Size:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<spacer name="horizontalSpacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>40</width> | ||
<height>20</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
Oops, something went wrong.