|
From: Yoda-JM <yo...@us...> - 2010-10-07 23:13:36
|
Module: performous
Branch: master
Commit: 826c167fc46761d14cecf606c998692ff2b9d0e5
Author: Vincent Le Ligeour <yo...@us...>
Date: Thu Oct 7 13:57:24 2010 +0200
Enhanced multiple singer midi parsing, Fixed midi parsing bug
---
game/midifile.cc | 2 +-
game/notes.hh | 2 +-
game/song.hh | 8 ++++++--
game/songparser-ini.cc | 19 +++++++++++++++----
4 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/game/midifile.cc b/game/midifile.cc
index 0317473..5272165 100644
--- a/game/midifile.cc
+++ b/game/midifile.cc
@@ -317,7 +317,7 @@ void MidiFileParser::process_midi_event(Track& track, uint8_t t, uint8_t arg1, u
pitch.push_back(Note(miditime));
}
// special management for lyrics
- if (track.name == "PART VOCALS") {
+ if (track.name == "PART VOCALS" || track.name == "PART HARM1" || track.name == "PART HARM2" || track.name == "PART HARM3") {
// Discard note effects
if( arg1 < 20 ) return;
if (t == 8 || (t == 9 && arg2 == 0)) {
diff --git a/game/notes.hh b/game/notes.hh
index ac8838c..4c67bae 100644
--- a/game/notes.hh
+++ b/game/notes.hh
@@ -122,7 +122,7 @@ struct VocalTrack {
MusicalScale scale; ///< scale in which song is sung
};
-typedef std::map<std::string, VocalTrack> VocalsTracks;
+typedef std::map<std::string, VocalTrack> VocalTracks;
struct DanceTrack {
DanceTrack(std::string& description, Notes& notes);
diff --git a/game/song.hh b/game/song.hh
index d753084..0c08df9 100644
--- a/game/song.hh
+++ b/game/song.hh
@@ -26,8 +26,12 @@ namespace TrackName {
const std::string GUITAR_RHYTHM = "Rhythm guitar";
const std::string BASS = "Bass";
const std::string DRUMS = "Drums";
+ const std::string LEAD_VOCAL = "Vocals";
+ const std::string HARMONIC_1 = "Harmonic 1";
+ const std::string HARMONIC_2 = "Harmonic 2";
+ const std::string HARMONIC_3 = "Harmonic 3";
#if 0 // Here is some dummy gettext calls to populate the dictionary
- _("Guitar") _("Coop guitar") _("Rhythm guitar") _("Bass") _("Drums")
+ _("Guitar") _("Coop guitar") _("Rhythm guitar") _("Bass") _("Drums") _("Vocals") _("Harmonic 1") _("Harmonic 2") _("Harmonic 3")
#endif
}
@@ -36,7 +40,7 @@ class Song: boost::noncopyable {
friend class SongParser;
public:
/// constructor
- Song(std::string const& path_, std::string const& filename_): vocals(std::string("VOCALS")), path(path_), filename(filename_) { reload(false); }
+ Song(std::string const& path_, std::string const& filename_): vocals(TrackName::LEAD_VOCAL), path(path_), filename(filename_) { reload(false); }
/// reload song
void reload(bool errorIgnore = true);
/// parse field
diff --git a/game/songparser-ini.cc b/game/songparser-ini.cc
index cdba2ad..a331f54 100644
--- a/game/songparser-ini.cc
+++ b/game/songparser-ini.cc
@@ -22,6 +22,15 @@ namespace {
std::string f = s.path + filename;
if (boost::filesystem::exists(f)) s.music[trackid] = f;
}
+ bool isVocalTrack(std::string name) {
+ if(name == TrackName::LEAD_VOCAL) return true;
+ /*
+ else if(name == TrackName::HARMONIC_1) return true;
+ else if(name == TrackName::HARMONIC_2) return true;
+ else if(name == TrackName::HARMONIC_3) return true;
+ */
+ return false;
+ }
/// Change the MIDI track name to Performous track name
/// Return false if not valid
bool mangleTrackName(std::string& name) {
@@ -36,7 +45,10 @@ namespace {
else if (name == "DRUMS") name = TrackName::DRUMS;
else if (name == "BASS") name = TrackName::BASS;
else if (name == "GUITAR") name = TrackName::GUITAR;
- else if (name == "VOCALS") return true;
+ 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;
}
@@ -112,7 +124,7 @@ void SongParser::iniParseHeader() {
else if (midi.tracks.size() == 1) name = TrackName::GUITAR; // Original (old) FoF songs only have one track
else continue;
// Add dummy notes to tracks so that they can be seen in song browser
- if (name == "VOCALS") s.vocals.notes.push_back(Note());
+ if (isVocalTrack(name)) s.vocals.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
@@ -137,7 +149,7 @@ void SongParser::iniParse() {
else if (midi.tracks.size() == 1) name = TrackName::GUITAR; // Original (old) FoF songs only have one track
else continue;
// Process non-vocal tracks
- if (name != "VOCALS") {
+ if (!isVocalTrack(name)) {
int durCount = 0;
s.instrumentTracks.insert(make_pair(name,InstrumentTrack(name)));
NoteMap& nm2 = s.instrumentTracks.find(name)->second.nm;
@@ -254,7 +266,6 @@ void SongParser::iniParse() {
}
}
}
- if (!vocal.notes.empty()) break;
}
// Figure out if we have BRE in the song
for (MidiFileParser::CommandEvents::const_iterator it = midi.cmdevents.begin(); it != midi.cmdevents.end(); ++it) {
|