private void ExtractWav(string path, string name = "",bool askSave = true)
{
if (!File.Exists(path))
return;
string loc = Path.GetDirectoryName(Application.ExecutablePath) + "\\exec";
Stream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
if (path.EndsWith(".pcc"))
{
using (ME3Package package = MEPackageHandler.OpenME3Package(path))
{
if (package.IsCompressed)
{
Stream result = CompressionHelper.DecompressME3(fs);
fs.Dispose();
fs = result;
}
}
}
if (DataOffset + DataSize > fs.Length)
return;
ExtractRawFromStream(fs);
ConvertRiffToWav();
SaveFileDialog d = new SaveFileDialog();
d.Filter = "Wave Files(*.wav)|*.wav";
d.FileName = name + ".wav";
if (askSave)
{
if (d.ShowDialog() == DialogResult.OK)
File.Copy(loc + "\\out.wav", d.FileName);
}
else
{
File.Copy(loc + "\\out.wav", name, true);
}
if (askSave)
MessageBox.Show("Done.");
}