|
From: Yoda-JM <yo...@us...> - 2010-10-08 13:11:28
|
Module: performous
Branch: master
Commit: 0db9cd04f01640248cfdc70d38debe000da28601
Author: Vincent Le Ligeour <yo...@us...>
Date: Fri Oct 8 15:12:26 2010 +0200
Changed vocal tracks visibility, fixed bug crashing when midi song has multiple vocal tracks
---
game/guitargraph.cc | 2 +-
game/screen_players.cc | 2 +-
game/screen_sing.cc | 10 +++++-----
game/song.hh | 3 ++-
game/songparser-ini.cc | 8 +++++---
game/songparser-txt.cc | 4 ++--
game/songparser.cc | 15 ++++++++-------
7 files changed, 24 insertions(+), 20 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index fdbbcc2..16d89d0 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -239,7 +239,7 @@ void GuitarGraph::changeDifficulty(int dir) {
void GuitarGraph::difficultyAuto(bool tryKeep) {
if (tryKeep && difficulty(Difficulty(m_level))) return;
for (int level = 0; level < DIFFICULTYCOUNT; ++level) if (difficulty(Difficulty(level))) return;
- throw std::runtime_error("No difficulty levels found");
+ throw std::runtime_error("No difficulty levels found for track " + m_track_index->first);
}
/// Attempt to use a given difficulty level
diff --git a/game/screen_players.cc b/game/screen_players.cc
index 680a075..5f0c867 100644
--- a/game/screen_players.cc
+++ b/game/screen_players.cc
@@ -23,7 +23,7 @@ ScreenPlayers::ScreenPlayers(std::string const& name, Audio& audio, Database& da
}
void ScreenPlayers::enter() {
- m_layout_singer.reset(new LayoutSinger(m_song->vocals, m_database));
+ m_layout_singer.reset(new LayoutSinger(m_song->getVocalTrack(), m_database));
theme.reset(new ThemeSongs());
m_emptyCover.reset(new Surface(getThemePath("no_player_image.svg")));
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 4509b47..c1d4cd1 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -90,7 +90,7 @@ void ScreenSing::enter() {
m_progress->dimensions.fixedWidth(0.4).left(-0.5).screenTop();
theme->timer.dimensions.screenTop(0.5 * m_progress->dimensions.h());
boost::ptr_vector<Analyzer>& analyzers = m_audio.analyzers();
- m_layout_singer.reset(new LayoutSinger(m_song->vocals, m_database, theme));
+ m_layout_singer.reset(new LayoutSinger(m_song->getVocalTrack(), m_database, theme));
// Load instrument and dance tracks
sm->loading(_("Loading instruments..."), 0.8);
{
@@ -124,7 +124,7 @@ void ScreenSing::enter() {
double setup_delay = (m_instruments.empty() && m_dancers.empty() ? -1.0 : -3.0);
sm->loading(_("Finalizing..."), 0.95);
m_audio.playMusic(m_song->music, false, 0.0, setup_delay);
- m_engine.reset(new Engine(m_audio, m_song->vocals, analyzers.begin(), analyzers.end(), m_database));
+ m_engine.reset(new Engine(m_audio, m_song->getVocalTrack(), analyzers.begin(), analyzers.end(), m_database));
sm->loading(_("Loading complete"), 1.0);
// Notify about broken tracks
if (m_song->b0rkedTracks) ScreenManager::getSingletonPtr()->dialog(_("Song contains broken tracks!"));
@@ -293,7 +293,7 @@ void ScreenSing::manageEvent(SDL_Event event) {
else if (nav == input::UP) { m_menu.move(-1); return; }
}
// Start button has special functions for skipping things (only in singing for now)
- if (nav == input::START && m_only_singers_alive && !m_song->vocals.notes.empty() && !m_audio.isPaused()) {
+ if (nav == input::START && m_only_singers_alive && !m_song->getVocalTrack().notes.empty() && !m_audio.isPaused()) {
// Open score dialog early
if (status == Song::FINISHED) {
m_engine->kill(); // Kill the engine thread
@@ -311,7 +311,7 @@ void ScreenSing::manageEvent(SDL_Event event) {
}
// Ctrl combinations that can be used while performing (not when score dialog is displayed)
if (event.type == SDL_KEYDOWN && (event.key.keysym.mod & KMOD_CTRL) && !m_score_window.get()) {
- if (key == SDLK_s) m_audio.toggleSynth(m_song->vocals.notes);
+ if (key == SDLK_s) m_audio.toggleSynth(m_song->getVocalTrack().notes);
if (key == SDLK_v) m_audio.streamFade("vocals", event.key.keysym.mod & KMOD_SHIFT ? 1.0 : 0.0);
if (key == SDLK_k) dispInFlash(++config["game/karaoke_mode"]); // Toggle karaoke mode
if (key == SDLK_w) dispInFlash(++config["game/pitch"]); // Toggle pitch wave
@@ -453,7 +453,7 @@ void ScreenSing::draw() {
statustxt = (boost::format("%02u:%02u - %s") % (t / 60) % (t % 60) % section.name).str();
} else statustxt = (boost::format("%02u:%02u") % (t / 60) % (t % 60)).str();
- if (!m_score_window.get() && m_only_singers_alive && !m_song->vocals.notes.empty()) {
+ if (!m_score_window.get() && m_only_singers_alive && !m_song->getVocalTrack().notes.empty()) {
if (status == Song::INSTRUMENTAL_BREAK) statustxt += _(" ENTER to skip instrumental break");
if (status == Song::FINISHED && !config["game/karaoke_mode"].b()) statustxt += _(" Remember to wait for grading!");
}
diff --git a/game/song.hh b/game/song.hh
index 0c08df9..75c96f7 100644
--- a/game/song.hh
+++ b/game/song.hh
@@ -38,6 +38,7 @@ namespace TrackName {
/// class to load and parse songfiles
class Song: boost::noncopyable {
friend class SongParser;
+ VocalTrack vocals; ///< notes for the sing part
public:
/// constructor
Song(std::string const& path_, std::string const& filename_): vocals(TrackName::LEAD_VOCAL), path(path_), filename(filename_) { reload(false); }
@@ -58,7 +59,7 @@ class Song: boost::noncopyable {
/** Get the song status at a given timestamp **/
Status status(double time) const;
int randomIdx; ///< sorting index used for random order
- VocalTrack vocals; ///< notes for the sing part
+ VocalTrack& getVocalTrack(std::string vocalTrack = TrackName::LEAD_VOCAL) { (void) vocalTrack; return vocals; };
InstrumentTracks instrumentTracks; ///< guitar etc. notes for this song
DanceTracks danceTracks; ///< dance tracks
bool hasDance() const { return !danceTracks.empty(); }
diff --git a/game/songparser-ini.cc b/game/songparser-ini.cc
index c63f4e7..5839255 100644
--- a/game/songparser-ini.cc
+++ b/game/songparser-ini.cc
@@ -46,9 +46,11 @@ namespace {
else if (name == "BASS") name = TrackName::BASS;
else if (name == "GUITAR") name = TrackName::GUITAR;
else if (name == "VOCALS") name = TrackName::LEAD_VOCAL;
+ /*
else if (name == "HARM1") name = TrackName::HARMONIC_1;
else if (name == "HARM2") name = TrackName::HARMONIC_2;
else if (name == "HARM3") name = TrackName::HARMONIC_3;
+ */
else return false;
return true;
}
@@ -124,7 +126,7 @@ void SongParser::iniParseHeader() {
else if (midi.tracks.size() == 1) name = TrackName::GUITAR; // Original (old) FoF songs only have one track
else continue; // not a valid track
// Add dummy notes to tracks so that they can be seen in song browser
- if (isVocalTrack(name)) s.vocals.notes.push_back(Note());
+ if (isVocalTrack(name)) s.getVocalTrack().notes.push_back(Note());
else {
for (MidiFileParser::NoteMap::const_iterator it2 = it->notes.begin(); it2 != it->notes.end(); ++it2) {
// If a track has not enough notes on any level, ignore it
@@ -268,8 +270,8 @@ void SongParser::iniParse() {
}
}
}
- s.vocals.notes.clear();
- s.vocals = vocal;
+ s.getVocalTrack().notes.clear();
+ s.getVocalTrack() = vocal;
}
}
// Figure out if we have BRE in the song
diff --git a/game/songparser-txt.cc b/game/songparser-txt.cc
index bbd014c..f658e07 100644
--- a/game/songparser-txt.cc
+++ b/game/songparser-txt.cc
@@ -22,13 +22,13 @@ void SongParser::txtParseHeader() {
while (getline(line) && txtParseField(line)) {}
if (s.title.empty() || s.artist.empty()) throw std::runtime_error("Required header fields missing");
if (m_bpm != 0.0) addBPM(0, m_bpm);
- s.vocals.notes.push_back(Note()); // Dummy note to indicate there is a track
+ s.getVocalTrack().notes.push_back(Note()); // Dummy note to indicate there is a track
}
/// Parse notes
void SongParser::txtParse() {
std::string line;
- VocalTrack &vocal = m_song.vocals;
+ VocalTrack &vocal = m_song.getVocalTrack();
vocal.notes.clear();
while (getline(line) && txtParseField(line)) {} // Parse the header again
if (m_bpm != 0.0) addBPM(0, m_bpm);
diff --git a/game/songparser.cc b/game/songparser.cc
index af47a6d..3728d8e 100644
--- a/game/songparser.cc
+++ b/game/songparser.cc
@@ -117,18 +117,19 @@ SongParser::SongParser(Song& s):
void SongParser::finalize() {
// Adjust negative notes
- if (m_song.vocals.noteMin <= 0) {
- unsigned int shift = (1 - m_song.vocals.noteMin / 12) * 12;
- m_song.vocals.noteMin += shift;
- m_song.vocals.noteMax += shift;
- for (Notes::iterator it = m_song.vocals.notes.begin(); it != m_song.vocals.notes.end(); ++it) {
+ VocalTrack& vocal = m_song.getVocalTrack();
+ if (vocal.noteMin <= 0) {
+ unsigned int shift = (1 - vocal.noteMin / 12) * 12;
+ vocal.noteMin += shift;
+ vocal.noteMax += shift;
+ for (Notes::iterator it = vocal.notes.begin(); it != vocal.notes.end(); ++it) {
it->note += shift;
it->notePrev += shift;
}
}
// Set begin/end times
- 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 (!vocal.notes.empty()) vocal.beginTime = vocal.notes.front().begin, vocal.endTime = vocal.notes.back().end;
+ vocal.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));
|