aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/base/bpm.cpp48
-rw-r--r--src/base/bpm.hpp45
-rw-r--r--src/base/lyric_line.cpp65
-rw-r--r--src/base/lyric_line.hpp55
-rw-r--r--src/base/lyric_word.cpp52
-rw-r--r--src/base/lyric_word.hpp55
-rw-r--r--src/base/song.cpp189
-rw-r--r--src/base/song.hpp74
-rw-r--r--src/base/songloading/songloading_strategy_txt.cpp6
9 files changed, 486 insertions, 103 deletions
diff --git a/src/base/bpm.cpp b/src/base/bpm.cpp
new file mode 100644
index 00000000..b6072f9d
--- /dev/null
+++ b/src/base/bpm.cpp
@@ -0,0 +1,48 @@
+/*
+ * UltraStar Deluxe - Karaoke Game
+ *
+ * UltraStar Deluxe is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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; either 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; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#include "bpm.hpp"
+
+namespace usdx
+{
+ BPM::BPM(float bpm, int beat) : std::pair<int, float>(beat, bpm)
+ {
+ }
+
+ BPM::~BPM()
+ {
+ }
+
+ const int BPM::get_beat(void) const
+ {
+ return first;
+ }
+
+ const float BPM::get_bpm(void) const
+ {
+ return second;
+ }
+};
diff --git a/src/base/bpm.hpp b/src/base/bpm.hpp
new file mode 100644
index 00000000..2e75feee
--- /dev/null
+++ b/src/base/bpm.hpp
@@ -0,0 +1,45 @@
+/*
+ * UltraStar Deluxe - Karaoke Game
+ *
+ * UltraStar Deluxe is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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; either 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; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#ifndef BPM_HPP
+#define BPM_HPP
+
+#include <utility>
+
+namespace usdx
+{
+ class BPM : public std::pair<int, float>
+ {
+ public:
+ BPM(float bpm, int beat = 0);
+ virtual ~BPM();
+
+ const int get_beat(void) const;
+ const float get_bpm(void) const;
+ };
+};
+
+#endif
diff --git a/src/base/lyric_line.cpp b/src/base/lyric_line.cpp
new file mode 100644
index 00000000..c15ddd58
--- /dev/null
+++ b/src/base/lyric_line.cpp
@@ -0,0 +1,65 @@
+/*
+ * UltraStar Deluxe - Karaoke Game
+ *
+ * UltraStar Deluxe is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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; either 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; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#include "lyric_line.hpp"
+
+namespace usdx
+{
+ LyricLine::LyricLine(int start)
+ {
+ }
+
+ LyricLine::~LyricLine()
+ {
+ words.clear();
+ }
+
+ void LyricLine::set_end(int end)
+ {
+ this->end = end;
+ }
+
+ const int LyricLine::get_end(void) const
+ {
+ return end;
+ }
+
+ void LyricLine::set_start(int start)
+ {
+ this->start = start;
+ }
+
+ const int LyricLine::get_start(void) const
+ {
+ return start;
+ }
+
+ void LyricLine::add_word(LyricWord* word)
+ {
+ words.push_back(word);
+ }
+
+};
diff --git a/src/base/lyric_line.hpp b/src/base/lyric_line.hpp
new file mode 100644
index 00000000..69bf4d0d
--- /dev/null
+++ b/src/base/lyric_line.hpp
@@ -0,0 +1,55 @@
+/*
+ * UltraStar Deluxe - Karaoke Game
+ *
+ * UltraStar Deluxe is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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; either 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; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#ifndef LYRIC_LINE_HPP
+#define LYRIC_LINE_HPP
+
+#include <list>
+#include "lyric_word.hpp"
+
+namespace usdx
+{
+ class LyricLine
+ {
+ private:
+ std::list<LyricWord*> words;
+ int start; ///< in beats
+ int end; ///< in beats
+ public:
+ LyricLine(int start = 0);
+ virtual ~LyricLine();
+
+ void set_end(int end);
+ const int get_end(void) const;
+
+ void set_start(int start);
+ const int get_start(void) const;
+
+ void add_word(LyricWord* word);
+ };
+};
+
+#endif
diff --git a/src/base/lyric_word.cpp b/src/base/lyric_word.cpp
new file mode 100644
index 00000000..c6c5d7d9
--- /dev/null
+++ b/src/base/lyric_word.cpp
@@ -0,0 +1,52 @@
+/*
+ * UltraStar Deluxe - Karaoke Game
+ *
+ * UltraStar Deluxe is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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; either 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; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#include "lyric_word.hpp"
+
+namespace usdx
+{
+ LyricWord::LyricWord(const char type,
+ const int beat,
+ const int length,
+ const int height,
+ const std::string& lyric) :
+ beat(beat), length(length), height(height), text(lyric)
+ {
+ if (type == ':') {
+ this->type = nt_normal;
+ }
+ else if (type == '*') {
+ this->type = nt_golden;
+ }
+ else if (type == 'F') {
+ this->type = nt_freestyle;
+ }
+ }
+
+ LyricWord::~LyricWord(void)
+ {
+ }
+};
diff --git a/src/base/lyric_word.hpp b/src/base/lyric_word.hpp
new file mode 100644
index 00000000..4b19b13c
--- /dev/null
+++ b/src/base/lyric_word.hpp
@@ -0,0 +1,55 @@
+/*
+ * UltraStar Deluxe - Karaoke Game
+ *
+ * UltraStar Deluxe is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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; either 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; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#ifndef LYRIC_WORD_HPP
+#define LYRIC_WORD_HPP
+
+#include <string>
+
+namespace usdx
+{
+ typedef enum {
+ nt_normal,
+ nt_golden,
+ nt_freestyle
+ } NoteType;
+
+ class LyricWord
+ {
+ private:
+ NoteType type;
+ int beat;
+ int length;
+ int height;
+ std::string text;
+
+ public:
+ LyricWord(const char type, const int beat, const int length, const int height, const std::string& lyric);
+ virtual ~LyricWord(void);
+ };
+};
+
+#endif
diff --git a/src/base/song.cpp b/src/base/song.cpp
index bbaae58b..ad5bb724 100644
--- a/src/base/song.cpp
+++ b/src/base/song.cpp
@@ -25,13 +25,14 @@
*/
#include "song.hpp"
+#include "lyric_word.hpp"
namespace usdx
{
log4cxx::LoggerPtr Song::log =
log4cxx::Logger::getLogger("usdx.base.Song");
- const std::string& Song::get_filename(void)
+ const std::string& Song::get_filename(void) const
{
return filename;
}
@@ -44,8 +45,8 @@ namespace usdx
title = get_header_tag("TITLE", true);
artist = get_header_tag("ARTIST", true);
mp3 = get_header_tag("MP3", true);
- // TODO: bpm array
- bpm = get_header_tag("BPM", true);
+ // TODO
+ // bpm.push_back(new BPM(get_header_tag("BPM", true)));
// TODO: float
// gap = get_header_tag("GAP");
@@ -87,6 +88,12 @@ namespace usdx
// encoding = get_header_tag("ENCODING");
}
+ Song::~Song(void)
+ {
+ bpm.clear();
+ lyrics.clear();
+ }
+
std::string Song::get_header_tag(const std::string& tag, const bool required)
{
std::map<std::string, std::string>::iterator it;
@@ -104,113 +111,157 @@ namespace usdx
return result;
}
- const std::string& Song::get_title(void)
+ LyricLine* Song::get_last_lyric_line(void)
+ {
+ LyricLine* line = lyrics.back();
+
+ if (line) {
+ return line;
+ }
+
+ return create_new_lyric_line(0);
+ }
+
+ LyricLine* Song::create_new_lyric_line(int start)
+ {
+ LyricLine* line = new LyricLine(start);
+ lyrics.push_back(line);
+ return line;
+ }
+
+ const std::string& Song::get_title(void) const
{
return title;
}
- const std::string& Song::get_artist(void)
+ const std::string& Song::get_artist(void) const
{
return artist;
}
- const std::string& Song::get_mp3(void)
+ const std::string& Song::get_mp3(void) const
{
return mp3;
}
-// TODO: bpm array
-// const bpmarray Song::get_bpm(void)
-// {
-// return bpm;
-// }
+ const float Song::get_bpm(int beat) const
+ {
+ float last_bpm;
+
+ for (std::list<BPM*>::const_iterator it = bpm.begin(); it != bpm.end(); it++) {
+ if ((*it)->get_beat() > beat) {
+ break;
+ }
+
+ last_bpm = (*it)->get_bpm();
+ }
-// TODO
-// const float Song::get_gap(void)
-// {
-// return gap;
-// }
+ return last_bpm;
+ }
- const std::string& Song::get_cover(void)
+ // TODO
+ // const float Song::get_gap(void) const
+ // {
+ // return gap;
+ // }
+
+ const std::string& Song::get_cover(void) const
{
return cover;
}
- const std::string& Song::get_background(void)
+ const std::string& Song::get_background(void) const
{
return background;
}
- const std::string& Song::get_video(void)
+ const std::string& Song::get_video(void) const
{
return video;
}
-// TODO
-// const float Song::get_videogap(void)
-// {
-// return videogap;
-// }
+ // TODO
+ // const float Song::get_videogap(void) const
+ // {
+ // return videogap;
+ // }
- const std::string& Song::get_genre(void)
+ const std::string& Song::get_genre(void) const
{
return genre;
}
- const std::string& Song::get_edition(void)
+ const std::string& Song::get_edition(void) const
{
return edition;
}
- const std::string& Song::get_creator(void)
+ const std::string& Song::get_creator(void) const
{
return creator;
}
- const std::string& Song::get_language(void)
+ const std::string& Song::get_language(void) const
{
return language;
}
-// TODO
-// const int Song::get_year(void)
-// {
-// return year;
-// }
-
-// TODO
-// const float Song::get_start(void)
-// {
-// return start;
-// }
-
-// TODO
-// const int Song::get_end(void)
-// {
-// return end;
-// }
-
-// TODO
-// const int Song::get_resolution(void)
-// {
-// return resolution;
-// }
-
-// TODO
-// const int Song::get_notesgap(void)
-// {
-// return notesgap;
-// }
-
-// TODO
-// const bool Song::get_relative(void)
-// {
-// return relative;
-// }
-
-// TODO: filetype
-// const std::string& Song::get_encoding(void)
-// {
-// return encoding;
-// }
+ // TODO
+ // const int Song::get_year(void) const
+ // {
+ // return year;
+ // }
+
+ // TODO
+ // const float Song::get_start(void) const
+ // {
+ // return start;
+ // }
+
+ // TODO
+ // const int Song::get_end(void) const
+ // {
+ // return end;
+ // }
+
+ // TODO
+ // const int Song::get_resolution(void) const
+ // {
+ // return resolution;
+ // }
+
+ // TODO
+ // const int Song::get_notesgap(void) const
+ // {
+ // return notesgap;
+ // }
+
+ // TODO
+ // const bool Song::get_relative(void) const
+ // {
+ // return relative;
+ // }
+
+ // TODO: filetype
+ // const std::string& Song::get_encoding(void) const
+ // {
+ // return encoding;
+ // }
+
+ void Song::new_bpm(const int beat, const float new_bpm)
+ {
+ bpm.push_back(new BPM(beat, new_bpm));
+ }
+
+ void Song::new_line(const int line_out, const int line_in)
+ {
+ get_last_lyric_line()->set_end(line_out);
+ create_new_lyric_line(line_in);
+ }
+
+ void Song::new_note(const char type, const int beat, const int length, const int height, const std::string& lyric)
+ {
+ get_last_lyric_line()->add_word(new LyricWord(type, beat, length, height, lyric));
+ }
+
};
diff --git a/src/base/song.hpp b/src/base/song.hpp
index 4cdd4c09..af613370 100644
--- a/src/base/song.hpp
+++ b/src/base/song.hpp
@@ -29,7 +29,10 @@
#include <string>
#include <map>
+#include <list>
#include <log4cxx/logger.h>
+#include "bpm.hpp"
+#include "lyric_line.hpp"
namespace usdx
{
@@ -61,48 +64,57 @@ namespace usdx
std::string creator;
int notes_gap;
- float gap; // in miliseconds
+ float gap; ///< in miliseconds
- float start; // in seconds
- int finish; // in miliseconds
+ float start; ///< in seconds
+ int finish; ///< in miliseconds
bool relative;
int resolution;
- // TODO: bpm: array of TBPM
- std::string bpm;
- // TODO: list of LyricLines
+ std::list<BPM*> bpm;
+
+ std::list<LyricLine*> lyrics;
// TODO: Encoding: TEncoding;
+
std::map<std::string, std::string> custom_header_tags;
std::string get_header_tag(const std::string& tag, const bool required = false);
- public:
- const std::string& get_filename(void);
+ LyricLine* get_last_lyric_line(void);
+ LyricLine* create_new_lyric_line(int start);
+ public:
Song(const std::string& filename, const std::map<std::string, std::string>& header);
-
- const std::string& get_title(void);
- const std::string& get_artist(void);
- const std::string& get_mp3(void);
- // TODO: bpm array
- //const bpmarray get_bpm(void);
- //const float get_gap(void);
- const std::string& get_cover(void);
- const std::string& get_background(void);
- const std::string& get_video(void);
- //const float get_videogap(void);
- const std::string& get_genre(void);
- const std::string& get_edition(void);
- const std::string& get_creator(void);
- const std::string& get_language(void);
- //const int get_year(void);
- //const float get_start(void);
- //const int get_end(void);
- //const int get_resolution(void);
- //const int get_notesgap(void);
- //const bool get_relative(void);
- // TODO: encodeing class
- //const std::string& get_encoding(void);
+ virtual ~Song(void);
+
+ const std::string& get_filename(void) const;
+
+ const std::string& get_title(void) const;
+ const std::string& get_artist(void) const;
+ const std::string& get_mp3(void) const;
+ const float get_bpm(int beat) const;
+ // const float get_gap(void) const;
+ const std::string& get_cover(void) const;
+ const std::string& get_background(void) const;
+ const std::string& get_video(void) const;
+ // const float get_videogap(void) const;
+ const std::string& get_genre(void) const;
+ const std::string& get_edition(void) const;
+ const std::string& get_creator(void) const;
+ const std::string& get_language(void) const;
+ // const int get_year(void) const;
+ // const float get_start(void) const;
+ // const int get_end(void) const;
+ // const int get_resolution(void) const;
+ // const int get_notesgap(void) const;
+ // const bool get_relative(void) const;
+
+ // TODO: encoding class
+ // const std::string& get_encoding(void) const;
+
+ void new_bpm(const int beat, const float new_bpm);
+ void new_line(const int line_out, const int line_in);
+ void new_note(const char type, const int beat, const int length, const int height, const std::string& lyric);
};
};
diff --git a/src/base/songloading/songloading_strategy_txt.cpp b/src/base/songloading/songloading_strategy_txt.cpp
index 5f2017a6..1a2c8eaf 100644
--- a/src/base/songloading/songloading_strategy_txt.cpp
+++ b/src/base/songloading/songloading_strategy_txt.cpp
@@ -171,7 +171,7 @@ namespace usdx
<< line_out);
}
- // song.new_line(line_out, line_in);
+ song->new_line(line_out, line_in);
}
void SongloadingStrategyTxt::parse_bpm(Song *song, std::istringstream& linestream, const int line_number)
@@ -184,7 +184,7 @@ namespace usdx
LOG4CXX_DEBUG(log, "Found new bpm in line " <<
line_number << " starting at beat: " <<
beat << " and new bpm of " << new_bpm.get_value());
- // song.new_bpm(new_beat, new_bpm);
+ song->new_bpm(beat, new_bpm.get_value());
}
void SongloadingStrategyTxt::parse_note(Song *song, char type, std::istringstream& linestream, const int line_number)
@@ -200,7 +200,7 @@ namespace usdx
LOG4CXX_DEBUG(log, "Found lyric: '" << lyric << "' at line: " << line_number <<
" at beat: " << beat << " with length: " << length <<
" at height: " << height);
- // song.new_note(beat, length, height, lyric);
+ song->new_note(type, beat, length, height, lyric);
}
Song* SongloadingStrategyTxt::load_header(const std::string& filename)