Skip to content

Commit

Permalink
feat: implement new libjamesdsp features & fix bugs
Browse files Browse the repository at this point in the history
1. Compander: support for time-frequency transforms parameter
2. Stereo widener: fixed broken audio when enaling without setting
   strength
3. Convolver benchmarking: Add setting to disable benchmarks on boot
   (Pipewire only)
  • Loading branch information
timschneeb committed Jul 22, 2023
1 parent 8c3169a commit 2edc449
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 15 deletions.
58 changes: 57 additions & 1 deletion libjamesdsp/libjamesdsp.pro
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,21 @@ HEADERS += \
$$BASEPATH/jdsp_header.h \
EELStdOutExtension.h \
PrintfStdOutExtension.h \
JdspImpResToolbox.h
JdspImpResToolbox.h \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/cxpre.h \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/cxxsrc/xcomplex.h \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/cxxsrc/xreal.h \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/xcomplex.h \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/xreal.h \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/hpaconf.h \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/mp/const07.h \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/mp/const11.h \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/mp/const15.h \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/mp/const19.h \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/mp/const23.h \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/mp/const27.h \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/mp/const31.h \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xpre.h

SOURCES += \
$$BASEPATH/Effects/arbEqConv.c \
Expand Down Expand Up @@ -107,6 +121,45 @@ SOURCES += \
EELStdOutExtension.c \
PrintfStdOutExtension.c \
JdspImpResToolbox.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/loose_eel.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/atox.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/constant.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/cxaop.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/cxbasic.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/cxconstant.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/cxconvf.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/cxexp.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/cxhypb.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/cxidiv.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/cxpow.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/cxprcmp.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/cxtrig.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/hpaconf.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/prcxpr.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/print.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/prxpr.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/sfmod.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/shift.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xadd.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xchcof.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xdiv.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xevtch.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xexp.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xfmod.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xfrac.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xhypb.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xivhypb.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xivtrg.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xlog.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xmul.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xneg.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xprcmp.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xpwr.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xsigerr.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xsqrt.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xtodbl.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xtoflt.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/xtrig.c \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/multimodalEQ.c

unix {
Expand All @@ -120,3 +173,6 @@ unix {
else: error("Static linking only available on Linux systems")

!isEmpty(target.path): INSTALLS += target

DISTFILES += \
subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt
5 changes: 0 additions & 5 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,6 @@ MainWindow::MainWindow(bool statupInTray,
// GraphicEQ
ui->graphicEq->setEnableSwitchVisible(true);
ui->graphicEq->setAutoEqAvailable(true);

// Compander
// TODO remove this once the option is actually implemented in libjamesdsp
ui->label_5->setVisible(false);
ui->comp_tf_transforms->setVisible(false);
}

// Allocate pointers and init important variables
Expand Down
1 change: 1 addition & 0 deletions src/audio/base/DspHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ bool DspHost::update(DspConfig *config, bool ignoreCache)
StereoEnhancementEnable(cast(this->_dsp));
else
StereoEnhancementDisable(cast(this->_dsp));
StereoEnhancementSetParam(cast(this->_dsp), _cache->get<float>(DspConfig::stereowide_level) / 100.0f);
break;
case DspConfig::stereowide_level:
StereoEnhancementDisable(cast(this->_dsp));
Expand Down
4 changes: 3 additions & 1 deletion src/audio/pipewire/PwJamesDspPlugin.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "PwJamesDspPlugin.h"
#include <QString>

#include "config/AppConfig.h"

extern "C" {
#ifdef DEBUG_FPE
#include <fenv.h>
Expand All @@ -27,7 +29,7 @@ PwJamesDspPlugin::PwJamesDspPlugin(PwPipelineManager* pipe_manager, IAudioServic
#ifdef DEBUG_FPE
feenableexcept(FE_ALL_EXCEPT & ~FE_INEXACT & ~FE_INVALID);
#endif
JamesDSPGlobalMemoryAllocation();
JamesDSPGlobalMemoryAllocation((int)AppConfig::instance().get<bool>(AppConfig::BenchmarkOnBoot));
JamesDSPInit(this->dsp, 128, 48000);
#ifdef DEBUG_FPE
fedisableexcept(FE_ALL_EXCEPT & ~FE_INEXACT & ~FE_INVALID);
Expand Down
3 changes: 2 additions & 1 deletion src/audio/pulseaudio/wrapper/gstjamesdsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ gst_jamesdsp_init(Gstjamesdsp *self) {
self->dsp = malloc(sizeof(JamesDSPLib));
memset(self->dsp, 0, sizeof(JamesDSPLib));

JamesDSPGlobalMemoryAllocation();
// TODO: Add benchmark toggle support to pulse version...
JamesDSPGlobalMemoryAllocation(0);
JamesDSPInit(self->dsp, 128, 48000);

self->enable = FALSE;
Expand Down
2 changes: 2 additions & 0 deletions src/config/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ AppConfig::AppConfig()
DEFINE_KEY(AudioAppBlocklistInvert, false);
DEFINE_KEY(AudioInactivityTimeout, 10);

DEFINE_KEY(BenchmarkOnBoot, true);

DEFINE_KEY(AeqPlotDarkMode, false);

DEFINE_KEY(ConvolverDefaultPath, ENCLOSE_QUOTES(getPath("irs")));
Expand Down
2 changes: 2 additions & 0 deletions src/config/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class AppConfig :
AudioAppBlocklistInvert,
AudioInactivityTimeout,

BenchmarkOnBoot,

AeqPlotDarkMode,

ConvolverDefaultPath,
Expand Down
25 changes: 19 additions & 6 deletions src/interface/fragment/SettingsFragment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ SettingsFragment::SettingsFragment(TrayIcon *trayIcon,
ui->setupUi(this);

#ifdef USE_PULSEAUDIO
ui->selector->topLevelItem(2)->setHidden(true); // Hide devices
ui->selector->topLevelItem(3)->setHidden(true); // Hide devices
ui->devices->setVisible(false);
ui->blocklistBox->setVisible(false);
ui->benchmarkOnBoot->setEnabled(false);
#endif

_paletteEditor->setFixedSize(_paletteEditor->geometry().width(), _paletteEditor->geometry().height());
Expand All @@ -54,7 +55,7 @@ SettingsFragment::SettingsFragment(TrayIcon *trayIcon,
ui->selector->setCurrentItem(ui->selector->topLevelItem(0));
ui->stackedWidget->setCurrentIndex(0);
ui->stackedWidget->repaint();
ui->selector->expandItem(ui->selector->topLevelItem(4)); // Expand tray-icon
ui->selector->expandItem(ui->selector->topLevelItem(5)); // Expand tray-icon
connect(ui->selector, &QTreeWidget::currentItemChanged, this, &SettingsFragment::onTreeItemSelected);

/*
Expand Down Expand Up @@ -86,14 +87,19 @@ SettingsFragment::SettingsFragment(TrayIcon *trayIcon,
connect(ui->menu_edit, &QMenuEditor::resetPressed, this, &SettingsFragment::onTrayEditorReset);
ui->menu_edit->setSourceMenu(trayIcon->buildAvailableActions());

/*
/*
* Interface signals
*/
*/
connect(ui->themeSelect, qOverload<int>(&QComboBox::currentIndexChanged), this, &SettingsFragment::onThemeSelected);
connect(ui->paletteSelect, qOverload<int>(&QComboBox::currentIndexChanged), this, &SettingsFragment::onPaletteSelected);
connect(ui->paletteConfig, &QPushButton::clicked, _paletteEditor, &PaletteEditor::show);
connect(ui->eq_alwaysdrawhandles, &QCheckBox::clicked, this, &SettingsFragment::onEqualizerHandlesToggled);

/*
* Audio processing
*/
connect(ui->benchmarkOnBoot, &QCheckBox::clicked, this, &SettingsFragment::onBenchmarkOnBootToggled);

/*
* Paths signals
*/
Expand Down Expand Up @@ -252,6 +258,8 @@ void SettingsFragment::refreshAll()

ui->eq_alwaysdrawhandles->setChecked(AppConfig::instance().get<bool>(AppConfig::EqualizerShowHandles));

ui->benchmarkOnBoot->setChecked(AppConfig::instance().get<bool>(AppConfig::BenchmarkOnBoot));

ui->blocklistInvert->blockSignals(true);
ui->blocklistInvert->setChecked(AppConfig::instance().get<bool>(AppConfig::AudioAppBlocklistInvert));
ui->blocklistInvert->blockSignals(false);
Expand Down Expand Up @@ -313,9 +321,9 @@ void SettingsFragment::onTreeItemSelected(QTreeWidgetItem *cur, QTreeWidgetItem
switch (topLevelIndex)
{
case -1:
if (ui->selector->indexOfTopLevelItem(cur->parent()) == 4 /* Tray-icon */)
if (ui->selector->indexOfTopLevelItem(cur->parent()) == 5 /* Tray-icon */)
{
ui->stackedWidget->setCurrentIndex(5); // Context menu
ui->stackedWidget->setCurrentIndex(6); // Context menu
}
break;
default:
Expand Down Expand Up @@ -419,6 +427,11 @@ void SettingsFragment::onEqualizerHandlesToggled()
AppConfig::instance().set(AppConfig::EqualizerShowHandles, ui->eq_alwaysdrawhandles->isChecked());
}

void SettingsFragment::onBenchmarkOnBootToggled()
{
AppConfig::instance().set(AppConfig::BenchmarkOnBoot, ui->benchmarkOnBoot->isChecked());
}

void SettingsFragment::onLiveprogAutoExtractToggled()
{
AppConfig::instance().set(AppConfig::LiveprogAutoExtract, ui->liveprog_autoextract->isChecked());
Expand Down
1 change: 1 addition & 0 deletions src/interface/fragment/SettingsFragment.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private slots:
void onTrayEditorCommitted();
void onTrayEditorReset();
void onEqualizerHandlesToggled();
void onBenchmarkOnBootToggled();
void onLiveprogAutoExtractToggled();
void onGithubLinkClicked();
void onAeqDatabaseManageClicked();
Expand Down
50 changes: 49 additions & 1 deletion src/interface/fragment/SettingsFragment.ui
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
<string>Interface</string>
</property>
</item>
<item>
<property name="text">
<string>Audio processing</string>
</property>
</item>
<item>
<property name="text">
<string>Default paths</string>
Expand Down Expand Up @@ -129,7 +134,7 @@
<bool>true</bool>
</property>
<property name="currentIndex">
<number>3</number>
<number>1</number>
</property>
<widget class="QWidget" name="interface_2">
<property name="maximumSize">
Expand Down Expand Up @@ -286,6 +291,49 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="audioProcessing">
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<widget class="QGroupBox" name="groupBox_7">
<property name="title">
<string>Convolver benchmarking</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QCheckBox" name="benchmarkOnBoot">
<property name="text">
<string>Enable benchmarking on boot</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Optimizes convolver performance but causes temporarily increased CPU usage for about 1 minute after launch.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="paths">
<property name="autoFillBackground">
<bool>true</bool>
Expand Down

0 comments on commit 2edc449

Please sign in to comment.