From bc44788dfb4da39f7276f4bbd488b064d286d97f Mon Sep 17 00:00:00 2001 From: Werner Schweer Date: Wed, 10 May 2006 15:11:54 +0000 Subject: project handling --- muse/CMakeLists.txt | 2 +- muse/TODO | 26 +- muse/all.h | 1 + muse/muse/CMakeLists.txt | 6 +- muse/muse/conf.cpp | 11 +- muse/muse/dssihost.cpp | 2 +- muse/muse/exportmidi.cpp | 4 +- muse/muse/gconfig.cpp | 19 +- muse/muse/gconfig.h | 13 +- muse/muse/globals.cpp | 2 - muse/muse/globals.h | 2 - muse/muse/importmidi.cpp | 8 +- muse/muse/muse.cpp | 687 +++---- muse/muse/muse.h | 21 +- muse/muse/preferences.cpp | 39 +- muse/muse/preferences.h | 2 +- muse/muse/preferences.ui | 4156 ++++++++++++++++++++------------------- muse/muse/projectdialog.cpp | 143 ++ muse/muse/projectdialog.h | 43 + muse/muse/projectdialog.ui | 206 ++ muse/muse/song.cpp | 122 ++ muse/muse/song.h | 130 +- muse/muse/songfile.cpp | 80 +- muse/muse/synth.cpp | 2 +- muse/muse/wave.cpp | 14 +- muse/muse/waveedit/waveview.cpp | 4 +- muse/muse/waveevent.cpp | 11 +- 27 files changed, 3094 insertions(+), 2662 deletions(-) create mode 100644 muse/muse/projectdialog.cpp create mode 100644 muse/muse/projectdialog.h create mode 100644 muse/muse/projectdialog.ui diff --git a/muse/CMakeLists.txt b/muse/CMakeLists.txt index 97a81145..bb434178 100644 --- a/muse/CMakeLists.txt +++ b/muse/CMakeLists.txt @@ -20,7 +20,7 @@ project(muse) CMAKE_MINIMUM_REQUIRED(VERSION 2.4.1) -set(CMAKE_VERBOSE_MAKEFILE ON) +# set(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_INCLUDE_CURRENT_DIR TRUE) set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) set(CMAKE_SKIP_RULE_DEPENDENCY TRUE) diff --git a/muse/TODO b/muse/TODO index 2d83731e..ddb09e0d 100644 --- a/muse/TODO +++ b/muse/TODO @@ -1,17 +1,17 @@ -----------------------------TODO------------------------------------------- -(4.5.2006) - - manage project subdirectories (better organize wave files) - - muse is always associated with a project, there is no - "No Project" or "Default Project" - - muse on start asks for a project name (select or create) - - midi files cannot be loaded directly als project anymore, - you have to first create a project and then call - "import midifile" - - "New File" and "Select File" are combined into - "Select Project" - - there is no "Save As" anymore (your project always has a - name) - +(10.5.2006) + - Select Project Dialog: + - add Toolbar with Functions: + - create Subfolder + - Folder Up + - Folder Down + - display project subfolder + - show current project path in QLabel + - marke projects with different samplerat as current + - check for samplerate when loading project + - compute song len in seconds when saving project + - create dialog to edit project comment + BUGS - updating the gui during midi recording is too slow; a new, faster implementation is needed diff --git a/muse/all.h b/muse/all.h index 7200f872..17acda0e 100644 --- a/muse/all.h +++ b/muse/all.h @@ -46,6 +46,7 @@ #include #include #include +#include #include #include diff --git a/muse/muse/CMakeLists.txt b/muse/muse/CMakeLists.txt index a997f084..438d22f1 100644 --- a/muse/muse/CMakeLists.txt +++ b/muse/muse/CMakeLists.txt @@ -43,16 +43,19 @@ MACRO(WRAP_UI outfiles ) subdirs( ctrl widgets master driver instruments marker liste ) + set (muse_uics muse preferences exportmididialog configmidifile transport aboutbox transpose + projectdialog midiedit/quantconfig mixer/routedialog arranger/configtrack ) set(muse_mocs - preferences plugingui midiplugin muse song transport conf editor + projectdialog preferences plugingui midiplugin muse + song transport conf editor cobject transpose track midisynti midiport miditrack wavetrack audiotrack audioaux audiooutput audioinput audiogroup exportmidi @@ -110,7 +113,6 @@ add_executable ( muse midiedit/drummap.cpp midiedit/citem.cpp -# midiedit/midieditor.cpp ${muse_mocCPP} ${muse_moc_headers} diff --git a/muse/muse/conf.cpp b/muse/muse/conf.cpp index 40f91dec..ca8064f7 100644 --- a/muse/muse/conf.cpp +++ b/muse/muse/conf.cpp @@ -248,9 +248,9 @@ void readConfiguration(QDomNode node) //TD else if (tag == "midiTransform") // readMidiTransform(node.firstChild()); else if (tag == "startMode") - config.startMode = i; - else if (tag == "startSong") - config.startSong = s; + config.startMode = (StartMode)i; + else if (tag == "startProject") + config.startProject = s; else if (tag == "followMode") TimeCanvas::followMode = (FollowMode)i; else if (tag == "defaultMidiInputDevice") @@ -265,6 +265,8 @@ void readConfiguration(QDomNode node) config.connectToAllMidiTracks = i; else if (tag == "createDefaultMidiInput") config.createDefaultMidiInput = i; + else if (tag == "projectPath") + config.projectPath = s; else if (tag == "PianoRoll") PianoRoll::readConfiguration(node); else if (tag == "DrumEdit") @@ -394,7 +396,7 @@ void MusE::writeGlobalConfiguration(Xml& xml) const xml.strTag("copyright", config.copyright); xml.intTag("smfFormat", config.smfFormat); xml.intTag("startMode", config.startMode); - xml.strTag("startSong", config.startSong); + xml.strTag("startProject", config.startProject); xml.intTag("freewheelMode", config.useJackFreewheelMode); xml.intTag("txDeviceId", txDeviceId); @@ -482,6 +484,7 @@ void MusE::writeGlobalConfiguration(Xml& xml) const xml.intTag("connectToAllMidiDevices", config.connectToAllMidiDevices); xml.intTag("connectToAllMidiTracks", config.connectToAllMidiTracks); xml.intTag("createDefaultMidiInput", config.createDefaultMidiInput); + xml.strTag("projectPath", config.projectPath); PianoRoll::writeConfiguration(xml); DrumEdit::writeConfiguration(xml); diff --git a/muse/muse/dssihost.cpp b/muse/muse/dssihost.cpp index 1e8ab542..7fbe5274 100644 --- a/muse/muse/dssihost.cpp +++ b/muse/muse/dssihost.cpp @@ -116,7 +116,7 @@ int DssiSynthIF::oscUpdate(lo_arg **argv) */ lo_send(uiTarget, uiOscConfigurePath, "ss", - DSSI_PROJECT_DIRECTORY_KEY, museProject.toLatin1().data()); + DSSI_PROJECT_DIRECTORY_KEY, song->projectDirectory().toLatin1().data()); #if 0 /* Send current bank/program (-FIX- another race...) */ diff --git a/muse/muse/exportmidi.cpp b/muse/muse/exportmidi.cpp index d1713a35..1cfff45e 100644 --- a/muse/muse/exportmidi.cpp +++ b/muse/muse/exportmidi.cpp @@ -40,7 +40,7 @@ // addController //--------------------------------------------------------- -static void addController(MPEventList* l, int tick, int port, int channel, int a, int b) +static void addController(MPEventList* l, int tick, int /*port*/, int channel, int a, int b) { if (a < 0x1000) { // 7 Bit Controller l->add(MidiEvent(tick, channel, ME_CONTROLLER, a, b)); @@ -116,7 +116,7 @@ static void addController(MPEventList* l, int tick, int port, int channel, int a void MusE::exportMidi() { if (exportMidiDialog == 0) - exportMidiDialog = new ExportMidiDialog(project.filePath()); + exportMidiDialog = new ExportMidiDialog(song->projectDirectory()); int rv = exportMidiDialog->exec(); if (rv == 0) return; diff --git a/muse/muse/gconfig.cpp b/muse/muse/gconfig.cpp index 25d6013b..37534203 100644 --- a/muse/muse/gconfig.cpp +++ b/muse/muse/gconfig.cpp @@ -93,7 +93,7 @@ GlobalConfigValues config = { 384, // division for smf export QString(""), // copyright string for smf export 1, // smf export file format - 1, // startMode + START_ASK_FOR_PROJECT, // startMode QString(""), // start song path 384, // gui division QRect(0, 0, 800, 560), // GeometryMain; @@ -102,15 +102,15 @@ GlobalConfigValues config = { QRect(100, 100, 600, 400), // GeometryPianoroll; QRect(0, 0, 600, 400), // GeometryDrumedit; { - QRect(0, 0, 300, 500), // Mixer1 - false, true, true, true, true, - true, true, true, true, true, true - }, + QRect(0, 0, 300, 500), // Mixer1 + false, true, true, true, true, + true, true, true, true, true, true + }, { - QRect(200, 200, 300, 500), // Mixer2 - false, true, true, true, true, - true, true, true, true, true, true - }, + QRect(200, 200, 300, 500), // Mixer2 + false, true, true, true, true, + true, true, true, true, true, true + }, false, // TransportVisible false, // BigTimeVisible; false, // mixerVisible1; @@ -135,5 +135,6 @@ GlobalConfigValues config = { true, // connectToAllMidiDevices true, // connectToAllMidiTracks true, // createDefaultMidiInput + QString("MusE/projects"), // projectPath }; diff --git a/muse/muse/gconfig.h b/muse/muse/gconfig.h index 328d2810..8bfed74b 100644 --- a/muse/muse/gconfig.h +++ b/muse/muse/gconfig.h @@ -27,6 +27,12 @@ #include "al/xml.h" using AL::Xml; +enum StartMode { + START_ASK_FOR_PROJECT, + START_LAST_PROJECT, + START_START_PROJECT + }; + //--------------------------------------------------------- // MixerConfig //--------------------------------------------------------- @@ -80,10 +86,8 @@ struct GlobalConfigValues { QString copyright; // copyright string for smf export int smfFormat; // smf export file type - int startMode; // 0 - start with last song - // 1 - start with default template - // 2 - start with song - QString startSong; // path for start song + enum StartMode startMode; + QString startProject; // path for start project int guiDivision; // division for tick display QRect geometryMain; @@ -119,6 +123,7 @@ struct GlobalConfigValues { bool connectToAllMidiDevices; bool connectToAllMidiTracks; bool createDefaultMidiInput; + QString projectPath; }; extern GlobalConfigValues config; diff --git a/muse/muse/globals.cpp b/muse/muse/globals.cpp index 54f3665f..3a5f9558 100644 --- a/muse/muse/globals.cpp +++ b/muse/muse/globals.cpp @@ -66,8 +66,6 @@ const signed char flatTab[14][7] = { QString museGlobalLib; QString museGlobalShare; QString museUser; -QString museProject; -QString museProjectInitPath("./"); QString configName; QString lastWavePath("."); diff --git a/muse/muse/globals.h b/muse/muse/globals.h index ddd1a377..9e7f413b 100644 --- a/muse/muse/globals.h +++ b/muse/muse/globals.h @@ -47,8 +47,6 @@ extern const signed char flatTab[14][7]; extern QString museGlobalLib; extern QString museGlobalShare; extern QString museUser; -extern QString museProject; // current project directory -extern QString museProjectInitPath; extern QString configName; extern QString lastWavePath; diff --git a/muse/muse/importmidi.cpp b/muse/muse/importmidi.cpp index 928fc078..4fd5808d 100644 --- a/muse/muse/importmidi.cpp +++ b/muse/muse/importmidi.cpp @@ -74,7 +74,7 @@ void MusE::importMidi(const QString &file) song->update(-1); break; case 1: - loadProjectFile(fn, false, false); // replace +//TODO loadProjectFile(fn, false, false); // replace break; default: return; @@ -303,9 +303,9 @@ bool MusE::importMidi(const QString name, bool merge) int z = sig.z; int n = sig.n; - int tempo = AL::tempomap.tempo(0); transport->setTimesig(z, n); -//TD transport->setTempo(tempo); +//TD int tempo = AL::tempomap.tempo(0); +// transport->setTempo(tempo); bool masterF = !AL::tempomap.empty(); song->setMasterFlag(masterF); @@ -426,7 +426,7 @@ void MusE::processTrack(MidiTrack* track) } if (tevents->size()) - printf("-----------events left: %ld\n", tevents->size()); + printf("-----------events left: %zd\n", tevents->size()); for (iEvent i = tevents->begin(); i != tevents->end(); ++i) { printf("%d===\n", i->first); i->second.dump(); diff --git a/muse/muse/muse.cpp b/muse/muse/muse.cpp index 052c1278..ea454a9a 100644 --- a/muse/muse/muse.cpp +++ b/muse/muse/muse.cpp @@ -59,6 +59,7 @@ #include "widgets/utils.h" #include "instruments/editinstrument.h" #include "part.h" +#include "projectdialog.h" static pthread_t watchdogThread; @@ -444,12 +445,10 @@ MusE::MusE() midiFilterConfig = 0; midiInputTransform = 0; midiRhythmGenerator = 0; -// globalSettingsConfig = 0; preferencesDialog = 0; softSynthesizerConfig = 0; midiTransformerDialog = 0; shortcutConfig = 0; -// appearance = 0; editInstrument = 0; appName = QString("MusE"); _raster = 0; @@ -794,9 +793,6 @@ MusE::MusE() //------------------------------------------------------------- menuSettings = mb->addMenu(tr("Setti&ngs")); - -// menu_ids[CMD_GLOBAL_CONFIG] = menuSettings->addAction(QIcon(*settings_globalsettingsIcon), tr("Global Settings")); -// connect(menu_ids[CMD_GLOBAL_CONFIG], SIGNAL(triggered()), this, SLOT(configGlobalSettings())); menu_ids[CMD_CONFIG_SHORTCUTS] = menuSettings->addAction(QIcon(*settings_configureshortcutsIcon), tr("Configure shortcuts")); connect(menu_ids[CMD_CONFIG_SHORTCUTS], SIGNAL(triggered()), this, SLOT(configShortCuts())); @@ -822,7 +818,6 @@ MusE::MusE() menu_ids[CMD_MIDI_FILE_CONFIG] = menuSettings->addAction(QIcon(*settings_midifileexportIcon), tr("Midi File Export")); connect(menu_ids[CMD_MIDI_FILE_CONFIG], SIGNAL(triggered()), this, SLOT(configMidiFile())); menuSettings->addSeparator(); -// menu_ids[CMD_GLOBAL_CONFIG] = menuSettings->addAction(QIcon(*settings_globalsettingsIcon), tr("Global Settings")); QAction* action = menuSettings->addAction(QIcon(*settings_globalsettingsIcon), tr("Preferences")); connect(action, SIGNAL(triggered()), this, SLOT(preferences())); @@ -949,7 +944,7 @@ MusE::MusE() connect(tools1, SIGNAL(toolChanged(int)), SLOT(setTool(int))); connect(arranger, SIGNAL(editPart(Part*)), SLOT(startEditor(Part*))); -//TODO1 connect(arranger, SIGNAL(dropSongFile(const QString&)), SLOT(loadProjectFile(const QString&))); +//TODO1 connect(arranger, SIGNAL(dropSongFile(const QString&)), SLOT(loadProject(const QString&))); //TODO1 connect(arranger, SIGNAL(dropMidiFile(const QString&)), SLOT(importMidi(const QString&))); connect(arranger, SIGNAL(cursorPos(const AL::Pos&,bool)), cursorPos, SLOT(setValue(const AL::Pos&,bool))); @@ -1041,20 +1036,10 @@ void MusE::localOff() } //--------------------------------------------------------- -// loadProjectFile -// load *.med, *.mid, *.kar -// -// template - if true, load file but do not change -// project name +// loadProject //--------------------------------------------------------- -// for drop: -void MusE::loadProjectFile(const QString& name) - { - loadProjectFile(name, false, false); - } - -void MusE::loadProjectFile(const QString& name, bool songTemplate, bool loadAll) +void MusE::loadProject(const QString& name) { // // stop audio threads if running @@ -1068,22 +1053,17 @@ void MusE::loadProjectFile(const QString& name, bool songTemplate, bool loadAll) } seqStop(); } - loadProjectFile1(name, songTemplate, loadAll); + loadProject1(name); if (restartSequencer) seqStart(); audio->msgSeek(song->cPos()); } //--------------------------------------------------------- -// loadProjectFile1 -// load *.med, *.mid, *.kar -// -// template - if true, load file but do not change -// project name -// loadAll - load song data + configuration data +// loadProject1 //--------------------------------------------------------- -void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool loadAll) +void MusE::loadProject1(const QString& name) { if (mixer1) mixer1->clear(); @@ -1109,6 +1089,17 @@ void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool loadAll printf("InternalError: gibt %d\n", n); } } + + QDir pd(QDir::homePath() + "/" + config.projectPath + "/" + name); + bool newProject = false; + if (!pd.exists()) { + newProject = true; + if (!pd.mkdir(pd.path())) { + QMessageBox::critical(this, QString("MusE: new project"), + tr("Cannot create project directory")); + return; + } + } foreach(QWidget* w, QApplication::topLevelWidgets()) { if (!w->isVisible()) continue; @@ -1123,77 +1114,30 @@ void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool loadAll else if (strcmp("ListEdit", w->metaObject()->className()) == 0) w->close(); } - emit startLoadSong(); - - song->clear(false); - QFileInfo fi(name); - if (songTemplate) { - if (!fi.isReadable()) { - QMessageBox::critical(this, QString("MusE"), - tr("Cannot read template")); - return; - } - project.setFile("untitled"); - } - else { - museProject = fi.absolutePath(); - project.setFile(name); - } - QString ex = fi.suffix().toLower(); - if (ex.isEmpty() || ex == "med") { - // - // read *.med file - // - QFile* f = new QFile(ex.isEmpty() ? name + ".med" : name); - if (f->open(QIODevice::ReadOnly)) { - int rv = read(f, !loadAll); - f->close(); - if (rv) { - QMessageBox::critical(this, QString("MusE"), - tr("File read error")); - setUntitledProject(); - } - } - delete f; - } - else if (ex == "mid" || ex == "kar") { - if (importMidi(name, false)) { - setUntitledProject(); - } - } - else { - QMessageBox::critical(this, QString("MusE"), - tr("Unknown File Format")); - setUntitledProject(); - } - if (!songTemplate) { - addProject(project); - setWindowTitle(QString("MusE: Song: ") + project.baseName()); - } - song->dirty = false; + song->setProjectName(name); + song->load(); tr_id->setChecked(config.transportVisible); bt_id->setChecked(config.bigTimeVisible); - if (loadAll) { - // - // dont emit song->update(): - song->blockSignals(true); + // + // dont emit song->update(): + song->blockSignals(true); - showBigtime(config.bigTimeVisible); - showMixer1(config.mixer1Visible); - showMixer2(config.mixer2Visible); - resize(config.geometryMain.size()); - move(config.geometryMain.topLeft()); + showBigtime(config.bigTimeVisible); + showMixer1(config.mixer1Visible); + showMixer2(config.mixer2Visible); + resize(config.geometryMain.size()); + move(config.geometryMain.topLeft()); - if (config.transportVisible) - transport->show(); - transport->move(config.geometryTransport.topLeft()); - showTransport(config.transportVisible); + if (config.transportVisible) + transport->show(); + transport->move(config.geometryTransport.topLeft()); + showTransport(config.transportVisible); - song->blockSignals(false); - } + song->blockSignals(false); + transport->setMasterFlag(song->masterFlag()); punchinAction->setChecked(song->punchin()); punchoutAction->setChecked(song->punchout()); @@ -1202,7 +1146,6 @@ void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool loadAll selectionChanged(); // enable/disable "Copy" & "Paste" song->setLen(song->len()); // emit song->lenChanged() signal - // song->update(); // // add connected channels // @@ -1234,17 +1177,7 @@ void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool loadAll } (*i)->blockSignals(false); } - } - -//--------------------------------------------------------- -// setUntitledProject -//--------------------------------------------------------- - -void MusE::setUntitledProject() - { - QString name("untitled"); - museProject = QFileInfo(name).absolutePath(); - project.setFile(name); + setWindowTitle(QString("MusE: Song: ") + name); } //--------------------------------------------------------- @@ -1253,16 +1186,14 @@ void MusE::setUntitledProject() void MusE::loadProject() { - QStringList pattern; - const char** p = med_midi_file_pattern; - while (*p) - pattern << *p++; - QString fn = getOpenFileName(QString("."), pattern, this, - tr("MusE: load project")); - if (!fn.isEmpty()) { - museProject = QFileInfo(fn).absolutePath(); - loadProjectFile(fn, false, true); // load all - } + ProjectDialog projectDialog; + int rv = projectDialog.exec(); + if (rv == 0) + return; + QString name = projectDialog.project(); + if (name.isEmpty()) + return; + loadProject(name); } //--------------------------------------------------------- @@ -1270,75 +1201,49 @@ void MusE::loadProject() //--------------------------------------------------------- bool MusE::save() - { - return save(project.filePath(), false); - } - -//--------------------------------------------------------- -// save -//--------------------------------------------------------- - -bool MusE::save(const QString& fname, bool overwriteWarn) { QString backupCommand; - QString name(fname); - QFileInfo info(name); - QString zip; + QString name(song->projectName() + ".med"); + QFileInfo fi(song->projectDirectory() + "/" + name); - if (info.completeSuffix() == "") { - name += ".med"; - info.setFile(name); - } - if (overwriteWarn && info.exists()) { - QString s(QWidget::tr("File\n") + name + QWidget::tr("\nexists")); - int rv = QMessageBox::warning(this, - QWidget::tr("MusE: write"), - s, - QWidget::tr("Overwrite"), - QWidget::tr("Quit"), QString::null, 0, 1); - switch(rv) { - case 0: // overwrite - break; - case 1: // quit - return 0; - } - } - char* tmpName = tempnam(info.absolutePath().toLatin1().data(), "MusE"); - FILE* fp = fopen(tmpName, "w"); - if (fp == 0) { + QTemporaryFile tmp(fi.path() + "/MusEXXXXXX"); + tmp.setAutoRemove(false); + + if (!tmp.open()) { QString s("Creating temp file failed: "); s += strerror(errno); QMessageBox::critical(this, tr("MusE: Create tmp file failed"), s); return false; } - QFile file; - file.open(fp, QIODevice::WriteOnly); - Xml xml(&file); + Xml xml(&tmp); write(xml); - if (ferror(fp)) { - QString s = QString("Write File\n") + name + QString("\nfailed: ") - + QString(strerror(errno)); - QMessageBox::critical(this, - tr("MusE: Write File failed"), s); - fclose(fp); - unlink(tmpName); + if (tmp.error()) { + QString s = QString("Write File\n") + tmp.fileName() + QString("\nfailed: ") + + tmp.errorString(); + QMessageBox::critical(this, tr("MusE: Write File failed"), s); return false; } - file.close(); - fclose(fp); - if (!overwriteWarn && !song->backupWritten()) { + if (!song->backupWritten()) { // - // create backup file + // remove old backup file // - if (info.exists()) { - QString backupName = "." + name + ","; - rename(name.toLatin1().data(), backupName.toLatin1().data()); - song->setBackupWritten(true); - } + QDir dir(fi.path()); + QString backupName = QString(".") + fi.fileName() + QString(","); + dir.remove(backupName); + + // + // rename old file to backup + // + QString n(fi.filePath()); + dir.rename(n, backupName); } - rename(tmpName, name.toLatin1().data()); + // + // rename temp name to file name + // + tmp.rename(fi.filePath()); + song->dirty = false; SndFile::updateRecFiles(); return true; @@ -1634,7 +1539,7 @@ void MusE::selectProject(QAction* a) QString* name = projectList[id]; if (name == 0) return; - loadProjectFile(*name, false, true); + loadProject(*name); } //--------------------------------------------------------- @@ -1776,207 +1681,6 @@ static void catchSignal(int sig) } #endif -//--------------------------------------------------------- -// main -//--------------------------------------------------------- - -int main(int argc, char* argv[]) - { - museUser = QString(getenv("MUSEHOME")); - if (museUser.isEmpty()) - museUser = QString(getenv("HOME")); - QString museGlobal; - const char* p = getenv("MUSE"); - museGlobal = p ? p : INSTPREFIX; - - museGlobalLib = museGlobal + "/lib/" INSTALL_NAME; - museGlobalShare = museGlobal + "/share/" INSTALL_NAME; - - museProject = museProjectInitPath; - configName = museUser + QString("/." INSTALL_NAME); - - srand(time(0)); // initialize random number generator - initMidiController(); - MuseApplication app(argc, argv); - - config.fonts[0] = new QFont(QString("arial"), 10, QFont::Normal); - config.fonts[1] = new QFont(QString("arial"), 8, QFont::Normal); - config.fonts[2] = new QFont(QString("arial"), 10, QFont::Normal); - config.fonts[3] = new QFont(QString("arial"), 8, QFont::Bold); - config.fonts[4] = new QFont(QString("arial"), 8, QFont::Bold); // simple buttons, timescale numbers - config.fonts[5] = new QFont(QString("Lucidatypewriter"), 14, QFont::Bold); - - initShortCuts(); - gmDrumMap.initGm(); // init default drum map - readConfiguration(); - - QApplication::setFont(*config.fonts[0]); - - // SHOW MUSE SPLASH SCREEN - if (config.showSplashScreen) { - QPixmap splsh(":/xpm/splash.png"); - - if (!splsh.isNull()) { - QSplashScreen* muse_splash = new QSplashScreen(splsh, - Qt::WindowStaysOnTopHint); - muse_splash->show(); - QTimer* stimer = new QTimer(0); - muse_splash->connect(stimer, SIGNAL(timeout()), muse_splash, SLOT(close())); - stimer->start(6000); - } - } - char c; - QString opts("mvdDiosP:p"); - -#ifdef VST_SUPPORT - opts += "V"; -#endif -#ifdef DSSI_SUPPORT - opts += "I"; -#endif - while ((c = getopt(argc, argv, opts.toLatin1().data())) != EOF) { - switch (c) { - case 'v': printVersion(argv[0]); return 0; - case 'd': - debugMode = true; - realTimePriority = false; - break; - case 'm': midiOnly = true; break; - case 'D': debugMsg = true; break; - case 'i': midiInputTrace = true; break; - case 'o': midiOutputTrace = true; break; - case 's': debugSync = true; break; - case 'p': loadPlugins = false; break; - case 'V': loadVST = false; break; - case 'I': loadDSSI = false; break; - default: usage(argv[0], "bad argument"); return -1; - } - } - if (midiOnly) { - loadDSSI = false; - loadPlugins = false; - loadVST = false; - } - - bool useJACK = !(debugMode || midiOnly); - if (useJACK) { - if (initJackAudio()) { - if (!debugMode) - { - QMessageBox::critical(NULL, "MusE fatal error", - "MusE failed to find a Jack audio server.\n" - "Check that Jack was started.\n" - "If Jack was started check that it was\n" - "started as the same user as MusE."); - // fatalError("cannot start JACK"); - } - else - { - fprintf(stderr, "fatal error: no JACK audio server found\n"); - fprintf(stderr, "no audio functions available\n"); - fprintf(stderr, "*** experimental mode -- no play possible ***\n"); - } - useJACK = false; - debugMode = true; - } - } - if (!useJACK) - initDummyAudio(); - - argc -= optind; - ++argc; - - if (debugMsg) { - printf("global lib: <%s>\n", museGlobalLib.toLatin1().data()); - printf("global share: <%s>\n", museGlobalShare.toLatin1().data()); - printf("muse home: <%s>\n", museUser.toLatin1().data()); - printf("project dir: <%s>\n", museProject.toLatin1().data()); - printf("config file: <%s>\n", configName.toLatin1().data()); - } - - static QTranslator translator; - QString lo(QLocale::system().name()); - - if (lo != "C") { - QString loc("muse_"); - loc += lo; - if (translator.load(loc, QString(".")) == false) { - QString lp(museGlobalShare); - lp += QString("/locale"); - if (translator.load(loc, lp) == false) { - printf("no locale <%s> in <%s>\n", loc.toLatin1().data(), lp.toLatin1().data()); - } - } - qApp->installTranslator(&translator); - } - - if (loadPlugins) { - initPlugins(); - initMidiPlugins(); - } - if (loadVST) - initVST(); - if (loadDSSI) - initDSSI(); - - initIcons(); - if (!midiOnly) - initMetronome(); - - if (debugMsg) { - QStringList list = app.libraryPaths(); - QStringList::Iterator it = list.begin(); - printf("QtLibraryPath:\n"); - while(it != list.end()) { - printf(" <%s>\n", (*it).toLatin1().data()); - ++it; - } - } - - song = new Song(); - muse = new MusE(); - app.setMuse(muse); - muse->setWindowIcon(*museIcon); - - //--------------------------------------------------- - // load project - // if no songname entered on command line: - // startMode: 0 - load last song - // 1 - load default template - // 2 - load configured start song - //--------------------------------------------------- - - QString name; - bool useTemplate = false; - if (argc >= 2) - name = argv[optind]; - else if (config.startMode == 0) { - if (argc < 2) - name = projectList[0] ? *projectList[0] : QString("untitled"); - else - name = argv[0]; - } - else if (config.startMode == 1) { - name = museGlobalShare + QString("/templates/default.med"); - useTemplate = true; - } - else if (config.startMode == 2) - name = config.startSong; - muse->loadProjectFile(name, useTemplate, true); - muse->changeConfig(false); - - if (!debugMode) { - if (mlockall(MCL_CURRENT | MCL_FUTURE)) - perror("WARNING: Cannot lock memory:"); - } - muse->show(); - muse->seqStart(); - int n = app.exec(); - if (n) - fprintf(stderr, "app end %d\n", n); - return n; - } - //--------------------------------------------------------- // setFollow //--------------------------------------------------------- @@ -2985,3 +2689,252 @@ void MusE::setGlobalTempo(int val) globalTempoSpinBox->setValue(val); } +//--------------------------------------------------------- +// main +//--------------------------------------------------------- + +int main(int argc, char* argv[]) + { + museUser = QString(getenv("MUSEHOME")); + if (museUser.isEmpty()) + museUser = QString(getenv("HOME")); + QString museGlobal; + const char* p = getenv("MUSE"); + museGlobal = p ? p : INSTPREFIX; + + museGlobalLib = museGlobal + "/lib/" INSTALL_NAME; + museGlobalShare = museGlobal + "/share/" INSTALL_NAME; + + configName = museUser + QString("/." INSTALL_NAME); + + srand(time(0)); // initialize random number generator + initMidiController(); + MuseApplication app(argc, argv); + + config.fonts[0] = new QFont(QString("arial"), 10, QFont::Normal); + config.fonts[1] = new QFont(QString("arial"), 8, QFont::Normal); + config.fonts[2] = new QFont(QString("arial"), 10, QFont::Normal); + config.fonts[3] = new QFont(QString("arial"), 8, QFont::Bold); + config.fonts[4] = new QFont(QString("arial"), 8, QFont::Bold); // simple buttons, timescale numbers + config.fonts[5] = new QFont(QString("Lucidatypewriter"), 14, QFont::Bold); + + initShortCuts(); + gmDrumMap.initGm(); // init default drum map + readConfiguration(); + + QApplication::setFont(*config.fonts[0]); + + // SHOW MUSE SPLASH SCREEN + if (config.showSplashScreen) { + QPixmap splsh(":/xpm/splash.png"); + + if (!splsh.isNull()) { + QSplashScreen* muse_splash = new QSplashScreen(splsh, + Qt::WindowStaysOnTopHint); + muse_splash->show(); + QTimer* stimer = new QTimer(0); + muse_splash->connect(stimer, SIGNAL(timeout()), muse_splash, SLOT(close())); + stimer->start(6000); + } + } + char c; + QString opts("mvdDiosP:p"); + +#ifdef VST_SUPPORT + opts += "V"; +#endif +#ifdef DSSI_SUPPORT + opts += "I"; +#endif + while ((c = getopt(argc, argv, opts.toLatin1().data())) != EOF) { + switch (c) { + case 'v': printVersion(argv[0]); return 0; + case 'd': + debugMode = true; + realTimePriority = false; + break; + case 'm': midiOnly = true; break; + case 'D': debugMsg = true; break; + case 'i': midiInputTrace = true; break; + case 'o': midiOutputTrace = true; break; + case 's': debugSync = true; break; + case 'p': loadPlugins = false; break; + case 'V': loadVST = false; break; + case 'I': loadDSSI = false; break; + default: usage(argv[0], "bad argument"); return -1; + } + } + if (midiOnly) { + loadDSSI = false; + loadPlugins = false; + loadVST = false; + } + + bool useJACK = !(debugMode || midiOnly); + if (useJACK) { + if (initJackAudio()) { + if (!debugMode) + { + QMessageBox::critical(NULL, "MusE fatal error", + "MusE failed to find a Jack audio server.\n" + "Check that Jack was started.\n" + "If Jack was started check that it was\n" + "started as the same user as MusE."); + // fatalError("cannot start JACK"); + } + else + { + fprintf(stderr, "fatal error: no JACK audio server found\n"); + fprintf(stderr, "no audio functions available\n"); + fprintf(stderr, "*** experimental mode -- no play possible ***\n"); + } + useJACK = false; + debugMode = true; + } + } + if (!useJACK) + initDummyAudio(); + + argc -= optind; + ++argc; + + if (debugMsg) { + printf("global lib: <%s>\n", museGlobalLib.toLatin1().data()); + printf("global share: <%s>\n", museGlobalShare.toLatin1().data()); + printf("muse home: <%s>\n", museUser.toLatin1().data()); + printf("project dir: <%s>\n", config.projectPath.toLatin1().data()); + printf("config file: <%s>\n", configName.toLatin1().data()); + } + + static QTranslator translator; + QString lo(QLocale::system().name()); + + if (lo != "C") { + QString loc("muse_"); + loc += lo; + if (translator.load(loc, QString(".")) == false) { + QString lp(museGlobalShare); + lp += QString("/locale"); + if (translator.load(loc, lp) == false) { + printf("no locale <%s> in <%s>\n", loc.toLatin1().data(), lp.toLatin1().data()); + } + } + qApp->installTranslator(&translator); + } + + if (loadPlugins) { + initPlugins(); + initMidiPlugins(); + } + if (loadVST) + initVST(); + if (loadDSSI) + initDSSI(); + + initIcons(); + if (!midiOnly) + initMetronome(); + + if (debugMsg) { + QStringList list = app.libraryPaths(); + QStringList::Iterator it = list.begin(); + printf("QtLibraryPath:\n"); + while(it != list.end()) { + printf(" <%s>\n", (*it).toLatin1().data()); + ++it; + } + } + + song = new Song(); + muse = new MusE(); + app.setMuse(muse); + muse->setWindowIcon(*museIcon); + + //--------------------------------------------------- + // load project + //--------------------------------------------------- + + // first check if there is a project directory: + + QDir pd(QDir::homePath() + "/" + config.projectPath); + if (!pd.exists()) { + // ask user to create a new project directory + QString s; + s = "The MusE project directory\n%1\ndoes not exists"; + s = s.arg(pd.path()); + + int rv = QMessageBox::question(0, + "MusE: create project directory", + s, + "Create", + "Abort", + QString(), + 0, 1); + if (rv == 1) + exit(0); + if (!pd.mkpath(pd.path())) { + // TODO: tell user why this has happened + QMessageBox::critical(0, + "MusE: create project directory", + "Creating project directory failed"); + exit(-1); + } + } + + QString name; + if (argc >= 2) + name = argv[optind]; // start with first name on command line + else if (config.startMode == START_LAST_PROJECT) { + if (projectList[0]) + name = *projectList[0]; + } + else if (config.startMode == START_START_PROJECT) + name = config.startProject; + + //DEBUG: + name = ""; + + if (name.isEmpty()) { + // + // ask user for a project + // + for (;;) { + ProjectDialog projectDialog; + int rv = projectDialog.exec(); + if (rv == 1) { + name = projectDialog.project(); + if (!name.isEmpty()) + break; + } + // the user did not select/create a project + QString s; + s = "before MusE starts, you must select a project\n" + "or create a new one"; + rv = QMessageBox::question(0, + "MusE: create select project", + s, + "Go Back", + "Abort", + QString(), + 0, 1); + if (rv == 1) + exit(0); + } + } + + muse->loadProject(name); + muse->changeConfig(false); + + if (!debugMode) { + if (mlockall(MCL_CURRENT | MCL_FUTURE)) + perror("WARNING: Cannot lock memory:"); + } + muse->show(); + muse->seqStart(); + int n = app.exec(); + if (n) + fprintf(stderr, "app end %d\n", n); + return n; + } + + diff --git a/muse/muse/muse.h b/muse/muse/muse.h index 7b9e0bd6..a3bd0749 100644 --- a/muse/muse/muse.h +++ b/muse/muse/muse.h @@ -43,13 +43,11 @@ class AudioConf; class MidiFileConfig; class MidiFilterConfig; class MarkerView; -// class GlobalSettingsConfig; class MidiInputTransformDialog; class MidiTransformerDialog; class RhythmGen; class MidiTrack; class ShortcutConfig; -// class Appearance; class PreferencesDialog; class EditInstrument; class Mixer; @@ -62,7 +60,6 @@ extern void configMidiController(); //--------------------------------------------------------- class MusE : public QMainWindow, public Ui::MuseBase -// class MusE : public QMainWindow { Q_OBJECT enum { @@ -95,7 +92,6 @@ class MusE : public QMainWindow, public Ui::MuseBase QAction* fileNewAction; QString appName; - QFileInfo project; QToolBar *tools; EditToolBar *tools1; int _raster; @@ -139,11 +135,9 @@ class MusE : public QMainWindow, public Ui::MuseBase MetronomeConfig* metronomeConfig; AudioConf* audioConfig; MidiFileConfig* midiFileConfig; -// GlobalSettingsConfig* globalSettingsConfig; MidiFilterConfig* midiFilterConfig; MidiInputTransformDialog* midiInputTransform; ShortcutConfig* shortcutConfig; -// Appearance* appearance; PreferencesDialog* preferencesDialog; ExportMidiDialog* exportMidiDialog; @@ -154,23 +148,17 @@ class MusE : public QMainWindow, public Ui::MuseBase //------------------------------------------ bool readMidi(FILE*); - bool read(QFile*, bool skipConfig); - void read10(QDomNode); - void read20(QDomNode); void processTrack(MidiTrack* track); void write(Xml& xml) const; - bool save(const QString&, bool); - void setUntitledProject(); void setFollow(FollowMode); void readConfigParts(QDomNode); void readCtrl(QDomNode, int port, int channel); - void readToplevels(QDomNode); PartList* getMidiPartsToEdit(); Part* readPart(QDomNode); bool checkRegionNotNull(); - void loadProjectFile1(const QString&, bool songTemplate, bool loadAll); + void loadProject1(const QString&); void writeGlobalConfiguration(Xml&) const; void writeConfiguration(Xml&) const; void updateConfiguration(); @@ -185,7 +173,6 @@ class MusE : public QMainWindow, public Ui::MuseBase private slots: void loadProject(); bool save(); -// void configGlobalSettings(); void quitDoc(); void about(); void aboutQt(); @@ -201,7 +188,6 @@ class MusE : public QMainWindow, public Ui::MuseBase void configMidiSync(); void configMidiFile(); void configShortCuts(); -// void configAppearance(); void startMasterEditor(); void startListEditor(); @@ -214,7 +200,6 @@ class MusE : public QMainWindow, public Ui::MuseBase void startPianoroll(PartList* pl); void startWaveEditor(); void startWaveEditor(PartList*); -// void startMidiTransformer(); void writeGlobalConfiguration() const; void startEditInstrument(); @@ -256,8 +241,7 @@ class MusE : public QMainWindow, public Ui::MuseBase public slots: void bounceToFile(); void closeEvent(QCloseEvent*e); - void loadProjectFile(const QString&); - void loadProjectFile(const QString&, bool songTemplate, bool loadAll); + void loadProject(const QString&); void loadTheme(const QString&); bool seqStart(); void showTransport(bool flag); @@ -298,6 +282,7 @@ class MusE : public QMainWindow, public Ui::MuseBase // 0xaabb aa - major version, bb minor version int raster() const { return _raster; } void setupTransportToolbar(QToolBar* tb) const; + void readToplevels(QDomNode); }; extern MusE* muse; diff --git a/muse/muse/preferences.cpp b/muse/muse/preferences.cpp index 2c85b228..96054b4a 100644 --- a/muse/muse/preferences.cpp +++ b/muse/muse/preferences.cpp @@ -286,17 +286,23 @@ PreferencesDialog::PreferencesDialog(Arranger* a, QWidget* parent) minMeterSelect->setValue(config->minMeter); peakHoldTime->setValue(config->peakHoldTime); helpBrowser->setText(config->helpBrowser); - startSongEntry->setText(config->startSong); + startProjectEntry->setText(config->startProject); - startSongGroup = new QButtonGroup(this); - startSongGroup->addButton(startLast); - startSongGroup->addButton(startTemplate); - startSongGroup->addButton(startSong); + startProjectGroup = new QButtonGroup(this); + startProjectGroup->addButton(alwaysAsk); + startProjectGroup->addButton(startWithLastProject); + startProjectGroup->addButton(startWithProject); switch(config->startMode) { - case 0: startLast->setChecked(true); break; - case 1: startTemplate->setChecked(true); break; - case 2: startSong->setChecked(true); break; + case START_ASK_FOR_PROJECT: + alwaysAsk->setChecked(true); + break; + case START_LAST_PROJECT: + startWithLastProject->setChecked(true); + break; + case START_START_PROJECT: + startWithProject->setChecked(true); + break; } showTransport->setChecked(config->transportVisible); @@ -545,14 +551,14 @@ void PreferencesDialog::apply() ::config.rtcTicks = rtcResolutions[rtcticks]; ::config.guiDivision = divisions[div]; ::config.helpBrowser = helpBrowser->text(); - ::config.startSong = startSongEntry->text(); + ::config.startProject = startProjectEntry->text(); - if (startLast->isChecked()) - ::config.startMode = 0; - else if (startTemplate->isChecked()) - ::config.startMode = 1; - else if (startSong->isChecked()) - ::config.startMode = 2; + if (alwaysAsk->isChecked()) + ::config.startMode = START_ASK_FOR_PROJECT; + else if (startWithLastProject->isChecked()) + ::config.startMode = START_LAST_PROJECT; + else if (startWithProject->isChecked()) + ::config.startMode = START_START_PROJECT; ::config.transportVisible = showTransport->isChecked(); ::config.bigTimeVisible = showBigtime->isChecked(); @@ -587,6 +593,8 @@ void PreferencesDialog::apply() ::config.useJackFreewheelMode = freewheelMode->isChecked(); ::config.showSplashScreen = showSplash->isChecked(); + ::config.projectPath = projectPath->text(); + PianoRoll::initWidth = pianorollWidth->value(); PianoRoll::initHeight = pianorollHeight->value(); PianoRoll::initRaster = pianorollRaster->raster(); @@ -620,6 +628,7 @@ void PreferencesDialog::apply() w->move(::config.geometryBigTime.topLeft()); } + muse->resize(::config.geometryMain.size()); muse->move(::config.geometryMain.topLeft()); diff --git a/muse/muse/preferences.h b/muse/muse/preferences.h index d4f1496c..c3ab3929 100644 --- a/muse/muse/preferences.h +++ b/muse/muse/preferences.h @@ -40,7 +40,7 @@ class PreferencesDialog : public QDialog, public Ui::PreferencesDialogBase { QString currentBg; GlobalConfigValues* config; QButtonGroup* colorGroup; - QButtonGroup* startSongGroup; + QButtonGroup* startProjectGroup; void updateFonts(); void updateColor(); diff --git a/muse/muse/preferences.ui b/muse/muse/preferences.ui index 1a2fdd63..cb7e2db4 100644 --- a/muse/muse/preferences.ui +++ b/muse/muse/preferences.ui @@ -8,551 +8,373 @@ 0 0 - 721 - 569 + 731 + 602 Dialog - - - - 9 - 9 - 703 - 508 - + + + 9 - - - Application - - - - Views - - - - 9 - - - 6 - - - - - Cur - - - - - - - show - - - - - - - Mixer 1 - - - - - - - Big Time - - - - - - - Cur - - - - - - - Cur - - - - - - - Cur - - - - - - - 9999 - - - - - - - 9999 - - - 0 - - - - - - - 9999 - - - - - - - 9999 - - - - - - - 9999 - - - - - - - 9999 - - - - - - - 9999 - - - - - - - 9999 - - - - - - - 9999 - - - - - - - 9999 - - - - - - - 9999 - - - - - - - 9999 - - - - - - - 9999 - - - - - - - 9999 - - - - - - - 9999 - - - - - - - 9999 - - - - - - - 9999 - - - - - - - 9999 - - - - - - - show - - - - - - - show - - - - - - - Mixer 2 - - - - - - - Transport - - - - - - - Arranger - - - - - - - show - - - - - - - Cur - - - - - - - - Start MusE - - - - 9 - - - 6 - - - - - - - - - 9 - - - 6 - - - - - always ask - - - - - - - start with last project - - - - - - - start with project: - - - - - - - - - - - - - 0 - - - 6 - - - - - show splash screen - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Editors - - - - - 9 - 9 - 641 - 457 - - - + + 6 + + + + - Arranger + Application - + 9 6 - - - - show snap grid + + + + Start MusE + + + 9 + + + 3 + + + + + 0 + + + 3 + + + + + always ask + + + + + + + start with last project + + + + + + + start with project: + + + + + + + + + + + + 0 + + + 6 + + + + + show splash screen + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + - - + + - Events + Path - + - 11 + 9 6 - - + + - note on + Project Path - - + + + + + + + + + + Views + + + + 9 + + + 3 + + + - poly pressure + Cur - - + + - controller + show - - + + - aftertouch + Mixer 1 - - + + - pitch bend + Big Time - - + + - program change + Cur - - + + - special + Cur - - - - - - - Background - - - false - - - - 9 - - - 6 - - - + + - select... + Cur - - - - select... + + + + 9999 - - - - Color + + + + 9999 + + + 0 - - - - Pixmap + + + + 9999 - - - - - 7 - 1 - 0 - 0 - + + + + 9999 - - bg + + + + + + 9999 + + + + + + + 9999 + + + + + + + 9999 + + + + + + + 9999 + + + + + + + 9999 + + + + + + + 9999 + + + + + + + 9999 + + + + + + + 9999 + + + + + + + 9999 + + + + + + + 9999 + + + + + + + 9999 - - Qt::AlignCenter + + + + + + 9999 + + + + + + + 9999 + + + + + + + 9999 - - -1 + + + + + + show - + - Color + show - - Qt::AlignCenter + + + + + + Mixer 2 - - - - - - - Parts - - - - 11 - - - 6 - - - + + - show names + Transport - - + + - show events + Arranger - - + + + + show + + + + + - show Cakewalk Style + Cur @@ -561,184 +383,635 @@ - + - Pianoroll + Editors - + 9 6 - - - - Qt::Vertical - - - - 20 - 211 - - - - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-size:10pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;">Quant</p></body></html> - - - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-size:10pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;">Raster</p></body></html> - - - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-size:10pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;">Geometry</p></body></html> - - - - - - - height: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - width: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 9999 - - - 50 - - - - - - - 9999 - - - 50 - - - - - - - - - - - - - - DrumEditor - - + + + + + Arranger + + + + 9 + + + 6 + + + + + show snap grid + + + + + + + Events + + + + 11 + + + 6 + + + + + note on + + + + + + + poly pressure + + + + + + + controller + + + + + + + aftertouch + + + + + + + pitch bend + + + + + + + program change + + + + + + + special + + + + + + + + + + Background + + + false + + + + 9 + + + 6 + + + + + select... + + + + + + + select... + + + + + + + Color + + + + + + + Pixmap + + + + + + + + 7 + 1 + 0 + 0 + + + + bg + + + Qt::AlignCenter + + + -1 + + + + + + + Color + + + Qt::AlignCenter + + + + + + + + + + Parts + + + + 11 + + + 6 + + + + + show names + + + + + + + show events + + + + + + + show Cakewalk Style + + + + + + + + + + + Pianoroll + + + + 9 + + + 6 + + + + + Qt::Vertical + + + + 20 + 211 + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-size:10pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;">Quant</p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-size:10pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;">Raster</p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-size:10pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;">Geometry</p></body></html> + + + + + + + height: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + width: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 9999 + + + 50 + + + + + + + 9999 + + + 50 + + + + + + + + + + + + + + DrumEditor + + + + 9 + + + 6 + + + + + Qt::Vertical + + + + 20 + 351 + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-size:10pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;">Geometry</p></body></html> + + + + + + + 9999 + + + 50 + + + + + + + width: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 9999 + + + 50 + + + + + + + height: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + MasterEditor + + + + 9 + + + 6 + + + + + Qt::Vertical + + + + 20 + 331 + + + + + + + + 9999 + + + 50 + + + + + + + height: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 9999 + + + 50 + + + + + + + width: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-size:10pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;">Geometry</p></body></html> + + + + + + + + WaveEditor + + + + 9 + + + 6 + + + + + 9999 + + + 50 + + + + + + + height: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + width: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-size:10pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;">Geometry</p></body></html> + + + + + + + 9999 + + + 50 + + + + + + + Qt::Vertical + + + + 20 + 351 + + + + + + + + + + + + + Audio + + 9 6 - - - - Qt::Vertical - - - - 20 - 351 - - - - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-size:10pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;">Geometry</p></body></html> - - - - - - - 9999 - - - 50 - - - - - - - width: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 9999 - - - 50 + + + + Mixer + + + 9 + + + 6 + + + + + ms + + + 5000 + + + 20 + + + + + + + Peak Hold Time: + + + + + + + dB + + + 0 + + + -100 + + + 10 + + + -60 + + + + + + + dB + + + 0 + + + -100 + + + -60 + + + + + + + min. Meter Val + + + + + + + min. Slider Val + + + + - - + + - height: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + use JACK freewheel mode if possible - - - - - MasterEditor - - - - 9 - - - 6 - - + Qt::Vertical @@ -746,1537 +1019,1293 @@ 20 - 331 + 40 - - - - 9999 - - - 50 - - - - - - - height: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 9999 - - - 50 - - - - - - - width: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-size:10pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;">Geometry</p></body></html> - - - - + - WaveEditor + Midi - + - 9 + 8 6 - - - - 9999 - - - 50 - - - - - - - height: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - width: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-size:10pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;">Geometry</p></body></html> - - - - - - - 9999 - - - 50 - - - - - - - Qt::Vertical - - - - 20 - 351 - + + + + Ticks - - - - - - - - - Audio - - - - 9 - - - 6 - - - - - Mixer - - - - 9 - - - 6 - - - - - ms - - - 5000 - - - 20 - - - - - - - Peak Hold Time: - - - - - - - dB - - - 0 - - - -100 - - - 10 - - - -60 - - - - - - - dB - - - 0 - - - -100 - - - -60 - - - - - - - min. Meter Val + + + 9 - - - - - - min. Slider Val + + 6 - - - - - - - - - use JACK freewheel mode if possible - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Midi - - - - 8 - - - 6 - - - - - Ticks - - - - 9 - - - 6 - - - - - Displayed Resolution + + + + Displayed Resolution (Ticks/Quarternote) - - - - - - - RTC Resolution -(Ticks/Sec) - - - - - - - - 1024 - + + - - - 2048 - + + + + RTC Resolution +(Ticks/Sec) + + - - - 4096 - + + + + + 1024 + + + + + 2048 + + + + + 4096 + + + + + 8172 + + + - - - 8172 - + + + + 3 + + + + 48 + + + + + 96 + + + + + 192 + + + + + 384 + + + + + 768 + + + + + 1536 + + + + + 3072 + + + + + 6144 + + + + + 12288 + + + - - - - - - 3 + + + + + + + Input Routing + + + + 8 - - - 48 - + + 6 + + + + + Connect to all Tracks + + - - - 96 - + + + + Connect to all Input Devices + + - - - 192 - + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Preferred Input Device:</p></body></html> + + - - - 384 - + + - - - 768 - + + + + Create Default Input Strip + + - - - 1536 - + + + + + + + Output Routing + + + + 8 + + + 8 + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Preferred Output Device:</p></body></html> + + - - - 3072 - + + - - - 6144 - + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Preferred Instrument:</p></body></html> + + - - - 12288 - + + - - - - - - - - - Input Routing - - - - 8 - - - 6 - - - - - Connect to all Tracks - - - - - - - Connect to all Input Devices - - - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Preferred Input Device:</p></body></html> - - - - - - - - - - Create Default Input Strip - - - - - - - - - - Output Routing - - - - 8 - - - 8 - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Preferred Output Device:</p></body></html> - - - - - - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Preferred Instrument:</p></body></html> - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 20 - - - - - - - - - GUI - - - - 9 - - - 6 - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Help Browser - - - - - - - /sec - - - 100 - - - 2 - - - 20 - - - - - - - GUI Refresh Rate: - - - - - - - - RemoteControl - - - - 9 - - - 6 - - - - - enable midi remote control - - - Midi Remote Control - - - true - - - - 9 - - - 6 - - - - - Record - - - - - - - Goto Left Mark - - - - - - - Stop - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Play - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Colors - - - - 9 - - - 6 - - - - - 0 + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + + GUI + + + + 9 6 - - - - S + + + + Qt::Vertical - - Qt::AlignCenter + + + 20 + 40 + - + - - - - 255 - - - Qt::Horizontal - - + + - - - - - - 0 - - - 6 - - - + + - H - - - Qt::AlignCenter + Help Browser - - + + + + /sec + - 255 + 100 - - Qt::Horizontal + + 2 + + + 20 + + + + + + + GUI Refresh Rate: - - - - - - 7 - 7 - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - - - - - add to palette - - - - - - - Qt::NoFocus - - - Palette - - - - 9 - - - 6 - - - - - - - - true - - - - - - - - - - true - - - - - - - - - - true - - - - - - - - - - true - - - - - - - - - - true - - - - - - - - - - true - - - - - - - - - - true - - - - - - - - - - true - - - - - - - - - - true - - - - - - - - - - true - - - - - - - - - - true - - - - - - - - - - true - - - - - - - - - - true - - - - - - - - - - true - - - - - - - - - - true - - - - - - - - - - true - - - - - - - - - - - 1 - 7 - 0 - 0 - - - - true - - - - Items - - - - - - + + + + RemoteControl + + - 0 + 9 6 - - - V - - - Qt::AlignCenter + + + enable midi remote control - - - - - - 255 + + Midi Remote Control - - Qt::Horizontal + + true - - - - - - - - - Style/Fonts - - - - 9 - - - 6 - - - - - - 7 - 5 - 0 - 0 - - - - QT Theme - - - - 11 - - - 6 - - - + - 0 + 9 6 - - + + + + Record + + + + + + + Goto Left Mark + + + + + + + Stop + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Play + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Colors + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + S + + + Qt::AlignCenter + + + + + + + 255 + + + Qt::Horizontal + + + + + + + + + 0 + + + 6 + + + + + H + + + Qt::AlignCenter + + + + + + + 255 + + + Qt::Horizontal + + + + + + + + + + 7 + 7 + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + + + + + add to palette + + + + + + + Qt::NoFocus + + + Palette + + + + 9 + + + 6 + + + + + + + + true + + + + + + + + + + true + + + + + + + + + + true + + + + + + + + + + true + + + + + + + + + + true + + + + + + + + + + true + + + + + + + + + + true + + + + + + + + + + true + + + + + + + + + + true + + + + + + + + + + true + + + + + + + + + + true + + + + + + + + + + true + + + + + + + + + + true + + + + + + + + + + true + + + + + + + + + + true + + + + + + + + + + true + + + + + + + + + + + 1 + 7 + 0 + 0 + + + + true + + + + Items + + + + + + + + 0 + + + 6 + + + + + V + + + Qt::AlignCenter + + + + + + + 255 + + + Qt::Horizontal + + + + + + + + + + Fonts/Style + + + + 9 + + + 6 + + + + + + 7 + 5 + 0 + 0 + + + + QT Theme + + + + 11 + + + 6 + + + + + 0 + + + 6 + + + + + + 1 + 0 + 0 + 0 + + + + + Windows + + + + + MusE + + + + + Metal + + + + + Norwegian Wood + + + + + Platinum + + + + + CDE + + + + + Motif + + + + + Motif Plus + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 190 + 20 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + + + + + + + + Fonts + + + + 11 + + + 2 + + + + + Family + + + + + + + Size + + + + + + + Font 1 + + + + + + + Font 2 + + + + + + + Font 3 + + + + + + + + 7 + 0 + 0 + 0 + + + + + + + + + 7 + 0 + 0 + 0 + + + + + + + + + 7 + 0 + 0 + 0 + + + + + + + + + 7 + 0 + 0 + 0 + + + + + + + + Font 0 + + + + + + + + 4 + 0 + 0 + 0 + + + + + + + + + 4 + 0 + 0 + 0 + + + + + + + + + 4 + 0 + 0 + 0 + + + + + + + + + 4 + 0 + 0 + 0 + + + + + + + + Bold + + + + + + + Bold + + + + + + + Bold + + + + + + + Bold + + + + + + + Italic + + + + + + + Italic + + + + + + + Italic + + + + + + + Italic + + + + + + + + 4 + 1 + 0 + 0 + + + + ... + + + + + + + + 4 + 1 + 0 + 0 + + + + ... + + + + + + + + 4 + 1 + 0 + 0 + + + + ... + + + + + + + + 4 + 1 + 0 + 0 + + + + ... + + + + + + + Font 4 + + + + + + + + 7 + 0 + 0 + 0 + + + + + + + + Font 5 + + + + + - 1 + 7 0 0 0 - - - Windows - - - - - MusE - - - - - Metal - - - - - Norwegian Wood - - - - - Platinum - - - - - CDE - - - - - Motif - - - - - Motif Plus - - - - - - Qt::Horizontal + + + + + 4 + 0 + 0 + 0 + - - QSizePolicy::Expanding + + + + + + + 4 + 0 + 0 + 0 + - - - 190 - 20 - + + + + + + Bold - + + + + + + Bold + + + + + + + Italic + + + + + + + Italic + + + + + + + + 4 + 1 + 0 + 0 + + + + ... + + + + + + + + 4 + 1 + 0 + 0 + + + + ... + + - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 40 - - - - - + + + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 131 + 31 + + + + + + + + Apply + - - - Fonts + + + OK + + + + + + + Cancel - - - 11 - - - 6 - - - - - Family - - - - - - - Size - - - - - - - Font 1 - - - - - - - Font 2 - - - - - - - Font 3 - - - - - - - - 7 - 0 - 0 - 0 - - - - - - - - - 7 - 0 - 0 - 0 - - - - - - - - - 7 - 0 - 0 - 0 - - - - - - - - - 7 - 0 - 0 - 0 - - - - - - - - Font 0 - - - - - - - - 4 - 0 - 0 - 0 - - - - - - - - - 4 - 0 - 0 - 0 - - - - - - - - - 4 - 0 - 0 - 0 - - - - - - - - - 4 - 0 - 0 - 0 - - - - - - - - Bold - - - - - - - Bold - - - - - - - Bold - - - - - - - Bold - - - - - - - Italic - - - - - - - Italic - - - - - - - Italic - - - - - - - Italic - - - - - - - - 4 - 1 - 0 - 0 - - - - ... - - - - - - - - 4 - 1 - 0 - 0 - - - - ... - - - - - - - - 4 - 1 - 0 - 0 - - - - ... - - - - - - - - 4 - 1 - 0 - 0 - - - - ... - - - - - - - Font 4 - - - - - - - - 7 - 0 - 0 - 0 - - - - - - - - Font 5 - - - - - - - - 7 - 0 - 0 - 0 - - - - - - - - - 4 - 0 - 0 - 0 - - - - - - - - - 4 - 0 - 0 - 0 - - - - - - - - Bold - - - - - - - Bold - - - - - - - Italic - - - - - - - Italic - - - - - - - - 4 - 1 - 0 - 0 - - - - ... - - - - - - - - 4 - 1 - 0 - 0 - - - - ... - - - - - - - - - - 0 - - - 6 - - - - - Qt::Horizontal - - - - 131 - 31 - - - - - - - - Apply - - - - - - - OK - - - - - - - Cancel - - - - - + + - - RecordButton - QToolButton -
recordbutton.h
- 0 - -
GreendotButton QToolButton @@ -2298,6 +2327,13 @@ 0 + + RecordButton + QToolButton +
recordbutton.h
+ 0 + +
diff --git a/muse/muse/projectdialog.cpp b/muse/muse/projectdialog.cpp new file mode 100644 index 00000000..95108be1 --- /dev/null +++ b/muse/muse/projectdialog.cpp @@ -0,0 +1,143 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2002-2006 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#include "projectdialog.h" +#include "gconfig.h" +#include "song.h" + +//--------------------------------------------------------- +// ProjectDialog +//--------------------------------------------------------- + +ProjectDialog::ProjectDialog(QWidget* parent) + : QDialog(parent) + { + setupUi(this); + projectTree->setSelectionBehavior(QAbstractItemView::SelectRows); + projectTree->setSelectionMode(QAbstractItemView::SingleSelection); + QDir pd(QDir::homePath() + "/" + config.projectPath); + QStringList el = pd.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); + QTreeWidgetItem* current = 0; + foreach (QString s, el) { + QFile pf(QDir::homePath() + "/" + config.projectPath + "/" + + s + "/" + s + ".med"); + if (pf.exists()) { + QTreeWidgetItem* pi = new QTreeWidgetItem; + pi->setText(0, s); + projectTree->addTopLevelItem(pi); + if (s == song->projectName()) + current = pi; + } + } + connect(projectTree, + SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), + SLOT(currentChanged(QTreeWidgetItem*, QTreeWidgetItem*))); + connect(projectTree, + SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), + SLOT(accept())); + connect(projectName, + SIGNAL(textEdited(const QString&)), + SLOT(projectNameEdited(const QString&))); + + if (current) + projectTree->setCurrentItem(current); + else + currentChanged(0, 0); + } + +//--------------------------------------------------------- +// currentChanged +//--------------------------------------------------------- + +void ProjectDialog::currentChanged(QTreeWidgetItem* item, QTreeWidgetItem*) + { + bool enable = item != 0; + createdDate->setEnabled(enable); + modifiedDate->setEnabled(enable); + comment->setEnabled(enable); + length->setEnabled(enable); + + if (!enable) + return; + + projectName->setText(item->text(0)); + QFileInfo pf(QDir::homePath() + "/" + config.projectPath + "/" + + item->text(0) + "/" + item->text(0) + ".med"); + createdDate->setDateTime(pf.created()); + modifiedDate->setDateTime(pf.lastModified()); + + QTime time(0, 0, 0); + + QFile f(pf.filePath()); + QDomDocument doc; + int line, column; + QString err; + if (!doc.setContent(&f, false, &err, &line, &column)) { + QString col, ln, error; + col.setNum(column); + ln.setNum(line); + error = err + "\n at line: " + ln + " col: " + col; + printf("error reading med file: %s\n", error.toLatin1().data()); + return; + } + for (QDomNode node = doc.documentElement(); !node.isNull(); node = node.nextSibling()) { + QDomElement e = node.toElement(); + if (e.isNull()) + continue; + if (e.tagName() == "muse") { + QString sversion = e.attribute("version", "1.0"); + int major=0, minor=0; + sscanf(sversion.toLatin1().data(), "%d.%d", &major, &minor); + int version = major << 8 + minor; + if (version >= 0x200) { + for (QDomNode n1 = node.firstChild(); !n1.isNull(); n1 = n1.nextSibling()) { + QDomElement e = n1.toElement(); + if (e.tagName() == "song") { + for (QDomNode n2 = n1.firstChild(); !n2.isNull(); n2 = n2.nextSibling()) { + QDomElement e = n2.toElement(); + QString tag(e.tagName()); + QString s(e.text()); + if (tag == "comment") + comment->setPlainText(s); + else if (tag == "LenInSec") { + int sec = s.toInt(); + time = time.addSecs(sec); + } + } + } + } + } + } + } + length->setTime(time); + } + +//--------------------------------------------------------- +// projectNameEdited +//--------------------------------------------------------- + +void ProjectDialog::projectNameEdited(const QString&) + { + QTreeWidgetItem* item = projectTree->currentItem(); + if (item) + projectTree->setItemSelected(item, false); + projectTree->setCurrentItem(0); + } + diff --git a/muse/muse/projectdialog.h b/muse/muse/projectdialog.h new file mode 100644 index 00000000..c0ddfee9 --- /dev/null +++ b/muse/muse/projectdialog.h @@ -0,0 +1,43 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2002-2006 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#ifndef __PROJECT_DIALOG_H__ +#define __PROJECT_DIALOG_H__ + +#include "ui_projectdialog.h" + +//--------------------------------------------------------- +// ProjectDialog +//--------------------------------------------------------- + +class ProjectDialog : public QDialog, public Ui_ProjectDialogBase { + Q_OBJECT + + private slots: + void currentChanged(QTreeWidgetItem*, QTreeWidgetItem*); + void projectNameEdited(const QString&); + + public: + ProjectDialog(QWidget* parent = 0); + QString project() const { return projectName->text(); } + }; + +#endif + diff --git a/muse/muse/projectdialog.ui b/muse/muse/projectdialog.ui new file mode 100644 index 00000000..006db8cc --- /dev/null +++ b/muse/muse/projectdialog.ui @@ -0,0 +1,206 @@ + + + + + ProjectDialogBase + + + + 0 + 0 + 574 + 385 + + + + MusE: Select Project + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + + Project + + + + + + + + Properties + + + + 9 + + + 3 + + + + + true + + + + + + + true + + + + + + + true + + + + + + + Length: + + + + + + + Comment: + + + + + + + Modified: + + + + + + + Created: + + + + + + + + + + + + + + + 0 + + + 6 + + + + + Project: + + + + + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 131 + 31 + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + + + + okButton + clicked() + ProjectDialogBase + accept() + + + 278 + 253 + + + 96 + 254 + + + + + cancelButton + clicked() + ProjectDialogBase + reject() + + + 369 + 253 + + + 179 + 282 + + + + + diff --git a/muse/muse/song.cpp b/muse/muse/song.cpp index 287bf812..47965f43 100644 --- a/muse/muse/song.cpp +++ b/muse/muse/song.cpp @@ -39,6 +39,7 @@ #include "midiplugin.h" #include "midirc.h" #include "part.h" +#include "conf.h" Song* song; @@ -2353,3 +2354,124 @@ bool Song::trackExists(Track* t) const } return false; } + +//--------------------------------------------------------- +// projectDirectory +//--------------------------------------------------------- + +QString Song::projectDirectory() const + { + return QDir::homePath() + "/" + config.projectPath + "/" + _projectName; + } + +//--------------------------------------------------------- +// projectName +//--------------------------------------------------------- + +QString Song::projectName() const + { + return _projectName; + } + +//--------------------------------------------------------- +// setProjectName +//--------------------------------------------------------- + +void Song::setProjectName(const QString& s) + { + _projectName = s; + } + +//--------------------------------------------------------- +// load +//--------------------------------------------------------- + +void Song::load() + { + clear(false); + + QString s = projectDirectory() + "/" + _projectName + ".med"; + + QFile f(s); + if (f.open(QIODevice::ReadOnly)) { + int rv = read(&f); + f.close(); + if (rv) { + QMessageBox::critical(0, QString("MusE"), + tr("File read error")); + return; + } + } + dirty = false; + } + +//--------------------------------------------------------- +// read +//--------------------------------------------------------- + +bool Song::read(QFile* qf) + { + QDomDocument doc; + + int line, column; + QString err; + if (!doc.setContent(qf, false, &err, &line, &column)) { + QString col, ln, error; + col.setNum(column); + ln.setNum(line); + error = err + "\n at line: " + ln + " col: " + col; + printf("error reading med file: %s\n", error.toLatin1().data()); + return true; + } + for (QDomNode node = doc.documentElement(); !node.isNull(); node = node.nextSibling()) { + QDomElement e = node.toElement(); + if (e.isNull()) + continue; + if (e.tagName() == "muse") { + QString sversion = e.attribute("version", "1.0"); + int major=0, minor=0; + sscanf(sversion.toLatin1().data(), "%d.%d", &major, &minor); + int version = major << 8 + minor; + if (version >= 0x200) + read20(node.firstChild()); + else if (version == 0x100) + read10(node.firstChild()); + else + printf("unsupported *.med file version %s\n", sversion.toLatin1().data()); + } + else + printf("MusE: %s not supported\n", e.tagName().toLatin1().data()); + } + return false; + } + +//--------------------------------------------------------- +// read10 +//--------------------------------------------------------- + +void Song::read10(QDomNode) + { + printf("reading type 1.0 *.med files not implemented\n"); + } + +//--------------------------------------------------------- +// read20 +//--------------------------------------------------------- + +void Song::read20(QDomNode node) + { + for (; !node.isNull(); node = node.nextSibling()) { + QDomElement e = node.toElement(); + if (e.isNull()) + continue; + if (e.tagName() == "configuration") + readConfiguration(node.firstChild()); + else if (e.tagName() == "song") + read(node.firstChild()); + else if (e.tagName() == "toplevels") + muse->readToplevels(node.firstChild()); + else + printf("MusE:read20(): unknown tag %s\n", e.tagName().toLatin1().data()); + } + } + diff --git a/muse/muse/song.h b/muse/muse/song.h index 0ff78413..2317ae6d 100644 --- a/muse/muse/song.h +++ b/muse/muse/song.h @@ -86,6 +86,9 @@ class Song : public QObject { MARKER_TICK, MARKER_LOCK }; private: + QString _projectName; + QString _comment; + MidiFifo eventFifo; int updateFlags; @@ -126,6 +129,66 @@ class Song : public QObject { int _globalPitchShift; void readMarker(QDomNode); + public slots: + void beat(); + + void undo(); + void redo(); + + void setTempo(int t); + void setSig(const AL::TimeSignature&); + + void setMasterFlag(bool flag); + void setLoop(bool f); + void setRecord(bool f); + void setPlay(bool f); + void setStop(bool); + void forward(); + void rewindStart(); + void rewind(); + void setPunchin(bool f); + void setPunchout(bool f); + void setClick(bool val); + void setQuantize(bool val); + void panic(); + void seqSignal(int fd); + Track* addTrack(QAction*); + void setMeasureLen(int l); + void changePart(Part*, unsigned, unsigned); + void createLRPart(Track* track); + void setTickPos(int, unsigned); + + void setPos(int, const AL::Pos&); + void setPos(int, const AL::Pos&, bool sig, bool isSeek = true, + bool adjustScrollbar = false); + + signals: + void songChanged(int); + void posChanged(int, const AL::Pos&, bool); + void loopChanged(bool); + void recordChanged(bool); + void playChanged(bool); + void punchinChanged(bool); + void punchoutChanged(bool); + void clickChanged(bool); + void quantizeChanged(bool); + void markerChanged(int); + void midiPortsChanged(); + void midiEvent(const MidiEvent&); + void trackAdded(Track*, int idx); + void trackRemoved(Track*); + void lenChanged(const AL::Pos&); + void measureLenChanged(int); + + void recordChanged(Track*,bool); + void muteChanged(Track*,bool); + void soloChanged(Track*,bool); + void offChanged(Track*,bool); + void autoReadChanged(Track*,bool); + void autoWriteChanged(Track*,bool); + void trackSelectionChanged(Track*); + void tempoChanged(); + public: Song(); ~Song(); @@ -332,65 +395,16 @@ class Song : public QObject { void setSolo(Track*,bool); void setOff(Track*,bool); - public slots: - void beat(); - - void undo(); - void redo(); - - void setTempo(int t); - void setSig(const AL::TimeSignature&); - - void setMasterFlag(bool flag); - void setLoop(bool f); - void setRecord(bool f); - void setPlay(bool f); - void setStop(bool); - void forward(); - void rewindStart(); - void rewind(); - void setPunchin(bool f); - void setPunchout(bool f); - void setClick(bool val); - void setQuantize(bool val); - void panic(); - void seqSignal(int fd); - Track* addTrack(QAction*); - void setMeasureLen(int l); - void changePart(Part*, unsigned, unsigned); - void createLRPart(Track* track); - void setTickPos(int, unsigned); + QString projectDirectory() const; + QString projectName() const; + void setProjectName(const QString&); + QString comment() const { return _comment; } + void setComment(const QString& s) { _comment = s; } - void setPos(int, const AL::Pos&); - void setPos(int, const AL::Pos&, bool sig, bool isSeek = true, - bool adjustScrollbar = false); - - signals: - void songChanged(int); - void posChanged(int, const AL::Pos&, bool); - void loopChanged(bool); - void recordChanged(bool); - void playChanged(bool); - void punchinChanged(bool); - void punchoutChanged(bool); - void clickChanged(bool); - void quantizeChanged(bool); - void markerChanged(int); - void midiPortsChanged(); - void midiEvent(const MidiEvent&); - void trackAdded(Track*, int idx); - void trackRemoved(Track*); - void lenChanged(const AL::Pos&); - void measureLenChanged(int); - - void recordChanged(Track*,bool); - void muteChanged(Track*,bool); - void soloChanged(Track*,bool); - void offChanged(Track*,bool); - void autoReadChanged(Track*,bool); - void autoWriteChanged(Track*,bool); - void trackSelectionChanged(Track*); - void tempoChanged(); + void load(); + bool read(QFile* qf); + void read20(QDomNode node); + void read10(QDomNode); }; extern Song* song; diff --git a/muse/muse/songfile.cpp b/muse/muse/songfile.cpp index ba6409d1..3e62ccaf 100644 --- a/muse/muse/songfile.cpp +++ b/muse/muse/songfile.cpp @@ -250,6 +250,8 @@ void Song::read(QDomNode node) PianoRoll::readConfiguration(node); else if (tag == "DrumEdit") DrumEdit::readConfiguration(node); + else if (tag == "comment") + _comment = e.text(); else printf("MusE:Song: unknown tag %s\n", tag.toLatin1().data()); } @@ -263,9 +265,10 @@ void Song::read(QDomNode node) void Song::write(Xml& xml) const { xml.tag("song"); - xml.intTag("cpos", song->cpos()); - xml.intTag("rpos", song->rpos()); - xml.intTag("lpos", song->lpos()); + xml.strTag("comment", _comment); + xml.intTag("cpos", cpos()); + xml.intTag("rpos", rpos()); + xml.intTag("lpos", lpos()); xml.intTag("master", _masterFlag); if (loopFlag) xml.intTag("loop", loopFlag); @@ -354,74 +357,3 @@ void MusE::write(Xml& xml) const xml.etag("muse"); } -//--------------------------------------------------------- -// read -// read song -//--------------------------------------------------------- - -bool MusE::read(QFile* qf, bool /*skipConfig*/) - { - QDomDocument doc; - - int line, column; - QString err; - if (!doc.setContent(qf, false, &err, &line, &column)) { - QString col, ln, error; - col.setNum(column); - ln.setNum(line); - error = err + "\n at line: " + ln + " col: " + col; - printf("error reading med file: %s\n", error.toLatin1().data()); - return true; - } - for (QDomNode node = doc.documentElement(); !node.isNull(); node = node.nextSibling()) { - QDomElement e = node.toElement(); - if (e.isNull()) - continue; - if (e.tagName() == "muse") { - QString sversion = e.attribute("version", "1.0"); - int major=0, minor=0; - sscanf(sversion.toLatin1().data(), "%d.%d", &major, &minor); - version = major << 8 + minor; - if (version >= 0x200) - read20(node.firstChild()); - else if (version == 0x100) - read10(node.firstChild()); - else - printf("unsupported *.med file version %s\n", sversion.toLatin1().data()); - } - else - printf("MusE: %s not supported\n", e.tagName().toLatin1().data()); - } - return false; - } - -//--------------------------------------------------------- -// read10 -//--------------------------------------------------------- - -void MusE::read10(QDomNode) - { - printf("reading type 1.0 *.med files not implemented\n"); - } - -//--------------------------------------------------------- -// read20 -//--------------------------------------------------------- - -void MusE::read20(QDomNode node) - { - for (; !node.isNull(); node = node.nextSibling()) { - QDomElement e = node.toElement(); - if (e.isNull()) - continue; - if (e.tagName() == "configuration") - readConfiguration(node.firstChild()); - else if (e.tagName() == "song") - song->read(node.firstChild()); - else if (e.tagName() == "toplevels") - readToplevels(node.firstChild()); - else - printf("MusE:read20(): unknown tag %s\n", e.tagName().toLatin1().data()); - } - } - diff --git a/muse/muse/synth.cpp b/muse/muse/synth.cpp index fecd5084..06e798a0 100644 --- a/muse/muse/synth.cpp +++ b/muse/muse/synth.cpp @@ -345,7 +345,7 @@ void initMidiSynth() synthis.push_back(new MessSynth(&fi)); } if (debugMsg) - printf("%ld soft synth found\n", synthis.size()); + printf("%zd soft synth found\n", synthis.size()); } } diff --git a/muse/muse/wave.cpp b/muse/muse/wave.cpp index cb0d7d49..4bd0b262 100644 --- a/muse/muse/wave.cpp +++ b/muse/muse/wave.cpp @@ -465,18 +465,8 @@ QString SndFile::strerror() const SndFile* SndFile::getWave(const QString& inName, bool writeFlag) { - QString name = inName; + QString name = song->projectDirectory() + "/" + inName; - if (QFileInfo(name).isRelative()) { - name = museProject + QString("/") + name; - } - else { - if (!QFile::exists(name)) { - if (QFile::exists(museProject + QString("/") + name)) { - name = museProject + QString("/") + name; - } - } - } // printf("=====%s %s\n", inName.toLatin1().data(), name.toLatin1().data()); SndFile* f = sndFiles.value(name); if (f == 0) { @@ -769,7 +759,7 @@ SndFile* SndFile::createRecFile(int channels) QString fileName("%1/rec%2.wav"); QFileInfo fi; do { - fi.setFile(fileName.arg(museProject).arg(recFileNumber)); + fi.setFile(fileName.arg(song->projectDirectory()).arg(recFileNumber)); ++recFileNumber; } while (fi.exists()); SndFile* recFile = new SndFile(fi.absoluteFilePath()); diff --git a/muse/muse/waveedit/waveview.cpp b/muse/muse/waveedit/waveview.cpp index 84a187ad..d01e8148 100644 --- a/muse/muse/waveedit/waveview.cpp +++ b/muse/muse/waveedit/waveview.cpp @@ -761,11 +761,11 @@ void WaveView::editExternal(unsigned file_format, unsigned file_samplerate, unsi bool WaveView::getUniqueTmpfileName(QString& newFilename) { // Check if tmp-directory exists under project path - QString tmpWavDir = museProject + "/tmp_musewav"; //!@TODO: Don't hardcode like this + QString tmpWavDir = song->projectDirectory() + "/tmp_musewav"; //!@TODO: Don't hardcode like this QFileInfo tmpdirfi(tmpWavDir); if (!tmpdirfi.isDir()) { // Try to create a tmpdir - QDir projdir(museProject); + QDir projdir(song->projectDirectory()); if (!projdir.mkdir("tmp_musewav")) { printf("Could not create undo dir!\n"); return false; diff --git a/muse/muse/waveevent.cpp b/muse/muse/waveevent.cpp index eee863c2..a15418cc 100644 --- a/muse/muse/waveevent.cpp +++ b/muse/muse/waveevent.cpp @@ -104,16 +104,7 @@ void WaveEventBase::write(Xml& xml, const Pos& offset) const // wpos.setTick(wpos.tick() + offset); wpos.write(xml, "poslen"); xml.intTag("frame", _spos); // offset in wave file - - // - // waves in the project dirctory are stored - // with relative path name, others with absolute path - // - QString path = f.finfo()->absolutePath(); - if (path == museProject) - xml.strTag("file", f.finfo()->fileName()); - else - xml.strTag("file", f.finfo()->filePath()); + xml.strTag("file", f.finfo()->fileName()); xml.etag("event"); } -- cgit v1.2.3