summaryrefslogtreecommitdiff
path: root/muse2/muse/songfile.cpp
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-09-10 17:06:00 +0000
committerFlorian Jung <flo@windfisch.org>2011-09-10 17:06:00 +0000
commit24f84a489364741eb3fc126a3f83d91a86b65e27 (patch)
tree63a4e20aaf4a2ebd2462c91b574eddceeac31170 /muse2/muse/songfile.cpp
parent38c5cccc7273247353264bb7dc97f42296d8e259 (diff)
parent2120ea4f083228dde0d7307203391a4ec8f57e2d (diff)
merged the first bunch of orcans changes
STILL WAIT WITH COMMITTING NEW STUFF! i have to merge the rest as well! this is a bit buggy (connect errors, not tested much), but doesn't segfault immediately
Diffstat (limited to 'muse2/muse/songfile.cpp')
-rw-r--r--muse2/muse/songfile.cpp221
1 files changed, 121 insertions, 100 deletions
diff --git a/muse2/muse/songfile.cpp b/muse2/muse/songfile.cpp
index fb279e92..6bc0f24d 100644
--- a/muse2/muse/songfile.cpp
+++ b/muse2/muse/songfile.cpp
@@ -4,6 +4,21 @@
// $Id: songfile.cpp,v 1.25.2.12 2009/11/04 15:06:07 spamatica Exp $
//
// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; version 2 of
+// the License, or (at your option) any later version.
+//
+// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
//=========================================================
#include <assert.h>
@@ -944,6 +959,8 @@ QFont Song::readFont(Xml& xml, const char* name)
return f;
}
+namespace MusEApp {
+
//---------------------------------------------------------
// readPart
//---------------------------------------------------------
@@ -1206,6 +1223,102 @@ void MusE::readMidiport(Xml& xml)
}
//---------------------------------------------------------
+// read
+// read song
+//---------------------------------------------------------
+
+void MusE::read(Xml& xml, bool skipConfig, bool isTemplate)
+ {
+ bool skipmode = true;
+ for (;;) {
+ if (progress)
+ progress->setValue(progress->value()+1);
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (skipmode && tag == "muse")
+ skipmode = false;
+ else if (skipmode)
+ break;
+ else if (tag == "configuration")
+ if (skipConfig)
+ //xml.skip(tag);
+ readConfiguration(xml,true /* only read sequencer settings */);
+ else
+ readConfiguration(xml, false);
+ else if (tag == "song")
+ {
+ song->read(xml, isTemplate);
+ audio->msgUpdateSoloStates();
+ }
+ else if (tag == "midiport")
+ readMidiport(xml);
+ else if (tag == "Controller") { // obsolete
+ MidiController* ctrl = new MidiController;
+ ctrl->read(xml);
+ delete ctrl;
+ }
+ else if (tag == "mplugin")
+ readStatusMidiInputTransformPlugin(xml);
+ else if (tag == "toplevels")
+ readToplevels(xml);
+ else
+ xml.unknown("muse");
+ break;
+ case Xml::Attribut:
+ if (tag == "version") {
+ int major = xml.s2().section('.', 0, 0).toInt();
+ int minor = xml.s2().section('.', 1, 1).toInt();
+ xml.setVersion(major, minor);
+ }
+ break;
+ case Xml::TagEnd:
+ if (!skipmode && tag == "muse")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+
+//---------------------------------------------------------
+// write
+// write song
+//---------------------------------------------------------
+
+void MusE::write(Xml& xml) const
+ {
+ xml.header();
+
+ int level = 0;
+ xml.tag(level++, "muse version=\"2.0\"");
+ writeConfiguration(level, xml);
+
+ writeStatusMidiInputTransformPlugins(level, xml);
+
+ song->write(level, xml);
+
+ if (!toplevels.empty()) {
+ xml.tag(level++, "toplevels");
+ for (ciToplevel i = toplevels.begin(); i != toplevels.end(); ++i) {
+ if ((*i)->isVisible())
+ (*i)->writeStatus(level, xml);
+ }
+ xml.tag(level--, "/toplevels");
+ }
+
+ xml.tag(level, "/muse");
+ }
+
+} // namespace MusEApp
+
+
+//---------------------------------------------------------
// readMarker
//---------------------------------------------------------
@@ -1224,8 +1337,8 @@ void Song::read(Xml& xml, bool isTemplate)
{
cloneList.clear();
for (;;) {
- if (muse->progress)
- muse->progress->setValue(muse->progress->value()+1);
+ if (MusEGlobal::muse->progress)
+ MusEGlobal::muse->progress->setValue(MusEGlobal::muse->progress->value()+1);
Xml::Token token;
token = xml.parse();
@@ -1267,8 +1380,8 @@ void Song::read(Xml& xml, bool isTemplate)
_follow = FollowMode(xml.parseInt());
else if (tag == "sampleRate") {
int sRate = xml.parseInt();
- if (!isTemplate && audioDevice->deviceType() != AudioDevice::DUMMY_AUDIO && sRate != sampleRate)
- QMessageBox::warning(muse,"Wrong sample rate", "The sample rate in this project and the current system setting differs, the project may not work as intended!");
+ if (!isTemplate && audioDevice->deviceType() != AudioDevice::DUMMY_AUDIO && sRate != MusEGlobal::sampleRate)
+ QMessageBox::warning(MusEGlobal::muse,"Wrong sample rate", "The sample rate in this project and the current system setting differs, the project may not work as intended!");
}
else if (tag == "tempolist") {
tempomap.read(xml);
@@ -1336,8 +1449,8 @@ void Song::read(Xml& xml, bool isTemplate)
readMarker(xml);
else if (tag == "globalPitchShift")
_globalPitchShift = xml.parseInt();
- else if (tag == "automation")
- automation = xml.parseInt();
+ else if (tag == "MusEGlobal::automation")
+ MusEGlobal::automation = xml.parseInt();
else if (tag == "cpos") {
int pos = xml.parseInt();
Pos p(pos, true);
@@ -1376,69 +1489,6 @@ void Song::read(Xml& xml, bool isTemplate)
}
//---------------------------------------------------------
-// read
-// read song
-//---------------------------------------------------------
-
-void MusE::read(Xml& xml, bool skipConfig, bool isTemplate)
- {
- bool skipmode = true;
- for (;;) {
- if (progress)
- progress->setValue(progress->value()+1);
- Xml::Token token = xml.parse();
- const QString& tag = xml.s1();
- switch (token) {
- case Xml::Error:
- case Xml::End:
- return;
- case Xml::TagStart:
- if (skipmode && tag == "muse")
- skipmode = false;
- else if (skipmode)
- break;
- else if (tag == "configuration")
- if (skipConfig)
- //xml.skip(tag);
- readConfiguration(xml,true /* only read sequencer settings */);
- else
- readConfiguration(xml, false);
- else if (tag == "song")
- {
- song->read(xml, isTemplate);
- audio->msgUpdateSoloStates();
- }
- else if (tag == "midiport")
- readMidiport(xml);
- else if (tag == "Controller") { // obsolete
- MidiController* ctrl = new MidiController;
- ctrl->read(xml);
- delete ctrl;
- }
- else if (tag == "mplugin")
- readStatusMidiInputTransformPlugin(xml);
- else if (tag == "toplevels")
- readToplevels(xml);
- else
- xml.unknown("muse");
- break;
- case Xml::Attribut:
- if (tag == "version") {
- int major = xml.s2().section('.', 0, 0).toInt();
- int minor = xml.s2().section('.', 1, 1).toInt();
- xml.setVersion(major, minor);
- }
- break;
- case Xml::TagEnd:
- if (!skipmode && tag == "muse")
- return;
- default:
- break;
- }
- }
- }
-
-//---------------------------------------------------------
// write
//---------------------------------------------------------
@@ -1447,7 +1497,7 @@ void Song::write(int level, Xml& xml) const
xml.tag(level++, "song");
xml.strTag(level, "info", songInfoStr);
xml.intTag(level, "showinfo", showSongInfo);
- xml.intTag(level, "automation", automation);
+ xml.intTag(level, "MusEGlobal::automation", MusEGlobal::automation);
xml.intTag(level, "cpos", song->cpos());
xml.intTag(level, "rpos", song->rpos());
xml.intTag(level, "lpos", song->lpos());
@@ -1464,7 +1514,7 @@ void Song::write(int level, Xml& xml) const
xml.intTag(level, "quantize", _quantize);
xml.intTag(level, "len", _len);
xml.intTag(level, "follow", _follow);
- xml.intTag(level, "sampleRate", sampleRate);
+ xml.intTag(level, "sampleRate", MusEGlobal::sampleRate);
if (_globalPitchShift)
xml.intTag(level, "globalPitchShift", _globalPitchShift);
@@ -1518,32 +1568,3 @@ void Song::write(int level, Xml& xml) const
cloneList = copyCloneList;
}
-//---------------------------------------------------------
-// write
-// write song
-//---------------------------------------------------------
-
-void MusE::write(Xml& xml) const
- {
- xml.header();
-
- int level = 0;
- xml.tag(level++, "muse version=\"2.0\"");
- writeConfiguration(level, xml);
-
- writeStatusMidiInputTransformPlugins(level, xml);
-
- song->write(level, xml);
-
- if (!toplevels.empty()) {
- xml.tag(level++, "toplevels");
- for (ciToplevel i = toplevels.begin(); i != toplevels.end(); ++i) {
- if ((*i)->isVisible())
- (*i)->writeStatus(level, xml);
- }
- xml.tag(level--, "/toplevels");
- }
-
- xml.tag(level, "/muse");
- }
-