From 2f2e1b447fd5f3b8e4fc043b22b5bb2964e152ba Mon Sep 17 00:00:00 2001 From: NotImplementedLife Date: Mon, 17 Jul 2023 17:47:56 +0300 Subject: [PATCH] add padding silence before sound --- MainForm.cs | 39 +++++++++++++++++++++++++++++++++++---- WAV.cs | 6 +++--- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/MainForm.cs b/MainForm.cs index 2c297c4..8d39b68 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -221,15 +221,35 @@ namespace TaikoSoundEditor File.WriteAllText("tja.txt", tja.ToString()); - var seconds = Math.Ceiling(tja.Headers.Offset + 3); + var seconds = (int)Math.Ceiling(tja.Headers.Offset + 3); if (seconds < 0) seconds = 0; - FeedbackBox.AppendText("Converting to wav\r\n"); - WAV.ConvertToWav(audioFilePath, $@".-tmp\{songName}.wav"); + WAV.ConvertToWav(audioFilePath, $@".-tmp\{songName}.wav", seconds); + + tja.Headers.Offset -= seconds; + tja.Headers.DemoStart += seconds; + + var text = File.ReadAllLines(tjaPath); + + text = text.Select(l => + { + if (l.StartsWith("OFFSET:")) + return $"OFFSET:{tja.Headers.Offset:n3}"; + if (l.StartsWith("DEMOSTART:")) + return $"DEMOSTART:{tja.Headers.DemoStart:n3}"; + return l; + }).ToArray(); + + + var newTja = @$".-tmp\{Path.GetFileName(tjaPath)}"; + File.WriteAllLines(newTja, text); + + FeedbackBox.AppendText("Running tja2fumen\r\n"); - var tja_binaries = TJA.RunTja2Fumen(tjaPath); + + var tja_binaries = TJA.RunTja2Fumen(newTja); FeedbackBox.AppendText("Creating sound data\r\n"); NewSongData ns = new NewSongData(); @@ -315,6 +335,17 @@ namespace TaikoSoundEditor mi.SongFileName = $"sound/song_{songName}"; + mi.RendaTimeEasy = 0; + mi.RendaTimeHard = 0; + mi.RendaTimeMania = 0; + mi.RendaTimeNormal = 0; + mi.RendaTimeUra = 0; + mi.FuusenTotalEasy = 0; + mi.FuusenTotalHard = 0; + mi.FuusenTotalMania = 0; + mi.FuusenTotalNormal = 0; + mi.FuusenTotalUra = 0; + Dictionary genres = new Dictionary { { "POP", 0 }, diff --git a/WAV.cs b/WAV.cs index b484a58..e35a14a 100644 --- a/WAV.cs +++ b/WAV.cs @@ -10,7 +10,7 @@ namespace TaikoSoundEditor internal static class WAV { - public static void ConvertToWav(string sourcePath, string destPath, int seconds_before = 0) + public static void ConvertToWav(string sourcePath, string destPath, int seconds_before) { sourcePath = Path.GetFullPath(sourcePath); destPath = Path.GetFullPath(destPath); @@ -19,9 +19,9 @@ namespace TaikoSoundEditor p.StartInfo.FileName = Path.GetFullPath(@"Tools\sox\sox.exe"); p.StartInfo.ArgumentList.Add(sourcePath); p.StartInfo.ArgumentList.Add(destPath); - /*p.StartInfo.ArgumentList.Add("pad"); + p.StartInfo.ArgumentList.Add("pad"); p.StartInfo.ArgumentList.Add(seconds_before.ToString()); - p.StartInfo.ArgumentList.Add("0");*/ + p.StartInfo.ArgumentList.Add("0"); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardError = true; p.StartInfo.RedirectStandardOutput = true;