4 #include "mainwindow.h"
10 #include <QMessageBox>
11 #include <QCloseEvent>
14 #include "ui_mainwindow.h"
20 char backend_name
[16];
26 #ifdef HAVE_PULSEAUDIO
27 { "pulse", "PulseAudio" },
33 { "core", "CoreAudio" },
39 { "solaris", "Solaris" },
42 { "sndio", "SoundIO" },
48 { "wasapi", "WASAPI" },
51 { "dsound", "DirectSound" },
54 { "winmm", "Windows Multimedia" },
57 { "port", "PortAudio" },
60 { "opensl", "OpenSL" },
63 { "null", "Null Output" },
65 { "wave", "Wave Writer" },
70 static const struct NameValuePair
{
73 } speakerModeList
[] = {
76 { "Stereo", "stereo" },
77 { "Quadraphonic", "quad" },
78 { "5.1 Surround (Side)", "surround51" },
79 { "5.1 Surround (Rear)", "surround51rear" },
80 { "6.1 Surround", "surround61" },
81 { "7.1 Surround", "surround71" },
83 { "Ambisonic, 1st Order", "ambi1" },
84 { "Ambisonic, 2nd Order", "ambi2" },
85 { "Ambisonic, 3rd Order", "ambi3" },
88 }, sampleTypeList
[] = {
90 { "8-bit int", "int8" },
91 { "8-bit uint", "uint8" },
92 { "16-bit int", "int16" },
93 { "16-bit uint", "uint16" },
94 { "32-bit int", "int32" },
95 { "32-bit uint", "uint32" },
96 { "32-bit float", "float32" },
99 }, resamplerList
[] = {
100 { "Point", "point" },
101 { "Linear", "linear" },
102 { "Default (Linear)", "" },
103 { "Cubic Spline", "cubic" },
104 { "11th order Sinc", "bsinc12" },
105 { "23rd order Sinc", "bsinc24" },
108 }, stereoModeList
[] = {
109 { "Autodetect", "" },
110 { "Speakers", "speakers" },
111 { "Headphones", "headphones" },
114 }, stereoEncList
[] = {
116 { "Pan Pot", "panpot" },
120 }, ambiFormatList
[] = {
122 { "AmbiX (ACN, SN3D)", "ambix" },
123 { "ACN, N3D", "acn+n3d" },
124 { "Furse-Malham", "fuma" },
127 }, hrtfModeList
[] = {
128 { "1st Order Ambisonic", "ambi1" },
129 { "2nd Order Ambisonic", "ambi2" },
130 { "3rd Order Ambisonic", "ambi3" },
131 { "Default (Full)", "" },
137 static QString
getDefaultConfigName()
140 static const char fname
[] = "alsoft.ini";
141 QByteArray base
= qgetenv("AppData");
143 static const char fname
[] = "alsoft.conf";
144 QByteArray base
= qgetenv("XDG_CONFIG_HOME");
147 base
= qgetenv("HOME");
148 if(base
.isEmpty() == false)
152 if(base
.isEmpty() == false)
153 return base
+'/'+ fname
;
157 static QString
getBaseDataPath()
160 QByteArray base
= qgetenv("AppData");
162 QByteArray base
= qgetenv("XDG_DATA_HOME");
165 base
= qgetenv("HOME");
167 base
+= "/.local/share";
173 static QStringList
getAllDataPaths(const QString
&append
)
176 list
.append(getBaseDataPath());
178 // TODO: Common AppData path
180 QString paths
= qgetenv("XDG_DATA_DIRS");
182 paths
= "/usr/local/share/:/usr/share/";
183 list
+= paths
.split(QChar(':'), QString::SkipEmptyParts
);
185 QStringList::iterator iter
= list
.begin();
186 while(iter
!= list
.end())
189 iter
= list
.erase(iter
);
192 iter
->append(append
);
200 static QString
getValueFromName(const NameValuePair (&list
)[N
], const QString
&str
)
202 for(size_t i
= 0;i
< N
-1;i
++)
204 if(str
== list
[i
].name
)
205 return list
[i
].value
;
211 static QString
getNameFromValue(const NameValuePair (&list
)[N
], const QString
&str
)
213 for(size_t i
= 0;i
< N
-1;i
++)
215 if(str
== list
[i
].value
)
222 Qt::CheckState
getCheckState(const QVariant
&var
)
225 return Qt::PartiallyChecked
;
228 return Qt::Unchecked
;
231 QString
getCheckValue(const QCheckBox
*checkbox
)
233 const Qt::CheckState state
{checkbox
->checkState()};
234 if(state
== Qt::Checked
)
235 return QString
{"true"};
236 if(state
== Qt::Unchecked
)
237 return QString
{"false"};
243 MainWindow::MainWindow(QWidget
*parent
) :
245 ui(new Ui::MainWindow
),
246 mPeriodSizeValidator(nullptr),
247 mPeriodCountValidator(nullptr),
248 mSourceCountValidator(nullptr),
249 mEffectSlotValidator(nullptr),
250 mSourceSendValidator(nullptr),
251 mSampleRateValidator(nullptr),
252 mJackBufferValidator(nullptr),
257 for(int i
= 0;speakerModeList
[i
].name
[0];i
++)
258 ui
->channelConfigCombo
->addItem(speakerModeList
[i
].name
);
259 ui
->channelConfigCombo
->adjustSize();
260 for(int i
= 0;sampleTypeList
[i
].name
[0];i
++)
261 ui
->sampleFormatCombo
->addItem(sampleTypeList
[i
].name
);
262 ui
->sampleFormatCombo
->adjustSize();
263 for(int i
= 0;stereoModeList
[i
].name
[0];i
++)
264 ui
->stereoModeCombo
->addItem(stereoModeList
[i
].name
);
265 ui
->stereoModeCombo
->adjustSize();
266 for(int i
= 0;stereoEncList
[i
].name
[0];i
++)
267 ui
->stereoEncodingComboBox
->addItem(stereoEncList
[i
].name
);
268 ui
->stereoEncodingComboBox
->adjustSize();
269 for(int i
= 0;ambiFormatList
[i
].name
[0];i
++)
270 ui
->ambiFormatComboBox
->addItem(ambiFormatList
[i
].name
);
271 ui
->ambiFormatComboBox
->adjustSize();
274 for(count
= 0;resamplerList
[count
].name
[0];count
++) {
276 ui
->resamplerSlider
->setRange(0, count
-1);
278 for(count
= 0;hrtfModeList
[count
].name
[0];count
++) {
280 ui
->hrtfmodeSlider
->setRange(0, count
-1);
281 ui
->hrtfStateComboBox
->adjustSize();
283 #if !defined(HAVE_NEON) && !defined(HAVE_SSE)
284 ui
->cpuExtDisabledLabel
->move(ui
->cpuExtDisabledLabel
->x(), ui
->cpuExtDisabledLabel
->y() - 60);
286 ui
->cpuExtDisabledLabel
->setVisible(false);
295 ui
->enableSSECheckBox
->setVisible(false);
297 ui
->enableSSE2CheckBox
->setVisible(false);
299 ui
->enableSSE3CheckBox
->setVisible(false);
301 ui
->enableSSE41CheckBox
->setVisible(false);
303 ui
->enableNeonCheckBox
->setVisible(false);
311 ui
->enableNeonCheckBox
->move(ui
->enableNeonCheckBox
->x(), ui
->enableNeonCheckBox
->y() - 30);
312 ui
->enableSSECheckBox
->setVisible(false);
314 ui
->enableSSE2CheckBox
->setVisible(false);
316 ui
->enableSSE3CheckBox
->setVisible(false);
318 ui
->enableSSE41CheckBox
->setVisible(false);
323 mPeriodSizeValidator
= new QIntValidator
{64, 8192, this};
324 ui
->periodSizeEdit
->setValidator(mPeriodSizeValidator
);
325 mPeriodCountValidator
= new QIntValidator
{2, 16, this};
326 ui
->periodCountEdit
->setValidator(mPeriodCountValidator
);
328 mSourceCountValidator
= new QIntValidator
{0, 4096, this};
329 ui
->srcCountLineEdit
->setValidator(mSourceCountValidator
);
330 mEffectSlotValidator
= new QIntValidator
{0, 64, this};
331 ui
->effectSlotLineEdit
->setValidator(mEffectSlotValidator
);
332 mSourceSendValidator
= new QIntValidator
{0, 16, this};
333 ui
->srcSendLineEdit
->setValidator(mSourceSendValidator
);
334 mSampleRateValidator
= new QIntValidator
{8000, 192000, this};
335 ui
->sampleRateCombo
->lineEdit()->setValidator(mSampleRateValidator
);
337 mJackBufferValidator
= new QIntValidator
{0, 8192, this};
338 ui
->jackBufferSizeLine
->setValidator(mJackBufferValidator
);
340 connect(ui
->actionLoad
, &QAction::triggered
, this, &MainWindow::loadConfigFromFile
);
341 connect(ui
->actionSave_As
, &QAction::triggered
, this, &MainWindow::saveConfigAsFile
);
343 connect(ui
->actionAbout
, &QAction::triggered
, this, &MainWindow::showAboutPage
);
345 connect(ui
->closeCancelButton
, &QPushButton::clicked
, this, &MainWindow::cancelCloseAction
);
346 connect(ui
->applyButton
, &QPushButton::clicked
, this, &MainWindow::saveCurrentConfig
);
348 auto qcb_cicstr
= static_cast<void(QComboBox::*)(const QString
&)>(&QComboBox::currentIndexChanged
);
349 connect(ui
->channelConfigCombo
, qcb_cicstr
, this, &MainWindow::enableApplyButton
);
350 connect(ui
->sampleFormatCombo
, qcb_cicstr
, this, &MainWindow::enableApplyButton
);
351 connect(ui
->stereoModeCombo
, qcb_cicstr
, this, &MainWindow::enableApplyButton
);
352 connect(ui
->sampleRateCombo
, qcb_cicstr
, this, &MainWindow::enableApplyButton
);
353 connect(ui
->sampleRateCombo
, &QComboBox::editTextChanged
, this, &MainWindow::enableApplyButton
);
355 connect(ui
->resamplerSlider
, &QSlider::valueChanged
, this, &MainWindow::updateResamplerLabel
);
357 connect(ui
->periodSizeSlider
, &QSlider::valueChanged
, this, &MainWindow::updatePeriodSizeEdit
);
358 connect(ui
->periodSizeEdit
, &QLineEdit::editingFinished
, this, &MainWindow::updatePeriodSizeSlider
);
359 connect(ui
->periodCountSlider
, &QSlider::valueChanged
, this, &MainWindow::updatePeriodCountEdit
);
360 connect(ui
->periodCountEdit
, &QLineEdit::editingFinished
, this, &MainWindow::updatePeriodCountSlider
);
362 connect(ui
->stereoEncodingComboBox
, qcb_cicstr
, this, &MainWindow::enableApplyButton
);
363 connect(ui
->ambiFormatComboBox
, qcb_cicstr
, this, &MainWindow::enableApplyButton
);
364 connect(ui
->outputLimiterCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
365 connect(ui
->outputDitherCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
367 connect(ui
->decoderHQModeCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
368 connect(ui
->decoderDistCompCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
369 connect(ui
->decoderNFEffectsCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
370 auto qdsb_vcd
= static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged
);
371 connect(ui
->decoderNFRefDelaySpinBox
, qdsb_vcd
, this, &MainWindow::enableApplyButton
);
372 connect(ui
->decoderQuadLineEdit
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
373 connect(ui
->decoderQuadButton
, &QPushButton::clicked
, this, &MainWindow::selectQuadDecoderFile
);
374 connect(ui
->decoder51LineEdit
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
375 connect(ui
->decoder51Button
, &QPushButton::clicked
, this, &MainWindow::select51DecoderFile
);
376 connect(ui
->decoder61LineEdit
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
377 connect(ui
->decoder61Button
, &QPushButton::clicked
, this, &MainWindow::select61DecoderFile
);
378 connect(ui
->decoder71LineEdit
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
379 connect(ui
->decoder71Button
, &QPushButton::clicked
, this, &MainWindow::select71DecoderFile
);
381 connect(ui
->preferredHrtfComboBox
, qcb_cicstr
, this, &MainWindow::enableApplyButton
);
382 connect(ui
->hrtfStateComboBox
, qcb_cicstr
, this, &MainWindow::enableApplyButton
);
383 connect(ui
->hrtfmodeSlider
, &QSlider::valueChanged
, this, &MainWindow::updateHrtfModeLabel
);
385 connect(ui
->hrtfAddButton
, &QPushButton::clicked
, this, &MainWindow::addHrtfFile
);
386 connect(ui
->hrtfRemoveButton
, &QPushButton::clicked
, this, &MainWindow::removeHrtfFile
);
387 connect(ui
->hrtfFileList
, &QListWidget::itemSelectionChanged
, this, &MainWindow::updateHrtfRemoveButton
);
388 connect(ui
->defaultHrtfPathsCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
390 connect(ui
->srcCountLineEdit
, &QLineEdit::editingFinished
, this, &MainWindow::enableApplyButton
);
391 connect(ui
->srcSendLineEdit
, &QLineEdit::editingFinished
, this, &MainWindow::enableApplyButton
);
392 connect(ui
->effectSlotLineEdit
, &QLineEdit::editingFinished
, this, &MainWindow::enableApplyButton
);
394 connect(ui
->enableSSECheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
395 connect(ui
->enableSSE2CheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
396 connect(ui
->enableSSE3CheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
397 connect(ui
->enableSSE41CheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
398 connect(ui
->enableNeonCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
400 ui
->enabledBackendList
->setContextMenuPolicy(Qt::CustomContextMenu
);
401 connect(ui
->enabledBackendList
, &QListWidget::customContextMenuRequested
, this, &MainWindow::showEnabledBackendMenu
);
403 ui
->disabledBackendList
->setContextMenuPolicy(Qt::CustomContextMenu
);
404 connect(ui
->disabledBackendList
, &QListWidget::customContextMenuRequested
, this, &MainWindow::showDisabledBackendMenu
);
405 connect(ui
->backendCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
407 connect(ui
->defaultReverbComboBox
, qcb_cicstr
, this, &MainWindow::enableApplyButton
);
408 connect(ui
->enableEaxReverbCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
409 connect(ui
->enableStdReverbCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
410 connect(ui
->enableAutowahCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
411 connect(ui
->enableChorusCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
412 connect(ui
->enableCompressorCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
413 connect(ui
->enableDistortionCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
414 connect(ui
->enableEchoCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
415 connect(ui
->enableEqualizerCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
416 connect(ui
->enableFlangerCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
417 connect(ui
->enableFrequencyShifterCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
418 connect(ui
->enableModulatorCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
419 connect(ui
->enableDedicatedCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
420 connect(ui
->enablePitchShifterCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
421 connect(ui
->enableVocalMorpherCheck
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
423 connect(ui
->pulseAutospawnCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
424 connect(ui
->pulseAllowMovesCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
425 connect(ui
->pulseFixRateCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
426 connect(ui
->pulseAdjLatencyCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
428 connect(ui
->jackAutospawnCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
429 connect(ui
->jackBufferSizeSlider
, &QSlider::valueChanged
, this, &MainWindow::updateJackBufferSizeEdit
);
430 connect(ui
->jackBufferSizeLine
, &QLineEdit::editingFinished
, this, &MainWindow::updateJackBufferSizeSlider
);
432 connect(ui
->alsaDefaultDeviceLine
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
433 connect(ui
->alsaDefaultCaptureLine
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
434 connect(ui
->alsaResamplerCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
435 connect(ui
->alsaMmapCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
437 connect(ui
->ossDefaultDeviceLine
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
438 connect(ui
->ossPlaybackPushButton
, &QPushButton::clicked
, this, &MainWindow::selectOSSPlayback
);
439 connect(ui
->ossDefaultCaptureLine
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
440 connect(ui
->ossCapturePushButton
, &QPushButton::clicked
, this, &MainWindow::selectOSSCapture
);
442 connect(ui
->solarisDefaultDeviceLine
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
443 connect(ui
->solarisPlaybackPushButton
, &QPushButton::clicked
, this, &MainWindow::selectSolarisPlayback
);
445 connect(ui
->waveOutputLine
, &QLineEdit::textChanged
, this, &MainWindow::enableApplyButton
);
446 connect(ui
->waveOutputButton
, &QPushButton::clicked
, this, &MainWindow::selectWaveOutput
);
447 connect(ui
->waveBFormatCheckBox
, &QCheckBox::stateChanged
, this, &MainWindow::enableApplyButton
);
449 ui
->backendListWidget
->setCurrentRow(0);
450 ui
->tabWidget
->setCurrentIndex(0);
452 for(int i
= 1;i
< ui
->backendListWidget
->count();i
++)
453 ui
->backendListWidget
->setRowHidden(i
, true);
454 for(int i
= 0;backendList
[i
].backend_name
[0];i
++)
456 QList
<QListWidgetItem
*> items
= ui
->backendListWidget
->findItems(
457 backendList
[i
].full_string
, Qt::MatchFixedString
459 foreach(const QListWidgetItem
*item
, items
)
460 ui
->backendListWidget
->setItemHidden(item
, false);
463 loadConfig(getDefaultConfigName());
466 MainWindow::~MainWindow()
469 delete mPeriodSizeValidator
;
470 delete mPeriodCountValidator
;
471 delete mSourceCountValidator
;
472 delete mEffectSlotValidator
;
473 delete mSourceSendValidator
;
474 delete mSampleRateValidator
;
475 delete mJackBufferValidator
;
478 void MainWindow::closeEvent(QCloseEvent
*event
)
484 QMessageBox::StandardButton btn
= QMessageBox::warning(this,
485 tr("Apply changes?"), tr("Save changes before quitting?"),
486 QMessageBox::Save
| QMessageBox::No
| QMessageBox::Cancel
);
487 if(btn
== QMessageBox::Save
)
489 if(btn
== QMessageBox::Cancel
)
496 void MainWindow::cancelCloseAction()
503 void MainWindow::showAboutPage()
505 QMessageBox::information(this, tr("About"),
506 tr("OpenAL Soft Configuration Utility.\nBuilt for OpenAL Soft library version ") +
511 QStringList
MainWindow::collectHrtfs()
514 QStringList processed
;
516 for(int i
= 0;i
< ui
->hrtfFileList
->count();i
++)
518 QDir
dir(ui
->hrtfFileList
->item(i
)->text());
519 QStringList fnames
= dir
.entryList(QDir::Files
| QDir::Readable
, QDir::Name
);
520 foreach(const QString
&fname
, fnames
)
522 if(!fname
.endsWith(".mhr", Qt::CaseInsensitive
))
524 QString fullname
{dir
.absoluteFilePath(fname
)};
525 if(processed
.contains(fullname
))
527 processed
.push_back(fullname
);
529 QString name
{fname
.left(fname
.length()-4)};
530 if(!ret
.contains(name
))
536 QString s
= name
+" #"+QString::number(i
);
548 if(ui
->defaultHrtfPathsCheckBox
->isChecked())
550 QStringList paths
= getAllDataPaths("/openal/hrtf");
551 foreach(const QString
&name
, paths
)
554 QStringList fnames
{dir
.entryList(QDir::Files
| QDir::Readable
, QDir::Name
)};
555 foreach(const QString
&fname
, fnames
)
557 if(!fname
.endsWith(".mhr", Qt::CaseInsensitive
))
559 QString fullname
{dir
.absoluteFilePath(fname
)};
560 if(processed
.contains(fullname
))
562 processed
.push_back(fullname
);
564 QString name
{fname
.left(fname
.length()-4)};
565 if(!ret
.contains(name
))
571 QString s
{name
+" #"+QString::number(i
)};
583 #ifdef ALSOFT_EMBED_HRTF_DATA
584 ret
.push_back("Built-In 44100hz");
585 ret
.push_back("Built-In 48000hz");
592 void MainWindow::loadConfigFromFile()
594 QString fname
= QFileDialog::getOpenFileName(this, tr("Select Files"));
595 if(fname
.isEmpty() == false)
599 void MainWindow::loadConfig(const QString
&fname
)
601 QSettings settings
{fname
, QSettings::IniFormat
};
603 QString sampletype
= settings
.value("sample-type").toString();
604 ui
->sampleFormatCombo
->setCurrentIndex(0);
605 if(sampletype
.isEmpty() == false)
607 QString str
{getNameFromValue(sampleTypeList
, sampletype
)};
610 const int j
{ui
->sampleFormatCombo
->findText(str
)};
611 if(j
> 0) ui
->sampleFormatCombo
->setCurrentIndex(j
);
615 QString channelconfig
{settings
.value("channels").toString()};
616 ui
->channelConfigCombo
->setCurrentIndex(0);
617 if(channelconfig
.isEmpty() == false)
619 QString str
{getNameFromValue(speakerModeList
, channelconfig
)};
622 const int j
{ui
->channelConfigCombo
->findText(str
)};
623 if(j
> 0) ui
->channelConfigCombo
->setCurrentIndex(j
);
627 QString srate
{settings
.value("frequency").toString()};
629 ui
->sampleRateCombo
->setCurrentIndex(0);
632 ui
->sampleRateCombo
->lineEdit()->clear();
633 ui
->sampleRateCombo
->lineEdit()->insert(srate
);
636 ui
->srcCountLineEdit
->clear();
637 ui
->srcCountLineEdit
->insert(settings
.value("sources").toString());
638 ui
->effectSlotLineEdit
->clear();
639 ui
->effectSlotLineEdit
->insert(settings
.value("slots").toString());
640 ui
->srcSendLineEdit
->clear();
641 ui
->srcSendLineEdit
->insert(settings
.value("sends").toString());
643 QString resampler
= settings
.value("resampler").toString().trimmed();
644 ui
->resamplerSlider
->setValue(2);
645 ui
->resamplerLabel
->setText(resamplerList
[2].name
);
646 /* The "sinc4" and "sinc8" resamplers are no longer supported. Use "cubic"
649 if(resampler
== "sinc4" || resampler
== "sinc8")
651 /* The "bsinc" resampler name is an alias for "bsinc12". */
652 else if(resampler
== "bsinc")
653 resampler
= "bsinc12";
654 for(int i
= 0;resamplerList
[i
].name
[0];i
++)
656 if(resampler
== resamplerList
[i
].value
)
658 ui
->resamplerSlider
->setValue(i
);
659 ui
->resamplerLabel
->setText(resamplerList
[i
].name
);
664 QString stereomode
= settings
.value("stereo-mode").toString().trimmed();
665 ui
->stereoModeCombo
->setCurrentIndex(0);
666 if(stereomode
.isEmpty() == false)
668 QString str
{getNameFromValue(stereoModeList
, stereomode
)};
671 const int j
{ui
->stereoModeCombo
->findText(str
)};
672 if(j
> 0) ui
->stereoModeCombo
->setCurrentIndex(j
);
676 int periodsize
{settings
.value("period_size").toInt()};
677 ui
->periodSizeEdit
->clear();
680 ui
->periodSizeEdit
->insert(QString::number(periodsize
));
681 updatePeriodSizeSlider();
684 int periodcount
{settings
.value("periods").toInt()};
685 ui
->periodCountEdit
->clear();
688 ui
->periodCountEdit
->insert(QString::number(periodcount
));
689 updatePeriodCountSlider();
692 ui
->outputLimiterCheckBox
->setCheckState(getCheckState(settings
.value("output-limiter")));
693 ui
->outputDitherCheckBox
->setCheckState(getCheckState(settings
.value("dither")));
695 QString stereopan
{settings
.value("stereo-encoding").toString()};
696 ui
->stereoEncodingComboBox
->setCurrentIndex(0);
697 if(stereopan
.isEmpty() == false)
699 QString str
{getNameFromValue(stereoEncList
, stereopan
)};
702 const int j
{ui
->stereoEncodingComboBox
->findText(str
)};
703 if(j
> 0) ui
->stereoEncodingComboBox
->setCurrentIndex(j
);
707 QString ambiformat
{settings
.value("ambi-format").toString()};
708 ui
->ambiFormatComboBox
->setCurrentIndex(0);
709 if(ambiformat
.isEmpty() == false)
711 QString str
{getNameFromValue(ambiFormatList
, ambiformat
)};
714 const int j
{ui
->ambiFormatComboBox
->findText(str
)};
715 if(j
> 0) ui
->ambiFormatComboBox
->setCurrentIndex(j
);
719 bool hqmode
{settings
.value("decoder/hq-mode", true).toBool()};
720 ui
->decoderHQModeCheckBox
->setChecked(hqmode
);
721 ui
->decoderDistCompCheckBox
->setCheckState(getCheckState(settings
.value("decoder/distance-comp")));
722 ui
->decoderNFEffectsCheckBox
->setCheckState(getCheckState(settings
.value("decoder/nfc")));
723 double refdelay
{settings
.value("decoder/nfc-ref-delay", 0.0).toDouble()};
724 ui
->decoderNFRefDelaySpinBox
->setValue(refdelay
);
726 ui
->decoderQuadLineEdit
->setText(settings
.value("decoder/quad").toString());
727 ui
->decoder51LineEdit
->setText(settings
.value("decoder/surround51").toString());
728 ui
->decoder61LineEdit
->setText(settings
.value("decoder/surround61").toString());
729 ui
->decoder71LineEdit
->setText(settings
.value("decoder/surround71").toString());
731 QStringList disabledCpuExts
{settings
.value("disable-cpu-exts").toStringList()};
732 if(disabledCpuExts
.size() == 1)
733 disabledCpuExts
= disabledCpuExts
[0].split(QChar(','));
734 for(QString
&name
: disabledCpuExts
)
735 name
= name
.trimmed();
736 ui
->enableSSECheckBox
->setChecked(!disabledCpuExts
.contains("sse", Qt::CaseInsensitive
));
737 ui
->enableSSE2CheckBox
->setChecked(!disabledCpuExts
.contains("sse2", Qt::CaseInsensitive
));
738 ui
->enableSSE3CheckBox
->setChecked(!disabledCpuExts
.contains("sse3", Qt::CaseInsensitive
));
739 ui
->enableSSE41CheckBox
->setChecked(!disabledCpuExts
.contains("sse4.1", Qt::CaseInsensitive
));
740 ui
->enableNeonCheckBox
->setChecked(!disabledCpuExts
.contains("neon", Qt::CaseInsensitive
));
742 QString hrtfmode
{settings
.value("hrtf-mode").toString().trimmed()};
743 ui
->hrtfmodeSlider
->setValue(3);
744 ui
->hrtfmodeLabel
->setText(hrtfModeList
[3].name
);
745 /* The "basic" mode name is no longer supported. Use "ambi2" instead. */
746 if(hrtfmode
== "basic") hrtfmode
= "ambi2";
747 for(int i
= 0;hrtfModeList
[i
].name
[0];i
++)
749 if(hrtfmode
== hrtfModeList
[i
].value
)
751 ui
->hrtfmodeSlider
->setValue(i
);
752 ui
->hrtfmodeLabel
->setText(hrtfModeList
[i
].name
);
757 QStringList hrtf_paths
{settings
.value("hrtf-paths").toStringList()};
758 if(hrtf_paths
.size() == 1)
759 hrtf_paths
= hrtf_paths
[0].split(QChar(','));
760 for(QString
&name
: hrtf_paths
)
761 name
= name
.trimmed();
762 if(!hrtf_paths
.empty() && !hrtf_paths
.back().isEmpty())
763 ui
->defaultHrtfPathsCheckBox
->setCheckState(Qt::Unchecked
);
766 hrtf_paths
.removeAll(QString());
767 ui
->defaultHrtfPathsCheckBox
->setCheckState(Qt::Checked
);
769 hrtf_paths
.removeDuplicates();
770 ui
->hrtfFileList
->clear();
771 ui
->hrtfFileList
->addItems(hrtf_paths
);
772 updateHrtfRemoveButton();
774 QString hrtfstate
{settings
.value("hrtf").toString().toLower()};
775 if(hrtfstate
== "true")
776 ui
->hrtfStateComboBox
->setCurrentIndex(1);
777 else if(hrtfstate
== "false")
778 ui
->hrtfStateComboBox
->setCurrentIndex(2);
780 ui
->hrtfStateComboBox
->setCurrentIndex(0);
782 ui
->preferredHrtfComboBox
->clear();
783 ui
->preferredHrtfComboBox
->addItem("- Any -");
784 if(ui
->defaultHrtfPathsCheckBox
->isChecked())
786 QStringList hrtfs
{collectHrtfs()};
787 foreach(const QString
&name
, hrtfs
)
788 ui
->preferredHrtfComboBox
->addItem(name
);
791 QString defaulthrtf
{settings
.value("default-hrtf").toString()};
792 ui
->preferredHrtfComboBox
->setCurrentIndex(0);
793 if(defaulthrtf
.isEmpty() == false)
795 int i
{ui
->preferredHrtfComboBox
->findText(defaulthrtf
)};
797 ui
->preferredHrtfComboBox
->setCurrentIndex(i
);
800 i
= ui
->preferredHrtfComboBox
->count();
801 ui
->preferredHrtfComboBox
->addItem(defaulthrtf
);
802 ui
->preferredHrtfComboBox
->setCurrentIndex(i
);
805 ui
->preferredHrtfComboBox
->adjustSize();
807 ui
->enabledBackendList
->clear();
808 ui
->disabledBackendList
->clear();
809 QStringList drivers
{settings
.value("drivers").toStringList()};
810 if(drivers
.size() == 0)
811 ui
->backendCheckBox
->setChecked(true);
814 if(drivers
.size() == 1)
815 drivers
= drivers
[0].split(QChar(','));
816 for(QString
&name
: drivers
)
818 name
= name
.trimmed();
819 /* Convert "mmdevapi" references to "wasapi" for backwards
822 if(name
== "-mmdevapi")
824 else if(name
== "mmdevapi")
828 bool lastWasEmpty
= false;
829 foreach(const QString
&backend
, drivers
)
831 lastWasEmpty
= backend
.isEmpty();
832 if(lastWasEmpty
) continue;
834 if(!backend
.startsWith(QChar('-')))
835 for(int j
= 0;backendList
[j
].backend_name
[0];j
++)
837 if(backend
== backendList
[j
].backend_name
)
839 ui
->enabledBackendList
->addItem(backendList
[j
].full_string
);
843 else if(backend
.size() > 1)
845 QStringRef backendref
{backend
.rightRef(backend
.size()-1)};
846 for(int j
= 0;backendList
[j
].backend_name
[0];j
++)
848 if(backendref
== backendList
[j
].backend_name
)
850 ui
->disabledBackendList
->addItem(backendList
[j
].full_string
);
856 ui
->backendCheckBox
->setChecked(lastWasEmpty
);
859 QString defaultreverb
{settings
.value("default-reverb").toString().toLower()};
860 ui
->defaultReverbComboBox
->setCurrentIndex(0);
861 if(defaultreverb
.isEmpty() == false)
863 for(int i
= 0;i
< ui
->defaultReverbComboBox
->count();i
++)
865 if(defaultreverb
.compare(ui
->defaultReverbComboBox
->itemText(i
).toLower()) == 0)
867 ui
->defaultReverbComboBox
->setCurrentIndex(i
);
873 QStringList excludefx
{settings
.value("excludefx").toStringList()};
874 if(excludefx
.size() == 1)
875 excludefx
= excludefx
[0].split(QChar(','));
876 for(QString
&name
: excludefx
)
877 name
= name
.trimmed();
878 ui
->enableEaxReverbCheck
->setChecked(!excludefx
.contains("eaxreverb", Qt::CaseInsensitive
));
879 ui
->enableStdReverbCheck
->setChecked(!excludefx
.contains("reverb", Qt::CaseInsensitive
));
880 ui
->enableAutowahCheck
->setChecked(!excludefx
.contains("autowah", Qt::CaseInsensitive
));
881 ui
->enableChorusCheck
->setChecked(!excludefx
.contains("chorus", Qt::CaseInsensitive
));
882 ui
->enableCompressorCheck
->setChecked(!excludefx
.contains("compressor", Qt::CaseInsensitive
));
883 ui
->enableDistortionCheck
->setChecked(!excludefx
.contains("distortion", Qt::CaseInsensitive
));
884 ui
->enableEchoCheck
->setChecked(!excludefx
.contains("echo", Qt::CaseInsensitive
));
885 ui
->enableEqualizerCheck
->setChecked(!excludefx
.contains("equalizer", Qt::CaseInsensitive
));
886 ui
->enableFlangerCheck
->setChecked(!excludefx
.contains("flanger", Qt::CaseInsensitive
));
887 ui
->enableFrequencyShifterCheck
->setChecked(!excludefx
.contains("fshifter", Qt::CaseInsensitive
));
888 ui
->enableModulatorCheck
->setChecked(!excludefx
.contains("modulator", Qt::CaseInsensitive
));
889 ui
->enableDedicatedCheck
->setChecked(!excludefx
.contains("dedicated", Qt::CaseInsensitive
));
890 ui
->enablePitchShifterCheck
->setChecked(!excludefx
.contains("pshifter", Qt::CaseInsensitive
));
891 ui
->enableVocalMorpherCheck
->setChecked(!excludefx
.contains("vmorpher", Qt::CaseInsensitive
));
893 ui
->pulseAutospawnCheckBox
->setCheckState(getCheckState(settings
.value("pulse/spawn-server")));
894 ui
->pulseAllowMovesCheckBox
->setCheckState(getCheckState(settings
.value("pulse/allow-moves")));
895 ui
->pulseFixRateCheckBox
->setCheckState(getCheckState(settings
.value("pulse/fix-rate")));
896 ui
->pulseAdjLatencyCheckBox
->setCheckState(getCheckState(settings
.value("pulse/adjust-latency")));
898 ui
->jackAutospawnCheckBox
->setCheckState(getCheckState(settings
.value("jack/spawn-server")));
899 ui
->jackBufferSizeLine
->setText(settings
.value("jack/buffer-size", QString()).toString());
900 updateJackBufferSizeSlider();
902 ui
->alsaDefaultDeviceLine
->setText(settings
.value("alsa/device", QString()).toString());
903 ui
->alsaDefaultCaptureLine
->setText(settings
.value("alsa/capture", QString()).toString());
904 ui
->alsaResamplerCheckBox
->setCheckState(getCheckState(settings
.value("alsa/allow-resampler")));
905 ui
->alsaMmapCheckBox
->setCheckState(getCheckState(settings
.value("alsa/mmap")));
907 ui
->ossDefaultDeviceLine
->setText(settings
.value("oss/device", QString()).toString());
908 ui
->ossDefaultCaptureLine
->setText(settings
.value("oss/capture", QString()).toString());
910 ui
->solarisDefaultDeviceLine
->setText(settings
.value("solaris/device", QString()).toString());
912 ui
->waveOutputLine
->setText(settings
.value("wave/file", QString()).toString());
913 ui
->waveBFormatCheckBox
->setChecked(settings
.value("wave/bformat", false).toBool());
915 ui
->applyButton
->setEnabled(false);
916 ui
->closeCancelButton
->setText(tr("Close"));
920 void MainWindow::saveCurrentConfig()
922 saveConfig(getDefaultConfigName());
923 ui
->applyButton
->setEnabled(false);
924 ui
->closeCancelButton
->setText(tr("Close"));
926 QMessageBox::information(this, tr("Information"),
927 tr("Applications using OpenAL need to be restarted for changes to take effect."));
930 void MainWindow::saveConfigAsFile()
932 QString fname
{QFileDialog::getOpenFileName(this, tr("Select Files"))};
933 if(fname
.isEmpty() == false)
936 ui
->applyButton
->setEnabled(false);
941 void MainWindow::saveConfig(const QString
&fname
) const
943 QSettings settings
{fname
, QSettings::IniFormat
};
945 /* HACK: Compound any stringlist values into a comma-separated string. */
946 QStringList allkeys
{settings
.allKeys()};
947 foreach(const QString
&key
, allkeys
)
949 QStringList vals
{settings
.value(key
).toStringList()};
951 settings
.setValue(key
, vals
.join(QChar(',')));
954 settings
.setValue("sample-type", getValueFromName(sampleTypeList
, ui
->sampleFormatCombo
->currentText()));
955 settings
.setValue("channels", getValueFromName(speakerModeList
, ui
->channelConfigCombo
->currentText()));
957 uint rate
{ui
->sampleRateCombo
->currentText().toUInt()};
959 settings
.setValue("frequency", QString
{});
961 settings
.setValue("frequency", rate
);
963 settings
.setValue("period_size", ui
->periodSizeEdit
->text());
964 settings
.setValue("periods", ui
->periodCountEdit
->text());
966 settings
.setValue("sources", ui
->srcCountLineEdit
->text());
967 settings
.setValue("slots", ui
->effectSlotLineEdit
->text());
969 settings
.setValue("resampler", resamplerList
[ui
->resamplerSlider
->value()].value
);
971 settings
.setValue("stereo-mode", getValueFromName(stereoModeList
, ui
->stereoModeCombo
->currentText()));
972 settings
.setValue("stereo-encoding", getValueFromName(stereoEncList
, ui
->stereoEncodingComboBox
->currentText()));
973 settings
.setValue("ambi-format", getValueFromName(ambiFormatList
, ui
->ambiFormatComboBox
->currentText()));
975 settings
.setValue("output-limiter", getCheckValue(ui
->outputLimiterCheckBox
));
976 settings
.setValue("dither", getCheckValue(ui
->outputDitherCheckBox
));
978 settings
.setValue("decoder/hq-mode",
979 ui
->decoderHQModeCheckBox
->isChecked() ? QString
{/*"true"*/} : QString
{"false"}
981 settings
.setValue("decoder/distance-comp", getCheckValue(ui
->decoderDistCompCheckBox
));
982 settings
.setValue("decoder/nfc", getCheckValue(ui
->decoderNFEffectsCheckBox
));
983 double refdelay
= ui
->decoderNFRefDelaySpinBox
->value();
984 settings
.setValue("decoder/nfc-ref-delay",
985 (refdelay
> 0.0) ? QString::number(refdelay
) : QString
{}
988 settings
.setValue("decoder/quad", ui
->decoderQuadLineEdit
->text());
989 settings
.setValue("decoder/surround51", ui
->decoder51LineEdit
->text());
990 settings
.setValue("decoder/surround61", ui
->decoder61LineEdit
->text());
991 settings
.setValue("decoder/surround71", ui
->decoder71LineEdit
->text());
994 if(!ui
->enableSSECheckBox
->isChecked())
995 strlist
.append("sse");
996 if(!ui
->enableSSE2CheckBox
->isChecked())
997 strlist
.append("sse2");
998 if(!ui
->enableSSE3CheckBox
->isChecked())
999 strlist
.append("sse3");
1000 if(!ui
->enableSSE41CheckBox
->isChecked())
1001 strlist
.append("sse4.1");
1002 if(!ui
->enableNeonCheckBox
->isChecked())
1003 strlist
.append("neon");
1004 settings
.setValue("disable-cpu-exts", strlist
.join(QChar(',')));
1006 settings
.setValue("hrtf-mode", hrtfModeList
[ui
->hrtfmodeSlider
->value()].value
);
1008 if(ui
->hrtfStateComboBox
->currentIndex() == 1)
1009 settings
.setValue("hrtf", "true");
1010 else if(ui
->hrtfStateComboBox
->currentIndex() == 2)
1011 settings
.setValue("hrtf", "false");
1013 settings
.setValue("hrtf", QString
{});
1015 if(ui
->preferredHrtfComboBox
->currentIndex() == 0)
1016 settings
.setValue("default-hrtf", QString
{});
1019 QString str
{ui
->preferredHrtfComboBox
->currentText()};
1020 settings
.setValue("default-hrtf", str
);
1024 strlist
.reserve(ui
->hrtfFileList
->count());
1025 for(int i
= 0;i
< ui
->hrtfFileList
->count();i
++)
1026 strlist
.append(ui
->hrtfFileList
->item(i
)->text());
1027 if(!strlist
.empty() && ui
->defaultHrtfPathsCheckBox
->isChecked())
1028 strlist
.append(QString
{});
1029 settings
.setValue("hrtf-paths", strlist
.join(QChar
{','}));
1032 for(int i
= 0;i
< ui
->enabledBackendList
->count();i
++)
1034 QString label
{ui
->enabledBackendList
->item(i
)->text()};
1035 for(int j
= 0;backendList
[j
].backend_name
[0];j
++)
1037 if(label
== backendList
[j
].full_string
)
1039 strlist
.append(backendList
[j
].backend_name
);
1044 for(int i
= 0;i
< ui
->disabledBackendList
->count();i
++)
1046 QString label
{ui
->disabledBackendList
->item(i
)->text()};
1047 for(int j
= 0;backendList
[j
].backend_name
[0];j
++)
1049 if(label
== backendList
[j
].full_string
)
1051 strlist
.append(QChar
{'-'}+QString
{backendList
[j
].backend_name
});
1056 if(strlist
.size() == 0 && !ui
->backendCheckBox
->isChecked())
1057 strlist
.append("-all");
1058 else if(ui
->backendCheckBox
->isChecked())
1059 strlist
.append(QString
{});
1060 settings
.setValue("drivers", strlist
.join(QChar(',')));
1062 // TODO: Remove check when we can properly match global values.
1063 if(ui
->defaultReverbComboBox
->currentIndex() == 0)
1064 settings
.setValue("default-reverb", QString
{});
1067 QString str
{ui
->defaultReverbComboBox
->currentText().toLower()};
1068 settings
.setValue("default-reverb", str
);
1072 if(!ui
->enableEaxReverbCheck
->isChecked())
1073 strlist
.append("eaxreverb");
1074 if(!ui
->enableStdReverbCheck
->isChecked())
1075 strlist
.append("reverb");
1076 if(!ui
->enableAutowahCheck
->isChecked())
1077 strlist
.append("autowah");
1078 if(!ui
->enableChorusCheck
->isChecked())
1079 strlist
.append("chorus");
1080 if(!ui
->enableDistortionCheck
->isChecked())
1081 strlist
.append("distortion");
1082 if(!ui
->enableCompressorCheck
->isChecked())
1083 strlist
.append("compressor");
1084 if(!ui
->enableEchoCheck
->isChecked())
1085 strlist
.append("echo");
1086 if(!ui
->enableEqualizerCheck
->isChecked())
1087 strlist
.append("equalizer");
1088 if(!ui
->enableFlangerCheck
->isChecked())
1089 strlist
.append("flanger");
1090 if(!ui
->enableFrequencyShifterCheck
->isChecked())
1091 strlist
.append("fshifter");
1092 if(!ui
->enableModulatorCheck
->isChecked())
1093 strlist
.append("modulator");
1094 if(!ui
->enableDedicatedCheck
->isChecked())
1095 strlist
.append("dedicated");
1096 if(!ui
->enablePitchShifterCheck
->isChecked())
1097 strlist
.append("pshifter");
1098 if(!ui
->enableVocalMorpherCheck
->isChecked())
1099 strlist
.append("vmorpher");
1100 settings
.setValue("excludefx", strlist
.join(QChar
{','}));
1102 settings
.setValue("pulse/spawn-server", getCheckValue(ui
->pulseAutospawnCheckBox
));
1103 settings
.setValue("pulse/allow-moves", getCheckValue(ui
->pulseAllowMovesCheckBox
));
1104 settings
.setValue("pulse/fix-rate", getCheckValue(ui
->pulseFixRateCheckBox
));
1105 settings
.setValue("pulse/adjust-latency", getCheckValue(ui
->pulseAdjLatencyCheckBox
));
1107 settings
.setValue("jack/spawn-server", getCheckValue(ui
->jackAutospawnCheckBox
));
1108 settings
.setValue("jack/buffer-size", ui
->jackBufferSizeLine
->text());
1110 settings
.setValue("alsa/device", ui
->alsaDefaultDeviceLine
->text());
1111 settings
.setValue("alsa/capture", ui
->alsaDefaultCaptureLine
->text());
1112 settings
.setValue("alsa/allow-resampler", getCheckValue(ui
->alsaResamplerCheckBox
));
1113 settings
.setValue("alsa/mmap", getCheckValue(ui
->alsaMmapCheckBox
));
1115 settings
.setValue("oss/device", ui
->ossDefaultDeviceLine
->text());
1116 settings
.setValue("oss/capture", ui
->ossDefaultCaptureLine
->text());
1118 settings
.setValue("solaris/device", ui
->solarisDefaultDeviceLine
->text());
1120 settings
.setValue("wave/file", ui
->waveOutputLine
->text());
1121 settings
.setValue("wave/bformat",
1122 ui
->waveBFormatCheckBox
->isChecked() ? QString
{"true"} : QString
{/*"false"*/}
1125 /* Remove empty keys
1126 * FIXME: Should only remove keys whose value matches the globally-specified value.
1128 allkeys
= settings
.allKeys();
1129 foreach(const QString
&key
, allkeys
)
1131 QString str
{settings
.value(key
).toString()};
1132 if(str
== QString
{})
1133 settings
.remove(key
);
1138 void MainWindow::enableApplyButton()
1141 ui
->applyButton
->setEnabled(true);
1143 ui
->closeCancelButton
->setText(tr("Cancel"));
1147 void MainWindow::updateResamplerLabel(int num
)
1149 ui
->resamplerLabel
->setText(resamplerList
[num
].name
);
1150 enableApplyButton();
1154 void MainWindow::updatePeriodSizeEdit(int size
)
1156 ui
->periodSizeEdit
->clear();
1158 ui
->periodSizeEdit
->insert(QString::number(size
));
1159 enableApplyButton();
1162 void MainWindow::updatePeriodSizeSlider()
1164 int pos
= ui
->periodSizeEdit
->text().toInt();
1169 ui
->periodSizeSlider
->setSliderPosition(pos
);
1171 enableApplyButton();
1174 void MainWindow::updatePeriodCountEdit(int count
)
1176 ui
->periodCountEdit
->clear();
1178 ui
->periodCountEdit
->insert(QString::number(count
));
1179 enableApplyButton();
1182 void MainWindow::updatePeriodCountSlider()
1184 int pos
= ui
->periodCountEdit
->text().toInt();
1189 ui
->periodCountSlider
->setSliderPosition(pos
);
1190 enableApplyButton();
1194 void MainWindow::selectQuadDecoderFile()
1195 { selectDecoderFile(ui
->decoderQuadLineEdit
, "Select Quadraphonic Decoder");}
1196 void MainWindow::select51DecoderFile()
1197 { selectDecoderFile(ui
->decoder51LineEdit
, "Select 5.1 Surround Decoder");}
1198 void MainWindow::select61DecoderFile()
1199 { selectDecoderFile(ui
->decoder61LineEdit
, "Select 6.1 Surround Decoder");}
1200 void MainWindow::select71DecoderFile()
1201 { selectDecoderFile(ui
->decoder71LineEdit
, "Select 7.1 Surround Decoder");}
1202 void MainWindow::selectDecoderFile(QLineEdit
*line
, const char *caption
)
1204 QString dir
{line
->text()};
1205 if(dir
.isEmpty() || QDir::isRelativePath(dir
))
1207 QStringList paths
{getAllDataPaths("/openal/presets")};
1208 while(!paths
.isEmpty())
1210 if(QDir
{paths
.last()}.exists())
1218 QString fname
{QFileDialog::getOpenFileName(this, tr(caption
),
1219 dir
, tr("AmbDec Files (*.ambdec);;All Files (*.*)"))};
1220 if(!fname
.isEmpty())
1222 line
->setText(fname
);
1223 enableApplyButton();
1228 void MainWindow::updateJackBufferSizeEdit(int size
)
1230 ui
->jackBufferSizeLine
->clear();
1232 ui
->jackBufferSizeLine
->insert(QString::number(1<<size
));
1233 enableApplyButton();
1236 void MainWindow::updateJackBufferSizeSlider()
1238 int value
{ui
->jackBufferSizeLine
->text().toInt()};
1239 auto pos
= static_cast<int>(floor(log2(value
) + 0.5));
1240 ui
->jackBufferSizeSlider
->setSliderPosition(pos
);
1241 enableApplyButton();
1245 void MainWindow::updateHrtfModeLabel(int num
)
1247 ui
->hrtfmodeLabel
->setText(hrtfModeList
[num
].name
);
1248 enableApplyButton();
1252 void MainWindow::addHrtfFile()
1254 QString path
{QFileDialog::getExistingDirectory(this, tr("Select HRTF Path"))};
1255 if(path
.isEmpty() == false && !getAllDataPaths("/openal/hrtf").contains(path
))
1257 ui
->hrtfFileList
->addItem(path
);
1258 enableApplyButton();
1262 void MainWindow::removeHrtfFile()
1264 QList
<QListWidgetItem
*> selected
{ui
->hrtfFileList
->selectedItems()};
1265 if(!selected
.isEmpty())
1267 foreach(QListWidgetItem
*item
, selected
)
1269 enableApplyButton();
1273 void MainWindow::updateHrtfRemoveButton()
1275 ui
->hrtfRemoveButton
->setEnabled(ui
->hrtfFileList
->selectedItems().size() != 0);
1278 void MainWindow::showEnabledBackendMenu(QPoint pt
)
1280 QHash
<QAction
*,QString
> actionMap
;
1282 pt
= ui
->enabledBackendList
->mapToGlobal(pt
);
1285 QAction
*removeAction
{ctxmenu
.addAction(QIcon::fromTheme("list-remove"), "Remove")};
1286 if(ui
->enabledBackendList
->selectedItems().size() == 0)
1287 removeAction
->setEnabled(false);
1288 ctxmenu
.addSeparator();
1289 for(size_t i
= 0;backendList
[i
].backend_name
[0];i
++)
1291 QString backend
{backendList
[i
].full_string
};
1292 QAction
*action
{ctxmenu
.addAction(QString("Add ")+backend
)};
1293 actionMap
[action
] = backend
;
1294 if(ui
->enabledBackendList
->findItems(backend
, Qt::MatchFixedString
).size() != 0 ||
1295 ui
->disabledBackendList
->findItems(backend
, Qt::MatchFixedString
).size() != 0)
1296 action
->setEnabled(false);
1299 QAction
*gotAction
{ctxmenu
.exec(pt
)};
1300 if(gotAction
== removeAction
)
1302 QList
<QListWidgetItem
*> selected
{ui
->enabledBackendList
->selectedItems()};
1303 foreach(QListWidgetItem
*item
, selected
)
1305 enableApplyButton();
1307 else if(gotAction
!= nullptr)
1309 auto iter
= actionMap
.constFind(gotAction
);
1310 if(iter
!= actionMap
.cend())
1311 ui
->enabledBackendList
->addItem(iter
.value());
1312 enableApplyButton();
1316 void MainWindow::showDisabledBackendMenu(QPoint pt
)
1318 QHash
<QAction
*,QString
> actionMap
;
1320 pt
= ui
->disabledBackendList
->mapToGlobal(pt
);
1323 QAction
*removeAction
{ctxmenu
.addAction(QIcon::fromTheme("list-remove"), "Remove")};
1324 if(ui
->disabledBackendList
->selectedItems().size() == 0)
1325 removeAction
->setEnabled(false);
1326 ctxmenu
.addSeparator();
1327 for(size_t i
= 0;backendList
[i
].backend_name
[0];i
++)
1329 QString backend
{backendList
[i
].full_string
};
1330 QAction
*action
{ctxmenu
.addAction(QString("Add ")+backend
)};
1331 actionMap
[action
] = backend
;
1332 if(ui
->disabledBackendList
->findItems(backend
, Qt::MatchFixedString
).size() != 0 ||
1333 ui
->enabledBackendList
->findItems(backend
, Qt::MatchFixedString
).size() != 0)
1334 action
->setEnabled(false);
1337 QAction
*gotAction
{ctxmenu
.exec(pt
)};
1338 if(gotAction
== removeAction
)
1340 QList
<QListWidgetItem
*> selected
{ui
->disabledBackendList
->selectedItems()};
1341 foreach(QListWidgetItem
*item
, selected
)
1343 enableApplyButton();
1345 else if(gotAction
!= nullptr)
1347 auto iter
= actionMap
.constFind(gotAction
);
1348 if(iter
!= actionMap
.cend())
1349 ui
->disabledBackendList
->addItem(iter
.value());
1350 enableApplyButton();
1354 void MainWindow::selectOSSPlayback()
1356 QString current
{ui
->ossDefaultDeviceLine
->text()};
1357 if(current
.isEmpty()) current
= ui
->ossDefaultDeviceLine
->placeholderText();
1358 QString fname
{QFileDialog::getOpenFileName(this, tr("Select Playback Device"), current
)};
1359 if(!fname
.isEmpty())
1361 ui
->ossDefaultDeviceLine
->setText(fname
);
1362 enableApplyButton();
1366 void MainWindow::selectOSSCapture()
1368 QString current
{ui
->ossDefaultCaptureLine
->text()};
1369 if(current
.isEmpty()) current
= ui
->ossDefaultCaptureLine
->placeholderText();
1370 QString fname
{QFileDialog::getOpenFileName(this, tr("Select Capture Device"), current
)};
1371 if(!fname
.isEmpty())
1373 ui
->ossDefaultCaptureLine
->setText(fname
);
1374 enableApplyButton();
1378 void MainWindow::selectSolarisPlayback()
1380 QString current
{ui
->solarisDefaultDeviceLine
->text()};
1381 if(current
.isEmpty()) current
= ui
->solarisDefaultDeviceLine
->placeholderText();
1382 QString fname
{QFileDialog::getOpenFileName(this, tr("Select Playback Device"), current
)};
1383 if(!fname
.isEmpty())
1385 ui
->solarisDefaultDeviceLine
->setText(fname
);
1386 enableApplyButton();
1390 void MainWindow::selectWaveOutput()
1392 QString fname
{QFileDialog::getSaveFileName(this, tr("Select Wave File Output"),
1393 ui
->waveOutputLine
->text(), tr("Wave Files (*.wav *.amb);;All Files (*.*)"))};
1394 if(!fname
.isEmpty())
1396 ui
->waveOutputLine
->setText(fname
);
1397 enableApplyButton();