3 #include "config_backends.h"
4 #include "config_simd.h"
6 #include "mainwindow.h"
11 #include <QFileDialog>
12 #include <QMessageBox>
13 #include <QCloseEvent>
16 #include "ui_mainwindow.h"
29 struct BackendNamePair
{
30 /* NOLINTBEGIN(*-avoid-c-arrays) */
31 char backend_name
[16];
33 /* NOLINTEND(*-avoid-c-arrays) */
35 constexpr std::array backendList
{
37 BackendNamePair
{ "pipewire", "PipeWire" },
40 BackendNamePair
{ "pulse", "PulseAudio" },
43 BackendNamePair
{ "alsa", "ALSA" },
46 BackendNamePair
{ "jack", "JACK" },
49 BackendNamePair
{ "core", "CoreAudio" },
52 BackendNamePair
{ "oss", "OSS" },
55 BackendNamePair
{ "solaris", "Solaris" },
58 BackendNamePair
{ "sndio", "SndIO" },
61 BackendNamePair
{ "wasapi", "WASAPI" },
64 BackendNamePair
{ "dsound", "DirectSound" },
67 BackendNamePair
{ "winmm", "Windows Multimedia" },
70 BackendNamePair
{ "port", "PortAudio" },
73 BackendNamePair
{ "opensl", "OpenSL" },
76 BackendNamePair
{ "null", "Null Output" },
78 BackendNamePair
{ "wave", "Wave Writer" },
82 struct NameValuePair
{
83 /* NOLINTBEGIN(*-avoid-c-arrays) */
86 /* NOLINTEND(*-avoid-c-arrays) */
88 constexpr std::array speakerModeList
{
89 NameValuePair
{ "Autodetect", "" },
90 NameValuePair
{ "Mono", "mono" },
91 NameValuePair
{ "Stereo", "stereo" },
92 NameValuePair
{ "Quadraphonic", "quad" },
93 NameValuePair
{ "5.1 Surround", "surround51" },
94 NameValuePair
{ "6.1 Surround", "surround61" },
95 NameValuePair
{ "7.1 Surround", "surround71" },
96 NameValuePair
{ "3D7.1 Surround", "surround3d71" },
98 NameValuePair
{ "Ambisonic, 1st Order", "ambi1" },
99 NameValuePair
{ "Ambisonic, 2nd Order", "ambi2" },
100 NameValuePair
{ "Ambisonic, 3rd Order", "ambi3" },
102 constexpr std::array sampleTypeList
{
103 NameValuePair
{ "Autodetect", "" },
104 NameValuePair
{ "8-bit int", "int8" },
105 NameValuePair
{ "8-bit uint", "uint8" },
106 NameValuePair
{ "16-bit int", "int16" },
107 NameValuePair
{ "16-bit uint", "uint16" },
108 NameValuePair
{ "32-bit int", "int32" },
109 NameValuePair
{ "32-bit uint", "uint32" },
110 NameValuePair
{ "32-bit float", "float32" },
112 constexpr std::array resamplerList
{
113 NameValuePair
{ "Point", "point" },
114 NameValuePair
{ "Linear", "linear" },
115 NameValuePair
{ "Cubic Spline", "spline" },
116 NameValuePair
{ "4-point Gaussian", "gaussian" },
117 NameValuePair
{ "Default (4-point Gaussian)", "" },
118 NameValuePair
{ "11th order Sinc (fast)", "fast_bsinc12" },
119 NameValuePair
{ "11th order Sinc", "bsinc12" },
120 NameValuePair
{ "23rd order Sinc (fast)", "fast_bsinc24" },
121 NameValuePair
{ "23rd order Sinc", "bsinc24" },
123 constexpr std::array stereoModeList
{
124 NameValuePair
{ "Autodetect", "" },
125 NameValuePair
{ "Speakers", "speakers" },
126 NameValuePair
{ "Headphones", "headphones" },
128 constexpr std::array stereoEncList
{
129 NameValuePair
{ "Default", "" },
130 NameValuePair
{ "Basic", "panpot" },
131 NameValuePair
{ "UHJ", "uhj" },
132 NameValuePair
{ "Binaural", "hrtf" },
134 constexpr std::array ambiFormatList
{
135 NameValuePair
{ "Default", "" },
136 NameValuePair
{ "AmbiX (ACN, SN3D)", "ambix" },
137 NameValuePair
{ "Furse-Malham", "fuma" },
138 NameValuePair
{ "ACN, N3D", "acn+n3d" },
139 NameValuePair
{ "ACN, FuMa", "acn+fuma" },
141 constexpr std::array hrtfModeList
{
142 NameValuePair
{ "1st Order Ambisonic", "ambi1" },
143 NameValuePair
{ "2nd Order Ambisonic", "ambi2" },
144 NameValuePair
{ "3rd Order Ambisonic", "ambi3" },
145 NameValuePair
{ "Default (Full)", "" },
146 NameValuePair
{ "Full", "full" },
149 QString
getDefaultConfigName()
152 const char *fname
{"alsoft.ini"};
153 auto get_appdata_path
= []() noexcept
-> QString
157 if(const HRESULT hr
{SHGetKnownFolderPath(FOLDERID_RoamingAppData
, KF_FLAG_DONT_UNEXPAND
,
158 nullptr, &buffer
)}; SUCCEEDED(hr
))
159 ret
= QString::fromWCharArray(buffer
);
160 CoTaskMemFree(buffer
);
163 QString base
= get_appdata_path();
165 const char *fname
{"alsoft.conf"};
166 QString base
= qgetenv("XDG_CONFIG_HOME");
169 base
= qgetenv("HOME");
170 if(base
.isEmpty() == false)
174 if(base
.isEmpty() == false)
175 return base
+'/'+ fname
;
179 QString
getBaseDataPath()
182 auto get_appdata_path
= []() noexcept
-> QString
186 if(const HRESULT hr
{SHGetKnownFolderPath(FOLDERID_RoamingAppData
, KF_FLAG_DONT_UNEXPAND
,
187 nullptr, &buffer
)}; SUCCEEDED(hr
))
188 ret
= QString::fromWCharArray(buffer
);
189 CoTaskMemFree(buffer
);
192 QString base
= get_appdata_path();
194 QString base
= qgetenv("XDG_DATA_HOME");
197 base
= qgetenv("HOME");
199 base
+= "/.local/share";
205 QStringList
getAllDataPaths(const QString
&append
)
208 list
.append(getBaseDataPath());
210 // TODO: Common AppData path
212 QString paths
= qgetenv("XDG_DATA_DIRS");
214 paths
= "/usr/local/share/:/usr/share/";
215 #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
216 list
+= paths
.split(QChar(':'), Qt::SkipEmptyParts
);
218 list
+= paths
.split(QChar(':'), QString::SkipEmptyParts
);
221 QStringList::iterator iter
= list
.begin();
222 while(iter
!= list
.end())
225 iter
= list
.erase(iter
);
228 iter
->append(append
);
235 QString
getValueFromName(const al::span
<const NameValuePair
> list
, const QString
&str
)
237 for(size_t i
{0};i
< list
.size();++i
)
239 if(str
== std::data(list
[i
].name
))
240 return std::data(list
[i
].value
);
245 QString
getNameFromValue(const al::span
<const NameValuePair
> list
, const QString
&str
)
247 for(size_t i
{0};i
< list
.size();++i
)
249 if(str
== std::data(list
[i
].value
))
250 return std::data(list
[i
].name
);
256 Qt::CheckState
getCheckState(const QVariant
&var
)
259 return Qt::PartiallyChecked
;
262 return Qt::Unchecked
;
265 QString
getCheckValue(const QCheckBox
*checkbox
)
267 const Qt::CheckState state
{checkbox
->checkState()};
268 if(state
== Qt::Checked
)
269 return QStringLiteral("true");
270 if(state
== Qt::Unchecked
)
271 return QStringLiteral("false");
277 MainWindow::MainWindow(QWidget
*parent
) : QMainWindow
{parent
}
278 , ui
{std::make_unique
<Ui::MainWindow
>()}
282 for(auto &item
: speakerModeList
)
283 ui
->channelConfigCombo
->addItem(std::data(item
.name
));
284 ui
->channelConfigCombo
->adjustSize();
285 for(auto &item
: sampleTypeList
)
286 ui
->sampleFormatCombo
->addItem(std::data(item
.name
));
287 ui
->sampleFormatCombo
->adjustSize();
288 for(auto &item
: stereoModeList
)
289 ui
->stereoModeCombo
->addItem(std::data(item
.name
));
290 ui
->stereoModeCombo
->adjustSize();
291 for(auto &item
: stereoEncList
)
292 ui
->stereoEncodingComboBox
->addItem(std::data(item
.name
));
293 ui
->stereoEncodingComboBox
->adjustSize();
294 for(auto &item
: ambiFormatList
)
295 ui
->ambiFormatComboBox
->addItem(std::data(item
.name
));
296 ui
->ambiFormatComboBox
->adjustSize();
298 ui
->resamplerSlider
->setRange(0, resamplerList
.size()-1);
299 ui
->hrtfmodeSlider
->setRange(0, hrtfModeList
.size()-1);
301 #if !HAVE_NEON && !HAVE_SSE
302 ui
->cpuExtDisabledLabel
->move(ui
->cpuExtDisabledLabel
->x(), ui
->cpuExtDisabledLabel
->y() - 60);
304 ui
->cpuExtDisabledLabel
->setVisible(false);
313 ui
->enableSSECheckBox
->setVisible(false);
315 ui
->enableSSE2CheckBox
->setVisible(false);
317 ui
->enableSSE3CheckBox
->setVisible(false);
319 ui
->enableSSE41CheckBox
->setVisible(false);
321 ui
->enableNeonCheckBox
->setVisible(false);
329 ui
->enableNeonCheckBox
->move(ui
->enableNeonCheckBox
->x(), ui
->enableNeonCheckBox
->y() - 30);
330 ui
->enableSSECheckBox
->setVisible(false);
332 ui
->enableSSE2CheckBox
->setVisible(false);
334 ui
->enableSSE3CheckBox
->setVisible(false);
336 ui
->enableSSE41CheckBox
->setVisible(false);
342 ui
->enableEaxCheck
->setChecked(Qt::Unchecked
);
343 ui
->enableEaxCheck
->setEnabled(false);
344 ui
->enableEaxCheck
->setVisible(false);
347 mPeriodSizeValidator
= std::make_unique
<QIntValidator
>(64, 8192, this);
348 ui
->periodSizeEdit
->setValidator(mPeriodSizeValidator
.get());
349 mPeriodCountValidator
= std::make_unique
<QIntValidator
>(2, 16, this);
350 ui
->periodCountEdit
->setValidator(mPeriodCountValidator
.get());
352 mSourceCountValidator
= std::make_unique
<QIntValidator
>(0, 4096, this);
353 ui
->srcCountLineEdit
->setValidator(mSourceCountValidator
.get());
354 mEffectSlotValidator
= std::make_unique
<QIntValidator
>(0, 64, this);
355 ui
->effectSlotLineEdit
->setValidator(mEffectSlotValidator
.get());
356 mSourceSendValidator
= std::make_unique
<QIntValidator
>(0, 16, this);
357 ui
->srcSendLineEdit
->setValidator(mSourceSendValidator
.get());
358 mSampleRateValidator
= std::make_unique
<QIntValidator
>(8000, 192000, this);
359 ui
->sampleRateCombo
->lineEdit()->setValidator(mSampleRateValidator
.get());
361 mJackBufferValidator
= std::make_unique
<QIntValidator
>(0, 8192, this);
362 ui
->jackBufferSizeLine
->setValidator(mJackBufferValidator
.get());
364 connect(ui
->actionLoad
, &QAction::triggered
, this, &MainWindow::loadConfigFromFile
);
365 connect(ui
->actionSave_As
, &QAction::triggered
, this, &MainWindow::saveConfigAsFile
);
367 connect(ui
->actionAbout
, &QAction::triggered
, this, &MainWindow::showAboutPage
);
369 connect(ui
->closeCancelButton
, &QPushButton::clicked
, this, &MainWindow::cancelCloseAction
);
370 connect(ui
->applyButton
, &QPushButton::clicked
, this, &MainWindow::saveCurrentConfig
);
372 auto qcb_cicint
= static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged
);
373 connect(ui
->channelConfigCombo
, qcb_cicint
, this, &MainWindow::enableApplyButton
);
374 connect(ui
->sampleFormatCombo
, qcb_cicint
, this, &MainWindow::enableApplyButton
);
375 connect(ui
->stereoModeCombo
, qcb_cicint
, this, &MainWindow::enableApplyButton
);
376 connect(ui
->sampleRateCombo
, qcb_cicint
, this, &MainWindow::enableApplyButton
);
377 connect(ui
->sampleRateCombo
, &QComboBox::editTextChanged
, this, &MainWindow::enableApplyButton
);
379 connect(ui
->resamplerSlider
, &QSlider::valueChanged
, this, &MainWindow::updateResamplerLabel
);
381 connect(ui
->periodSizeSlider
, &QSlider::valueChanged
, this, &MainWindow::updatePeriodSizeEdit
);
382 connect(ui
->periodSizeEdit
, &QLineEdit::editingFinished
, this, &MainWindow::updatePeriodSizeSlider
);
383 connect(ui
->periodCountSlider
, &QSlider::valueChanged
, this, &MainWindow::updatePeriodCountEdit
);
384 connect(ui
->periodCountEdit
, &QLineEdit::editingFinished
, this, &MainWindow::updatePeriodCountSlider
);
386 connect(ui
->stereoEncodingComboBox
, qcb_cicint
, this, &MainWindow::enableApplyButton
);
387 connect(ui
->ambiFormatComboBox
, qcb_cicint
, this, &MainWindow::enableApplyButton
);
388 connect(ui
->outputLimiterCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
389 connect(ui
->outputDitherCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
391 connect(ui
->decoderHQModeCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
392 connect(ui
->decoderDistCompCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
393 connect(ui
->decoderNFEffectsCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
394 auto qdsb_vcd
= static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged
);
395 connect(ui
->decoderSpeakerDistSpinBox
, qdsb_vcd
, this, &MainWindow::enableApplyButton
);
396 connect(ui
->decoderQuadLineEdit
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
397 connect(ui
->decoderQuadButton
, &QPushButton::clicked
, this, &MainWindow::selectQuadDecoderFile
);
398 connect(ui
->decoder51LineEdit
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
399 connect(ui
->decoder51Button
, &QPushButton::clicked
, this, &MainWindow::select51DecoderFile
);
400 connect(ui
->decoder61LineEdit
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
401 connect(ui
->decoder61Button
, &QPushButton::clicked
, this, &MainWindow::select61DecoderFile
);
402 connect(ui
->decoder71LineEdit
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
403 connect(ui
->decoder71Button
, &QPushButton::clicked
, this, &MainWindow::select71DecoderFile
);
404 connect(ui
->decoder3D71LineEdit
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
405 connect(ui
->decoder3D71Button
, &QPushButton::clicked
, this, &MainWindow::select3D71DecoderFile
);
407 connect(ui
->preferredHrtfComboBox
, qcb_cicint
, this, &MainWindow::enableApplyButton
);
408 connect(ui
->hrtfmodeSlider
, &QSlider::valueChanged
, this, &MainWindow::updateHrtfModeLabel
);
410 connect(ui
->hrtfAddButton
, &QPushButton::clicked
, this, &MainWindow::addHrtfFile
);
411 connect(ui
->hrtfRemoveButton
, &QPushButton::clicked
, this, &MainWindow::removeHrtfFile
);
412 connect(ui
->hrtfFileList
, &QListWidget::itemSelectionChanged
, this, &MainWindow::updateHrtfRemoveButton
);
413 connect(ui
->defaultHrtfPathsCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
415 connect(ui
->srcCountLineEdit
, &QLineEdit::editingFinished
, this, &MainWindow::enableApplyButton
);
416 connect(ui
->srcSendLineEdit
, &QLineEdit::editingFinished
, this, &MainWindow::enableApplyButton
);
417 connect(ui
->effectSlotLineEdit
, &QLineEdit::editingFinished
, this, &MainWindow::enableApplyButton
);
419 connect(ui
->enableSSECheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
420 connect(ui
->enableSSE2CheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
421 connect(ui
->enableSSE3CheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
422 connect(ui
->enableSSE41CheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
423 connect(ui
->enableNeonCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
425 ui
->enabledBackendList
->setContextMenuPolicy(Qt::CustomContextMenu
);
426 connect(ui
->enabledBackendList
, &QListWidget::customContextMenuRequested
, this, &MainWindow::showEnabledBackendMenu
);
428 ui
->disabledBackendList
->setContextMenuPolicy(Qt::CustomContextMenu
);
429 connect(ui
->disabledBackendList
, &QListWidget::customContextMenuRequested
, this, &MainWindow::showDisabledBackendMenu
);
430 connect(ui
->backendCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
432 connect(ui
->defaultReverbComboBox
, qcb_cicint
, this, &MainWindow::enableApplyButton
);
433 connect(ui
->enableEaxReverbCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
434 connect(ui
->enableStdReverbCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
435 connect(ui
->enableAutowahCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
436 connect(ui
->enableChorusCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
437 connect(ui
->enableCompressorCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
438 connect(ui
->enableDistortionCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
439 connect(ui
->enableEchoCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
440 connect(ui
->enableEqualizerCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
441 connect(ui
->enableFlangerCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
442 connect(ui
->enableFrequencyShifterCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
443 connect(ui
->enableModulatorCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
444 connect(ui
->enableDedicatedCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
445 connect(ui
->enablePitchShifterCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
446 connect(ui
->enableVocalMorpherCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
447 connect(ui
->enableEaxCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
449 connect(ui
->pulseAutospawnCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
450 connect(ui
->pulseAllowMovesCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
451 connect(ui
->pulseFixRateCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
452 connect(ui
->pulseAdjLatencyCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
454 connect(ui
->pwireAssumeAudioCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
455 connect(ui
->pwireRtMixCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
457 connect(ui
->wasapiResamplerCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
459 connect(ui
->jackAutospawnCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
460 connect(ui
->jackConnectPortsCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
461 connect(ui
->jackRtMixCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
462 connect(ui
->jackBufferSizeSlider
, &QSlider::valueChanged
, this, &MainWindow::updateJackBufferSizeEdit
);
463 connect(ui
->jackBufferSizeLine
, &QLineEdit::editingFinished
, this, &MainWindow::updateJackBufferSizeSlider
);
465 connect(ui
->alsaDefaultDeviceLine
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
466 connect(ui
->alsaDefaultCaptureLine
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
467 connect(ui
->alsaResamplerCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
468 connect(ui
->alsaMmapCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
470 connect(ui
->ossDefaultDeviceLine
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
471 connect(ui
->ossPlaybackPushButton
, &QPushButton::clicked
, this, &MainWindow::selectOSSPlayback
);
472 connect(ui
->ossDefaultCaptureLine
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
473 connect(ui
->ossCapturePushButton
, &QPushButton::clicked
, this, &MainWindow::selectOSSCapture
);
475 connect(ui
->solarisDefaultDeviceLine
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
476 connect(ui
->solarisPlaybackPushButton
, &QPushButton::clicked
, this, &MainWindow::selectSolarisPlayback
);
478 connect(ui
->waveOutputLine
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
479 connect(ui
->waveOutputButton
, &QPushButton::clicked
, this, &MainWindow::selectWaveOutput
);
480 connect(ui
->waveBFormatCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
482 ui
->backendListWidget
->setCurrentRow(0);
483 ui
->tabWidget
->setCurrentIndex(0);
485 for(int i
= 1;i
< ui
->backendListWidget
->count();i
++)
486 ui
->backendListWidget
->setRowHidden(i
, true);
487 for(size_t i
{0};i
< backendList
.size();++i
)
489 QList
<QListWidgetItem
*> items
= ui
->backendListWidget
->findItems(
490 std::data(backendList
[i
].full_string
), Qt::MatchFixedString
);
491 Q_FOREACH(QListWidgetItem
*item
, items
)
492 item
->setHidden(false);
495 loadConfig(getDefaultConfigName());
498 MainWindow::~MainWindow() = default;
500 void MainWindow::closeEvent(QCloseEvent
*event
)
506 QMessageBox::StandardButton btn
= QMessageBox::warning(this,
507 tr("Apply changes?"), tr("Save changes before quitting?"),
508 QMessageBox::Save
| QMessageBox::No
| QMessageBox::Cancel
);
509 if(btn
== QMessageBox::Save
)
511 if(btn
== QMessageBox::Cancel
)
518 void MainWindow::cancelCloseAction()
525 void MainWindow::showAboutPage()
527 QMessageBox::information(this, tr("About"),
528 tr("OpenAL Soft Configuration Utility.\nBuilt for OpenAL Soft library version ") +
533 QStringList
MainWindow::collectHrtfs()
536 QStringList processed
;
538 for(int i
= 0;i
< ui
->hrtfFileList
->count();i
++)
540 QDir
dir(ui
->hrtfFileList
->item(i
)->text());
541 QStringList fnames
= dir
.entryList(QDir::Files
| QDir::Readable
, QDir::Name
);
542 Q_FOREACH(const QString
&fname
, fnames
)
544 if(!fname
.endsWith(QStringLiteral(".mhr"), Qt::CaseInsensitive
))
546 QString fullname
{dir
.absoluteFilePath(fname
)};
547 if(processed
.contains(fullname
))
549 processed
.push_back(fullname
);
551 QString name
{fname
.left(fname
.length()-4)};
552 if(!ret
.contains(name
))
558 QString s
= name
+" #"+QString::number(i
);
570 if(ui
->defaultHrtfPathsCheckBox
->isChecked())
572 QStringList paths
= getAllDataPaths(QStringLiteral("/openal/hrtf"));
573 Q_FOREACH(const QString
&name
, paths
)
576 QStringList fnames
{dir
.entryList(QDir::Files
| QDir::Readable
, QDir::Name
)};
577 Q_FOREACH(const QString
&fname
, fnames
)
579 if(!fname
.endsWith(QStringLiteral(".mhr"), Qt::CaseInsensitive
))
581 QString fullname
{dir
.absoluteFilePath(fname
)};
582 if(processed
.contains(fullname
))
584 processed
.push_back(fullname
);
586 QString name
{fname
.left(fname
.length()-4)};
587 if(!ret
.contains(name
))
593 QString s
{name
+" #"+QString::number(i
)};
605 #ifdef ALSOFT_EMBED_HRTF_DATA
606 ret
.push_back(QStringLiteral("Built-In HRTF"));
613 void MainWindow::loadConfigFromFile()
615 QString fname
= QFileDialog::getOpenFileName(this, tr("Select Files"));
616 if(fname
.isEmpty() == false)
620 void MainWindow::loadConfig(const QString
&fname
)
622 QSettings settings
{fname
, QSettings::IniFormat
};
624 QString sampletype
{settings
.value(QStringLiteral("sample-type")).toString()};
625 ui
->sampleFormatCombo
->setCurrentIndex(0);
626 if(sampletype
.isEmpty() == false)
628 QString str
{getNameFromValue(sampleTypeList
, sampletype
)};
631 const int j
{ui
->sampleFormatCombo
->findText(str
)};
632 if(j
> 0) ui
->sampleFormatCombo
->setCurrentIndex(j
);
636 QString channelconfig
{settings
.value(QStringLiteral("channels")).toString()};
637 ui
->channelConfigCombo
->setCurrentIndex(0);
638 if(channelconfig
.isEmpty() == false)
640 if(channelconfig
== QStringLiteral("surround51rear"))
641 channelconfig
= QStringLiteral("surround51");
642 QString str
{getNameFromValue(speakerModeList
, channelconfig
)};
645 const int j
{ui
->channelConfigCombo
->findText(str
)};
646 if(j
> 0) ui
->channelConfigCombo
->setCurrentIndex(j
);
650 QString srate
{settings
.value(QStringLiteral("frequency")).toString()};
652 ui
->sampleRateCombo
->setCurrentIndex(0);
655 ui
->sampleRateCombo
->lineEdit()->clear();
656 ui
->sampleRateCombo
->lineEdit()->insert(srate
);
659 ui
->srcCountLineEdit
->clear();
660 ui
->srcCountLineEdit
->insert(settings
.value(QStringLiteral("sources")).toString());
661 ui
->effectSlotLineEdit
->clear();
662 ui
->effectSlotLineEdit
->insert(settings
.value(QStringLiteral("slots")).toString());
663 ui
->srcSendLineEdit
->clear();
664 ui
->srcSendLineEdit
->insert(settings
.value(QStringLiteral("sends")).toString());
666 QString resampler
= settings
.value(QStringLiteral("resampler")).toString().trimmed();
667 ui
->resamplerSlider
->setValue(2);
668 ui
->resamplerLabel
->setText(std::data(resamplerList
[2].name
));
669 /* "Cubic" is an alias for the 4-point spline resampler. The "sinc4" and
670 * "sinc8" resamplers are unsupported, use "gaussian" as a fallback.
672 if(resampler
== QLatin1String
{"cubic"})
673 resampler
= QStringLiteral("spline");
674 else if(resampler
== QLatin1String
{"sinc4"} || resampler
== QLatin1String
{"sinc8"})
675 resampler
= QStringLiteral("gaussian");
676 /* The "bsinc" resampler name is an alias for "bsinc12". */
677 else if(resampler
== QLatin1String
{"bsinc"})
678 resampler
= QStringLiteral("bsinc12");
679 for(int i
= 0;resamplerList
[i
].name
[0];i
++)
681 if(resampler
== std::data(resamplerList
[i
].value
))
683 ui
->resamplerSlider
->setValue(i
);
684 ui
->resamplerLabel
->setText(std::data(resamplerList
[i
].name
));
689 QString stereomode
{settings
.value(QStringLiteral("stereo-mode")).toString().trimmed()};
690 ui
->stereoModeCombo
->setCurrentIndex(0);
691 if(stereomode
.isEmpty() == false)
693 QString str
{getNameFromValue(stereoModeList
, stereomode
)};
696 const int j
{ui
->stereoModeCombo
->findText(str
)};
697 if(j
> 0) ui
->stereoModeCombo
->setCurrentIndex(j
);
701 int periodsize
{settings
.value("period_size").toInt()};
702 ui
->periodSizeEdit
->clear();
705 ui
->periodSizeEdit
->insert(QString::number(periodsize
));
706 updatePeriodSizeSlider();
709 int periodcount
{settings
.value("periods").toInt()};
710 ui
->periodCountEdit
->clear();
713 ui
->periodCountEdit
->insert(QString::number(periodcount
));
714 updatePeriodCountSlider();
717 ui
->outputLimiterCheckBox
->setCheckState(getCheckState(settings
.value(QStringLiteral("output-limiter"))));
718 ui
->outputDitherCheckBox
->setCheckState(getCheckState(settings
.value(QStringLiteral("dither"))));
720 QString stereopan
{settings
.value(QStringLiteral("stereo-encoding")).toString()};
721 ui
->stereoEncodingComboBox
->setCurrentIndex(0);
722 if(stereopan
.isEmpty() == false)
724 QString str
{getNameFromValue(stereoEncList
, stereopan
)};
727 const int j
{ui
->stereoEncodingComboBox
->findText(str
)};
728 if(j
> 0) ui
->stereoEncodingComboBox
->setCurrentIndex(j
);
732 QString ambiformat
{settings
.value(QStringLiteral("ambi-format")).toString()};
733 ui
->ambiFormatComboBox
->setCurrentIndex(0);
734 if(ambiformat
.isEmpty() == false)
736 QString str
{getNameFromValue(ambiFormatList
, ambiformat
)};
739 const int j
{ui
->ambiFormatComboBox
->findText(str
)};
740 if(j
> 0) ui
->ambiFormatComboBox
->setCurrentIndex(j
);
744 ui
->decoderHQModeCheckBox
->setChecked(getCheckState(settings
.value(QStringLiteral("decoder/hq-mode"))));
745 ui
->decoderDistCompCheckBox
->setCheckState(getCheckState(settings
.value(QStringLiteral("decoder/distance-comp"))));
746 ui
->decoderNFEffectsCheckBox
->setCheckState(getCheckState(settings
.value(QStringLiteral("decoder/nfc"))));
747 double speakerdist
{settings
.value(QStringLiteral("decoder/speaker-dist"), 1.0).toDouble()};
748 ui
->decoderSpeakerDistSpinBox
->setValue(speakerdist
);
750 ui
->decoderQuadLineEdit
->setText(settings
.value(QStringLiteral("decoder/quad")).toString());
751 ui
->decoder51LineEdit
->setText(settings
.value(QStringLiteral("decoder/surround51")).toString());
752 ui
->decoder61LineEdit
->setText(settings
.value(QStringLiteral("decoder/surround61")).toString());
753 ui
->decoder71LineEdit
->setText(settings
.value(QStringLiteral("decoder/surround71")).toString());
754 ui
->decoder3D71LineEdit
->setText(settings
.value(QStringLiteral("decoder/surround3d71")).toString());
756 QStringList disabledCpuExts
{settings
.value(QStringLiteral("disable-cpu-exts")).toStringList()};
757 if(disabledCpuExts
.size() == 1)
758 disabledCpuExts
= disabledCpuExts
[0].split(QChar(','));
759 for(QString
&name
: disabledCpuExts
)
760 name
= name
.trimmed();
761 ui
->enableSSECheckBox
->setChecked(!disabledCpuExts
.contains(QStringLiteral("sse"), Qt::CaseInsensitive
));
762 ui
->enableSSE2CheckBox
->setChecked(!disabledCpuExts
.contains(QStringLiteral("sse2"), Qt::CaseInsensitive
));
763 ui
->enableSSE3CheckBox
->setChecked(!disabledCpuExts
.contains(QStringLiteral("sse3"), Qt::CaseInsensitive
));
764 ui
->enableSSE41CheckBox
->setChecked(!disabledCpuExts
.contains(QStringLiteral("sse4.1"), Qt::CaseInsensitive
));
765 ui
->enableNeonCheckBox
->setChecked(!disabledCpuExts
.contains(QStringLiteral("neon"), Qt::CaseInsensitive
));
767 QString hrtfmode
{settings
.value(QStringLiteral("hrtf-mode")).toString().trimmed()};
768 ui
->hrtfmodeSlider
->setValue(2);
769 ui
->hrtfmodeLabel
->setText(std::data(hrtfModeList
[3].name
));
770 /* The "basic" mode name is no longer supported. Use "ambi2" instead. */
771 if(hrtfmode
== QLatin1String
{"basic"})
772 hrtfmode
= QStringLiteral("ambi2");
773 for(size_t i
{0};i
< hrtfModeList
.size();++i
)
775 if(hrtfmode
== std::data(hrtfModeList
[i
].value
))
777 ui
->hrtfmodeSlider
->setValue(static_cast<int>(i
));
778 ui
->hrtfmodeLabel
->setText(std::data(hrtfModeList
[i
].name
));
783 QStringList hrtf_paths
{settings
.value(QStringLiteral("hrtf-paths")).toStringList()};
784 if(hrtf_paths
.size() == 1)
785 hrtf_paths
= hrtf_paths
[0].split(QChar(','));
786 for(QString
&name
: hrtf_paths
)
787 name
= name
.trimmed();
788 if(!hrtf_paths
.empty() && !hrtf_paths
.back().isEmpty())
789 ui
->defaultHrtfPathsCheckBox
->setCheckState(Qt::Unchecked
);
792 hrtf_paths
.removeAll(QString());
793 ui
->defaultHrtfPathsCheckBox
->setCheckState(Qt::Checked
);
795 hrtf_paths
.removeDuplicates();
796 ui
->hrtfFileList
->clear();
797 ui
->hrtfFileList
->addItems(hrtf_paths
);
798 updateHrtfRemoveButton();
800 ui
->preferredHrtfComboBox
->clear();
801 ui
->preferredHrtfComboBox
->addItem(QStringLiteral("- Any -"));
802 if(ui
->defaultHrtfPathsCheckBox
->isChecked())
804 QStringList hrtfs
{collectHrtfs()};
805 Q_FOREACH(const QString
&name
, hrtfs
)
806 ui
->preferredHrtfComboBox
->addItem(name
);
809 QString defaulthrtf
{settings
.value(QStringLiteral("default-hrtf")).toString()};
810 ui
->preferredHrtfComboBox
->setCurrentIndex(0);
811 if(defaulthrtf
.isEmpty() == false)
813 int i
{ui
->preferredHrtfComboBox
->findText(defaulthrtf
)};
815 ui
->preferredHrtfComboBox
->setCurrentIndex(i
);
818 i
= ui
->preferredHrtfComboBox
->count();
819 ui
->preferredHrtfComboBox
->addItem(defaulthrtf
);
820 ui
->preferredHrtfComboBox
->setCurrentIndex(i
);
823 ui
->preferredHrtfComboBox
->adjustSize();
825 ui
->enabledBackendList
->clear();
826 ui
->disabledBackendList
->clear();
827 QStringList drivers
{settings
.value(QStringLiteral("drivers")).toStringList()};
829 ui
->backendCheckBox
->setChecked(true);
832 if(drivers
.size() == 1)
833 drivers
= drivers
[0].split(QChar(','));
834 for(QString
&name
: drivers
)
836 name
= name
.trimmed();
837 /* Convert "mmdevapi" references to "wasapi" for backwards
840 if(name
== QLatin1String
{"-mmdevapi"})
841 name
= QStringLiteral("-wasapi");
842 else if(name
== QLatin1String
{"mmdevapi"})
843 name
= QStringLiteral("wasapi");
846 bool lastWasEmpty
{false};
847 Q_FOREACH(const QString
&backend
, drivers
)
849 lastWasEmpty
= backend
.isEmpty();
850 if(lastWasEmpty
) continue;
852 if(!backend
.startsWith(QChar('-')))
854 for(size_t j
{0};j
< backendList
.size();++j
)
856 if(backend
== std::data(backendList
[j
].backend_name
))
858 ui
->enabledBackendList
->addItem(std::data(backendList
[j
].full_string
));
863 else if(backend
.size() > 1)
865 QStringRef backendref
{backend
.rightRef(backend
.size()-1)};
866 for(size_t j
{0};j
< backendList
.size();++j
)
868 if(backendref
== std::data(backendList
[j
].backend_name
))
870 ui
->disabledBackendList
->addItem(std::data(backendList
[j
].full_string
));
876 ui
->backendCheckBox
->setChecked(lastWasEmpty
);
879 QString defaultreverb
{settings
.value(QStringLiteral("default-reverb")).toString().toLower()};
880 ui
->defaultReverbComboBox
->setCurrentIndex(0);
881 if(defaultreverb
.isEmpty() == false)
883 for(int i
= 0;i
< ui
->defaultReverbComboBox
->count();i
++)
885 if(defaultreverb
.compare(ui
->defaultReverbComboBox
->itemText(i
).toLower()) == 0)
887 ui
->defaultReverbComboBox
->setCurrentIndex(i
);
893 QStringList excludefx
{settings
.value(QStringLiteral("excludefx")).toStringList()};
894 if(excludefx
.size() == 1)
895 excludefx
= excludefx
[0].split(QChar(','));
896 for(QString
&name
: excludefx
)
897 name
= name
.trimmed();
898 ui
->enableEaxReverbCheck
->setChecked(!excludefx
.contains(QStringLiteral("eaxreverb"), Qt::CaseInsensitive
));
899 ui
->enableStdReverbCheck
->setChecked(!excludefx
.contains(QStringLiteral("reverb"), Qt::CaseInsensitive
));
900 ui
->enableAutowahCheck
->setChecked(!excludefx
.contains(QStringLiteral("autowah"), Qt::CaseInsensitive
));
901 ui
->enableChorusCheck
->setChecked(!excludefx
.contains(QStringLiteral("chorus"), Qt::CaseInsensitive
));
902 ui
->enableCompressorCheck
->setChecked(!excludefx
.contains(QStringLiteral("compressor"), Qt::CaseInsensitive
));
903 ui
->enableDistortionCheck
->setChecked(!excludefx
.contains(QStringLiteral("distortion"), Qt::CaseInsensitive
));
904 ui
->enableEchoCheck
->setChecked(!excludefx
.contains(QStringLiteral("echo"), Qt::CaseInsensitive
));
905 ui
->enableEqualizerCheck
->setChecked(!excludefx
.contains(QStringLiteral("equalizer"), Qt::CaseInsensitive
));
906 ui
->enableFlangerCheck
->setChecked(!excludefx
.contains(QStringLiteral("flanger"), Qt::CaseInsensitive
));
907 ui
->enableFrequencyShifterCheck
->setChecked(!excludefx
.contains(QStringLiteral("fshifter"), Qt::CaseInsensitive
));
908 ui
->enableModulatorCheck
->setChecked(!excludefx
.contains(QStringLiteral("modulator"), Qt::CaseInsensitive
));
909 ui
->enableDedicatedCheck
->setChecked(!excludefx
.contains(QStringLiteral("dedicated"), Qt::CaseInsensitive
));
910 ui
->enablePitchShifterCheck
->setChecked(!excludefx
.contains(QStringLiteral("pshifter"), Qt::CaseInsensitive
));
911 ui
->enableVocalMorpherCheck
->setChecked(!excludefx
.contains(QStringLiteral("vmorpher"), Qt::CaseInsensitive
));
912 if(ui
->enableEaxCheck
->isEnabled())
913 ui
->enableEaxCheck
->setChecked(getCheckState(settings
.value(QStringLiteral("eax/enable"))) != Qt::Unchecked
);
915 ui
->pulseAutospawnCheckBox
->setCheckState(getCheckState(settings
.value(QStringLiteral("pulse/spawn-server"))));
916 ui
->pulseAllowMovesCheckBox
->setCheckState(getCheckState(settings
.value(QStringLiteral("pulse/allow-moves"))));
917 ui
->pulseFixRateCheckBox
->setCheckState(getCheckState(settings
.value(QStringLiteral("pulse/fix-rate"))));
918 ui
->pulseAdjLatencyCheckBox
->setCheckState(getCheckState(settings
.value(QStringLiteral("pulse/adjust-latency"))));
920 ui
->pwireAssumeAudioCheckBox
->setCheckState(getCheckState(settings
.value(QStringLiteral("pipewire/assume-audio"))));
921 ui
->pwireRtMixCheckBox
->setCheckState(getCheckState(settings
.value(QStringLiteral("pipewire/rt-mix"))));
923 ui
->wasapiResamplerCheckBox
->setCheckState(getCheckState(settings
.value(QStringLiteral("wasapi/allow-resampler"))));
925 ui
->jackAutospawnCheckBox
->setCheckState(getCheckState(settings
.value(QStringLiteral("jack/spawn-server"))));
926 ui
->jackConnectPortsCheckBox
->setCheckState(getCheckState(settings
.value(QStringLiteral("jack/connect-ports"))));
927 ui
->jackRtMixCheckBox
->setCheckState(getCheckState(settings
.value(QStringLiteral("jack/rt-mix"))));
928 ui
->jackBufferSizeLine
->setText(settings
.value(QStringLiteral("jack/buffer-size"), QString()).toString());
929 updateJackBufferSizeSlider();
931 ui
->alsaDefaultDeviceLine
->setText(settings
.value(QStringLiteral("alsa/device"), QString()).toString());
932 ui
->alsaDefaultCaptureLine
->setText(settings
.value(QStringLiteral("alsa/capture"), QString()).toString());
933 ui
->alsaResamplerCheckBox
->setCheckState(getCheckState(settings
.value(QStringLiteral("alsa/allow-resampler"))));
934 ui
->alsaMmapCheckBox
->setCheckState(getCheckState(settings
.value(QStringLiteral("alsa/mmap"))));
936 ui
->ossDefaultDeviceLine
->setText(settings
.value(QStringLiteral("oss/device"), QString()).toString());
937 ui
->ossDefaultCaptureLine
->setText(settings
.value(QStringLiteral("oss/capture"), QString()).toString());
939 ui
->solarisDefaultDeviceLine
->setText(settings
.value(QStringLiteral("solaris/device"), QString()).toString());
941 ui
->waveOutputLine
->setText(settings
.value(QStringLiteral("wave/file"), QString()).toString());
942 ui
->waveBFormatCheckBox
->setChecked(settings
.value(QStringLiteral("wave/bformat"), false).toBool());
944 ui
->applyButton
->setEnabled(false);
945 ui
->closeCancelButton
->setText(tr("Close"));
949 void MainWindow::saveCurrentConfig()
951 saveConfig(getDefaultConfigName());
952 ui
->applyButton
->setEnabled(false);
953 ui
->closeCancelButton
->setText(tr("Close"));
955 QMessageBox::information(this, tr("Information"),
956 tr("Applications using OpenAL need to be restarted for changes to take effect."));
959 void MainWindow::saveConfigAsFile()
961 QString fname
{QFileDialog::getOpenFileName(this, tr("Select Files"))};
962 if(fname
.isEmpty() == false)
965 ui
->applyButton
->setEnabled(false);
970 void MainWindow::saveConfig(const QString
&fname
) const
972 QSettings settings
{fname
, QSettings::IniFormat
};
974 /* HACK: Compound any stringlist values into a comma-separated string. */
975 QStringList allkeys
{settings
.allKeys()};
976 Q_FOREACH(const QString
&key
, allkeys
)
978 QStringList vals
{settings
.value(key
).toStringList()};
980 settings
.setValue(key
, vals
.join(QChar(',')));
983 settings
.setValue(QStringLiteral("sample-type"), getValueFromName(sampleTypeList
, ui
->sampleFormatCombo
->currentText()));
984 settings
.setValue(QStringLiteral("channels"), getValueFromName(speakerModeList
, ui
->channelConfigCombo
->currentText()));
986 uint rate
{ui
->sampleRateCombo
->currentText().toUInt()};
988 settings
.setValue(QStringLiteral("frequency"), QString
{});
990 settings
.setValue(QStringLiteral("frequency"), rate
);
992 settings
.setValue(QStringLiteral("period_size"), ui
->periodSizeEdit
->text());
993 settings
.setValue(QStringLiteral("periods"), ui
->periodCountEdit
->text());
995 settings
.setValue(QStringLiteral("sources"), ui
->srcCountLineEdit
->text());
996 settings
.setValue(QStringLiteral("slots"), ui
->effectSlotLineEdit
->text());
998 settings
.setValue(QStringLiteral("resampler"), std::data(resamplerList
[ui
->resamplerSlider
->value()].value
));
1000 settings
.setValue(QStringLiteral("stereo-mode"), getValueFromName(stereoModeList
, ui
->stereoModeCombo
->currentText()));
1001 settings
.setValue(QStringLiteral("stereo-encoding"), getValueFromName(stereoEncList
, ui
->stereoEncodingComboBox
->currentText()));
1002 settings
.setValue(QStringLiteral("ambi-format"), getValueFromName(ambiFormatList
, ui
->ambiFormatComboBox
->currentText()));
1004 settings
.setValue(QStringLiteral("output-limiter"), getCheckValue(ui
->outputLimiterCheckBox
));
1005 settings
.setValue(QStringLiteral("dither"), getCheckValue(ui
->outputDitherCheckBox
));
1007 settings
.setValue(QStringLiteral("decoder/hq-mode"), getCheckValue(ui
->decoderHQModeCheckBox
));
1008 settings
.setValue(QStringLiteral("decoder/distance-comp"), getCheckValue(ui
->decoderDistCompCheckBox
));
1009 settings
.setValue(QStringLiteral("decoder/nfc"), getCheckValue(ui
->decoderNFEffectsCheckBox
));
1010 double speakerdist
{ui
->decoderSpeakerDistSpinBox
->value()};
1011 settings
.setValue(QStringLiteral("decoder/speaker-dist"),
1012 (speakerdist
!= 1.0) ? QString::number(speakerdist
) : QString
{}
1015 settings
.setValue(QStringLiteral("decoder/quad"), ui
->decoderQuadLineEdit
->text());
1016 settings
.setValue(QStringLiteral("decoder/surround51"), ui
->decoder51LineEdit
->text());
1017 settings
.setValue(QStringLiteral("decoder/surround61"), ui
->decoder61LineEdit
->text());
1018 settings
.setValue(QStringLiteral("decoder/surround71"), ui
->decoder71LineEdit
->text());
1019 settings
.setValue(QStringLiteral("decoder/surround3d71"), ui
->decoder3D71LineEdit
->text());
1021 QStringList strlist
;
1022 if(!ui
->enableSSECheckBox
->isChecked())
1023 strlist
.append(QStringLiteral("sse"));
1024 if(!ui
->enableSSE2CheckBox
->isChecked())
1025 strlist
.append(QStringLiteral("sse2"));
1026 if(!ui
->enableSSE3CheckBox
->isChecked())
1027 strlist
.append(QStringLiteral("sse3"));
1028 if(!ui
->enableSSE41CheckBox
->isChecked())
1029 strlist
.append(QStringLiteral("sse4.1"));
1030 if(!ui
->enableNeonCheckBox
->isChecked())
1031 strlist
.append(QStringLiteral("neon"));
1032 settings
.setValue(QStringLiteral("disable-cpu-exts"), strlist
.join(QChar(',')));
1034 settings
.setValue(QStringLiteral("hrtf-mode"), std::data(hrtfModeList
[ui
->hrtfmodeSlider
->value()].value
));
1036 if(ui
->preferredHrtfComboBox
->currentIndex() == 0)
1037 settings
.setValue(QStringLiteral("default-hrtf"), QString
{});
1040 QString str
{ui
->preferredHrtfComboBox
->currentText()};
1041 settings
.setValue(QStringLiteral("default-hrtf"), str
);
1045 strlist
.reserve(ui
->hrtfFileList
->count());
1046 for(int i
= 0;i
< ui
->hrtfFileList
->count();i
++)
1047 strlist
.append(ui
->hrtfFileList
->item(i
)->text());
1048 if(!strlist
.empty() && ui
->defaultHrtfPathsCheckBox
->isChecked())
1049 strlist
.append(QString
{});
1050 settings
.setValue(QStringLiteral("hrtf-paths"), strlist
.join(QChar
{','}));
1053 for(int i
= 0;i
< ui
->enabledBackendList
->count();i
++)
1055 QString label
{ui
->enabledBackendList
->item(i
)->text()};
1056 for(size_t j
{0};j
< backendList
.size();++j
)
1058 if(label
== std::data(backendList
[j
].full_string
))
1060 strlist
.append(std::data(backendList
[j
].backend_name
));
1065 for(int i
= 0;i
< ui
->disabledBackendList
->count();i
++)
1067 QString label
{ui
->disabledBackendList
->item(i
)->text()};
1068 for(size_t j
{0};j
< backendList
.size();++j
)
1070 if(label
== std::data(backendList
[j
].full_string
))
1072 strlist
.append(QChar
{'-'}+QString
{std::data(backendList
[j
].backend_name
)});
1077 if(strlist
.empty() && !ui
->backendCheckBox
->isChecked())
1078 strlist
.append(QStringLiteral("-all"));
1079 else if(ui
->backendCheckBox
->isChecked())
1080 strlist
.append(QString
{});
1081 settings
.setValue(QStringLiteral("drivers"), strlist
.join(QChar(',')));
1083 // TODO: Remove check when we can properly match global values.
1084 if(ui
->defaultReverbComboBox
->currentIndex() == 0)
1085 settings
.setValue(QStringLiteral("default-reverb"), QString
{});
1088 QString str
{ui
->defaultReverbComboBox
->currentText().toLower()};
1089 settings
.setValue(QStringLiteral("default-reverb"), str
);
1093 if(!ui
->enableEaxReverbCheck
->isChecked())
1094 strlist
.append(QStringLiteral("eaxreverb"));
1095 if(!ui
->enableStdReverbCheck
->isChecked())
1096 strlist
.append(QStringLiteral("reverb"));
1097 if(!ui
->enableAutowahCheck
->isChecked())
1098 strlist
.append(QStringLiteral("autowah"));
1099 if(!ui
->enableChorusCheck
->isChecked())
1100 strlist
.append(QStringLiteral("chorus"));
1101 if(!ui
->enableDistortionCheck
->isChecked())
1102 strlist
.append(QStringLiteral("distortion"));
1103 if(!ui
->enableCompressorCheck
->isChecked())
1104 strlist
.append(QStringLiteral("compressor"));
1105 if(!ui
->enableEchoCheck
->isChecked())
1106 strlist
.append(QStringLiteral("echo"));
1107 if(!ui
->enableEqualizerCheck
->isChecked())
1108 strlist
.append(QStringLiteral("equalizer"));
1109 if(!ui
->enableFlangerCheck
->isChecked())
1110 strlist
.append(QStringLiteral("flanger"));
1111 if(!ui
->enableFrequencyShifterCheck
->isChecked())
1112 strlist
.append(QStringLiteral("fshifter"));
1113 if(!ui
->enableModulatorCheck
->isChecked())
1114 strlist
.append(QStringLiteral("modulator"));
1115 if(!ui
->enableDedicatedCheck
->isChecked())
1116 strlist
.append(QStringLiteral("dedicated"));
1117 if(!ui
->enablePitchShifterCheck
->isChecked())
1118 strlist
.append(QStringLiteral("pshifter"));
1119 if(!ui
->enableVocalMorpherCheck
->isChecked())
1120 strlist
.append(QStringLiteral("vmorpher"));
1121 settings
.setValue(QStringLiteral("excludefx"), strlist
.join(QChar
{','}));
1122 settings
.setValue(QStringLiteral("eax/enable"),
1123 (!ui
->enableEaxCheck
->isEnabled() || ui
->enableEaxCheck
->isChecked())
1124 ? QString
{/*"true"*/} : QStringLiteral("false"));
1126 settings
.setValue(QStringLiteral("pipewire/assume-audio"), getCheckValue(ui
->pwireAssumeAudioCheckBox
));
1127 settings
.setValue(QStringLiteral("pipewire/rt-mix"), getCheckValue(ui
->pwireRtMixCheckBox
));
1129 settings
.setValue(QStringLiteral("wasapi/allow-resampler"), getCheckValue(ui
->wasapiResamplerCheckBox
));
1131 settings
.setValue(QStringLiteral("pulse/spawn-server"), getCheckValue(ui
->pulseAutospawnCheckBox
));
1132 settings
.setValue(QStringLiteral("pulse/allow-moves"), getCheckValue(ui
->pulseAllowMovesCheckBox
));
1133 settings
.setValue(QStringLiteral("pulse/fix-rate"), getCheckValue(ui
->pulseFixRateCheckBox
));
1134 settings
.setValue(QStringLiteral("pulse/adjust-latency"), getCheckValue(ui
->pulseAdjLatencyCheckBox
));
1136 settings
.setValue(QStringLiteral("jack/spawn-server"), getCheckValue(ui
->jackAutospawnCheckBox
));
1137 settings
.setValue(QStringLiteral("jack/connect-ports"), getCheckValue(ui
->jackConnectPortsCheckBox
));
1138 settings
.setValue(QStringLiteral("jack/rt-mix"), getCheckValue(ui
->jackRtMixCheckBox
));
1139 settings
.setValue(QStringLiteral("jack/buffer-size"), ui
->jackBufferSizeLine
->text());
1141 settings
.setValue(QStringLiteral("alsa/device"), ui
->alsaDefaultDeviceLine
->text());
1142 settings
.setValue(QStringLiteral("alsa/capture"), ui
->alsaDefaultCaptureLine
->text());
1143 settings
.setValue(QStringLiteral("alsa/allow-resampler"), getCheckValue(ui
->alsaResamplerCheckBox
));
1144 settings
.setValue(QStringLiteral("alsa/mmap"), getCheckValue(ui
->alsaMmapCheckBox
));
1146 settings
.setValue(QStringLiteral("oss/device"), ui
->ossDefaultDeviceLine
->text());
1147 settings
.setValue(QStringLiteral("oss/capture"), ui
->ossDefaultCaptureLine
->text());
1149 settings
.setValue(QStringLiteral("solaris/device"), ui
->solarisDefaultDeviceLine
->text());
1151 settings
.setValue(QStringLiteral("wave/file"), ui
->waveOutputLine
->text());
1152 settings
.setValue(QStringLiteral("wave/bformat"),
1153 ui
->waveBFormatCheckBox
->isChecked() ? QStringLiteral("true") : QString
{/*"false"*/}
1156 /* Remove empty keys
1157 * FIXME: Should only remove keys whose value matches the globally-specified value.
1159 allkeys
= settings
.allKeys();
1160 Q_FOREACH(const QString
&key
, allkeys
)
1162 QString str
{settings
.value(key
).toString()};
1164 settings
.remove(key
);
1169 void MainWindow::enableApplyButton()
1172 ui
->applyButton
->setEnabled(true);
1174 ui
->closeCancelButton
->setText(tr("Cancel"));
1178 void MainWindow::updateResamplerLabel(int num
)
1180 ui
->resamplerLabel
->setText(std::data(resamplerList
[num
].name
));
1181 enableApplyButton();
1185 void MainWindow::updatePeriodSizeEdit(int size
)
1187 ui
->periodSizeEdit
->clear();
1189 ui
->periodSizeEdit
->insert(QString::number(size
));
1190 enableApplyButton();
1193 void MainWindow::updatePeriodSizeSlider()
1195 int pos
= ui
->periodSizeEdit
->text().toInt();
1200 ui
->periodSizeSlider
->setSliderPosition(pos
);
1202 enableApplyButton();
1205 void MainWindow::updatePeriodCountEdit(int count
)
1207 ui
->periodCountEdit
->clear();
1209 ui
->periodCountEdit
->insert(QString::number(count
));
1210 enableApplyButton();
1213 void MainWindow::updatePeriodCountSlider()
1215 int pos
= ui
->periodCountEdit
->text().toInt();
1220 ui
->periodCountSlider
->setSliderPosition(pos
);
1221 enableApplyButton();
1225 void MainWindow::selectQuadDecoderFile()
1226 { selectDecoderFile(ui
->decoderQuadLineEdit
, "Select Quadraphonic Decoder");}
1227 void MainWindow::select51DecoderFile()
1228 { selectDecoderFile(ui
->decoder51LineEdit
, "Select 5.1 Surround Decoder");}
1229 void MainWindow::select61DecoderFile()
1230 { selectDecoderFile(ui
->decoder61LineEdit
, "Select 6.1 Surround Decoder");}
1231 void MainWindow::select71DecoderFile()
1232 { selectDecoderFile(ui
->decoder71LineEdit
, "Select 7.1 Surround Decoder");}
1233 void MainWindow::select3D71DecoderFile()
1234 { selectDecoderFile(ui
->decoder3D71LineEdit
, "Select 3D7.1 Surround Decoder");}
1235 void MainWindow::selectDecoderFile(QLineEdit
*line
, const char *caption
)
1237 QString dir
{line
->text()};
1238 if(dir
.isEmpty() || QDir::isRelativePath(dir
))
1240 QStringList paths
{getAllDataPaths("/openal/presets")};
1241 while(!paths
.isEmpty())
1243 if(QDir
{paths
.last()}.exists())
1251 QString fname
{QFileDialog::getOpenFileName(this, tr(caption
),
1252 dir
, tr("AmbDec Files (*.ambdec);;All Files (*.*)"))};
1253 if(!fname
.isEmpty())
1255 line
->setText(fname
);
1256 enableApplyButton();
1261 void MainWindow::updateJackBufferSizeEdit(int size
)
1263 ui
->jackBufferSizeLine
->clear();
1265 ui
->jackBufferSizeLine
->insert(QString::number(1<<size
));
1266 enableApplyButton();
1269 void MainWindow::updateJackBufferSizeSlider()
1271 int value
{ui
->jackBufferSizeLine
->text().toInt()};
1272 auto pos
= static_cast<int>(floor(log2(value
) + 0.5));
1273 ui
->jackBufferSizeSlider
->setSliderPosition(pos
);
1274 enableApplyButton();
1278 void MainWindow::updateHrtfModeLabel(int num
)
1280 ui
->hrtfmodeLabel
->setText(std::data(hrtfModeList
[static_cast<uint
>(num
)].name
));
1281 enableApplyButton();
1285 void MainWindow::addHrtfFile()
1287 QString path
{QFileDialog::getExistingDirectory(this, tr("Select HRTF Path"))};
1288 if(path
.isEmpty() == false && !getAllDataPaths(QStringLiteral("/openal/hrtf")).contains(path
))
1290 ui
->hrtfFileList
->addItem(path
);
1291 enableApplyButton();
1295 void MainWindow::removeHrtfFile()
1297 QList
<gsl::owner
<QListWidgetItem
*>> selected
{ui
->hrtfFileList
->selectedItems()};
1298 if(!selected
.isEmpty())
1300 std::for_each(selected
.begin(), selected
.end(), std::default_delete
<QListWidgetItem
>{});
1301 enableApplyButton();
1305 void MainWindow::updateHrtfRemoveButton()
1307 ui
->hrtfRemoveButton
->setEnabled(!ui
->hrtfFileList
->selectedItems().empty());
1310 void MainWindow::showEnabledBackendMenu(QPoint pt
)
1312 QHash
<QAction
*,QString
> actionMap
;
1314 pt
= ui
->enabledBackendList
->mapToGlobal(pt
);
1317 QAction
*removeAction
{ctxmenu
.addAction(QIcon::fromTheme("list-remove"), "Remove")};
1318 if(ui
->enabledBackendList
->selectedItems().empty())
1319 removeAction
->setEnabled(false);
1320 ctxmenu
.addSeparator();
1321 for(size_t i
{0};i
< backendList
.size();++i
)
1323 QString backend
{std::data(backendList
[i
].full_string
)};
1324 QAction
*action
{ctxmenu
.addAction(QString("Add ")+backend
)};
1325 actionMap
[action
] = backend
;
1326 if(!ui
->enabledBackendList
->findItems(backend
, Qt::MatchFixedString
).empty() ||
1327 !ui
->disabledBackendList
->findItems(backend
, Qt::MatchFixedString
).empty())
1328 action
->setEnabled(false);
1331 QAction
*gotAction
{ctxmenu
.exec(pt
)};
1332 if(gotAction
== removeAction
)
1334 QList
<gsl::owner
<QListWidgetItem
*>> selected
{ui
->enabledBackendList
->selectedItems()};
1335 std::for_each(selected
.begin(), selected
.end(), std::default_delete
<QListWidgetItem
>{});
1336 enableApplyButton();
1338 else if(gotAction
!= nullptr)
1340 auto iter
= actionMap
.constFind(gotAction
);
1341 if(iter
!= actionMap
.cend())
1342 ui
->enabledBackendList
->addItem(iter
.value());
1343 enableApplyButton();
1347 void MainWindow::showDisabledBackendMenu(QPoint pt
)
1349 QHash
<QAction
*,QString
> actionMap
;
1351 pt
= ui
->disabledBackendList
->mapToGlobal(pt
);
1354 QAction
*removeAction
{ctxmenu
.addAction(QIcon::fromTheme("list-remove"), "Remove")};
1355 if(ui
->disabledBackendList
->selectedItems().empty())
1356 removeAction
->setEnabled(false);
1357 ctxmenu
.addSeparator();
1358 for(size_t i
{0};i
< backendList
.size();++i
)
1360 QString backend
{std::data(backendList
[i
].full_string
)};
1361 QAction
*action
{ctxmenu
.addAction(QString("Add ")+backend
)};
1362 actionMap
[action
] = backend
;
1363 if(!ui
->disabledBackendList
->findItems(backend
, Qt::MatchFixedString
).empty() ||
1364 !ui
->enabledBackendList
->findItems(backend
, Qt::MatchFixedString
).empty())
1365 action
->setEnabled(false);
1368 QAction
*gotAction
{ctxmenu
.exec(pt
)};
1369 if(gotAction
== removeAction
)
1371 QList
<gsl::owner
<QListWidgetItem
*>> selected
{ui
->disabledBackendList
->selectedItems()};
1372 std::for_each(selected
.begin(), selected
.end(), std::default_delete
<QListWidgetItem
>{});
1373 enableApplyButton();
1375 else if(gotAction
!= nullptr)
1377 auto iter
= actionMap
.constFind(gotAction
);
1378 if(iter
!= actionMap
.cend())
1379 ui
->disabledBackendList
->addItem(iter
.value());
1380 enableApplyButton();
1384 void MainWindow::selectOSSPlayback()
1386 QString current
{ui
->ossDefaultDeviceLine
->text()};
1387 if(current
.isEmpty()) current
= ui
->ossDefaultDeviceLine
->placeholderText();
1388 QString fname
{QFileDialog::getOpenFileName(this, tr("Select Playback Device"), current
)};
1389 if(!fname
.isEmpty())
1391 ui
->ossDefaultDeviceLine
->setText(fname
);
1392 enableApplyButton();
1396 void MainWindow::selectOSSCapture()
1398 QString current
{ui
->ossDefaultCaptureLine
->text()};
1399 if(current
.isEmpty()) current
= ui
->ossDefaultCaptureLine
->placeholderText();
1400 QString fname
{QFileDialog::getOpenFileName(this, tr("Select Capture Device"), current
)};
1401 if(!fname
.isEmpty())
1403 ui
->ossDefaultCaptureLine
->setText(fname
);
1404 enableApplyButton();
1408 void MainWindow::selectSolarisPlayback()
1410 QString current
{ui
->solarisDefaultDeviceLine
->text()};
1411 if(current
.isEmpty()) current
= ui
->solarisDefaultDeviceLine
->placeholderText();
1412 QString fname
{QFileDialog::getOpenFileName(this, tr("Select Playback Device"), current
)};
1413 if(!fname
.isEmpty())
1415 ui
->solarisDefaultDeviceLine
->setText(fname
);
1416 enableApplyButton();
1420 void MainWindow::selectWaveOutput()
1422 QString fname
{QFileDialog::getSaveFileName(this, tr("Select Wave File Output"),
1423 ui
->waveOutputLine
->text(), tr("Wave Files (*.wav *.amb);;All Files (*.*)"))};
1424 if(!fname
.isEmpty())
1426 ui
->waveOutputLine
->setText(fname
);
1427 enableApplyButton();