|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-28 13:39:41
|
Module: editor
Branch: master
Commit: 0cc803d4b0aa15cc58f53d76f3d4023e491844d2
Author: Lasse Karkkainen <tro...@tr...>
Date: Fri Jan 28 14:38:42 2011 +0100
Phase 1 of note normalization.
---
songparser.cc | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/songparser.cc b/songparser.cc
index 1fabe55..ffe6182 100644
--- a/songparser.cc
+++ b/songparser.cc
@@ -79,10 +79,13 @@ bool SongParser::getline(QString &line)
void SongParser::finalize() {
std::vector<QString> tracks = m_song.getVocalTrackNames();
for(std::vector<QString>::const_iterator it = tracks.begin() ; it != tracks.end() ; ++it) {
- // Adjust negative notes
+ // Note normalization
VocalTrack& vocal = m_song.getVocalTrack(*it);
- if (vocal.noteMin <= 0) {
- unsigned int shift = (1 - vocal.noteMin / 12) * 12;
+ const int limLow = 0, limHigh = 48;
+ if (vocal.noteMin <= limLow || vocal.noteMax >= limHigh) {
+ // Phase 1: Center the entire song to the middle of the permitted range
+ int midnote = (vocal.noteMin + vocal.noteMax) / 2;
+ unsigned int shift = (1006 + 24 - midnote) / 12 * 12 - 1006; // 1006 for mathematical rounding (always positive, round up from 6)
vocal.noteMin += shift;
vocal.noteMax += shift;
for (Notes::iterator it = vocal.notes.begin(); it != vocal.notes.end(); ++it) {
|