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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC