public static void SaveSoundFile(ICLIFlags flags, string directory, FindLogic.Combo.ComboInfo info, ulong soundFile, bool voice) { bool convertWem = true; if (flags is ExtractFlags extractFlags) { convertWem = extractFlags.ConvertSound && !extractFlags.Raw; if (extractFlags.SkipSound) { return; } } FindLogic.Combo.SoundFileInfo soundFileInfo = voice ? info.VoiceSoundFiles[soundFile] : info.SoundFiles[soundFile]; using (Stream soundStream = OpenFile(soundFile)) { if (soundStream == null) { return; } if (!convertWem) { WriteFile(soundStream, Path.Combine(directory, $"{soundFileInfo.GetName()}.wem")); } else { ConvertSoundFile(soundStream, soundFileInfo, directory); } } }
private static void ConvertSoundFile(Stream stream, FindLogic.Combo.SoundFileInfo soundFileInfo, string directory) { string outputFile = Path.Combine(directory, $"{soundFileInfo.GetName()}.ogg"); CreateDirectoryFromFile(outputFile); using (Stream outputStream = File.OpenWrite(outputFile)) { outputStream.SetLength(0); ConvertSoundFile(stream, outputStream); } }
private static void ConvertSoundFile(Stream stream, FindLogic.Combo.SoundFileInfo soundFileInfo, string directory) { string outputFile = Path.Combine(directory, $"{soundFileInfo.GetName()}.wem"); string outputFileOgg = Path.ChangeExtension(outputFile, "ogg"); CreateDirectoryFromFile(outputFile); using (Sound.WwiseRIFFVorbis vorbis = new Sound.WwiseRIFFVorbis(stream, Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Third Party", "packed_codebooks_aoTuV_603.bin")))) { Stream vorbisStream = new MemoryStream(); vorbis.ConvertToOgg(vorbisStream); vorbisStream.Position = 0; using (Stream revorbStream = RevorbStd.Revorb.Jiggle(vorbisStream)) { using (Stream outputStream = File.OpenWrite(outputFileOgg)) { outputStream.SetLength(0); revorbStream.Position = 0; revorbStream.CopyTo(outputStream); } } } }
public static void SaveSoundFile(ICLIFlags flags, string directory, FindLogic.Combo.ComboInfo info, ulong soundFile, bool voice) { // info.SaveConfig.Tasks.Add(Task.Run(() => { SaveSoundFile(flags, directory, info, soundFile, voice); })); bool convertWem = false; if (flags is ExtractFlags extractFlags) { convertWem = extractFlags.ConvertSound && !extractFlags.Raw; if (extractFlags.SkipSound) { return; } } FindLogic.Combo.SoundFileInfo soundFileInfo = voice ? info.VoiceSoundFiles[soundFile] : info.SoundFiles[soundFile]; Stream soundStream = OpenFile(soundFile); // disposed by thread if (soundStream == null) { return; } if (!convertWem) { WriteFile(soundStream, Path.Combine(directory, $"{soundFileInfo.GetName()}.wem")); soundStream.Dispose(); } else if (info.SaveRuntimeData.Threads) { info.SaveRuntimeData.Tasks.Add(Task.Run(() => { ConvertSoundFile(soundStream, soundFileInfo, directory); })); } else { ConvertSoundFile(soundStream, soundFileInfo, directory); } }