|
From: Tapio V. <aa...@us...> - 2011-01-28 07:59:22
|
Module: editor
Branch: master
Commit: 7202bb05b4532808dd3ad2710d230b831f16965e
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 28 09:58:26 2011 +0200
Remember bpm from importing and use it when exporting.
Something is still wrong. :(
---
song.cc | 1 +
song.hh | 1 +
songparser-txt.cc | 4 ++--
songparser-xml.cc | 8 ++++----
songparser.cc | 1 -
songparser.hh | 3 +--
songwriter-xml.cc | 6 +++++-
songwriter.hh | 3 ++-
8 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/song.cc b/song.cc
index 4850f79..4964e71 100644
--- a/song.cc
+++ b/song.cc
@@ -30,6 +30,7 @@ void Song::reload(bool errorIgnore) {
videoGap = 0.0;
start = 0.0;
preview_start = getNaN();
+ bpm = 0.0;
hasBRE = false;
b0rkedTracks = false;
if (!filename.isEmpty()) {
diff --git a/song.hh b/song.hh
index 941b580..fe5cbb7 100644
--- a/song.hh
+++ b/song.hh
@@ -125,6 +125,7 @@ class Song {
QString cover; ///< cd cover
QString background; ///< background image
QString video; ///< video
+ double bpm; ///< used for more accurate import --> export cycle
/// Variables used for comparisons (sorting)
QString collateByTitle;
QString collateByTitleOnly;
diff --git a/songparser-txt.cc b/songparser-txt.cc
index 1762b16..6f9a625 100644
--- a/songparser-txt.cc
+++ b/songparser-txt.cc
@@ -20,7 +20,7 @@ void SongParser::txtParse() {
while (getline(line) && txtParseField(line)) {}
if (m_song.title.isEmpty() || m_song.artist.isEmpty())
throw std::runtime_error("Required header fields missing");
- if (m_bpm != 0.0) addBPM(0, m_bpm);
+ if (m_song.bpm != 0.0) addBPM(0, m_song.bpm);
// Parse notes
VocalTrack vocal(TrackName::LEAD_VOCAL);
@@ -57,7 +57,7 @@ bool SongParser::txtParseField(QString const& line) {
else if (key == "PREVIEWSTART") m_song.preview_start = value.toDouble(&ok);
else if (key == "RELATIVE") assign(m_relative, value);
else if (key == "GAP") { m_gap = value.toDouble(&ok); m_gap *= 1e-3; }
- else if (key == "BPM") m_bpm = value.toDouble(&ok);
+ else if (key == "BPM") m_song.bpm = value.toDouble(&ok);
else if (key == "LANGUAGE") m_song.language= value;
else if (key == "YEAR") m_song.year = value;
diff --git a/songparser-xml.cc b/songparser-xml.cc
index ee266c4..14a3039 100644
--- a/songparser-xml.cc
+++ b/songparser-xml.cc
@@ -29,12 +29,12 @@ void SongParser::xmlParse()
// Parse meta
QDomElement root = doc.documentElement();
- m_bpm = root.attribute("Tempo").toInt();
- if (m_bpm == 0)
+ m_song.bpm = root.attribute("Tempo").toInt();
+ if (m_song.bpm == 0)
throw std::runtime_error(QT_TR_NOOP("Invalid tempo"));
if (root.attribute("Resolution") == QString("Demisemiquaver"))
- m_bpm *= 2;
- addBPM(0, m_bpm);
+ m_song.bpm *= 2;
+ addBPM(0, m_song.bpm);
m_song.genre = root.attribute("Genre");
m_song.year = root.attribute("Year");
diff --git a/songparser.cc b/songparser.cc
index 2a48c8e..1fabe55 100644
--- a/songparser.cc
+++ b/songparser.cc
@@ -20,7 +20,6 @@ SongParser::SongParser(Song& s):
m_linenum(),
m_relative(),
m_gap(),
- m_bpm(),
m_prevtime(),
m_prevts(),
m_relativeShift(),
diff --git a/songparser.hh b/songparser.hh
index 5ece020..46aa2e1 100644
--- a/songparser.hh
+++ b/songparser.hh
@@ -22,7 +22,6 @@ class SongParser {
bool getline(QString& line);
bool m_relative;
double m_gap;
- double m_bpm;
// UltraStar TXT
bool txtCheck(QString const& data);
@@ -48,7 +47,7 @@ class SongParser {
unsigned int m_relativeShift;
double m_maxScore;
struct BPM {
- BPM(double _begin, double _ts, double bpm): begin(_begin), step(0.25 * 60.0 / bpm), ts(_ts) {}
+ BPM(double _begin, double _ts, double _bpm): begin(_begin), step(0.25 * 60.0 / _bpm), ts(_ts) {}
double begin; // Time in seconds
double step; // Seconds per quarter note
double ts;
diff --git a/songwriter-xml.cc b/songwriter-xml.cc
index 456963e..3fd2d6d 100644
--- a/songwriter-xml.cc
+++ b/songwriter-xml.cc
@@ -6,6 +6,10 @@
void SingStarXMLWriter::writeXML() {
+ if (tempo > 300) {
+ tempo /= 2;
+ res = "Demisemiquaver"; // Demisemiquaver = 2x tempo of Semiquaver
+ }
QDomDocument doc("");
QDomElement root = doc.createElement("MELODY");
root.setAttribute("xmlns", "http://www.singstargame.com");
@@ -13,7 +17,7 @@ void SingStarXMLWriter::writeXML() {
root.setAttribute("Version", "1");
root.setAttribute("Tempo", QString::number(tempo));
root.setAttribute("FixedTempo", "Yes");
- root.setAttribute("Resolution", "Demisemiquaver"); // Demisemiquaver = 2x tempo of Semiquaver
+ root.setAttribute("Resolution", res);
root.setAttribute("Genre", s.genre);
root.setAttribute("Year", s.year);
root.setAttribute("xsi:schemaLocation", "http://www.singstargame.com http://15GMS-SINGSQL/xml_schema/melody.xsd");
diff --git a/songwriter.hh b/songwriter.hh
index fe21997..62da8e2 100644
--- a/songwriter.hh
+++ b/songwriter.hh
@@ -13,12 +13,13 @@ struct SongWriter
struct SingStarXMLWriter: public SongWriter
{
SingStarXMLWriter(const Song& s_, const QString& path_)
- : SongWriter(s_, path_), tempo(160) { writeXML(); }
+ : SongWriter(s_, path_), tempo(s_.bpm > 0 ? s_.bpm : 180), res("Semiquaver") { writeXML(); }
private:
void writeXML();
int sec2dur(double sec);
double dur2sec(int ts);
int tempo;
+ QString res;
};
struct UltraStarTXTWriter: public SongWriter
|