diff --git a/CHANGELOG.md b/CHANGELOG.md index cf10a13..8856ea2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ -## 2024.0728 +## 2024.0728.2 +* "" in the `.lrc` file is absolute time, not the relative time. + +## 2024.0728.1 * Add `StartTime` property in the `Model.Lyric` class. This property is used to store the start time of the lyric.~~ * `LrcParse` is re-written. Now it can follow the [LRC and Enhanced LRC format](https://en.wikipedia.org/wiki/LRC_(file_format) to decode/encode the lyric correctly. * Create the `KarParser`, which is used to parse the Karaoke file with format like `[00:51.00]ka[01:29.99]ra[01:48.29]o[02:31.00]ke[02:41.99]`. diff --git a/LrcParser.Tests/Parser/Lrc/LrcParserTest.cs b/LrcParser.Tests/Parser/Lrc/LrcParserTest.cs index d1ed788..b87793c 100644 --- a/LrcParser.Tests/Parser/Lrc/LrcParserTest.cs +++ b/LrcParser.Tests/Parser/Lrc/LrcParserTest.cs @@ -14,7 +14,7 @@ public void TestDecode() { var lrcText = new[] { - "[00:17.00] <00:00.00>帰<00:01.00>り<00:02.00>道<00:03.00>は<00:04.00>", + "[00:17.00] <00:17.00>帰<00:18.00>り<00:19.00>道<00:20.00>は<00:21.00>", }; var song = new Song @@ -65,7 +65,7 @@ public void TestEncode() var lrcText = new[] { - "[00:17.00] <00:00.00>帰<00:01.00>り<00:02.00>道<00:03.00>は<00:04.00>", + "[00:17.00] <00:17.00>帰<00:18.00>り<00:19.00>道<00:20.00>は<00:21.00>", }; checkEncode(song, lrcText); diff --git a/LrcParser/Parser/Lrc/LrcParser.cs b/LrcParser/Parser/Lrc/LrcParser.cs index c4aa108..f823bae 100644 --- a/LrcParser/Parser/Lrc/LrcParser.cs +++ b/LrcParser/Parser/Lrc/LrcParser.cs @@ -37,13 +37,13 @@ static IEnumerable convertLyric(LrcLyric lrcLyric) { Text = lrcLyric.Text, StartTime = startTime, - TimeTags = getTimeTags(lrcLyric.TimeTags, startTime), + TimeTags = getTimeTags(lrcLyric.TimeTags), }; } } - static SortedDictionary getTimeTags(SortedDictionary timeTags, int offsetTime) - => new(timeTags.ToDictionary(k => k.Key, v => v.Value + offsetTime as int?)); + static SortedDictionary getTimeTags(SortedDictionary timeTags) + => new(timeTags.ToDictionary(k => k.Key, v => v.Value as int?)); } protected override IEnumerable PreProcess(Song song) @@ -58,7 +58,7 @@ protected override IEnumerable PreProcess(Song song) { Text = lyric.Text, StartTimes = [lyric.StartTime], - TimeTags = getTimeTags(lyric.TimeTags, -lyric.StartTime), + TimeTags = getTimeTags(lyric.TimeTags), }; } @@ -72,7 +72,7 @@ protected override IEnumerable PreProcess(Song song) yield break; - static SortedDictionary getTimeTags(SortedDictionary timeTags, int offsetTime = 0) - => new(timeTags.Where(x => x.Value.HasValue).ToDictionary(k => k.Key, v => v.Value!.Value + offsetTime)); + static SortedDictionary getTimeTags(SortedDictionary timeTags) + => new(timeTags.Where(x => x.Value.HasValue).ToDictionary(k => k.Key, v => v.Value!.Value)); } } diff --git a/LrcParser/Parser/Lrc/Metadata/LrcLyric.cs b/LrcParser/Parser/Lrc/Metadata/LrcLyric.cs index 911d27a..23008c1 100644 --- a/LrcParser/Parser/Lrc/Metadata/LrcLyric.cs +++ b/LrcParser/Parser/Lrc/Metadata/LrcLyric.cs @@ -24,7 +24,7 @@ public LrcLyric() /// /// Time tags. - /// It's the relative time from the start time. + /// It's the absolute time. /// public SortedDictionary TimeTags { get; set; } = new();