Support #SOURCE, #ALBUM

Write #COMMENT
Keep unknown tags/lines
This commit is contained in:
Flamefire committed 2013-10-12 16:10:24 +02:00
1 parent 0a97a2e46d
commit b0cb402dc3
4 files changed
+41 -5

No files matched your search

+3
View File
@@ -119,6 +119,8 @@ namespace VocaluxeLib.Songs
public string Creator = ""; public string Creator = "";
public string Version = ""; public string Version = "";
public string Source = "";
public readonly List<String> UnknownTags = new List<string>();
/// <summary> /// <summary>
/// Start of the song in s (s in txt) /// Start of the song in s (s in txt)
@@ -153,6 +155,7 @@ namespace VocaluxeLib.Songs
public readonly List<string> Editions = new List<string>(); public readonly List<string> Editions = new List<string>();
public readonly List<string> Genres = new List<string>(); public readonly List<string> Genres = new List<string>();
public string Album = "";
public string Year = ""; public string Year = "";
public readonly List<string> Languages = new List<string>(); public readonly List<string> Languages = new List<string>();
+27 -3
View File
@@ -87,6 +87,7 @@ namespace VocaluxeLib.Songs
_Song.Languages.Clear(); _Song.Languages.Clear();
_Song.Genres.Clear(); _Song.Genres.Clear();
_Song.UnknownTags.Clear();
_Song._Comment = ""; _Song._Comment = "";
var headerFlags = new EHeaderFlags(); var headerFlags = new EHeaderFlags();
@@ -107,14 +108,21 @@ namespace VocaluxeLib.Songs
int pos = line.IndexOf(":", StringComparison.Ordinal); int pos = line.IndexOf(":", StringComparison.Ordinal);
if (pos <= 1) if (pos <= 1)
{
_Song.UnknownTags.Add(line);
continue; continue;
}
string identifier = line.Substring(1, pos - 1).Trim().ToUpper(); string identifier = line.Substring(1, pos - 1).Trim().ToUpper();
if (identifier.Contains(" ")) if (identifier.Contains(" "))
{
_Song.UnknownTags.Add(line);
continue; continue;
}
string value = line.Substring(pos + 1).Trim(); string value = line.Substring(pos + 1).Trim();
if (value == "") if (value == "")
{ {
_Song.UnknownTags.Add(line);
_LogWarning("Empty value skipped"); _LogWarning("Empty value skipped");
continue; continue;
} }
@@ -150,11 +158,17 @@ namespace VocaluxeLib.Songs
_Song.ArtistSorting = value; _Song.ArtistSorting = value;
break; break;
case "CREATOR": case "CREATOR":
case "AUTHOR":
case "AUTOR":
_Song.Creator = value; _Song.Creator = value;
break; break;
case "VERSION": case "VERSION":
_Song.Version = value; _Song.Version = value;
break; break;
case "SOURCE":
case "YOUTUBE":
_Song.Source = value;
break;
case "MP3": case "MP3":
if (File.Exists(Path.Combine(_Song.Folder, value))) if (File.Exists(Path.Combine(_Song.Folder, value)))
{ {
@@ -188,6 +202,9 @@ namespace VocaluxeLib.Songs
else else
_LogWarning("Invalid genre"); _LogWarning("Invalid genre");
break; break;
case "ALBUM":
_Song.Album = value;
break;
case "YEAR": case "YEAR":
int num; int num;
if (value.Length == 4 && int.TryParse(value, out num) && num > 0) if (value.Length == 4 && int.TryParse(value, out num) && num > 0)
@@ -289,7 +306,11 @@ namespace VocaluxeLib.Songs
break; break;
default: default:
if (identifier.StartsWith("DUETSINGER")) if (identifier.StartsWith("DUETSINGER"))
{
identifier = identifier.Substring(10); identifier = identifier.Substring(10);
if (identifier.StartsWith("P")) // Possible fix for missing "P"
identifier = "P" + identifier;
}
if (identifier.StartsWith("P")) if (identifier.StartsWith("P"))
{ {
int player; int player;
@@ -300,7 +321,10 @@ namespace VocaluxeLib.Songs
} }
} }
else else
{
_Song.UnknownTags.Add(line);
_LogWarning("Unknown tag: #" + identifier); _LogWarning("Unknown tag: #" + identifier);
}
break; break;
} }
@@ -606,13 +630,13 @@ namespace VocaluxeLib.Songs
currentBeat += length; currentBeat += length;
} }
if (lastNote != null && beat < lastNote.EndBeat) if (lastNote != null && beat <= lastNote.EndBeat)
{ {
_LogWarning("Line break is before previous note end. Adjusted."); _LogWarning("Line break is before previous note end. Adjusted.");
changesMade.AjustedBreakCt++; changesMade.AjustedBreakCt++;
if (_Song.Relative) if (_Song.Relative)
currentBeat += lastNote.EndBeat - beat; currentBeat += lastNote.EndBeat - beat + 1;
beat = lastNote.EndBeat; beat = lastNote.EndBeat + 1;
} }
if (beat < 1) if (beat < 1)
+10 -1
View File
@@ -43,7 +43,13 @@ namespace VocaluxeLib.Songs
_WriteHeaderEntry(sw, "ENCODING", _Song.Encoding); _WriteHeaderEntry(sw, "ENCODING", _Song.Encoding);
_WriteHeaderEntry(sw, "CREATOR", _Song.Creator); _WriteHeaderEntry(sw, "CREATOR", _Song.Creator);
_WriteHeaderEntry(sw, "VERSION", _Song.Version); _WriteHeaderEntry(sw, "VERSION", _Song.Version);
_WriteHeaderEntry(sw, "COMMENT", _Song._Comment); _WriteHeaderEntry(sw, "SOURCE", _Song.Source);
if (!String.IsNullOrEmpty(_Song._Comment))
{
string comment = _Song._Comment.Replace("\r\n", "\n").Replace('\r', '\n');
char[] splitChar = {'\n'};
_WriteHeaderEntry(sw, "COMMENT", comment.Split(splitChar));
}
_WriteHeaderEntry(sw, "TITLE", _Song.Title); _WriteHeaderEntry(sw, "TITLE", _Song.Title);
_WriteHeaderEntry(sw, "ARTIST", _Song.Artist); _WriteHeaderEntry(sw, "ARTIST", _Song.Artist);
if (!_Song.Title.Equals(_Song.TitleSorting)) if (!_Song.Title.Equals(_Song.TitleSorting))
@@ -53,6 +59,7 @@ namespace VocaluxeLib.Songs
_WriteHeaderEntry(sw, "EDITION", _Song.Editions); _WriteHeaderEntry(sw, "EDITION", _Song.Editions);
_WriteHeaderEntry(sw, "GENRE", _Song.Genres); _WriteHeaderEntry(sw, "GENRE", _Song.Genres);
_WriteHeaderEntry(sw, "LANGUAGE", _Song.Languages); _WriteHeaderEntry(sw, "LANGUAGE", _Song.Languages);
_WriteHeaderEntry(sw, "ALBUM", _Song.Album);
_WriteHeaderEntry(sw, "YEAR", _Song.Year); _WriteHeaderEntry(sw, "YEAR", _Song.Year);
_WriteHeaderEntry(sw, "MP3", _Song.MP3FileName); _WriteHeaderEntry(sw, "MP3", _Song.MP3FileName);
_WriteHeaderEntry(sw, "COVER", _Song.CoverFileName); _WriteHeaderEntry(sw, "COVER", _Song.CoverFileName);
@@ -78,6 +85,8 @@ namespace VocaluxeLib.Songs
if (_Song.Notes.VoiceNames.IsSet(i)) if (_Song.Notes.VoiceNames.IsSet(i))
_WriteHeaderEntry(sw, "P" + i, _Song.Notes.VoiceNames[i]); _WriteHeaderEntry(sw, "P" + i, _Song.Notes.VoiceNames[i]);
} }
foreach (string addLine in _Song.UnknownTags)
sw.WriteLine(addLine);
} }
} }
} }
+1 -1
View File
@@ -128,7 +128,7 @@ namespace VocaluxeLib.Songs
{ {
CSongLine prevLine = _Lines[insPos]; CSongLine prevLine = _Lines[insPos];
//We already have a line break here //We already have a line break here
if (prevLine.StartBeat == startBeat && prevLine.FirstNoteBeat == startBeat) if (prevLine.StartBeat == startBeat && (prevLine.NoteCount==0 || prevLine.FirstNoteBeat == startBeat))
return false; return false;
//Maybe we have to split the previous line //Maybe we have to split the previous line
while (prevLine.NoteCount > 0 && prevLine.LastNote.StartBeat >= startBeat) while (prevLine.NoteCount > 0 && prevLine.LastNote.StartBeat >= startBeat)