|
From: Yoda-JM <yo...@us...> - 2010-04-09 08:43:38
|
Module: performous
Branch: master
Commit: 5f12b33204db72f06ea5d72e43fba66356b5f399
Author: Vincent Le Ligeour <yo...@us...>
Date: Fri Apr 9 10:43:19 2010 +0200
Moved more member of the Song structure to the VocalTrack structure
---
game/engine.hh | 5 ++---
game/notegraph.cc | 2 +-
game/notes.cc | 5 +++--
game/notes.hh | 6 ++++--
game/player.cc | 8 ++++----
game/song.cc | 2 --
game/song.hh | 14 ++++----------
game/songparser.hh | 6 +++---
8 files changed, 21 insertions(+), 27 deletions(-)
diff --git a/game/engine.hh b/game/engine.hh
index a978406..9295aaa 100644
--- a/game/engine.hh
+++ b/game/engine.hh
@@ -47,10 +47,9 @@ class Engine {
m_database.cur.clear();
m_database.scores.clear();
// Only add players if the vocal track has sensible length (not NaN or extremely long)
- std::cout << "Endtime: " << song.endTime << std::endl;
- if (song.endTime < 10000.0) {
+ if (song.vocals.endTime < 10000.0) {
// Calculate the space required for pitch frames
- size_t frames = song.endTime / Engine::TIMESTEP;
+ size_t frames = song.vocals.endTime / Engine::TIMESTEP;
while (anBegin != anEnd) m_database.cur.push_back(Player(song, *anBegin++, frames));
size_t player = 0;
for (std::list<Player>::iterator it = m_database.cur.begin(); it != m_database.cur.end(); ++it, ++player) it->m_color = playerColors[player % playerColorsSize];
diff --git a/game/notegraph.cc b/game/notegraph.cc
index 17f7a6e..d220e8c 100644
--- a/game/notegraph.cc
+++ b/game/notegraph.cc
@@ -242,7 +242,7 @@ void NoteGraph::drawWaves(Database const& database) {
else if (hasNote) val = noteIt->note;
else val = notePrev->note;
// Now val contains the active note value. The following calculates note value for current freq:
- val += Note::diff(val, m_song.scale.getNote(freq));
+ val += Note::diff(val, m_song.vocals.scale.getNote(freq));
// Graphics positioning & animation:
double y = m_baseY + val * m_noteUnit;
double thickness = clamp(1.0 + pitch[idx].second / 60.0) + 0.5;
diff --git a/game/notes.cc b/game/notes.cc
index b489d29..e474643 100644
--- a/game/notes.cc
+++ b/game/notes.cc
@@ -79,6 +79,7 @@ VocalTrack::VocalTrack(std::string name) : name(name) {reload();}
void VocalTrack::reload() {
notes.clear();
- noteMin = std::numeric_limits<int>::max();
- noteMax = std::numeric_limits<int>::min();
+ m_scoreFactor = 0.0;
+ noteMin = noteMax = std::numeric_limits<int>::max();
+ beginTime = endTime = getNaN();
}
diff --git a/game/notes.hh b/game/notes.hh
index 7b52596..5c3a9af 100644
--- a/game/notes.hh
+++ b/game/notes.hh
@@ -114,8 +114,10 @@ struct VocalTrack {
void reload();
std::string name;
Notes notes;
- int noteMin;
- int noteMax;
+ int noteMin, noteMax; ///< lowest and highest note
+ double beginTime, endTime; ///< the period where there are notes
+ double m_scoreFactor; ///< normalization factor for the scoring system
+ MusicalScale scale; ///< scale in which song is sung
};
typedef std::map<std::string, VocalTrack> VocalsTracks;
diff --git a/game/player.cc b/game/player.cc
index 0f56b85..85f8a8b 100644
--- a/game/player.cc
+++ b/game/player.cc
@@ -28,9 +28,9 @@ void Player::update() {
if (endTime < m_scoreIt->begin) break; // The note begins later than on this timestep
// If tone was detected, calculate score
if (t) {
- double note = m_song.scale.getNote(t->freq);
+ double note = m_song.vocals.scale.getNote(t->freq);
// Add score
- double score_addition = m_song.m_scoreFactor * m_scoreIt->score(note, beginTime, endTime);
+ double score_addition = m_song.vocals.m_scoreFactor * m_scoreIt->score(note, beginTime, endTime);
m_score += score_addition;
m_noteScore += score_addition;
m_lineScore += score_addition;
@@ -45,7 +45,7 @@ void Player::update() {
}
if (endTime < m_scoreIt->end) break; // The note continues past this timestep
// Set accuracy
- m_scoreIt->accuracy = std::max(m_scoreIt->accuracy, m_noteScore / m_song.m_scoreFactor / m_scoreIt->maxScore());
+ m_scoreIt->accuracy = std::max(m_scoreIt->accuracy, m_noteScore / m_song.vocals.m_scoreFactor / m_scoreIt->maxScore());
m_noteScore = 0; // Reset noteScore as we are moving on to the next one
++m_scoreIt;
}
@@ -61,7 +61,7 @@ void Player::calcRowRank() {
// FIXME: MacOSX needs the following cast to compile correctly
// it is related to the fact that OSX default compiler is 4.0.1 that is buggy when not casting
while ((maxScoreIt != static_cast<Notes::const_reverse_iterator>(m_song.vocals.notes.rend())) && (maxScoreIt->type != Note::SLEEP)) {
- m_maxLineScore += m_song.m_scoreFactor * maxScoreIt->maxScore();
+ m_maxLineScore += m_song.vocals.m_scoreFactor * maxScoreIt->maxScore();
maxScoreIt++;
}
if (m_maxLineScore > 0) {
diff --git a/game/song.cc b/game/song.cc
index ee0db1e..c6274e6 100644
--- a/game/song.cc
+++ b/game/song.cc
@@ -29,8 +29,6 @@ void Song::reload(bool errorIgnore) {
videoGap = 0.0;
start = 0.0;
preview_start = getNaN();
- beginTime = endTime = getNaN();
- m_scoreFactor = 0.0;
hasBRE = false;
b0rkedTracks = false;
try { SongParser(*this); } catch (...) { if (!errorIgnore) throw; }
diff --git a/game/song.hh b/game/song.hh
index fb53b63..25d3c9d 100644
--- a/game/song.hh
+++ b/game/song.hh
@@ -53,8 +53,6 @@ class Song: boost::noncopyable {
VocalTrack vocals; ///< notes for the sing part
InstrumentTracks instrumentTracks; ///< guitar etc. notes for this song
DanceTracks danceTracks; ///< dance tracks
- typedef std::vector<double> Beats;
- Beats beats;
bool hasDance() const { return !danceTracks.empty(); }
bool hasDrums() const { return instrumentTracks.find(TrackName::DRUMS) != instrumentTracks.end(); }
bool hasGuitars() const { return instrumentTracks.size() - hasDrums(); }
@@ -87,15 +85,11 @@ class Song: boost::noncopyable {
double videoGap; ///< gap with video
double start; ///< start of song
double preview_start; ///< starting time for the preview
- MusicalScale scale; ///< scale in which song is sung
- std::vector<double> timePitchGraph; ///< time of pitch graph
- std::vector<double> pitchPitchGraph; ///< pitch of pitch graph
- std::vector<double> volumePitchGraph; ///< volume of pitch graph
- std::vector<bool> drawPitchGraph; ///< if pitch graph should be drawn
- double beginTime, endTime; ///< the period where there are notes
- double m_scoreFactor; ///< normalization factor for the scoring system
+
typedef std::vector<std::pair<double,double> > Stops;
- Stops stops;
+ Stops stops; ///< related to dance
+ typedef std::vector<double> Beats;
+ Beats beats; ///< related to instrument and dance
bool hasBRE; ///< is there a Big Rock Ending? (used for drums only)
bool b0rkedTracks; ///< are some tracks broken? (so that user can be notified)
};
diff --git a/game/songparser.hh b/game/songparser.hh
index dfa50a3..d83ac3b 100644
--- a/game/songparser.hh
+++ b/game/songparser.hh
@@ -103,8 +103,8 @@ class SongParser {
}
}
// Set begin/end times
- if (!m_song.vocals.notes.empty()) m_song.beginTime = m_song.vocals.notes.front().begin, m_song.endTime = m_song.vocals.notes.back().end;
- m_song.m_scoreFactor = 1.0 / m_maxScore;
+ if (!m_song.vocals.notes.empty()) m_song.vocals.beginTime = m_song.vocals.notes.front().begin, m_song.vocals.endTime = m_song.vocals.notes.back().end;
+ m_song.vocals.m_scoreFactor = 1.0 / m_maxScore;
if (m_tsPerBeat) {
// Add song beat markers
for (unsigned ts = 0; ts < m_tsEnd; ts += m_tsPerBeat) m_song.beats.push_back(tsTime(ts));
@@ -166,7 +166,7 @@ class SongParser {
throw std::logic_error("INTERNAL ERROR: BPM data invalid");
}
/// Stops stored in <ts, duration> format
- std::vector<std::pair<double, double> > m_stops;
+ Song::Stops m_stops;
/// Convert a stop into <time, duration> (as stored in the song)
std::pair<double, double> stopConvert(std::pair<double, double> s) {
s.first = tsTime(s.first);
|