summaryrefslogtreecommitdiff
path: root/muse2/muse/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'muse2/muse/main.cpp')
-rw-r--r--muse2/muse/main.cpp517
1 files changed, 309 insertions, 208 deletions
diff --git a/muse2/muse/main.cpp b/muse2/muse/main.cpp
index de2e2512..600ee79b 100644
--- a/muse2/muse/main.cpp
+++ b/muse2/muse/main.cpp
@@ -36,8 +36,11 @@
#include <QString>
#include <QStringList>
#include <QStyle>
+#include <QStyleFactory>
+#include <iostream>
-
+#include <unistd.h>
+#include <time.h>
#include <sys/mman.h>
#include <alsa/asoundlib.h>
@@ -49,11 +52,13 @@
#include "gconfig.h"
#include "globals.h"
#include "helper.h"
-#include "icons.h"
#include "sync.h"
#include "functions.h"
#include "appearance.h"
#include "midiseq.h"
+#include "minstrument.h"
+#include "midiport.h"
+#include "mididev.h"
#ifdef HAVE_LASH
#include <lash/lash.h>
@@ -69,12 +74,19 @@ extern void initVST();
extern void initPlugins();
extern void initDSSI();
extern void readConfiguration();
+
+extern void initMidiSequencer();
+extern void initAudio();
+extern void initAudioPrefetch();
+extern void initMidiSynth();
+
extern snd_seq_t * alsaSeq;
+extern void setAlsaClientName(const char*);
}
namespace MusEGui {
-extern void initIcons();
-extern void initShortCuts();
+void initIcons();
+void initShortCuts();
#ifdef HAVE_LASH
extern lash_client_t * lash_client;
#endif
@@ -210,38 +222,58 @@ static QString localeList()
static void usage(const char* prog, const char* txt)
{
- fprintf(stderr, "%s: %s\nusage: %s flags midifile\n Flags:\n",
+ fprintf(stderr, "\n");
+ fprintf(stderr, "%s: %s\nUsage: %s flags midifile\n Flags:\n",
prog, txt, prog);
- fprintf(stderr, " -h this help\n");
- fprintf(stderr, " -v print version\n");
- fprintf(stderr, " -d debug mode: no threads, no RT\n");
- fprintf(stderr, " -D debug mode: enable some debug messages\n");
- fprintf(stderr, " specify twice for lots of debug messages\n");
- fprintf(stderr, " this may slow down MusE massively!\n");
- fprintf(stderr, " -m debug mode: trace midi Input\n");
- fprintf(stderr, " -M debug mode: trace midi Output\n");
- fprintf(stderr, " -s debug mode: trace sync\n");
- fprintf(stderr, " -u ubuntu/unity workaround: don't allow sharing menus\n");
- fprintf(stderr, " and mdi-subwins.\n");
- fprintf(stderr, " -a no audio\n");
- fprintf(stderr, " -P n set audio driver real time priority to n\n");
- fprintf(stderr, " (Dummy only, default 40. Else fixed by Jack.)\n");
- fprintf(stderr, " -Y n force midi real time priority to n (default: audio driver prio +2)\n");
- fprintf(stderr, " -p don't load LADSPA plugins\n");
-#ifdef ENABLE_PYTHON
- fprintf(stderr, " -y enable Python control support\n");
-#endif
+ fprintf(stderr, " -h This help\n");
+ fprintf(stderr, " -v Print version\n");
+ fprintf(stderr, " -a No audio, use dummy audio driver, plus ALSA midi\n");
+ fprintf(stderr, " -A Force inclusion of ALSA midi even if using Jack\n");
+ fprintf(stderr, " -P n Set audio driver real time priority to n\n");
+ fprintf(stderr, " (Dummy only, default 40. Else fixed by Jack.)\n");
+ fprintf(stderr, " -Y n Force midi real time priority to n (default: audio driver prio +2)\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, " -p Don't load LADSPA plugins\n");
#ifdef VST_SUPPORT
- fprintf(stderr, " -V don't load VST plugins\n");
+ fprintf(stderr, " -V Don't load VST plugins\n");
#endif
#ifdef DSSI_SUPPORT
- fprintf(stderr, " -I don't load DSSI plugins\n");
+ fprintf(stderr, " -I Don't load DSSI plugins\n");
#endif
#ifdef HAVE_LASH
- fprintf(stderr, " -L don't use LASH\n");
+ fprintf(stderr, " -L Don't use LASH\n");
+#endif
+#ifdef ENABLE_PYTHON
+ fprintf(stderr, " -y Enable Python control support\n");
#endif
- fprintf(stderr, " -l xx force locale to the given language/country code\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, " -l xx Force locale to the given language/country code\n");
fprintf(stderr, " (xx = %s)\n", localeList().toLatin1().constData());
+ fprintf(stderr, " -u Ubuntu/unity workaround: don't allow sharing menus\n");
+ fprintf(stderr, " and mdi-subwins.\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, " -d Debug mode: no threads, no RT\n");
+ fprintf(stderr, " -D Debug mode: enable some debug messages\n");
+ fprintf(stderr, " specify twice for lots of debug messages\n");
+ fprintf(stderr, " this may slow down MusE massively!\n");
+ fprintf(stderr, " -m Debug mode: trace midi Input\n");
+ fprintf(stderr, " -M Debug mode: trace midi Output\n");
+ fprintf(stderr, " -s Debug mode: trace sync\n");
+ fprintf(stderr, "\n");
+#ifdef HAVE_LASH
+ fprintf(stderr, "LASH and ");
+#endif
+ fprintf(stderr, "Qt options are also accepted. Some common Qt options:\n");
+ fprintf(stderr, " -style [=] style Set application GUI style. Motif, Windows, Platinum etc.\n"
+ " -stylesheet [=] stylesheet Set application styleSheet\n"
+ " -session [=] session Restore application from an earlier session\n"
+ " -widgetcount Print debug message at end, about undestroyed/maximum widgets\n"
+ " -reverse Set application's layout direction to Qt::RightToLeft\n"
+ " -graphicssystem Set backend used for on-screen widgets/QPixmaps: raster or opengl\n"
+ " -qmljsdebugger = port Activate QML/JS debugger with port, formatted port:1234[,block]\n"
+ );
+
+ fprintf(stderr, "\n");
}
//---------------------------------------------------------
@@ -250,50 +282,17 @@ static void usage(const char* prog, const char* txt)
int main(int argc, char* argv[])
{
-
- MusEGlobal::ruid = getuid();
- MusEGlobal::euid = geteuid();
- MusEGlobal::undoSetuid();
- getCapabilities();
- int noAudio = false;
-
MusEGlobal::museUser = QString(getenv("HOME"));
MusEGlobal::museGlobalLib = QString(LIBDIR);
MusEGlobal::museGlobalShare = QString(SHAREDIR);
MusEGlobal::museProject = MusEGlobal::museProjectInitPath; //getcwd(0, 0);
MusEGlobal::museInstruments = MusEGlobal::museGlobalShare + QString("/instruments");
- // Create config dir if it doesn't exists
+ // Create config dir if it doesn't exist
QDir cPath = QDir(MusEGlobal::configPath);
if (! cPath.exists())
cPath.mkpath(".");
- // Create user templates dir if it doesn't exist
- QDir utemplDir = QDir(MusEGlobal::configPath + QString("/templates"));
- if(!utemplDir.exists())
- {
- utemplDir.mkpath(".");
- // Support old versions: Copy existing templates over.
- QDir old_utemplDir = QDir(QString(getenv("HOME")) + QString("/templates"));
- if(old_utemplDir.exists())
- {
- // We really just want these, even though it's possible other filenames were saved.
- // Another application might have used that directory.
- QStringList flt;
- flt << "*.med" << "*.med.gz" << "*.med.bz2" << "*.mid" << "*.midi" << "*.kar";
- old_utemplDir.setNameFilters(flt);
-
- QFileInfoList fil = old_utemplDir.entryInfoList();
- QFileInfo fi;
- foreach(fi, fil)
- {
- QString fn = fi.fileName();
- QFile f(fi.absoluteFilePath());
- f.copy(utemplDir.absolutePath() + "/" + fn);
- }
- }
- }
-
QFile cConf (MusEGlobal::configName);
QFile cConfTempl (MusEGlobal::museGlobalShare + QString("/templates/MusE.cfg"));
bool cConfExists = cConf.exists();
@@ -317,82 +316,38 @@ int main(int argc, char* argv[])
printf (" FAILED!\n");
}
-#ifdef HAVE_LASH
- lash_args_t * lash_args = 0;
- if(MusEGlobal::useLASH)
- lash_args = lash_extract_args (&argc, &argv);
-#endif
-
- srand(time(0)); // initialize random number generator
-// signal(SIGCHLD, catchSignal); // interferes with initVST(). see also app.cpp, function catchSignal()
- MusECore::initMidiController();
- QApplication::setColorSpec(QApplication::ManyColor);
- MuseApplication app(argc, argv);
- MusEGui::Appearance::defaultStyle = MuseApplication::style()->objectName();
-
- MusEGui::init_function_dialogs(MusEGlobal::muse);
MusEGui::initShortCuts();
-
MusECore::readConfiguration();
-
- // Need to put a sane default here because we can't use ~ in the file name string.
+
+ // Need to put a sane defaults here because we can't use '~' in the file name strings.
if(!cConfExists)
- MusEGlobal::config.projectBaseFolder = MusEGlobal::museUser + QString("/MusE");
-
- // Create user instruments dir if it doesn't exist
{
- QString uinstrPath = MusEGlobal::configPath + QString("/instruments");
- QDir uinstrDir = QDir(uinstrPath);
- if(!uinstrDir.exists())
- uinstrDir.mkpath(".");
-
- if(!MusEGlobal::config.userInstrumentsDir.isEmpty() && MusEGlobal::config.userInstrumentsDir != uinstrPath) // Only if it is different.
- {
- // Support old versions: Copy existing instruments over.
- QDir old_uinstrDir(MusEGlobal::config.userInstrumentsDir);
- if(old_uinstrDir.exists())
- {
- QStringList flt; flt << "*.idf";
- old_uinstrDir.setNameFilters(flt);
-
- QFileInfoList fil = old_uinstrDir.entryInfoList();
- QFileInfo fi;
- foreach(fi, fil)
- {
- QString fn = fi.fileName();
- QFile f(fi.absoluteFilePath());
- QFile newf(uinstrDir.absolutePath() + "/" + fn);
- if(!newf.exists())
- {
- f.copy(newf.fileName());
- }
- }
- }
- }
- MusEGlobal::museUserInstruments = uinstrPath;
+ MusEGlobal::config.projectBaseFolder = MusEGlobal::museUser + QString("/MusE");
+ MusEGlobal::config.startSong = MusEGlobal::museGlobalShare + QString("/templates/default.med");
}
- if (MusEGlobal::config.useDenormalBias)
- printf("Denormal protection enabled.\n");
- // SHOW MUSE SPLASH SCREEN
- if (MusEGlobal::config.showSplashScreen) {
- QPixmap splsh(MusEGlobal::museGlobalShare + "/splash.png");
-
- if (!splsh.isNull()) {
- QSplashScreen* muse_splash = new QSplashScreen(splsh,
- Qt::WindowStaysOnTopHint);
- muse_splash->setAttribute(Qt::WA_DeleteOnClose); // Possibly also Qt::X11BypassWindowManagerHint
- muse_splash->show();
- QTimer* stimer = new QTimer(0);
- muse_splash->connect(stimer, SIGNAL(timeout()), muse_splash, SLOT(close()));
- stimer->setSingleShot(true);
- stimer->start(6000);
- }
- }
-
- int i;
+ // May need this. Tested OK. Grab the default style BEFORE calling setStyle and creating the app.
+ //{ int dummy_argc = 1; char** dummy_argv = &argv[0];
+ // QApplication dummy_app(dummy_argc, dummy_argv);
+ // MusEGui::Appearance::defaultStyle = dummy_app.style()->objectName(); }
+ //QStringList sl = QStyleFactory::keys();
+ //if (sl.indexOf(MusEGlobal::config.style) != -1) {
+ // QStyle* style = QApplication::setStyle(MusEGlobal::config.style);
+ // style->setObjectName(MusEGlobal::config.style);
+ //}
+
+ // Let LASH remove its recognized arguments first (generally longer than Qt's).
+ // Tip: LADISH's LASH emulation (current 1.0) does not take any arguments.
+#ifdef HAVE_LASH
+ lash_args_t * lash_args = 0;
+ lash_args = lash_extract_args (&argc, &argv);
+#endif
- QString optstr("ahvdDumMsP:Y:l:py");
+ // Now create the application, and let Qt remove recognized arguments.
+ MuseApplication app(argc, argv);
+ MusEGui::Appearance::defaultStyle = app.style()->objectName(); // NOTE: May need alternate method, above.
+
+ QString optstr("aAhvdDumMsP:Y:l:py");
#ifdef VST_SUPPORT
optstr += QString("V");
#endif
@@ -402,23 +357,35 @@ int main(int argc, char* argv[])
#ifdef HAVE_LASH
optstr += QString("L");
#endif
-
+
+ bool noAudio = false;
+ int i;
+
+ // Now read the remaining arguments as our own...
while ((i = getopt(argc, argv, optstr.toLatin1().constData())) != EOF) {
char c = (char)i;
switch (c) {
- case 'v': printVersion(argv[0]); return 0;
+ case 'v': printVersion(argv[0]);
+#ifdef HAVE_LASH
+ if(lash_args) lash_args_destroy(lash_args);
+#endif
+ return 0;
+ case 'a':
+ noAudio = true;
+ break;
+ case 'A':
+ MusEGlobal::useAlsaWithJack = true;
+ break;
case 'd':
MusEGlobal::debugMode = true;
MusEGlobal::realTimeScheduling = false;
break;
- case 'a':
- noAudio = true;
- break;
case 'D':
if (!MusEGlobal::debugMsg)
MusEGlobal::debugMsg=true;
else
MusEGlobal::heavyDebugMsg=true;
+ break;
case 'm': MusEGlobal::midiInputTrace = true; break;
case 'M': MusEGlobal::midiOutputTrace = true; break;
case 's': MusEGlobal::debugSync = true; break;
@@ -428,20 +395,188 @@ int main(int argc, char* argv[])
case 'p': MusEGlobal::loadPlugins = false; break;
case 'V': MusEGlobal::loadVST = false; break;
case 'I': MusEGlobal::loadDSSI = false; break;
- case 'L': MusEGlobal::useLASH = false; break;
+ case 'L': MusEGlobal::useLASH = false; break;
case 'y': MusEGlobal::usePythonBridge = true; break;
case 'l': locale_override = QString(optarg); break;
- case 'h': usage(argv[0], argv[1]); return -1;
- default: usage(argv[0], "bad argument"); return -1;
+ case 'h': usage(argv[0], argv[1]);
+#ifdef HAVE_LASH
+ if(lash_args) lash_args_destroy(lash_args);
+#endif
+ return -1;
+ default: usage(argv[0], "bad argument");
+#ifdef HAVE_LASH
+ if(lash_args) lash_args_destroy(lash_args);
+#endif
+ return -1;
}
}
+
+ argc -= optind;
+ ++argc;
+
+ MusEGlobal::ruid = getuid();
+ MusEGlobal::euid = geteuid();
+ MusEGlobal::undoSetuid();
+ getCapabilities();
+ if (MusEGlobal::debugMsg)
+ printf("Start euid: %d ruid: %d, Now euid %d\n",
+ MusEGlobal::euid, MusEGlobal::ruid, geteuid());
+
+ srand(time(0)); // initialize random number generator
+ //signal(SIGCHLD, catchSignal); // interferes with initVST(). see also app.cpp, function catchSignal()
+ static QTranslator translator(0);
+ QString locale(QLocale::system().name());
+ if (locale_override.length() >0 )
+ locale = locale_override;
+ if (locale != "C") {
+ QString loc("muse_");
+ loc += locale;
+ if (translator.load(loc, QString(".")) == false) {
+ QString lp(MusEGlobal::museGlobalShare);
+ lp += QString("/locale");
+ if (translator.load(loc, lp) == false) {
+ printf("no locale <%s>/<%s>\n", loc.toLatin1().constData(), lp.toLatin1().constData());
+ }
+ }
+ app.installTranslator(&translator);
+ }
+ printf("LOCALE %s\n",QLocale::system().name().toLatin1().data());
+
+ if (QLocale::system().name() == "de" || locale_override == "de") {
+ printf("locale de - setting override parameter.\n");
+ MusEGlobal::hIsB = false;
+ }
+
+ QApplication::addLibraryPath(MusEGlobal::museGlobalLib + "/qtplugins");
+ if (MusEGlobal::debugMsg) {
+ QStringList list = app.libraryPaths();
+ QStringList::Iterator it = list.begin();
+ printf("QtLibraryPath:\n");
+ while(it != list.end()) {
+ printf(" <%s>\n", (*it).toLatin1().constData());
+ ++it;
+ }
+ }
+
+ // Create user templates dir if it doesn't exist
+ QDir utemplDir = QDir(MusEGlobal::configPath + QString("/templates"));
+ if(!utemplDir.exists())
+ {
+ utemplDir.mkpath(".");
+ // Support old versions: Copy existing templates over.
+ QDir old_utemplDir = QDir(QString(getenv("HOME")) + QString("/templates"));
+ if(old_utemplDir.exists())
+ {
+ // We really just want these, even though it's possible other filenames were saved.
+ // Another application might have used that directory.
+ QStringList flt;
+ flt << "*.med" << "*.med.gz" << "*.med.bz2" << "*.mid" << "*.midi" << "*.kar";
+ old_utemplDir.setNameFilters(flt);
+
+ QFileInfoList fil = old_utemplDir.entryInfoList();
+ QFileInfo fi;
+ foreach(fi, fil)
+ {
+ QString fn = fi.fileName();
+ QFile f(fi.absoluteFilePath());
+ f.copy(utemplDir.absolutePath() + "/" + fn);
+ }
+ }
+ }
+
+ // Create user instruments dir if it doesn't exist
+ QString uinstrPath = MusEGlobal::configPath + QString("/instruments");
+ QDir uinstrDir = QDir(uinstrPath);
+ if(!uinstrDir.exists())
+ uinstrDir.mkpath(".");
+ if(!MusEGlobal::config.userInstrumentsDir.isEmpty() && MusEGlobal::config.userInstrumentsDir != uinstrPath) // Only if it is different.
+ {
+ // Support old versions: Copy existing instruments over.
+ QDir old_uinstrDir(MusEGlobal::config.userInstrumentsDir);
+ if(old_uinstrDir.exists())
+ {
+ QStringList flt; flt << "*.idf";
+ old_uinstrDir.setNameFilters(flt);
+
+ QFileInfoList fil = old_uinstrDir.entryInfoList();
+ QFileInfo fi;
+ foreach(fi, fil)
+ {
+ QString fn = fi.fileName();
+ QFile f(fi.absoluteFilePath());
+ QFile newf(uinstrDir.absolutePath() + "/" + fn);
+ if(!newf.exists())
+ {
+ f.copy(newf.fileName());
+ }
+ }
+ }
+ }
+ MusEGlobal::museUserInstruments = uinstrPath;
+
+ // NOTE: May need alternate method, above.
+ // If setStyle is called after MusE is created, bug: I get transparent background in MDI windows, other artifacts.
+ // Docs say any style should be set before QApplication created, but this actually works OK up to that point!
+ QStringList sl = QStyleFactory::keys();
+ if (sl.indexOf(MusEGlobal::config.style) != -1)
+ {
+ QStyle* style = app.setStyle(MusEGlobal::config.style);
+ style->setObjectName(MusEGlobal::config.style);
+ }
AL::initDsp();
+ MusECore::initAudio();
+
+ MusEGui::initIcons();
+
+ MusEGlobal::muse = new MusEGui::MusE();
+ app.setMuse(MusEGlobal::muse);
+
+ MusEGui::init_function_dialogs(MusEGlobal::muse);
+ MusEGui::retranslate_function_dialogs();
+
+ // SHOW MUSE SPLASH SCREEN
+ if (MusEGlobal::config.showSplashScreen) {
+ QPixmap splsh(MusEGlobal::museGlobalShare + "/splash.png");
+
+ if (!splsh.isNull()) {
+ QSplashScreen* muse_splash = new QSplashScreen(splsh,
+ Qt::WindowStaysOnTopHint);
+ muse_splash->setAttribute(Qt::WA_DeleteOnClose); // Possibly also Qt::X11BypassWindowManagerHint
+ muse_splash->show();
+ QTimer* stimer = new QTimer(0);
+ muse_splash->connect(stimer, SIGNAL(timeout()), muse_splash, SLOT(close()));
+ stimer->setSingleShot(true);
+ stimer->start(6000);
+ }
+ }
+
+ if (MusEGlobal::config.useDenormalBias)
+ printf("Denormal protection enabled.\n");
+ if (MusEGlobal::debugMsg) {
+ printf("global lib: <%s>\n", MusEGlobal::museGlobalLib.toLatin1().constData());
+ printf("global share: <%s>\n", MusEGlobal::museGlobalShare.toLatin1().constData());
+ printf("muse home: <%s>\n", MusEGlobal::museUser.toLatin1().constData());
+ printf("project dir: <%s>\n", MusEGlobal::museProject.toLatin1().constData());
+ printf("user instruments: <%s>\n", MusEGlobal::museUserInstruments.toLatin1().constData());
+ }
+
+ //rlimit lim; getrlimit(RLIMIT_RTPRIO, &lim);
+ //printf("RLIMIT_RTPRIO soft:%d hard:%d\n", lim.rlim_cur, lim.rlim_max); // Reported 80, 80 even with non-RT kernel.
+ if (MusEGlobal::realTimePriority < sched_get_priority_min(SCHED_FIFO))
+ MusEGlobal::realTimePriority = sched_get_priority_min(SCHED_FIFO);
+ else if (MusEGlobal::realTimePriority > sched_get_priority_max(SCHED_FIFO))
+ MusEGlobal::realTimePriority = sched_get_priority_max(SCHED_FIFO);
+ // If we requested to force the midi thread priority...
+ if(MusEGlobal::midiRTPrioOverride > 0)
+ {
+ if (MusEGlobal::midiRTPrioOverride < sched_get_priority_min(SCHED_FIFO))
+ MusEGlobal::midiRTPrioOverride = sched_get_priority_min(SCHED_FIFO);
+ else if (MusEGlobal::midiRTPrioOverride > sched_get_priority_max(SCHED_FIFO))
+ MusEGlobal::midiRTPrioOverride = sched_get_priority_max(SCHED_FIFO);
+ }
- if (MusEGlobal::debugMsg)
- printf("Start euid: %d ruid: %d, Now euid %d\n",
- MusEGlobal::euid, MusEGlobal::ruid, geteuid());
if (MusEGlobal::debugMode) {
MusECore::initDummyAudio();
MusEGlobal::realTimeScheduling = false;
@@ -483,45 +618,26 @@ int main(int argc, char* argv[])
// I cannot seem to find a reliable answer to the question, even with dummy audio and system calls.
MusEGlobal::useJackTransport.setValue(true);
-
+
// setup the prefetch fifo length now that the segmentSize is known
MusEGlobal::fifoLength = 131072 / MusEGlobal::segmentSize;
+ MusECore::initAudioPrefetch();
+
+ // WARNING Must do it this way. Call registerClient long AFTER Jack client is created and MusE ALSA client is
+ // created (in initMidiDevices), otherwise random crashes can occur within Jack <= 1.9.8. Fixed in Jack 1.9.9. Tim.
+ MusECore::initMidiDevices();
+ // Wait until things have settled. One second seems OK so far.
+ for(int t = 0; t < 100; ++t)
+ usleep(10000);
+ // Now it is safe to call registerClient.
+ MusEGlobal::audioDevice->registerClient();
- argc -= optind;
- ++argc;
-
- if (MusEGlobal::debugMsg) {
- printf("global lib: <%s>\n", MusEGlobal::museGlobalLib.toLatin1().constData());
- printf("global share: <%s>\n", MusEGlobal::museGlobalShare.toLatin1().constData());
- printf("muse home: <%s>\n", MusEGlobal::museUser.toLatin1().constData());
- printf("project dir: <%s>\n", MusEGlobal::museProject.toLatin1().constData());
- printf("user instruments: <%s>\n", MusEGlobal::museUserInstruments.toLatin1().constData());
- }
-
- static QTranslator translator(0);
- QString locale(QApplication::keyboardInputLocale().name());
- if (locale_override.length())
- locale = locale_override;
- if (locale != "C") {
- QString loc("muse_");
- loc += locale;
- if (translator.load(loc, QString(".")) == false) {
- QString lp(MusEGlobal::museGlobalShare);
- lp += QString("/locale");
- if (translator.load(loc, lp) == false) {
- printf("no locale <%s>/<%s>\n", loc.toLatin1().constData(), lp.toLatin1().constData());
- }
- }
- app.installTranslator(&translator);
- }
+ MusECore::initMidiController();
+ MusECore::initMidiInstruments();
+ MusECore::initMidiPorts();
+ MusECore::initMidiSequencer();
+ MusEGlobal::midiSeq->checkAndReportTimingResolution();
- if (locale == "de") {
- printf("locale de\n");
- MusEGlobal::hIsB = false;
- }
-
- MusEGui::retranslate_function_dialogs();
-
if (MusEGlobal::loadPlugins)
MusECore::initPlugins();
@@ -533,32 +649,9 @@ int main(int argc, char* argv[])
MusECore::initOSC();
- MusEGui::initIcons();
-
MusECore::initMetronome();
- QApplication::addLibraryPath(MusEGlobal::museGlobalLib + "/qtplugins");
- if (MusEGlobal::debugMsg) {
- QStringList list = app.libraryPaths();
- QStringList::Iterator it = list.begin();
- printf("QtLibraryPath:\n");
- while(it != list.end()) {
- printf(" <%s>\n", (*it).toLatin1().constData());
- ++it;
- }
- }
-
- MusEGlobal::muse = new MusEGui::MusE(argc, &argv[optind]);
- app.setMuse(MusEGlobal::muse);
- MusEGlobal::muse->setWindowIcon(*MusEGui::museIcon);
-
- if (!MusEGlobal::debugMode) {
- if (mlockall(MCL_CURRENT | MCL_FUTURE))
- perror("WARNING: Cannot lock memory:");
- }
-
- MusEGlobal::muse->show();
- MusEGlobal::muse->seqStart();
+ MusECore::initMidiSynth();
#ifdef HAVE_LASH
{
@@ -568,19 +661,30 @@ int main(int argc, char* argv[])
int lash_flags = LASH_Config_File;
const char *muse_name = PACKAGE_NAME;
MusEGui::lash_client = lash_init (lash_args, muse_name, lash_flags, LASH_PROTOCOL(2,0));
- lash_alsa_client_id (MusEGui::lash_client, snd_seq_client_id (MusECore::alsaSeq));
+ if(MusECore::alsaSeq)
+ lash_alsa_client_id (MusEGui::lash_client, snd_seq_client_id (MusECore::alsaSeq));
if (!noAudio) {
const char *jack_name = MusEGlobal::audioDevice->clientName();
lash_jack_client_name (MusEGui::lash_client, jack_name);
}
}
+ if(lash_args)
+ lash_args_destroy(lash_args);
}
#endif /* HAVE_LASH */
+ if (!MusEGlobal::debugMode) {
+ if (mlockall(MCL_CURRENT | MCL_FUTURE))
+ perror("WARNING: Cannot lock memory:");
+ }
+
+ MusEGlobal::muse->show();
+ MusEGlobal::muse->seqStart();
+
//--------------------------------------------------
- // Auto-fill the midi ports, if appropriate. p4.0.41
+ // Auto-fill the midi ports, if appropriate.
//--------------------------------------------------
- if(argc < 2 && MusEGlobal::config.startMode == 1)
+ if(argc < 2 && (MusEGlobal::config.startMode == 1 || MusEGlobal::config.startMode == 2) && !MusEGlobal::config.startSongLoadConfig)
{
MusEGui::populateMidiPorts();
//MusEGlobal::muse->changeConfig(true); // save configuration file
@@ -590,11 +694,8 @@ int main(int argc, char* argv[])
//--------------------------------------------------
// Load the default song.
//--------------------------------------------------
- MusEGlobal::muse->loadDefaultSong(argc, &argv[optind]); // p4.0.41
+ MusEGlobal::muse->loadDefaultSong(argc, &argv[optind]);
- MusEGlobal::midiSeq->checkAndReportTimingResolution();
-
-
QTimer::singleShot(100, MusEGlobal::muse, SLOT(showDidYouKnowDialog()));
int rv = app.exec();