/[svn]/qsampler/trunk/src/qsamplerOptions.cpp
ViewVC logotype

Annotation of /qsampler/trunk/src/qsamplerOptions.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3855 - (hide annotations) (download)
Thu Feb 4 10:09:42 2021 UTC (3 years, 2 months ago) by capela
File size: 19306 byte(s)
- Silence compiler warnings to GNU/MinGW only.
1 capela 106 // qsamplerOptions.cpp
2     //
3     /****************************************************************************
4 capela 3849 Copyright (C) 2004-2021, rncbc aka Rui Nuno Capela. All rights reserved.
5 capela 3067 Copyright (C) 2007,2008,2015 Christian Schoenebeck
6 capela 106
7     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     as published by the Free Software Foundation; either version 2
10     of the License, or (at your option) any later version.
11    
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     GNU General Public License for more details.
16    
17 capela 920 You should have received a copy of the GNU General Public License along
18     with this program; if not, write to the Free Software Foundation, Inc.,
19     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 capela 106
21     *****************************************************************************/
22    
23 capela 753 #include "qsamplerAbout.h"
24 capela 106 #include "qsamplerOptions.h"
25 schoenebeck 1803 #include "qsamplerMainForm.h"
26 capela 106
27 capela 1499 #include <QTextStream>
28     #include <QComboBox>
29 capela 106
30 capela 3558 #include <QApplication>
31 capela 3796
32     #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
33 capela 3558 #include <QDesktopWidget>
34 capela 3796 #endif
35 capela 3558
36 capela 264 #include <lscp/client.h>
37 capela 106
38 capela 605 #ifdef CONFIG_LIBGIG
39 capela 3855 #if defined(Q_CC_GNU) || defined(Q_CC_MINGW)
40 capela 3849 #pragma GCC diagnostic push
41     #pragma GCC diagnostic ignored "-Wunused-parameter"
42 capela 3855 #endif
43 capela 605 #include <gig.h>
44 capela 3855 #if defined(Q_CC_GNU) || defined(Q_CC_MINGW)
45 capela 3849 #pragma GCC diagnostic pop
46 capela 605 #endif
47 capela 3855 #endif
48 capela 106
49 capela 605
50 capela 1558 namespace QSampler {
51    
52 capela 106 //-------------------------------------------------------------------------
53 capela 1558 // QSampler::Options - Prototype settings structure.
54 capela 106 //
55    
56     // Constructor.
57 capela 1558 Options::Options (void)
58 capela 1504 : m_settings(QSAMPLER_DOMAIN, QSAMPLER_TITLE)
59 capela 106 {
60 capela 2028 loadOptions();
61     }
62    
63    
64     // Default Destructor.
65     Options::~Options (void)
66     {
67     saveOptions();
68     }
69    
70    
71     // Explicit load method.
72     void Options::loadOptions (void)
73     {
74 capela 1509 // Begin into general options group.
75     m_settings.beginGroup("/Options");
76 capela 106
77 capela 1509 // Load server options...
78     m_settings.beginGroup("/Server");
79     sServerHost = m_settings.value("/ServerHost", "localhost").toString();
80     iServerPort = m_settings.value("/ServerPort", 8888).toInt();
81 capela 2642 #if defined(__APPLE__) // Toshi Nagata 20080105
82 nagata 1643 // TODO: Should this be a configure option?
83     iServerTimeout = m_settings.value("/ServerTimeout", 10000).toInt();
84 capela 2642 #else
85 capela 1509 iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt();
86 capela 2642 #endif
87 capela 1509 bServerStart = m_settings.value("/ServerStart", true).toBool();
88 schoenebeck 2712 #if defined(__APPLE__)
89     sServerCmdLine = m_settings.value("/ServerCmdLine", "/usr/local/bin/linuxsampler").toString();
90 capela 2642 #else
91 capela 1509 sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString();
92 capela 2642 #endif
93 capela 1509 iStartDelay = m_settings.value("/StartDelay", 3).toInt();
94     m_settings.endGroup();
95 capela 106
96 capela 1738 // Load logging options...
97     m_settings.beginGroup("/Logging");
98     bMessagesLog = m_settings.value("/MessagesLog", false).toBool();
99     sMessagesLogPath = m_settings.value("/MessagesLogPath", "qsampler.log").toString();
100     m_settings.endGroup();
101    
102 capela 1509 // Load display options...
103     m_settings.beginGroup("/Display");
104     sDisplayFont = m_settings.value("/DisplayFont").toString();
105     bDisplayEffect = m_settings.value("/DisplayEffect", true).toBool();
106     bAutoRefresh = m_settings.value("/AutoRefresh", true).toBool();
107     iAutoRefreshTime = m_settings.value("/AutoRefreshTime", 1000).toInt();
108     iMaxVolume = m_settings.value("/MaxVolume", 100).toInt();
109     sMessagesFont = m_settings.value("/MessagesFont").toString();
110     bMessagesLimit = m_settings.value("/MessagesLimit", true).toBool();
111     iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt();
112     bConfirmRemove = m_settings.value("/ConfirmRemove", true).toBool();
113 capela 2722 bConfirmReset = m_settings.value("/ConfirmReset", true).toBool();
114     bConfirmRestart = m_settings.value("/ConfirmRestart", true).toBool();
115     bConfirmError = m_settings.value("/ConfirmError", true).toBool();
116 capela 1509 bKeepOnTop = m_settings.value("/KeepOnTop", true).toBool();
117     bStdoutCapture = m_settings.value("/StdoutCapture", true).toBool();
118     bCompletePath = m_settings.value("/CompletePath", true).toBool();
119     iMaxRecentFiles = m_settings.value("/MaxRecentFiles", 5).toInt();
120 capela 1749 iBaseFontSize = m_settings.value("/BaseFontSize", 0).toInt();
121 schoenebeck 1527 // if libgig provides a fast way to retrieve instrument names even for large
122     // .gig files, then we enable this feature by default
123 capela 2646 #ifdef CONFIG_LIBGIG_SETAUTOLOAD
124 schoenebeck 1527 bInstrumentNames = m_settings.value("/InstrumentNames", true).toBool();
125     #else
126 capela 1509 bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool();
127 schoenebeck 1527 #endif
128 capela 1509 m_settings.endGroup();
129 capela 106
130 capela 3648 // Load custom options...
131     m_settings.beginGroup("/Custom");
132     sCustomColorTheme = m_settings.value("/ColorTheme").toString();
133     sCustomStyleTheme = m_settings.value("/StyleTheme").toString();
134     m_settings.endGroup();
135    
136 capela 1509 // And go into view options group.
137     m_settings.beginGroup("/View");
138     bMenubar = m_settings.value("/Menubar", true).toBool();
139     bToolbar = m_settings.value("/Toolbar", true).toBool();
140     bStatusbar = m_settings.value("/Statusbar", true).toBool();
141     bAutoArrange = m_settings.value("/AutoArrange", true).toBool();
142     m_settings.endGroup();
143 capela 106
144 capela 1509 m_settings.endGroup(); // Options group.
145 capela 106
146 capela 1499 // Recent file list.
147     recentFiles.clear();
148     m_settings.beginGroup("/RecentFiles");
149     for (int iFile = 0; iFile < iMaxRecentFiles; iFile++) {
150     QString sFilename = m_settings.value(
151     "/File" + QString::number(iFile + 1)).toString();
152     if (!sFilename.isEmpty())
153     recentFiles.append(sFilename);
154     }
155     m_settings.endGroup();
156 capela 106
157 schoenebeck 1803 // Sampler fine tuning settings.
158     m_settings.beginGroup("/Tuning");
159     iMaxVoices = m_settings.value("/MaxVoices", -1).toInt();
160     iMaxStreams = m_settings.value("/MaxStreams", -1).toInt();
161     m_settings.endGroup();
162    
163 capela 1509 // Last but not least, get the default directories.
164     m_settings.beginGroup("/Default");
165     sSessionDir = m_settings.value("/SessionDir").toString();
166     sInstrumentDir = m_settings.value("/InstrumentDir").toString();
167     sEngineName = m_settings.value("/EngineName").toString();
168     sAudioDriver = m_settings.value("/AudioDriver").toString();
169     sMidiDriver = m_settings.value("/MidiDriver").toString();
170     iMidiMap = m_settings.value("/MidiMap", 0).toInt();
171     iMidiBank = m_settings.value("/MidiBank", 0).toInt();
172     iMidiProg = m_settings.value("/MidiProg", 0).toInt();
173     iVolume = m_settings.value("/Volume", 100).toInt();
174     iLoadMode = m_settings.value("/Loadmode", 0).toInt();
175     m_settings.endGroup();
176 capela 106 }
177    
178    
179 capela 2028 // Explicit save method.
180     void Options::saveOptions (void)
181 capela 106 {
182 capela 1509 // Make program version available in the future.
183     m_settings.beginGroup("/Program");
184 capela 3038 m_settings.setValue("/Version", CONFIG_BUILD_VERSION);
185 capela 1509 m_settings.endGroup();
186 capela 106
187 capela 1509 // And go into general options group.
188     m_settings.beginGroup("/Options");
189 capela 106
190 capela 1509 // Save server options.
191     m_settings.beginGroup("/Server");
192     m_settings.setValue("/ServerHost", sServerHost);
193     m_settings.setValue("/ServerPort", iServerPort);
194     m_settings.setValue("/ServerTimeout", iServerTimeout);
195     m_settings.setValue("/ServerStart", bServerStart);
196     m_settings.setValue("/ServerCmdLine", sServerCmdLine);
197     m_settings.setValue("/StartDelay", iStartDelay);
198     m_settings.endGroup();
199 capela 106
200 capela 1738 // Save logging options...
201     m_settings.beginGroup("/Logging");
202     m_settings.setValue("/MessagesLog", bMessagesLog);
203     m_settings.setValue("/MessagesLogPath", sMessagesLogPath);
204     m_settings.endGroup();
205    
206 capela 1509 // Save display options.
207     m_settings.beginGroup("/Display");
208     m_settings.setValue("/DisplayFont", sDisplayFont);
209     m_settings.setValue("/DisplayEffect", bDisplayEffect);
210     m_settings.setValue("/AutoRefresh", bAutoRefresh);
211     m_settings.setValue("/AutoRefreshTime", iAutoRefreshTime);
212     m_settings.setValue("/MaxVolume", iMaxVolume);
213     m_settings.setValue("/MessagesFont", sMessagesFont);
214     m_settings.setValue("/MessagesLimit", bMessagesLimit);
215     m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines);
216     m_settings.setValue("/ConfirmRemove", bConfirmRemove);
217 capela 2722 m_settings.setValue("/ConfirmReset", bConfirmReset);
218     m_settings.setValue("/ConfirmRestart", bConfirmRestart);
219     m_settings.setValue("/ConfirmError", bConfirmError);
220 capela 1509 m_settings.setValue("/KeepOnTop", bKeepOnTop);
221     m_settings.setValue("/StdoutCapture", bStdoutCapture);
222     m_settings.setValue("/CompletePath", bCompletePath);
223     m_settings.setValue("/MaxRecentFiles", iMaxRecentFiles);
224 capela 1749 m_settings.setValue("/BaseFontSize", iBaseFontSize);
225 capela 1509 m_settings.setValue("/InstrumentNames", bInstrumentNames);
226     m_settings.endGroup();
227 capela 106
228 capela 3648 // Save custom options...
229     m_settings.beginGroup("/Custom");
230     m_settings.setValue("/ColorTheme", sCustomColorTheme);
231     m_settings.setValue("/StyleTheme", sCustomStyleTheme);
232     m_settings.endGroup();
233    
234 capela 1509 // View options group.
235     m_settings.beginGroup("/View");
236     m_settings.setValue("/Menubar", bMenubar);
237     m_settings.setValue("/Toolbar", bToolbar);
238     m_settings.setValue("/Statusbar", bStatusbar);
239     m_settings.setValue("/AutoArrange", bAutoArrange);
240     m_settings.endGroup();
241 capela 106
242 capela 1509 m_settings.endGroup(); // Options group.
243 capela 106
244 capela 1509 // Recent file list.
245 capela 1499 int iFile = 0;
246     m_settings.beginGroup("/RecentFiles");
247     QStringListIterator iter(recentFiles);
248     while (iter.hasNext())
249     m_settings.setValue("/File" + QString::number(++iFile), iter.next());
250     m_settings.endGroup();
251 capela 106
252 schoenebeck 1803 // Sampler fine tuning settings.
253     m_settings.beginGroup("/Tuning");
254     if (iMaxVoices > 0)
255     m_settings.setValue("/MaxVoices", iMaxVoices);
256     if (iMaxStreams >= 0)
257     m_settings.setValue("/MaxStreams", iMaxStreams);
258     m_settings.endGroup();
259    
260 capela 1509 // Default directories.
261     m_settings.beginGroup("/Default");
262     m_settings.setValue("/SessionDir", sSessionDir);
263     m_settings.setValue("/InstrumentDir", sInstrumentDir);
264     m_settings.setValue("/EngineName", sEngineName);
265     m_settings.setValue("/AudioDriver", sAudioDriver);
266     m_settings.setValue("/MidiDriver", sMidiDriver);
267     m_settings.setValue("/MidiMap", iMidiMap);
268     m_settings.setValue("/MidiBank", iMidiBank);
269     m_settings.setValue("/MidiProg", iMidiProg);
270     m_settings.setValue("/Volume", iVolume);
271     m_settings.setValue("/Loadmode", iLoadMode);
272     m_settings.endGroup();
273 capela 2028
274     // Save/commit to disk.
275     m_settings.sync();
276 capela 106 }
277    
278 capela 2028
279 capela 106 //-------------------------------------------------------------------------
280     // Settings accessor.
281     //
282    
283 capela 1558 QSettings& Options::settings (void)
284 capela 106 {
285 capela 1509 return m_settings;
286 capela 106 }
287    
288    
289     //-------------------------------------------------------------------------
290     // Command-line argument stuff.
291     //
292    
293     // Help about command line options.
294 capela 1890 void Options::print_usage ( const QString& arg0 )
295 capela 106 {
296 capela 1499 QTextStream out(stderr);
297     out << QObject::tr("Usage: %1 [options] [session-file]\n\n"
298     QSAMPLER_TITLE " - " QSAMPLER_SUBTITLE "\n\n"
299     "Options:\n\n"
300     " -s, --start\n\tStart linuxsampler server locally\n\n"
301 capela 2642 " -h, --hostname\n\tSpecify linuxsampler server hostname (default = localhost)\n\n"
302     " -p, --port\n\tSpecify linuxsampler server port number (default = 8888)\n\n"
303 capela 1499 " -?, --help\n\tShow help about command line options\n\n"
304     " -v, --version\n\tShow version information\n\n")
305     .arg(arg0);
306 capela 106 }
307    
308    
309     // Parse command line arguments into m_settings.
310 capela 1890 bool Options::parse_args ( const QStringList& args )
311 capela 106 {
312 capela 1499 QTextStream out(stderr);
313 capela 1509 const QString sEol = "\n\n";
314 capela 3556 const int argc = args.count();
315 capela 1509 int iCmdArgs = 0;
316 capela 106
317 capela 3556 for (int i = 1; i < argc; ++i) {
318 capela 106
319 capela 1509 if (iCmdArgs > 0) {
320     sSessionFile += " ";
321 capela 1890 sSessionFile += args.at(i);
322 capela 3556 ++iCmdArgs;
323 capela 1509 continue;
324     }
325 capela 106
326 capela 1890 QString sArg = args.at(i);
327 capela 3518 QString sVal;
328 capela 2642 const int iEqual = sArg.indexOf("=");
329 capela 1509 if (iEqual >= 0) {
330     sVal = sArg.right(sArg.length() - iEqual - 1);
331     sArg = sArg.left(iEqual);
332     }
333 capela 2642 else if (i < argc - 1) {
334 capela 1890 sVal = args.at(i + 1);
335 capela 2642 if (sVal[0] == '-')
336     sVal.clear();
337     }
338 capela 106
339 capela 1509 if (sArg == "-s" || sArg == "--start") {
340     bServerStart = true;
341     }
342     else if (sArg == "-h" || sArg == "--hostname") {
343     if (sVal.isNull()) {
344 capela 2642 out << QObject::tr("Option -h requires an argument (host).") + sEol;
345 capela 1509 return false;
346     }
347     sServerHost = sVal;
348     if (iEqual < 0)
349 capela 3556 ++i;
350 capela 1509 }
351     else if (sArg == "-p" || sArg == "--port") {
352     if (sVal.isNull()) {
353     out << QObject::tr("Option -p requires an argument (port).") + sEol;
354     return false;
355     }
356     iServerPort = sVal.toInt();
357     if (iEqual < 0)
358 capela 3556 ++i;
359 capela 1509 }
360     else if (sArg == "-?" || sArg == "--help") {
361 capela 1890 print_usage(args.at(0));
362 capela 1509 return false;
363     }
364     else if (sArg == "-v" || sArg == "--version") {
365 capela 3837 out << QString("Qt: %1").arg(qVersion());
366     #if defined(QT_STATIC)
367     out << "-static";
368     #endif
369     out << '\n';
370 capela 2642 #ifdef CONFIG_LIBGIG
371 capela 1499 out << QString("%1: %2\n")
372     .arg(gig::libraryName().c_str())
373     .arg(gig::libraryVersion().c_str());
374 capela 2642 #endif
375 capela 1499 out << QString("%1: %2\n")
376     .arg(::lscp_client_package())
377     .arg(::lscp_client_version());
378 capela 3849 out << QString("%1: %2\n")
379     .arg(QSAMPLER_TITLE)
380     .arg(CONFIG_BUILD_VERSION);
381 capela 1509 return false;
382     }
383     else {
384     // If we don't have one by now,
385     // this will be the startup sesion file...
386     sSessionFile += sArg;
387 capela 3556 ++iCmdArgs;
388 capela 1509 }
389     }
390 capela 106
391 capela 1509 // Alright with argument parsing.
392     return true;
393 capela 106 }
394    
395    
396     //---------------------------------------------------------------------------
397     // Widget geometry persistence helper methods.
398    
399 capela 2077 void Options::loadWidgetGeometry ( QWidget *pWidget, bool bVisible )
400 capela 106 {
401 capela 1499 // Try to restore old form window positioning.
402     if (pWidget) {
403 capela 2847 // if (bVisible) pWidget->show(); -- force initial exposure?
404 capela 1499 m_settings.beginGroup("/Geometry/" + pWidget->objectName());
405 capela 3520 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
406 capela 2779 const QByteArray& geometry
407     = m_settings.value("/geometry").toByteArray();
408 capela 3558 if (geometry.isEmpty()) {
409     QWidget *pParent = pWidget->parentWidget();
410     if (pParent)
411     pParent = pParent->window();
412 capela 3796 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
413 capela 3558 if (pParent == nullptr)
414     pParent = QApplication::desktop();
415 capela 3796 #endif
416 capela 3558 if (pParent) {
417     QRect wrect(pWidget->geometry());
418     wrect.moveCenter(pParent->geometry().center());
419     pWidget->move(wrect.topLeft());
420     }
421     } else {
422 capela 2779 pWidget->restoreGeometry(geometry);
423 capela 3558 }
424 capela 2843 #else//--LOAD_OLD_GEOMETRY
425     QPoint wpos;
426     QSize wsize;
427     wpos.setX(m_settings.value("/x", -1).toInt());
428     wpos.setY(m_settings.value("/y", -1).toInt());
429     wsize.setWidth(m_settings.value("/width", -1).toInt());
430     wsize.setHeight(m_settings.value("/height", -1).toInt());
431     if (wpos.x() > 0 && wpos.y() > 0)
432     pWidget->move(wpos);
433     if (wsize.width() > 0 && wsize.height() > 0)
434     pWidget->resize(wsize);
435     #endif
436 capela 3067 // else
437     // pWidget->adjustSize();
438 capela 2779 if (!bVisible)
439     bVisible = m_settings.value("/visible", false).toBool();
440 capela 1499 if (bVisible)
441     pWidget->show();
442 capela 2779 else
443     pWidget->hide();
444     m_settings.endGroup();
445 capela 1499 }
446 capela 106 }
447    
448    
449 capela 2077 void Options::saveWidgetGeometry ( QWidget *pWidget, bool bVisible )
450 capela 106 {
451 capela 1499 // Try to save form window position...
452     // (due to X11 window managers ideossincrasies, we better
453     // only save the form geometry while its up and visible)
454     if (pWidget) {
455     m_settings.beginGroup("/Geometry/" + pWidget->objectName());
456 capela 3520 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
457 capela 2843 m_settings.setValue("/geometry", pWidget->saveGeometry());
458     #else//--SAVE_OLD_GEOMETRY
459 capela 2077 const QPoint& wpos = pWidget->pos();
460     const QSize& wsize = pWidget->size();
461     m_settings.setValue("/x", wpos.x());
462     m_settings.setValue("/y", wpos.y());
463     m_settings.setValue("/width", wsize.width());
464     m_settings.setValue("/height", wsize.height());
465 capela 2779 #endif
466     if (!bVisible) bVisible = pWidget->isVisible();
467 capela 1499 m_settings.setValue("/visible", bVisible);
468     m_settings.endGroup();
469     }
470 capela 106 }
471    
472    
473     //---------------------------------------------------------------------------
474     // Combo box history persistence helper implementation.
475    
476 capela 1558 void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit )
477 capela 106 {
478 capela 2723 const bool bBlockSignals = pComboBox->blockSignals(true);
479    
480 capela 1499 // Load combobox list from configuration settings file...
481     m_settings.beginGroup("/History/" + pComboBox->objectName());
482 capela 106
483 capela 1499 if (m_settings.childKeys().count() > 0) {
484     pComboBox->setUpdatesEnabled(false);
485     pComboBox->setDuplicatesEnabled(false);
486     pComboBox->clear();
487 capela 2723 for (int i = 0; i < iLimit; ++i) {
488 capela 1499 const QString& sText = m_settings.value(
489     "/Item" + QString::number(i + 1)).toString();
490     if (sText.isEmpty())
491     break;
492     pComboBox->addItem(sText);
493     }
494     pComboBox->setUpdatesEnabled(true);
495     }
496 capela 106
497 capela 1499 m_settings.endGroup();
498 capela 2723
499     pComboBox->blockSignals(bBlockSignals);
500 capela 106 }
501    
502    
503 capela 1558 void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit )
504 capela 106 {
505 capela 2723 const bool bBlockSignals = pComboBox->blockSignals(true);
506    
507 capela 1499 // Add current text as latest item...
508 capela 2723 const QString sCurrentText = pComboBox->currentText();
509 capela 1499 int iCount = pComboBox->count();
510     for (int i = 0; i < iCount; i++) {
511     const QString& sText = pComboBox->itemText(i);
512     if (sText == sCurrentText) {
513     pComboBox->removeItem(i);
514 capela 2723 --iCount;
515 capela 1499 break;
516     }
517     }
518     while (iCount >= iLimit)
519     pComboBox->removeItem(--iCount);
520     pComboBox->insertItem(0, sCurrentText);
521 capela 2723 pComboBox->setCurrentIndex(0);
522     ++iCount;
523 capela 106
524 capela 1499 // Save combobox list to configuration settings file...
525     m_settings.beginGroup("/History/" + pComboBox->objectName());
526 capela 2723 for (int i = 0; i < iCount; ++i) {
527 capela 1499 const QString& sText = pComboBox->itemText(i);
528     if (sText.isEmpty())
529     break;
530     m_settings.setValue("/Item" + QString::number(i + 1), sText);
531     }
532     m_settings.endGroup();
533 capela 2723
534     pComboBox->blockSignals(bBlockSignals);
535 capela 106 }
536    
537 capela 2723
538 schoenebeck 1803 int Options::getMaxVoices() {
539     #ifndef CONFIG_MAX_VOICES
540     return -1;
541     #else
542     if (iMaxVoices > 0) return iMaxVoices;
543     return getEffectiveMaxVoices();
544     #endif // CONFIG_MAX_VOICES
545     }
546    
547     int Options::getEffectiveMaxVoices() {
548     #ifndef CONFIG_MAX_VOICES
549     return -1;
550     #else
551     MainForm *pMainForm = MainForm::getInstance();
552     if (!pMainForm || !pMainForm->client())
553     return -1;
554    
555     return ::lscp_get_voices(pMainForm->client());
556     #endif // CONFIG_MAX_VOICES
557     }
558    
559     void Options::setMaxVoices(int iMaxVoices) {
560     #ifdef CONFIG_MAX_VOICES
561     if (iMaxVoices < 1) return;
562    
563     MainForm *pMainForm = MainForm::getInstance();
564     if (!pMainForm || !pMainForm->client())
565     return;
566    
567     lscp_status_t result =
568     ::lscp_set_voices(pMainForm->client(), iMaxVoices);
569    
570     if (result != LSCP_OK) {
571     pMainForm->appendMessagesClient("lscp_set_voices");
572     return;
573     }
574    
575     this->iMaxVoices = iMaxVoices;
576     #endif // CONFIG_MAX_VOICES
577     }
578    
579     int Options::getMaxStreams() {
580     #ifndef CONFIG_MAX_VOICES
581     return -1;
582     #else
583     if (iMaxStreams > 0) return iMaxStreams;
584     return getEffectiveMaxStreams();
585     #endif // CONFIG_MAX_VOICES
586     }
587    
588     int Options::getEffectiveMaxStreams() {
589     #ifndef CONFIG_MAX_VOICES
590     return -1;
591     #else
592     MainForm *pMainForm = MainForm::getInstance();
593     if (!pMainForm || !pMainForm->client())
594     return -1;
595    
596     return ::lscp_get_streams(pMainForm->client());
597     #endif // CONFIG_MAX_VOICES
598     }
599    
600     void Options::setMaxStreams(int iMaxStreams) {
601     #ifdef CONFIG_MAX_VOICES
602     if (iMaxStreams < 0) return;
603    
604     MainForm *pMainForm = MainForm::getInstance();
605     if (!pMainForm || !pMainForm->client())
606     return;
607    
608     lscp_status_t result =
609     ::lscp_set_streams(pMainForm->client(), iMaxStreams);
610    
611     if (result != LSCP_OK) {
612     pMainForm->appendMessagesClient("lscp_set_streams");
613     return;
614     }
615    
616     this->iMaxStreams = iMaxStreams;
617     #endif // CONFIG_MAX_VOICES
618     }
619    
620     void Options::sendFineTuningSettings() {
621     setMaxVoices(iMaxVoices);
622     setMaxStreams(iMaxStreams);
623    
624     MainForm *pMainForm = MainForm::getInstance();
625     if (!pMainForm || !pMainForm->client())
626     return;
627    
628     pMainForm->appendMessages(QObject::tr("Sent fine tuning settings."));
629     }
630    
631 capela 1558 } // namespace QSampler
632 capela 106
633 capela 1558
634 capela 106 // end of qsamplerOptions.cpp
635 capela 3067

  ViewVC Help
Powered by ViewVC