/// <summary> /// Convert ogg or wave audio files to Wwise 2013 wem audio, including preview wem file. /// </summary> /// <param name="audioPath"></param> /// <param name="audioQuality"></param> /// <param name="previewLength"></param> /// <param name="chorusTime"></param> /// <returns>wemPath</returns> public static string Convert2Wem(string audioPath, int audioQuality = 4, long previewLength = 30000, long chorusTime = 4000) { // TODO: check for converted wem's from GUI call and ask if we want generate over or use existing files. var audioPathNoExt = Path.Combine(Path.GetDirectoryName(audioPath), Path.GetFileNameWithoutExtension(audioPath)); var oggPath = String.Format(audioPathNoExt + ".ogg"); var wavPath = String.Format(audioPathNoExt + ".wav"); var wemPath = String.Format(audioPathNoExt + ".wem"); var oggPreviewPath = String.Format(audioPathNoExt + "_preview.ogg"); var wavPreviewPath = String.Format(audioPathNoExt + "_preview.wav"); var wemPreviewPath = String.Format(audioPathNoExt + "_preview.wem"); //switch to verify headers instead, maybe Plus current implmentation bugged as for me. if (audioPath.Substring(audioPath.Length - 4).ToLower() == ".ogg") //in RS1 ogg was actually wwise { // create ogg preview if it does not exist if (!File.Exists(oggPreviewPath)) { ExternalApps.Ogg2Preview(audioPath, oggPreviewPath, previewLength, chorusTime); } // convert ogg to wav ExternalApps.Ogg2Wav(audioPath, wavPath); //detect quality here ExternalApps.Ogg2Wav(oggPreviewPath, wavPreviewPath); audioPath = wavPath; } if (audioPath.Substring(audioPath.Length - 4).ToLower() == ".wav") { if (!File.Exists(wavPreviewPath)) { // may cause issues if you've got another guitar.ogg in folder, but it's extremely rare. if (!File.Exists(oggPath)) { ExternalApps.Wav2Ogg(audioPath, oggPath, audioQuality); // 4 } // create preview from ogg and then convert back to wav ExternalApps.Ogg2Preview(oggPath, oggPreviewPath, previewLength, chorusTime); ExternalApps.Ogg2Wav(oggPreviewPath, wavPreviewPath); } Wwise.Wav2Wem(audioPath, wemPath, audioQuality); audioPath = wemPath; } if (audioPath.Substring(audioPath.Length - 4).ToLower() == ".wem" && !File.Exists(wemPreviewPath)) { Revorb(audioPath, oggPath, WwiseVersion.Wwise2013); ExternalApps.Ogg2Wav(oggPath, wavPath); ExternalApps.Ogg2Preview(oggPath, oggPreviewPath, previewLength, chorusTime); ExternalApps.Ogg2Wav(oggPreviewPath, wavPreviewPath); Wwise.Wav2Wem(wavPath, wemPath, audioQuality); audioPath = wemPath; } return(audioPath); }
/// <summary> /// Convert ogg or wave audio files to Wwise 2013 wem audio, including preview wem file. /// </summary> /// <param name="audioPath"></param> /// <param name="audioQuality"></param> /// <param name="previewLength"></param> /// <param name="chorusTime"></param> /// <returns>wemPath</returns> public static string Convert2Wem(string audioPath, int audioQuality = 4, long previewLength = 30000, long chorusTime = 4000) { // ExternalApps.VerifyExternalApps(); // for testing var audioPathNoExt = Path.Combine(Path.GetDirectoryName(audioPath), Path.GetFileNameWithoutExtension(audioPath)); var oggPath = String.Format(audioPathNoExt + ".ogg"); var wavPath = String.Format(audioPathNoExt + ".wav"); var wemPath = String.Format(audioPathNoExt + ".wem"); var oggPreviewPath = String.Format(audioPathNoExt + "_preview.ogg"); var wavPreviewPath = String.Format(audioPathNoExt + "_preview.wav"); var wemPreviewPath = String.Format(audioPathNoExt + "_preview.wem"); if (audioPath.Substring(audioPath.Length - 4).ToLower() == ".ogg") //in RS1 ogg was actually wwise { ExternalApps.Ogg2Wav(audioPath, wavPath); //detect quality here if (!File.Exists(oggPreviewPath)) { ExternalApps.Ogg2Preview(audioPath, oggPreviewPath, previewLength, chorusTime); ExternalApps.Ogg2Wav(oggPreviewPath, wavPreviewPath); } audioPath = wavPath; } if (audioPath.Substring(audioPath.Length - 4).ToLower() == ".wav") { if (!File.Exists(wavPreviewPath)) { if (!File.Exists(oggPath)) { //may cause issues if you've got another guitar.ogg in folder, but it's extremely rare. ExternalApps.Wav2Ogg(audioPath, oggPath, audioQuality); // 4 } ExternalApps.Ogg2Preview(oggPath, oggPreviewPath, previewLength, chorusTime); ExternalApps.Ogg2Wav(oggPreviewPath, wavPreviewPath); } Wwise.Convert2Wem(audioPath, wemPath, audioQuality); audioPath = wemPath; } if (audioPath.Substring(audioPath.Length - 4).ToLower() == ".wem" && !File.Exists(wemPreviewPath)) { Revorb(audioPath, oggPath, Path.GetDirectoryName(Application.ExecutablePath), WwiseVersion.Wwise2013); ExternalApps.Ogg2Wav(oggPath, wavPath); ExternalApps.Ogg2Preview(oggPath, oggPreviewPath, previewLength, chorusTime); ExternalApps.Ogg2Wav(oggPreviewPath, wavPreviewPath); Wwise.Convert2Wem(wavPath, wemPath, audioQuality); audioPath = wemPath; } return(audioPath); }
private static DLCPackageData ConvertAudio(DLCPackageData info) { var audioPath = info.OggPath; Console.WriteLine(@"Converting audio using: " + Path.GetFileName(audioPath)); var audioPathNoExt = Path.Combine(Path.GetDirectoryName(audioPath), Path.GetFileNameWithoutExtension(audioPath)); var oggPath = String.Format(audioPathNoExt + ".ogg"); var wavPath = String.Format(audioPathNoExt + ".wav"); var wemPath = String.Format(audioPathNoExt + ".wem"); var oggPreviewPath = String.Format(audioPathNoExt + "_preview.ogg"); var wavPreviewPath = String.Format(audioPathNoExt + "_preview.wav"); var wemPreviewPath = String.Format(audioPathNoExt + "_preview.wem"); var audioPreviewPath = wemPreviewPath; //RS1 old ogg was actually wwise if (audioPath.Substring(audioPath.Length - 4).ToLower() == ".ogg") { ExternalApps.Ogg2Wav(audioPath, wavPath); if (!File.Exists(oggPreviewPath)) { ExternalApps.Ogg2Preview(audioPath, oggPreviewPath); ExternalApps.Ogg2Wav(oggPreviewPath, wavPreviewPath); } audioPath = wavPath; } if (audioPath.Substring(audioPath.Length - 4).ToLower() == ".wav") { if (!File.Exists(wavPreviewPath)) { ExternalApps.Wav2Ogg(audioPath, oggPath, 4); ExternalApps.Ogg2Preview(oggPath, oggPreviewPath); ExternalApps.Ogg2Wav(oggPreviewPath, wavPreviewPath); } Wwise.Convert2Wem(audioPath, wemPath, 4); // default audio quality = 4 audioPath = wemPath; } info.OggPath = audioPath; info.OggPreviewPath = audioPreviewPath; return(info); }