Skip to content

Commit d1fb433

Browse files
committed
Implement app manager
1 parent 6b66eab commit d1fb433

File tree

10 files changed

+47
-260
lines changed

10 files changed

+47
-260
lines changed

src/MainWindow.cpp

Lines changed: 4 additions & 232 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ MainWindow::MainWindow(QString exepath,
330330
{
331331
QMenu *menu = new QMenu();
332332
spectrum = new QAction("Reload spectrum", this);
333-
connect(spectrum, &QAction::triggered, this, &MainWindow::restartSpectrum);
333+
//connect(spectrum, &QAction::triggered, this, &MainWindow::restartSpectrum);
334334
menu->addAction(tr("Reload JamesDSP"), this, SLOT(restart()));
335335
menu->addAction(tr("Reset to defaults"), this, SLOT(reset()));
336336
//menu->addAction(spectrum);
@@ -479,239 +479,11 @@ MainWindow::~MainWindow()
479479
delete ui;
480480
}
481481

482-
// Spectrum
483-
void MainWindow::setSpectrumVisibility(bool v)
484-
{
485-
/*m_spectrograph->setVisible(v);
486-
487-
if (v)
488-
{
489-
this->findChild<QFrame*>("analysisLayout_spectrum")->setFrameShape(QFrame::StyledPanel);
490-
}
491-
else
492-
{
493-
this->findChild<QFrame*>("analysisLayout_spectrum")->setFrameShape(QFrame::NoFrame);
494-
}*/
495-
}
496-
497-
void MainWindow::initializeSpectrum()
498-
{
499-
/*m_spectrograph = new Spectrograph(this);
500-
m_audioengine = new AudioStreamEngine(this);
501-
502-
int refresh = AppConfig::instance().get<int>(AppConfig::SpectrumRefresh);
503-
504-
if (refresh == 0)
505-
{
506-
refresh = 20;
507-
}
508-
509-
if (refresh < 10)
510-
{
511-
refresh = 10;
512-
}
513-
else if (refresh > 500)
514-
{
515-
refresh = 500;
516-
}
517-
518-
m_audioengine->setNotifyIntervalMs(refresh);
519-
520-
analysisLayout.reset(new QFrame());
521-
analysisLayout->setObjectName("analysisLayout_spectrum");
522-
analysisLayout->setFrameShape(QFrame::Shape::StyledPanel);
523-
analysisLayout->setLayout(new QHBoxLayout);
524-
analysisLayout->layout()->setMargin(0);
525-
analysisLayout->layout()->addWidget(m_spectrograph);
526-
527-
auto buttonbox = ui->centralWidget->layout()->takeAt(ui->centralWidget->layout()->count() - 1);
528-
ui->centralWidget->layout()->addWidget(analysisLayout.data());
529-
ui->centralWidget->layout()->addItem(buttonbox);
530-
analysisLayout.take();
531-
532-
setSpectrumVisibility(false);
533-
534-
connect(&AppConfig::instance(), &AppConfig::spectrumChanged, this, [this](bool needReload) {
535-
toggleSpectrum(AppConfig::instance().get<bool>(AppConfig::SpectrumEnabled), true);
536-
if(needReload)
537-
restartSpectrum();
538-
});*/
539-
}
540-
541-
void MainWindow::restartSpectrum()
542-
{
543-
//toggleSpectrum(false, false);
544-
//toggleSpectrum(AppConfig::instance().get<bool>(AppConfig::SpectrumEnabled), false);
545-
}
546-
547-
void MainWindow::refreshSpectrumParameters()
548-
{
549-
/*int bands = AppConfig::instance().get<int>(AppConfig::SpectrumBands);
550-
int minfreq = AppConfig::instance().get<int>(AppConfig::SpectrumMinFreq);
551-
int maxfreq = AppConfig::instance().get<int>(AppConfig::SpectrumMaxFreq);
552-
int refresh = AppConfig::instance().get<int>(AppConfig::SpectrumRefresh);
553-
float multiplier = AppConfig::instance().get<float>(AppConfig::SpectrumMultiplier);
554-
555-
// Set default values if undefined
556-
if (bands == 0)
557-
{
558-
bands = 100;
559-
}
560-
561-
if (maxfreq == 0)
562-
{
563-
maxfreq = 1000;
564-
}
565-
566-
if (refresh == 0)
567-
{
568-
refresh = 10;
569-
}
570-
571-
if (multiplier == 0)
572-
{
573-
multiplier = 0.15;
574-
}
575-
576-
// Check boundaries
577-
if (bands < 5 )
578-
{
579-
bands = 5;
580-
}
581-
else if (bands > 300)
582-
{
583-
bands = 300;
584-
}
585-
586-
if (minfreq < 0)
587-
{
588-
minfreq = 0;
589-
}
590-
else if (minfreq > 10000)
591-
{
592-
minfreq = 10000;
593-
}
594-
595-
if (maxfreq < 100)
596-
{
597-
maxfreq = 100;
598-
}
599-
else if (maxfreq > 24000)
600-
{
601-
maxfreq = 24000;
602-
}
603-
604-
if (refresh < 10)
605-
{
606-
refresh = 10;
607-
}
608-
else if (refresh > 500)
609-
{
610-
refresh = 500;
611-
}
612-
613-
if (multiplier < 0.01)
614-
{
615-
multiplier = 0.01;
616-
}
617-
else if (multiplier > 1)
618-
{
619-
multiplier = 1;
620-
}
621-
622-
if (maxfreq < minfreq)
623-
{
624-
maxfreq = minfreq + 100;
625-
}
626-
627-
QColor outline;
628-
629-
if (palette().window().style() == Qt::TexturePattern)
630-
{
631-
outline = QColor(0, 0, 0, 160);
632-
}
633-
else
634-
{
635-
outline = palette().window().color().lighter(140);
636-
}
637-
638-
m_spectrograph->setTheme(palette().window().color().lighter(),
639-
palette().highlight().color(),
640-
palette().text().color(),
641-
outline.lighter(108),
642-
AppConfig::instance().get<bool>(AppConfig::SpectrumGrid),
643-
(Spectrograph::Mode) AppConfig::instance().get<int>(AppConfig::SpectrumTheme));
644-
645-
m_spectrograph->setParams(bands, minfreq, maxfreq);
646-
m_audioengine->setNotifyIntervalMs(refresh);
647-
m_audioengine->setMultiplier(multiplier);*/
648-
}
649-
650-
void MainWindow::toggleSpectrum(bool on,
651-
bool ctrl_visibility)
652-
{
653-
/*refreshSpectrumParameters();
654-
655-
if (ctrl_visibility)
656-
{
657-
spectrum->setVisible(on);
658-
}
659-
660-
if (on && (!m_spectrograph->isVisible() || !ctrl_visibility))
661-
{
662-
if (ctrl_visibility)
663-
{
664-
setSpectrumVisibility(true);
665-
this->setFixedSize(this->width(), this->height() + m_spectrograph->size().height());
666-
}
667-
668-
QAudioDeviceInfo in;
669-
670-
for (auto item : QAudioDeviceInfo::availableDevices(QAudio::AudioInput))
671-
{
672-
if (item.deviceName() == AppConfig::instance().getSpectrumInput())
673-
{
674-
in = item;
675-
}
676-
}
677-
678-
m_audioengine->setAudioInputDevice(in);
679-
m_audioengine->initializeRecord();
680-
m_audioengine->startRecording();
681-
682-
connect(m_audioengine, static_cast<void (AudioStreamEngine::*)(QAudio::Mode, QAudio::State)>(&AudioStreamEngine::stateChanged),
683-
this, [this](QAudio::Mode mode, QAudio::State state) {
684-
Q_UNUSED(mode);
685-
686-
if (QAudio::ActiveState != state && QAudio::SuspendedState != state)
687-
{
688-
m_spectrograph->reset();
689-
}
690-
});
691-
692-
connect(m_audioengine, static_cast<void (AudioStreamEngine::*)(qint64, qint64, const FrequencySpectrum &)>(&AudioStreamEngine::spectrumChanged),
693-
this, [this](qint64, qint64, const FrequencySpectrum &spectrum) {
694-
m_spectrograph->spectrumChanged(spectrum);
695-
});
696-
}
697-
else if (!on && (m_spectrograph->isVisible() || !ctrl_visibility))
698-
{
699-
if (ctrl_visibility)
700-
{
701-
setSpectrumVisibility(false);
702-
this->setFixedSize(this->width(), this->height() - m_spectrograph->size().height());
703-
}
704-
705-
m_spectrograph->reset();
706-
m_audioengine->reset();
707-
}*/
708-
}
709-
710482
void MainWindow::fireTimerSignal()
711483
{
712484
if (spectrumReloadSignalQueued)
713485
{
714-
restartSpectrum();
486+
//restartSpectrum();
715487
}
716488

717489
spectrumReloadSignalQueued = false;
@@ -855,7 +627,7 @@ void MainWindow::savePresetFile(const QString &filename)
855627

856628
void MainWindow::loadExternalFile()
857629
{
858-
QString filename = QFileDialog::getOpenFileName(this, tr("Load custom audio.conf"), "", "*.conf");
630+
QString filename = QFileDialog::getOpenFileName(this, tr("Load custom audio.conf"), "", "JamesDSP Linux configuration (*.conf)");
859631

860632
if (filename == "")
861633
{
@@ -867,7 +639,7 @@ void MainWindow::loadExternalFile()
867639

868640
void MainWindow::saveExternalFile()
869641
{
870-
QString filename = QFileDialog::getSaveFileName(this, tr("Save current audio.conf"), "", "*.conf");
642+
QString filename = QFileDialog::getSaveFileName(this, tr("Save current audio.conf"), "", "JamesDSP Linux configuration (*.conf)");
871643

872644
if (filename == "")
873645
{

src/MainWindow.h

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ class MainWindow :
7676
void closeEvent(QCloseEvent *event) override;
7777

7878
public slots:
79-
void restartSpectrum();
8079
void reset();
8180
void restart();
8281
void raiseWindow();
@@ -96,8 +95,7 @@ private slots:
9695
void updateAllUnitLabels();
9796
void loadExternalFile();
9897
void saveExternalFile();
99-
void dialogHandler();
100-
void refreshSpectrumParameters();
98+
void dialogHandler();
10199
void updateEqStringFromWidget();
102100
void bs2bPresetSelectionUpdated();
103101
void reverbPresetSelectionUpdated();
@@ -151,35 +149,15 @@ private slots:
151149

152150
QJsonTableModel *model;
153151

154-
void initializeSpectrum();
155-
void toggleSpectrum(bool on,
156-
bool ctrl_visibility);
157152
void updateTooltipLabelUnit(QObject *sender,
158153
const QString &text,
159154
bool);
160155
void loadConfig();
161156
void connectActions();
162157

163-
void setSpectrumVisibility(bool v);
164158
void reloadDDCDB();
165159
void setLiveprogSelection(QString path);
166160

167-
static void replaceTab(QTabWidget *tab,
168-
int index,
169-
QWidget *page,
170-
QString title = "")
171-
{
172-
if (title.isEmpty())
173-
{
174-
title = tab->tabText(index);
175-
}
176-
177-
auto toDelete = tab->widget(index);
178-
tab->removeTab(index);
179-
toDelete->deleteLater();
180-
tab->insertTab(index, page, title);
181-
}
182-
183161
void updateIrsSelection();
184162

185163
};

src/audio/base/Base.pri

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ INCLUDEPATH += $$PWD
33
HEADERS += \
44
$$PWD/DspHost.h \
55
$$PWD/DspStatus.h \
6+
$$PWD/IAppManager.h \
67
$$PWD/IAudioService.h \
78
$$PWD/IDspElement.h \
89
$$PWD/IOutputDevice.h \

src/audio/base/IAppManager.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef IAPPMANAGER_H
2+
#define IAPPMANAGER_H
3+
4+
#include <QObject>
5+
6+
class IAppManager : public QObject
7+
{
8+
Q_OBJECT
9+
public:
10+
virtual ~IAppManager() {}
11+
12+
public slots:
13+
14+
15+
};
16+
17+
#endif // IAPPMANAGER_H

src/audio/base/IAudioService.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "IOutputDevice.h"
55
#include "DspStatus.h"
6+
#include "IAppManager.h"
67
#include <QObject>
78

89
class DspConfig;
@@ -17,8 +18,10 @@ public slots:
1718
virtual void update(DspConfig* config) = 0;
1819
virtual void reloadLiveprog() = 0;
1920
virtual void reloadService() = 0;
20-
virtual std::vector<IOutputDevice> sinkDevices() = 0;
2121

22+
virtual IAppManager* appManager() = 0;
23+
24+
virtual std::vector<IOutputDevice> sinkDevices() = 0;
2225
virtual DspStatus status() = 0;
2326

2427
signals:

src/audio/pipewire/PipewireAudioService.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ void PipewireAudioService::reloadService()
9595
effects.get()->connect_filters();
9696
}
9797

98+
IAppManager *PipewireAudioService::appManager()
99+
{
100+
return appMgr.get();
101+
}
102+
98103
std::vector<IOutputDevice> PipewireAudioService::sinkDevices()
99104
{
100105
std::vector<IOutputDevice> devices;

src/audio/pipewire/PipewireAudioService.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ public slots:
2727
void update(DspConfig* config) override;
2828
void reloadLiveprog() override;
2929
void reloadService() override;
30-
std::vector<IOutputDevice> sinkDevices() override;
3130

31+
IAppManager* appManager() override;
32+
std::vector<IOutputDevice> sinkDevices() override;
3233
DspStatus status() override;
3334

3435
private:

0 commit comments

Comments
 (0)