1
0
mirror of synced 2025-02-17 11:18:33 +01:00

38 lines
1.2 KiB
C#
Raw Normal View History

2023-07-17 11:20:00 +03:00
using System;
using System.Diagnostics;
2023-10-01 19:40:41 +03:00
using System.IO;
2023-07-17 11:20:00 +03:00
using System.Linq;
2023-10-01 19:40:41 +03:00
using System.Windows.Forms;
using TaikoSoundEditor.Commons.Utils;
2023-07-17 11:20:00 +03:00
2023-10-01 19:40:41 +03:00
namespace TaikoSoundEditor.Commons.IO
2023-07-17 11:20:00 +03:00
{
internal static class WAV
{
2023-07-17 17:47:56 +03:00
public static void ConvertToWav(string sourcePath, string destPath, int seconds_before)
2023-07-17 11:20:00 +03:00
{
sourcePath = Path.GetFullPath(sourcePath);
destPath = Path.GetFullPath(destPath);
var p = new Process();
2023-10-01 19:40:41 +03:00
2023-07-17 11:20:00 +03:00
p.StartInfo.FileName = Path.GetFullPath(@"Tools\sox\sox.exe");
2023-10-01 19:40:41 +03:00
p.StartInfo.Arguments = ProcessArgs.GetString(sourcePath, destPath, "pad", seconds_before.ToString(), "0");
2023-07-17 11:20:00 +03:00
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
p.WaitForExit();
int exitCode = p.ExitCode;
string stdout = p.StandardOutput.ReadToEnd();
string stderr = p.StandardError.ReadToEnd();
if (exitCode != 0)
throw new Exception($"Process sox failed with exit code {exitCode}:\n" + stderr);
}
}
}