public IArchData ToArchData(byte[] wave, string waveExt, Dictionary <string, object> context = null) { if (!File.Exists(ToolPath)) { return(null); } var tempFile = Path.GetTempFileName(); File.WriteAllBytes(tempFile, wave); var tempOutFile = Path.GetTempFileName(); byte[] outBytes = null; try { int bitRate = 96; if (context != null) { if (context.ContainsKey(At9BitRate) && context[At9BitRate] is int br) { bitRate = br; } else { context[At9BitRate] = bitRate; } } //br 96 for 1 channel, br 192 for 2 channels (need 2ch sample!) ProcessStartInfo info = new ProcessStartInfo(ToolPath, $"-e -br {bitRate} \"{tempFile}\" \"{tempOutFile}\"") { UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true }; Process process = Process.Start(info); process?.WaitForExit(); outBytes = File.ReadAllBytes(tempOutFile); File.Delete(tempFile); File.Delete(tempOutFile); } catch (Exception e) { Console.WriteLine(e); } var arch = new Atrac9ArchData { Data = new PsbResource { Data = outBytes } }; return(arch); }
public bool TryGetArchData(PSB psb, PsbDictionary dic, out IArchData data) { data = null; if (psb.Platform == PsbSpec.ps4 || psb.Platform == PsbSpec.vita) { if (dic.Count == 1 && dic["archData"] is PsbResource res) { data = new Atrac9ArchData { Data = res }; return(true); } return(false); } return(false); }