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