|
From: Lasse Kärkkäi. <tr...@us...> - 2010-01-09 23:33:04
|
Module: performous
Branch: master
Commit: 2d7c106cfef9fc794147224681c7b1e03b7843dc
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Jan 10 01:23:29 2010 +0200
Add phase info to notes
---
game/notes.cc | 2 +-
game/notes.hh | 1 +
game/songparser-sm.cc | 2 ++
3 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/game/notes.cc b/game/notes.cc
index 7719f04..0b78c10 100644
--- a/game/notes.cc
+++ b/game/notes.cc
@@ -52,7 +52,7 @@ double MusicalScale::getNoteOffset(double freq) const {
return 12.0 * std::log(frac) / std::log(2.0);
}
-Note::Note(): begin(getNaN()), end(getNaN()), power(getNaN()), type(NORMAL), note(), notePrev() {}
+Note::Note(): begin(getNaN()), end(getNaN()), phase(getNaN()), power(getNaN()), type(NORMAL), note(), notePrev() {}
double Note::diff(double note, double n) { return remainder(n - note, 12.0); }
double Note::maxScore() const { return scoreMultiplier(0.0) * (end - begin); }
diff --git a/game/notes.hh b/game/notes.hh
index 2d17f46..ae1694e 100644
--- a/game/notes.hh
+++ b/game/notes.hh
@@ -70,6 +70,7 @@ struct Note {
Note();
double begin, ///< begin time
end; ///< end time
+ double phase; /// Position within a measure, [0, 1)
/// power of note
mutable double power;
/// how well the note was sung [0,1] (used for drawing a star)
diff --git a/game/songparser-sm.cc b/game/songparser-sm.cc
index 477893e..af8ccc9 100644
--- a/game/songparser-sm.cc
+++ b/game/songparser-sm.cc
@@ -200,10 +200,12 @@ Notes SongParser::smParseNotes(std::string line) {
double step = (end - begin) / div;
for (unsigned note = 0; note < div; ++note) {
double t = begin + note * step;
+ double phase = double(note) / div;
for (DanceChord::iterator it = chords[note].begin(), end = chords[note].end(); it != end; ++it) {
int& holdIdx = holdMarks[it->first]; // holdIdx for current arrow
Note& n = it->second;
n.begin = n.end = t;
+ n.phase = phase;
// TODO: Proper LIFT handling
if (n.type == Note::TAP || n.type == Note::MINE || n.type == Note::LIFT) notes.push_back(n);
// TODO: Proper ROLL handling
|