|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:39
|
Module: performous
Branch: dance
Commit: 83a58d79dbad0294714ea8c03e292c78e900cf76
Author: Tapio Vierros <tap...@gm...>
Date: Thu Nov 12 23:17:22 2009 +0200
Reversed notes in midi file no longer produce error, only warning with count.
(A song could have perfectly fine tracks and a couple of missing notes shouldn't be fatal.)
---
game/songparser-ini.cc | 10 +++++++++-
game/songparser.hh | 2 +-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/game/songparser-ini.cc b/game/songparser-ini.cc
index 5184e83..1e79706 100644
--- a/game/songparser-ini.cc
+++ b/game/songparser-ini.cc
@@ -86,6 +86,7 @@ void SongParser::iniParse() {
}
MidiFileParser midi(s.path + "/" + midifilename);
+ int reversedNoteCount = 0;
for (uint32_t ts = 0, end = midi.ts_last + midi.division; ts < end; ts += midi.division) s.beats.push_back(midi.get_seconds(ts));
for (MidiFileParser::Tracks::const_iterator it = midi.tracks.begin(); it != midi.tracks.end(); ++it) {
// Figure out the track name
@@ -113,7 +114,7 @@ void SongParser::iniParse() {
double beg = midi.get_seconds(it3->begin);
double end = midi.get_seconds(it3->end);
if (end == 0) continue; // Note with no ending
- if (beg > end) throw std::runtime_error("Reversed notes");
+ if (beg > end) { reversedNoteCount++; continue; } // Reversed note
if (drums) end = beg;
dur.push_back(Duration(beg, end));
durCount++;
@@ -196,6 +197,13 @@ void SongParser::iniParse() {
}
if (!s.notes.empty()) break;
}
+ if (reversedNoteCount > 0) {
+ std::ostringstream oss;
+ oss << "WARNING: Skipping " << reversedNoteCount << " reversed note(s) in ";
+ oss << s.path << midifilename << std::endl;
+ std::cerr << oss.str(); // More likely to be atomic when written as one string
+ }
+
/*if (s.notes.empty()) {
Note n;
n.begin = 30.0;
diff --git a/game/songparser.hh b/game/songparser.hh
index d17b147..da15550 100644
--- a/game/songparser.hh
+++ b/game/songparser.hh
@@ -50,7 +50,7 @@ class SongParser {
if (m_song.cover.empty() || (m_song.background.empty() && m_song.video.empty())) {
boost::regex coverfile("((cover|album|label|\\[co\\])\\.(png|jpeg|jpg|svg|bmp|gif))$", boost::regex_constants::icase);
boost::regex backgroundfile("((background|bg||\\[bg\\])\\.(png|jpeg|jpg|svg|bmp|gif))$", boost::regex_constants::icase);
- boost::regex videofile("(.*\\.(avi|mpg|mpeg|flv|mov))$", boost::regex_constants::icase);
+ boost::regex videofile("(.*\\.(avi|mpg|mpeg|flv|mov|mp4))$", boost::regex_constants::icase);
boost::cmatch match;
for (boost::filesystem::directory_iterator dirIt(s.path), dirEnd; dirIt != dirEnd; ++dirIt) {
|