1
0
mirror of synced 2024-11-15 00:57:36 +01:00
TaikoSoundEditor/WAV.cs
NotImplementedLife 1ff7354141 first commit
2023-07-17 11:20:00 +03:00

38 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TaikoSoundEditor
{
internal static class WAV
{
public static void ConvertToWav(string sourcePath, string destPath)
{
sourcePath = Path.GetFullPath(sourcePath);
destPath = Path.GetFullPath(destPath);
var p = new Process();
p.StartInfo.FileName = Path.GetFullPath(@"Tools\sox\sox.exe");
p.StartInfo.ArgumentList.Add(sourcePath);
p.StartInfo.ArgumentList.Add(destPath);
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);
}
}
}