drumstick  2.2.0
sonivoxsettingsdialog.cpp
Go to the documentation of this file.
1 /*
2  Virtual Piano test using the MIDI Sequencer C++ library
3  Copyright (C) 2006-2021, Pedro Lopez-Cabanillas <plcl@users.sf.net>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #include <QDialogButtonBox>
20 #include <QPushButton>
21 
22 #include "sonivoxsettingsdialog.h"
23 #include "ui_sonivoxsettingsdialog.h"
25 
31 namespace drumstick { namespace widgets {
32 
33 const QString SonivoxSettingsDialog::QSTR_PREFERENCES = QStringLiteral("SonivoxEAS");
34 const QString SonivoxSettingsDialog::QSTR_BUFFERTIME = QStringLiteral("BufferTime");
35 const QString SonivoxSettingsDialog::QSTR_REVERBTYPE = QStringLiteral("ReverbType");
36 const QString SonivoxSettingsDialog::QSTR_REVERBAMT = QStringLiteral("ReverbAmt");
37 const QString SonivoxSettingsDialog::QSTR_CHORUSTYPE = QStringLiteral("ChorusType");
38 const QString SonivoxSettingsDialog::QSTR_CHORUSAMT = QStringLiteral("ChorusAmt");
39 
40 SonivoxSettingsDialog::SonivoxSettingsDialog(QWidget *parent) :
41  QDialog(parent),
42  ui(new Ui::SonivoxSettingsDialog)
43 {
44  ui->setupUi(this);
45  ui->combo_Reverb->addItem(QStringLiteral("Large Hall"), 0);
46  ui->combo_Reverb->addItem(QStringLiteral("Hall"), 1);
47  ui->combo_Reverb->addItem(QStringLiteral("Chamber"), 2);
48  ui->combo_Reverb->addItem(QStringLiteral("Room"), 3);
49  ui->combo_Reverb->addItem(QStringLiteral("None"), -1);
50  ui->combo_Reverb->setCurrentIndex(4);
51 
52  ui->combo_Chorus->addItem(QStringLiteral("Preset 1"), 0);
53  ui->combo_Chorus->addItem(QStringLiteral("Preset 2"), 1);
54  ui->combo_Chorus->addItem(QStringLiteral("Preset 3"), 2);
55  ui->combo_Chorus->addItem(QStringLiteral("Preset 4"), 3);
56  ui->combo_Chorus->addItem(QStringLiteral("None"), -1);
57  ui->combo_Chorus->setCurrentIndex(4);
58  connect(ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::pressed,
59  this, &SonivoxSettingsDialog::restoreDefaults);
60 }
61 
62 SonivoxSettingsDialog::~SonivoxSettingsDialog()
63 {
64  delete ui;
65 }
66 
67 void SonivoxSettingsDialog::accept()
68 {
69  writeSettings();
70  QDialog::accept();
71 }
72 
73 void SonivoxSettingsDialog::showEvent(QShowEvent *event)
74 {
75  readSettings();
76  event->accept();
77 }
78 
79 void SonivoxSettingsDialog::readSettings()
80 {
81 
82  SettingsFactory settings;
83  settings->beginGroup(QSTR_PREFERENCES);
84  int bufferTime = settings->value(QSTR_BUFFERTIME, 60).toInt();
85  int reverbType = settings->value(QSTR_REVERBTYPE, 1).toInt();
86  int reverbAmt = settings->value(QSTR_REVERBAMT, 25800).toInt();
87  int chorusType = settings->value(QSTR_CHORUSTYPE, -1).toInt();
88  int chorusAmt = settings->value(QSTR_CHORUSAMT, 0).toInt();
89  settings->endGroup();
90 
91  ui->spnTime->setValue(bufferTime);
92  ui->dial_Reverb->setValue(reverbAmt);
93  ui->dial_Chorus->setValue(chorusAmt);
94  int reverbIndex = ui->combo_Reverb->findData(reverbType);
95  int chorusIndex = ui->combo_Chorus->findData(chorusType);
96  ui->combo_Reverb->setCurrentIndex(reverbIndex);
97  ui->combo_Chorus->setCurrentIndex(chorusIndex);
98 }
99 
100 void SonivoxSettingsDialog::writeSettings()
101 {
102  SettingsFactory settings;
103  settings->beginGroup(QSTR_PREFERENCES);
104  settings->setValue(QSTR_BUFFERTIME, ui->spnTime->value());
105  settings->setValue(QSTR_REVERBTYPE, ui->combo_Reverb->currentData());
106  settings->setValue(QSTR_CHORUSTYPE, ui->combo_Chorus->currentData());
107  settings->setValue(QSTR_REVERBAMT, ui->dial_Reverb->value());
108  settings->setValue(QSTR_CHORUSAMT, ui->dial_Chorus->value());
109  settings->endGroup();
110  settings->sync();
111 }
112 
113 void SonivoxSettingsDialog::restoreDefaults()
114 {
115  ui->spnTime->setValue(60);
116  ui->combo_Reverb->setCurrentIndex(1);
117  ui->dial_Reverb->setValue(25800);
118  ui->combo_Chorus->setCurrentIndex(4);
119  ui->dial_Chorus->setValue(0);
120 }
121 
122 } // namespace widgets
123 } // namespace drumstick
124 
Drumstick common.
Definition: alsaclient.cpp:68
SettingsFactory class declaration.
Definition of the Sonivox Synth configuration dialog.