From af34e8b4807d981cdd75542c48be741059e91828 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Mon, 18 Jan 2010 02:57:12 +0100 Subject: added calculations to swap from relative mode to absolute beat times --- src/base/song.cpp | 16 ++++++++++++---- src/base/song.hpp | 8 ++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/base/song.cpp b/src/base/song.cpp index 1b904810..e1b39360 100644 --- a/src/base/song.cpp +++ b/src/base/song.cpp @@ -256,20 +256,28 @@ namespace usdx // return encoding; // } + int Song::get_relative_beat(void) + { + if (relative) + return get_last_lyric_line()->get_start(); + + return 0; + } + void Song::new_bpm(const int beat, const float new_bpm) { - bpm.push_back(new BPM(beat, new_bpm)); + bpm.push_back(new BPM(beat + get_relative_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); + get_last_lyric_line()->set_end(line_out + get_relative_beat()); + create_new_lyric_line(line_in + get_relative_beat()); } 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)); + get_last_lyric_line()->add_word(new LyricWord(type, beat + get_relative_beat(), length, height, lyric)); } }; diff --git a/src/base/song.hpp b/src/base/song.hpp index af613370..91d22742 100644 --- a/src/base/song.hpp +++ b/src/base/song.hpp @@ -83,6 +83,14 @@ namespace usdx LyricLine* get_last_lyric_line(void); LyricLine* create_new_lyric_line(int start); + + /** + * Used to calculate the absolute beat times in relative song + * mode. + * + * @return Start beat time from last line. + */ + int get_relative_beat(void); public: Song(const std::string& filename, const std::map& header); virtual ~Song(void); -- cgit v1.2.3