Support #SOURCE, #ALBUM
Write #COMMENT Keep unknown tags/lines
This commit is contained in:
1 parent
0a97a2e46d
commit
b0cb402dc3
4 files changed
+41
-5
No files matched your search
@@ -119,6 +119,8 @@ namespace VocaluxeLib.Songs
|
||||
|
||||
public string Creator = "";
|
||||
public string Version = "";
|
||||
public string Source = "";
|
||||
public readonly List<String> UnknownTags = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 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> Genres = new List<string>();
|
||||
public string Album = "";
|
||||
public string Year = "";
|
||||
|
||||
public readonly List<string> Languages = new List<string>();
|
||||
|
||||
@@ -87,6 +87,7 @@ namespace VocaluxeLib.Songs
|
||||
|
||||
_Song.Languages.Clear();
|
||||
_Song.Genres.Clear();
|
||||
_Song.UnknownTags.Clear();
|
||||
_Song._Comment = "";
|
||||
|
||||
var headerFlags = new EHeaderFlags();
|
||||
@@ -107,14 +108,21 @@ namespace VocaluxeLib.Songs
|
||||
int pos = line.IndexOf(":", StringComparison.Ordinal);
|
||||
|
||||
if (pos <= 1)
|
||||
{
|
||||
_Song.UnknownTags.Add(line);
|
||||
continue;
|
||||
}
|
||||
string identifier = line.Substring(1, pos - 1).Trim().ToUpper();
|
||||
if (identifier.Contains(" "))
|
||||
{
|
||||
_Song.UnknownTags.Add(line);
|
||||
continue;
|
||||
}
|
||||
string value = line.Substring(pos + 1).Trim();
|
||||
|
||||
if (value == "")
|
||||
{
|
||||
_Song.UnknownTags.Add(line);
|
||||
_LogWarning("Empty value skipped");
|
||||
continue;
|
||||
}
|
||||
@@ -150,11 +158,17 @@ namespace VocaluxeLib.Songs
|
||||
_Song.ArtistSorting = value;
|
||||
break;
|
||||
case "CREATOR":
|
||||
case "AUTHOR":
|
||||
case "AUTOR":
|
||||
_Song.Creator = value;
|
||||
break;
|
||||
case "VERSION":
|
||||
_Song.Version = value;
|
||||
break;
|
||||
case "SOURCE":
|
||||
case "YOUTUBE":
|
||||
_Song.Source = value;
|
||||
break;
|
||||
case "MP3":
|
||||
if (File.Exists(Path.Combine(_Song.Folder, value)))
|
||||
{
|
||||
@@ -188,6 +202,9 @@ namespace VocaluxeLib.Songs
|
||||
else
|
||||
_LogWarning("Invalid genre");
|
||||
break;
|
||||
case "ALBUM":
|
||||
_Song.Album = value;
|
||||
break;
|
||||
case "YEAR":
|
||||
int num;
|
||||
if (value.Length == 4 && int.TryParse(value, out num) && num > 0)
|
||||
@@ -289,7 +306,11 @@ namespace VocaluxeLib.Songs
|
||||
break;
|
||||
default:
|
||||
if (identifier.StartsWith("DUETSINGER"))
|
||||
{
|
||||
identifier = identifier.Substring(10);
|
||||
if (identifier.StartsWith("P")) // Possible fix for missing "P"
|
||||
identifier = "P" + identifier;
|
||||
}
|
||||
if (identifier.StartsWith("P"))
|
||||
{
|
||||
int player;
|
||||
@@ -300,7 +321,10 @@ namespace VocaluxeLib.Songs
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_Song.UnknownTags.Add(line);
|
||||
_LogWarning("Unknown tag: #" + identifier);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -606,13 +630,13 @@ namespace VocaluxeLib.Songs
|
||||
currentBeat += length;
|
||||
}
|
||||
|
||||
if (lastNote != null && beat < lastNote.EndBeat)
|
||||
if (lastNote != null && beat <= lastNote.EndBeat)
|
||||
{
|
||||
_LogWarning("Line break is before previous note end. Adjusted.");
|
||||
changesMade.AjustedBreakCt++;
|
||||
if (_Song.Relative)
|
||||
currentBeat += lastNote.EndBeat - beat;
|
||||
beat = lastNote.EndBeat;
|
||||
currentBeat += lastNote.EndBeat - beat + 1;
|
||||
beat = lastNote.EndBeat + 1;
|
||||
}
|
||||
|
||||
if (beat < 1)
|
||||
|
||||
@@ -43,7 +43,13 @@ namespace VocaluxeLib.Songs
|
||||
_WriteHeaderEntry(sw, "ENCODING", _Song.Encoding);
|
||||
_WriteHeaderEntry(sw, "CREATOR", _Song.Creator);
|
||||
_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, "ARTIST", _Song.Artist);
|
||||
if (!_Song.Title.Equals(_Song.TitleSorting))
|
||||
@@ -53,6 +59,7 @@ namespace VocaluxeLib.Songs
|
||||
_WriteHeaderEntry(sw, "EDITION", _Song.Editions);
|
||||
_WriteHeaderEntry(sw, "GENRE", _Song.Genres);
|
||||
_WriteHeaderEntry(sw, "LANGUAGE", _Song.Languages);
|
||||
_WriteHeaderEntry(sw, "ALBUM", _Song.Album);
|
||||
_WriteHeaderEntry(sw, "YEAR", _Song.Year);
|
||||
_WriteHeaderEntry(sw, "MP3", _Song.MP3FileName);
|
||||
_WriteHeaderEntry(sw, "COVER", _Song.CoverFileName);
|
||||
@@ -78,6 +85,8 @@ namespace VocaluxeLib.Songs
|
||||
if (_Song.Notes.VoiceNames.IsSet(i))
|
||||
_WriteHeaderEntry(sw, "P" + i, _Song.Notes.VoiceNames[i]);
|
||||
}
|
||||
foreach (string addLine in _Song.UnknownTags)
|
||||
sw.WriteLine(addLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace VocaluxeLib.Songs
|
||||
{
|
||||
CSongLine prevLine = _Lines[insPos];
|
||||
//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;
|
||||
//Maybe we have to split the previous line
|
||||
while (prevLine.NoteCount > 0 && prevLine.LastNote.StartBeat >= startBeat)
|
||||
|
||||
Reference in new issue
Block a user