1 |
// qsamplerOptions.cpp |
// qsamplerOptions.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2008, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2009, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, Christian Schoenebeck |
Copyright (C) 2007, Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
22 |
|
|
23 |
#include "qsamplerAbout.h" |
#include "qsamplerAbout.h" |
24 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
25 |
|
#include "qsamplerMainForm.h" |
26 |
|
|
27 |
#include <QTextStream> |
#include <QTextStream> |
28 |
#include <QComboBox> |
#include <QComboBox> |
118 |
} |
} |
119 |
m_settings.endGroup(); |
m_settings.endGroup(); |
120 |
|
|
121 |
|
// Sampler fine tuning settings. |
122 |
|
m_settings.beginGroup("/Tuning"); |
123 |
|
iMaxVoices = m_settings.value("/MaxVoices", -1).toInt(); |
124 |
|
iMaxStreams = m_settings.value("/MaxStreams", -1).toInt(); |
125 |
|
m_settings.endGroup(); |
126 |
|
|
127 |
// Last but not least, get the default directories. |
// Last but not least, get the default directories. |
128 |
m_settings.beginGroup("/Default"); |
m_settings.beginGroup("/Default"); |
129 |
sSessionDir = m_settings.value("/SessionDir").toString(); |
sSessionDir = m_settings.value("/SessionDir").toString(); |
204 |
m_settings.setValue("/File" + QString::number(++iFile), iter.next()); |
m_settings.setValue("/File" + QString::number(++iFile), iter.next()); |
205 |
m_settings.endGroup(); |
m_settings.endGroup(); |
206 |
|
|
207 |
|
// Sampler fine tuning settings. |
208 |
|
m_settings.beginGroup("/Tuning"); |
209 |
|
if (iMaxVoices > 0) |
210 |
|
m_settings.setValue("/MaxVoices", iMaxVoices); |
211 |
|
if (iMaxStreams >= 0) |
212 |
|
m_settings.setValue("/MaxStreams", iMaxStreams); |
213 |
|
m_settings.endGroup(); |
214 |
|
|
215 |
// Default directories. |
// Default directories. |
216 |
m_settings.beginGroup("/Default"); |
m_settings.beginGroup("/Default"); |
217 |
m_settings.setValue("/SessionDir", sSessionDir); |
m_settings.setValue("/SessionDir", sSessionDir); |
242 |
// |
// |
243 |
|
|
244 |
// Help about command line options. |
// Help about command line options. |
245 |
void Options::print_usage ( const char *arg0 ) |
void Options::print_usage ( const QString& arg0 ) |
246 |
{ |
{ |
247 |
QTextStream out(stderr); |
QTextStream out(stderr); |
248 |
out << QObject::tr("Usage: %1 [options] [session-file]\n\n" |
out << QObject::tr("Usage: %1 [options] [session-file]\n\n" |
258 |
|
|
259 |
|
|
260 |
// Parse command line arguments into m_settings. |
// Parse command line arguments into m_settings. |
261 |
bool Options::parse_args ( int argc, char **argv ) |
bool Options::parse_args ( const QStringList& args ) |
262 |
{ |
{ |
263 |
QTextStream out(stderr); |
QTextStream out(stderr); |
264 |
const QString sEol = "\n\n"; |
const QString sEol = "\n\n"; |
265 |
int iCmdArgs = 0; |
int iCmdArgs = 0; |
266 |
|
int argc = args.count(); |
267 |
|
|
268 |
for (int i = 1; i < argc; i++) { |
for (int i = 1; i < argc; i++) { |
269 |
|
|
270 |
if (iCmdArgs > 0) { |
if (iCmdArgs > 0) { |
271 |
sSessionFile += " "; |
sSessionFile += " "; |
272 |
sSessionFile += argv[i]; |
sSessionFile += args.at(i); |
273 |
iCmdArgs++; |
iCmdArgs++; |
274 |
continue; |
continue; |
275 |
} |
} |
276 |
|
|
277 |
QString sArg = argv[i]; |
QString sArg = args.at(i); |
278 |
QString sVal = QString::null; |
QString sVal = QString::null; |
279 |
int iEqual = sArg.indexOf("="); |
int iEqual = sArg.indexOf("="); |
280 |
if (iEqual >= 0) { |
if (iEqual >= 0) { |
281 |
sVal = sArg.right(sArg.length() - iEqual - 1); |
sVal = sArg.right(sArg.length() - iEqual - 1); |
282 |
sArg = sArg.left(iEqual); |
sArg = sArg.left(iEqual); |
283 |
} |
} |
284 |
else if (i < argc) |
else if (i < argc - 1) |
285 |
sVal = argv[i + 1]; |
sVal = args.at(i + 1); |
286 |
|
|
287 |
if (sArg == "-s" || sArg == "--start") { |
if (sArg == "-s" || sArg == "--start") { |
288 |
bServerStart = true; |
bServerStart = true; |
306 |
i++; |
i++; |
307 |
} |
} |
308 |
else if (sArg == "-?" || sArg == "--help") { |
else if (sArg == "-?" || sArg == "--help") { |
309 |
print_usage(argv[0]); |
print_usage(args.at(0)); |
310 |
return false; |
return false; |
311 |
} |
} |
312 |
else if (sArg == "-v" || sArg == "--version") { |
else if (sArg == "-v" || sArg == "--version") { |
441 |
m_settings.endGroup(); |
m_settings.endGroup(); |
442 |
} |
} |
443 |
|
|
444 |
|
int Options::getMaxVoices() { |
445 |
|
#ifndef CONFIG_MAX_VOICES |
446 |
|
return -1; |
447 |
|
#else |
448 |
|
if (iMaxVoices > 0) return iMaxVoices; |
449 |
|
return getEffectiveMaxVoices(); |
450 |
|
#endif // CONFIG_MAX_VOICES |
451 |
|
} |
452 |
|
|
453 |
|
int Options::getEffectiveMaxVoices() { |
454 |
|
#ifndef CONFIG_MAX_VOICES |
455 |
|
return -1; |
456 |
|
#else |
457 |
|
MainForm *pMainForm = MainForm::getInstance(); |
458 |
|
if (!pMainForm || !pMainForm->client()) |
459 |
|
return -1; |
460 |
|
|
461 |
|
return ::lscp_get_voices(pMainForm->client()); |
462 |
|
#endif // CONFIG_MAX_VOICES |
463 |
|
} |
464 |
|
|
465 |
|
void Options::setMaxVoices(int iMaxVoices) { |
466 |
|
#ifdef CONFIG_MAX_VOICES |
467 |
|
if (iMaxVoices < 1) return; |
468 |
|
|
469 |
|
MainForm *pMainForm = MainForm::getInstance(); |
470 |
|
if (!pMainForm || !pMainForm->client()) |
471 |
|
return; |
472 |
|
|
473 |
|
lscp_status_t result = |
474 |
|
::lscp_set_voices(pMainForm->client(), iMaxVoices); |
475 |
|
|
476 |
|
if (result != LSCP_OK) { |
477 |
|
pMainForm->appendMessagesClient("lscp_set_voices"); |
478 |
|
return; |
479 |
|
} |
480 |
|
|
481 |
|
this->iMaxVoices = iMaxVoices; |
482 |
|
#endif // CONFIG_MAX_VOICES |
483 |
|
} |
484 |
|
|
485 |
|
int Options::getMaxStreams() { |
486 |
|
#ifndef CONFIG_MAX_VOICES |
487 |
|
return -1; |
488 |
|
#else |
489 |
|
if (iMaxStreams > 0) return iMaxStreams; |
490 |
|
return getEffectiveMaxStreams(); |
491 |
|
#endif // CONFIG_MAX_VOICES |
492 |
|
} |
493 |
|
|
494 |
|
int Options::getEffectiveMaxStreams() { |
495 |
|
#ifndef CONFIG_MAX_VOICES |
496 |
|
return -1; |
497 |
|
#else |
498 |
|
MainForm *pMainForm = MainForm::getInstance(); |
499 |
|
if (!pMainForm || !pMainForm->client()) |
500 |
|
return -1; |
501 |
|
|
502 |
|
return ::lscp_get_streams(pMainForm->client()); |
503 |
|
#endif // CONFIG_MAX_VOICES |
504 |
|
} |
505 |
|
|
506 |
|
void Options::setMaxStreams(int iMaxStreams) { |
507 |
|
#ifdef CONFIG_MAX_VOICES |
508 |
|
if (iMaxStreams < 0) return; |
509 |
|
|
510 |
|
MainForm *pMainForm = MainForm::getInstance(); |
511 |
|
if (!pMainForm || !pMainForm->client()) |
512 |
|
return; |
513 |
|
|
514 |
|
lscp_status_t result = |
515 |
|
::lscp_set_streams(pMainForm->client(), iMaxStreams); |
516 |
|
|
517 |
|
if (result != LSCP_OK) { |
518 |
|
pMainForm->appendMessagesClient("lscp_set_streams"); |
519 |
|
return; |
520 |
|
} |
521 |
|
|
522 |
|
this->iMaxStreams = iMaxStreams; |
523 |
|
#endif // CONFIG_MAX_VOICES |
524 |
|
} |
525 |
|
|
526 |
|
void Options::sendFineTuningSettings() { |
527 |
|
setMaxVoices(iMaxVoices); |
528 |
|
setMaxStreams(iMaxStreams); |
529 |
|
|
530 |
|
MainForm *pMainForm = MainForm::getInstance(); |
531 |
|
if (!pMainForm || !pMainForm->client()) |
532 |
|
return; |
533 |
|
|
534 |
|
pMainForm->appendMessages(QObject::tr("Sent fine tuning settings.")); |
535 |
|
} |
536 |
|
|
537 |
} // namespace QSampler |
} // namespace QSampler |
538 |
|
|
539 |
|
|