static void Zero() { string value = "o"; ImplicitOperator implicitOperator = value; Console.WriteLine("implicitOperator.C: " + implicitOperator.C); implicitOperator += "3"; Console.WriteLine("implicitOperator.S: " + implicitOperator.S.Count.ToString() + " with values: " + string.Join(",", implicitOperator.S)); List <string> listOfValues = new List <string>(); listOfValues.Add("a"); listOfValues.Add("b"); implicitOperator += listOfValues; Console.WriteLine("implicitOperator.S: " + implicitOperator.S.Count.ToString() + " with values: " + string.Join(",", implicitOperator.S)); Console.WriteLine("implicitOperator finds: " + implicitOperator.FindValue("a")); List <string> examples = new List <string>(); examples.Add("a"); examples.Add("b"); examples.Add("c"); Console.WriteLine(examples.FindX("a")); //output first "a" by descending LocalMultithread.MakeItReal(); Multithread.MakeItReal(); Customer c = new Customer("Test"); Console.WriteLine("Waiting to get values from Orders"); Console.ReadLine(); foreach (var x in c.Orders) { Console.WriteLine(x.X.ToString()); } Console.ReadLine(); }
public void Run() { while (m_continue) { Async task = Multithread.GetTask(); task.Run(); task.SetResult(true); } }
private async void Extract_B_Click(object sender, RoutedEventArgs e) { if (IsClosing || IsBusy || IsOpenDialog) { return; } if (Event_Type_L.SelectedIndex == -1) { Message_Feed_Out("イベントIDが選択されていません。"); return; } if (Sound_L.Items.Count == 0) { Message_Feed_Out("イベント内にサウンドが存在しません。"); return; } IsOpenDialog = true; BetterFolderBrowser bfb = new BetterFolderBrowser() { Title = "保存先のフォルダを選択してください。", RootFolder = Sub_Code.Get_OpenDirectory_Path(), Multiselect = false, }; if (bfb.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Sub_Code.Set_Directory_Path(bfb.SelectedFolder); Message_T.Text = "イベント内のサウンドを抽出しています..."; await Task.Delay(50); List <string> Extract_Sound_Files = new List <string>(); for (int Number = 0; Number < Sound_L.Items.Count; Number++) { string To_File = Voice_Set.Special_Path + "/Wwise/BNK_WAV_Special/" + Sound_L.Items[Number]; if (IsPCKMode) { Wwise_PCK.Wwise_Extract_To_Ogg_File(uint.Parse(Sound_L.Items[Number].ToString()), To_File + ".ogg", true); } else { Wwise_BNK.Wwise_Extract_To_Ogg_File(uint.Parse(Sound_L.Items[Number].ToString()), To_File + ".ogg", true); } if (File.Exists(To_File + ".ogg")) { Extract_Sound_Files.Add(To_File + ".ogg"); } } Message_T.Text = "ファイルをwavに変換しています..."; await Multithread.Convert_To_Wav(Extract_Sound_Files.ToArray(), bfb.SelectedFolder, true, true); Message_Feed_Out("イベント内のファイルを抽出しました。"); } bfb.Dispose(); IsOpenDialog = false; }
#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable. #endregion #region Initialization private void InitializeDevices() { var createdDevice = Direct3D11Helper.CreateDevice(); device = createdDevice ?? throw new Exception("Failed to create Direct3D device."); var createdSharpDXDevice = Direct3D11Helper.CreateSharpDXDevice(device); sharpDXDevice = createdSharpDXDevice ?? throw new Exception("Failed to create SharpDX device."); multithread = sharpDXDevice.QueryInterface <Multithread>(); multithread.SetMultithreadProtected(true); }
public void StartCapture() { _multithread = _sharpDxD3dDevice.QueryInterface <SharpDX.Direct3D11.Multithread>(); _multithread.SetMultithreadProtected(true); _frameEvent = new ManualResetEvent(false); _closedEvent = new ManualResetEvent(false); _events = new[] { _closedEvent, _frameEvent }; _captureItem.Closed += OnClosed; _framePool = Direct3D11CaptureFramePool.CreateFreeThreaded( _device, DirectXPixelFormat.B8G8R8A8UIntNormalized, 1, _captureItem.Size); _framePool.FrameArrived += OnFrameArrived; _session = _framePool.CreateCaptureSession(_captureItem); _session.StartCapture(); }
private async void Start_B_Click(object sender, RoutedEventArgs e) { if (IsClosing || IsBusy || IsOpenDialog) { return; } if (BNK_Voices.Count == 0) { Message_Feed_Out("音声ファイルが選択されていません。"); return; } foreach (string BGM_File in BGM_Add) { if (!File.Exists(BGM_File)) { Message_Feed_Out(Path.GetFileName(BGM_File) + "が存在しませんでした。"); return; } } IsOpenDialog = true; BetterFolderBrowser fbd = new BetterFolderBrowser() { Title = "保存先を選択してください。", Multiselect = false, RootFolder = Sub_Code.Get_OpenDirectory_Path() }; if (fbd.ShowDialog() == DialogResult.OK) { IsBusy = true; string SetPath = fbd.SelectedFolder; Sub_Code.Set_Directory_Path(SetPath); if (!Sub_Code.CanDirectoryAccess(SetPath)) { Message_Feed_Out("指定したフォルダにアクセスできませんでした。"); IsBusy = false; IsOpenDialog = false; return; } try { Message_T.Opacity = 1; IsMessageShowing = false; List <string> Add_BGM_List = new List <string>(); if (BGM_Add_List.Items.Count > 0) { Message_T.Text = "BGMファイルを適応させています..."; await Task.Delay(50); for (int Number = 0; Number < BGM_Add.Count; Number++) { if (Number < 10) { File.Copy(BGM_Add[Number], Voice_Set.Special_Path + "/Wwise/BNK_WAV/battle_bgm_0" + Number + Path.GetExtension(BGM_Add[Number]), true); Add_BGM_List.Add(Voice_Set.Special_Path + "/Wwise/BNK_WAV/battle_bgm_0" + Number + ".wav"); } else { File.Copy(BGM_Add[Number], Voice_Set.Special_Path + "/Wwise/BNK_WAV/battle_bgm_" + Number + Path.GetExtension(BGM_Add[Number]), true); Add_BGM_List.Add(Voice_Set.Special_Path + "/Wwise/BNK_WAV/battle_bgm_" + Number + ".wav"); } } } if (Volume_Set_C.IsChecked.Value) { Message_T.Text = ".wavに変換しています..."; await Task.Delay(50); await Multithread.Convert_To_Wav(Directory.GetFiles(Voice_Set.Special_Path + "/Wwise/BNK_WAV", "*", SearchOption.TopDirectoryOnly), Voice_Set.Special_Path + "/Wwise/BNK_WAV", true, true); Message_T.Text = "音量をWoTB用に調整しています..."; await Task.Delay(50); Sub_Code.Volume_Set(Voice_Set.Special_Path + "/Wwise/BNK_WAV", Encode_Mode.WAV); } else { Message_T.Text = ".wavに変換しています..."; await Task.Delay(50); await Multithread.Convert_To_Wav(Directory.GetFiles(Voice_Set.Special_Path + "/Wwise/BNK_WAV", "*", SearchOption.TopDirectoryOnly), Voice_Set.Special_Path + "/Wwise/BNK_WAV", true, true); } Message_T.Text = "ファイルをコピーしています..."; if (Directory.Exists(Voice_Set.Special_Path + "/Wwise/BNK_WAV/Voices")) { Directory.Delete(Voice_Set.Special_Path + "/Wwise/BNK_WAV/Voices", true); } await Task.Delay(50); string Log_01 = Sub_Code.Set_Voice_Type_Change_Name_By_Index(Voice_Set.Special_Path + "/Wwise/BNK_WAV", Voice_Set.Special_Path + "/Wwise/BNK_WAV/Voices", BNK_Voices, BNK_Voices_Enable); if (Log_01 != "") { Message_Feed_Out("ファイルをコピーできませんでした。詳しくは\"Error_Log.txt\"を参照してください。"); Directory.Delete(Voice_Set.Special_Path + "/Wwise/BNK_WAV/Voices", true); IsBusy = false; IsOpenDialog = false; return; } foreach (string BGM_Now in Add_BGM_List) { Sub_Code.File_Move(BGM_Now, Voice_Set.Special_Path + "/Wwise/BNK_WAV/Voices/" + Path.GetFileName(BGM_Now), true); } Message_T.Text = "SEの有無をチェックし、適応しています..."; await Task.Delay(50); await BNK_Create_V2(Voice_Set.Special_Path + "/Wwise/BNK_WAV/Voices", SetPath); if (DVPL_C.IsChecked.Value) { Message_T.Text = "DVPL化しています..."; await Task.Delay(50); DVPL.DVPL_Pack(SetPath + "/voiceover_crew.bnk", SetPath + "/voiceover_crew.bnk.dvpl", true); DVPL.DVPL_Pack(SetPath + "/ui_battle.bnk", SetPath + "/ui_battle.bnk.dvpl", true); DVPL.DVPL_Pack(SetPath + "/ui_battle_basic.bnk", SetPath + "/ui_battle_basic.bnk.dvpl", true); DVPL.DVPL_Pack(SetPath + "/ui_chat_quick_commands.bnk", SetPath + "/ui_chat_quick_commands.bnk.dvpl", true); DVPL.DVPL_Pack(SetPath + "/reload.bnk", SetPath + "/reload.bnk.dvpl", true); } Directory.Delete(Voice_Set.Special_Path + "/Wwise/BNK_WAV/Voices", true); bool IsOK = true; if (Install_C.IsChecked.Value) { Message_T.Text = "WoTBに適応しています..."; await Task.Delay(50); Sub_Code.DVPL_File_Delete(Voice_Set.WoTB_Path + "/Data/WwiseSound/ja/voiceover_crew.bnk"); Sub_Code.DVPL_File_Delete(Voice_Set.WoTB_Path + "/Data/WwiseSound/reload.bnk"); Sub_Code.DVPL_File_Delete(Voice_Set.WoTB_Path + "/Data/WwiseSound/ui_chat_quick_commands.bnk"); Sub_Code.DVPL_File_Delete(Voice_Set.WoTB_Path + "/Data/WwiseSound/ui_battle.bnk"); Sub_Code.DVPL_File_Delete(Voice_Set.WoTB_Path + "/Data/WwiseSound/ui_battle_basic.bnk"); if (!Sub_Code.DVPL_File_Copy(SetPath + "/voiceover_crew.bnk", Voice_Set.WoTB_Path + "/Data/WwiseSound/ja/voiceover_crew.bnk", true)) { IsOK = false; } Sub_Code.DVPL_File_Copy(SetPath + "/reload.bnk", Voice_Set.WoTB_Path + "/Data/WwiseSound/reload.bnk", true); Sub_Code.DVPL_File_Copy(SetPath + "/ui_chat_quick_commands.bnk", Voice_Set.WoTB_Path + "/Data/WwiseSound/ui_chat_quick_commands.bnk", true); Sub_Code.DVPL_File_Copy(SetPath + "/ui_battle.bnk", Voice_Set.WoTB_Path + "/Data/WwiseSound/ui_battle.bnk", true); Sub_Code.DVPL_File_Copy(SetPath + "/ui_battle_basic.bnk", Voice_Set.WoTB_Path + "/Data/WwiseSound/ui_battle_basic.bnk", true); } Flash.Flash_Start(); if (IsOK) { Message_Feed_Out("完了しました。"); } else { Message_Feed_Out("エラー:WoTBに適応できませんでした。"); } } catch (Exception e1) { Sub_Code.Error_Log_Write(e1.Message); } IsBusy = false; } fbd.Dispose(); IsOpenDialog = false; }
//変換 //fsbからwavファイルを抽出し、ファイル名を変更、adpcmの場合ファイルが破損しているため復元してから.bnkを作成 private async void Chnage_To_Wwise_B_Click(object sender, RoutedEventArgs e) { if (IsClosing || Opacity < 1) { return; } if (Voice_FSB_File == "") { Message_Feed_Out("FSB file is not selected."); return; } try { IsClosing = true; BetterFolderBrowser sfd = new BetterFolderBrowser() { Title = "Please specify the save destination folder.", RootFolder = Sub_Code.Get_OpenDirectory_Path(), Multiselect = false }; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { FModChannel.setPaused(true); await Task.Delay(50); Sub_Code.Set_Directory_Path(sfd.SelectedFolder); FSB_Details_L.Items[2] = "Output:" + sfd.SelectedFolder.Substring(sfd.SelectedFolder.LastIndexOf("\\") + 1); if (Directory.Exists(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices_TMP")) { Directory.Delete(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices_TMP", true); } if (Directory.Exists(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices")) { Directory.Delete(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices", true); } Message_T.Text = "Extracting audio from FSB file..."; await Task.Delay(50); Fmod_File_Extract_V2.FSB_Extract_To_Directory(Voice_FSB_File, Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices_TMP"); Message_T.Text = "Encoding *.wav files..."; await Task.Delay(50); await Multithread.Convert_To_Wav(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices_TMP", Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices", true); Directory.Delete(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices_TMP", true); Message_T.Text = "Renaming *.wav files..."; await Task.Delay(50); Voice_Set.Voice_BGM_Name_Change_From_FSB(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices"); string[] Reload_Files = Directory.GetFiles(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices", "reload_*", SearchOption.TopDirectoryOnly); foreach (string Reload_Now in Reload_Files) { FileInfo fi_reload = new FileInfo(Reload_Now); if (fi_reload.Length == 290340 || fi_reload.Length == 335796 || fi_reload.Length == 336036 || fi_reload.Length == 445836 || fi_reload.Length == 497268 || fi_reload.Length == 541980) { fi_reload.Delete(); } } string[] Voice_Files = Directory.GetFiles(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices", "*.wav", SearchOption.TopDirectoryOnly); //音声の場合はたいていファイル名の語尾に_01や_02と書いているため、書かれていないファイルは削除する foreach (string Voice_Now in Voice_Files) { if (!Path.GetFileNameWithoutExtension(Voice_Now).Contains("_") || !Sub_Code.IsIncludeInt_From_String(Path.GetFileNameWithoutExtension(Voice_Now), "_")) { File.Delete(Voice_Now); } } if (File.Exists(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices/lock_on.wav")) { File.Delete(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices/lock_on.wav"); } Message_T.Text = "Creating a BNK file..."; await Task.Delay(50); FileInfo fi = new FileInfo(Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Default Work Unit.wwu"); if (File.Exists(Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Backup.tmp") && fi.Length >= 800000) { File.Copy(Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Backup.tmp", Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Default Work Unit.wwu", true); } if (!File.Exists(Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Backup.tmp")) { File.Copy(Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Default Work Unit.wwu", Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Backup.tmp", true); } WoTB_Voice_Mod_Creater.Wwise_Class.Wwise_Project_Create Wwise = new WoTB_Voice_Mod_Creater.Wwise_Class.Wwise_Project_Create(Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod"); Wwise.Sound_Add_Wwise(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices"); Wwise.Save(); Directory.Delete(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices", true); Wwise.Project_Build("voiceover_crew", sfd.SelectedFolder + "/voiceover_crew.bnk"); /*await Task.Delay(500); * Wwise.Project_Build("ui_battle", sfd.SelectedFolder + "/ui_battle.bnk"); * await Task.Delay(500); * Wwise.Project_Build("ui_chat_quick_commands", sfd.SelectedFolder + "/ui_chat_quick_commands.bnk"); * await Task.Delay(500); * Wwise.Project_Build("reload", sfd.SelectedFolder + "/reload.bnk");*/ Wwise.Clear(); if (File.Exists(Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Backup.tmp")) { File.Copy(Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Backup.tmp", Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Default Work Unit.wwu", true); } if (DVPL_C.IsChecked.Value) { Message_T.Text = "Encoding to DVPL format..."; await Task.Delay(50); DVPL.DVPL_Pack(sfd.SelectedFolder + "/voiceover_crew.bnk", sfd.SelectedFolder + "/voiceover_crew.bnk.dvpl", true); /*DVPL.DVPL_Pack(sfd.SelectedFolder + "/ui_battle.bnk", sfd.SelectedFolder + "/ui_battle.bnk.dvpl", true); * DVPL.DVPL_Pack(sfd.SelectedFolder + "/ui_chat_quick_commands.bnk", sfd.SelectedFolder + "/ui_chat_quick_commands.bnk.dvpl", true); * DVPL.DVPL_Pack(sfd.SelectedFolder + "/reload.bnk", sfd.SelectedFolder + "/reload.bnk.dvpl", true);*/ } Message_Feed_Out("The operation is complete. If the bnk file is extremely small in size, it may have failed."); } } catch (Exception e1) { Sub_Code.Error_Log_Write(e1.Message); Message_Feed_Out("An error has occurred. See Log.txt for details."); } IsClosing = false; Position_Change(); }
private async void Start_B_Click(object sender, RoutedEventArgs e) { if (IsClosing || IsBusy || IsOpenDialog) { return; } if (BNK_FSB_Voices.Count == 0) { Message_Feed_Out("音声ファイルが選択されていません。"); return; } IsOpenDialog = true; BetterFolderBrowser fbd = new BetterFolderBrowser() { Title = "保存先を選択してください。", Multiselect = false, RootFolder = Sub_Code.Get_OpenDirectory_Path() }; if (fbd.ShowDialog() == DialogResult.OK) { IsBusy = true; string To_Dir = Voice_Set.Special_Path + "/Wwise/BNK_WAV_WoT"; string SetPath = fbd.SelectedFolder; Sub_Code.Set_Directory_Path(SetPath); if (!Sub_Code.CanDirectoryAccess(SetPath)) { Message_Feed_Out("指定したフォルダにアクセスできませんでした。"); IsBusy = false; IsOpenDialog = false; return; } try { Message_T.Opacity = 1; IsMessageShowing = false; await Task.Delay(50); if (Volume_Set_C.IsChecked.Value) { Message_T.Text = ".wavに変換しています..."; await Task.Delay(50); await Multithread.Convert_To_Wav(Directory.GetFiles(To_Dir, "*", SearchOption.TopDirectoryOnly), To_Dir, true, true); Message_T.Text = "音量をWoT用に調整しています..."; await Task.Delay(50); Sub_Code.Volume_Set(To_Dir, Encode_Mode.WAV); } Message_T.Text = "ファイルをコピーしています..."; if (Directory.Exists(To_Dir + "/Voices")) { Directory.Delete(To_Dir + "/Voices", true); } await Task.Delay(50); string Log_01 = Sub_Code.Set_Voice_Type_Change_Name_By_Index(To_Dir, To_Dir + "/Voices", BNK_FSB_Voices, BNK_FSB_Enable); if (Log_01 != "") { Message_Feed_Out("ファイルをコピーできませんでした。詳しくは\"Error_Log.txt\"を参照してください。"); Directory.Delete(To_Dir + "/Voices", true); IsBusy = false; IsOpenDialog = false; return; } await BNK_Create_V2(To_Dir + "/Voices", SetPath); Directory.Delete(To_Dir + "/Voices", true); Flash.Flash_Start(); if (Sub_Code.WoT_Get_ModDirectory()) { Message_T.Text = "ダイアログを表示しています..."; await Task.Delay(50); MessageBoxResult result = System.Windows.MessageBox.Show("WoTのインストールフォルダの取得に成功しました。\n作成した音声ModをWoTに導入しますか?\n配置場所:" + Voice_Set.WoT_Mod_Path, "確認", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); if (result == MessageBoxResult.Yes) { try { if (!Directory.Exists(Voice_Set.WoT_Mod_Path + "/audioww")) { Directory.CreateDirectory(Voice_Set.WoT_Mod_Path + "/audioww"); } if (File.Exists(Voice_Set.WoT_Mod_Path + "/audioww/voiceover.bnk")) { File.Copy(Voice_Set.WoT_Mod_Path + "/audioww/voiceover.bnk", Voice_Set.WoT_Mod_Path + "/audioww/voiceover_bak.bnk", true); } File.Copy(SetPath + "/voiceover.bnk", Voice_Set.WoT_Mod_Path + "/audioww/voiceover.bnk", true); } catch (Exception e1) { Sub_Code.Error_Log_Write(e1.Message); Message_Feed_Out("WoTにインストールできませんでした。Error_Log.txtを確認してください。"); IsBusy = false; fbd.Dispose(); IsOpenDialog = false; return; } } } Message_Feed_Out("完了しました。"); } catch (Exception e1) { Sub_Code.Error_Log_Write(e1.Message); Message_Feed_Out("エラーが発生しました。Error_Log.txtを参照してください。"); } IsBusy = false; IsOpenDialog = false; } fbd.Dispose(); }
private async void Open_File_B_Click(object sender, RoutedEventArgs e) { if (IsClosing || IsBusy) { return; } OpenFileDialog ofd = new OpenFileDialog() { Title = "WoTBの音声Modを選択してください。", Multiselect = false, Filter = "WoTB音声(*.fsb;*.bnk)|*.fsb;*.bnk" }; if (ofd.ShowDialog() == DialogResult.OK) { IsBusy = true; try { string To_Dir = Voice_Set.Special_Path + "/Wwise/BNK_WAV_WoT"; try { if (Directory.Exists(To_Dir)) { Directory.Delete(To_Dir, true); } } catch (Exception e1) { Sub_Code.Error_Log_Write(e1.Message); } for (int Number = 0; Number < 34; Number++) { BNK_FSB_Enable.Add(new List <bool>()); } if (Path.GetExtension(ofd.FileName) == ".bnk") { Message_T.Text = ".bnkファイルを解析しています..."; await Task.Delay(50); Wwise_Class.BNK_Parse p = new Wwise_Class.BNK_Parse(ofd.FileName); if (!p.IsVoiceFile(true)) { Message_Feed_Out("選択されたbnkファイルは音声データではありません。"); IsBusy = false; return; } BNK_FSB_Voices = p.Get_Voices(true); List <string> Need_Files = new List <string>(); foreach (List <string> Types in BNK_FSB_Voices) { foreach (string File_Now in Types) { Need_Files.Add(File_Now); } } if (Need_Files.Count == 0) { Message_T.Text = "移植できるファイルが見つからなかったため、特殊な方法で解析しています..."; await Task.Delay(50); p.SpecialBNKFileMode = 1; BNK_FSB_Voices = p.Get_Voices(true); foreach (List <string> Types in BNK_FSB_Voices) { foreach (string File_Now in Types) { Need_Files.Add(File_Now); } } if (Need_Files.Count == 0) { p.Clear(); BNK_FSB_Voices.Clear(); Message_Feed_Out("移植できる音声が見つかりませんでした。"); IsBusy = false; return; } } p.Clear(); Voices_L.Items.Clear(); Content_L.Items.Clear(); Now_Stream_Count = 0; Message_T.Text = ".wavまたは.oggに変換しています..."; await Task.Delay(50); Wwise_File_Extract_V2 Wwise_BNK = new Wwise_File_Extract_V2(ofd.FileName); Max_Stream_Count = Wwise_BNK.Wwise_Get_Numbers(); Wwise_BNK.Wwise_Extract_To_WEM_Directory_V2(To_Dir); Wwise_BNK.Bank_Clear(); Message_T.Text = "不要な音声ファイルを削除しています..."; await Task.Delay(50); string[] All_Files = Directory.GetFiles(To_Dir, "*", SearchOption.TopDirectoryOnly); foreach (string File_Now in All_Files) { if (!Need_Files.Contains(Path.GetFileNameWithoutExtension(File_Now))) { Sub_Code.File_Delete_V2(File_Now); } } //効果音を削除(これ以外は取り除けない) string[] Files = Directory.GetFiles(To_Dir, "*.wem", SearchOption.TopDirectoryOnly); foreach (string File_Now in Files) { Sub_Code.File_Delete_V2(File_Now); } Message_T.Text = ".oggファイルを.wavファイルに変換しています..."; await Task.Delay(50); await Multithread.Convert_To_Wav(Directory.GetFiles(To_Dir, "*.ogg", SearchOption.TopDirectoryOnly), To_Dir, true, true); File_Name_T.Text = Path.GetFileName(ofd.FileName); Message_Feed_Out(".bnkファイルをロードしました。SEが含まれている場合は無効化してください。"); } else { Message_T.Text = ".fsbファイルを解析しています..."; await Task.Delay(50); bool IsVoiceExist = false; List <string> Voices = Fmod_Class.FSB_GetNames(ofd.FileName); foreach (string File_Now in Voices) { string File_Now_01 = File_Now.Replace(" ", ""); if (File_Now_01.Contains("battle_01") || File_Now_01.Contains("battle_02") || File_Now_01.Contains("battle_03") || File_Now_01.Contains("start_battle_01")) { IsVoiceExist = true; break; } } if (!IsVoiceExist) { Message_Feed_Out("指定したFSBファイルは対応していません。"); IsBusy = false; return; } Voices.Clear(); Message_T.Text = "FSBファイルからファイルを抽出しています..."; await Task.Delay(50); Max_Stream_Count = Fmod_Class.FSB_GetLength(ofd.FileName); Fmod_File_Extract_V2.FSB_Extract_To_Directory(ofd.FileName, To_Dir + "_TMP"); Message_T.Text = ".wavファイルを修正しています..."; await Task.Delay(50); await Multithread.Convert_To_Wav(To_Dir + "_TMP", To_Dir, true, true, false, false); Directory.Delete(To_Dir + "_TMP", true); Message_T.Text = "ファイル名からリストに配置しています..."; await Task.Delay(50); BNK_FSB_Voices = Voice_Set.Voice_BGM_Name_Change_From_FSB_To_Index(To_Dir); Voices_L.Items.Clear(); Content_L.Items.Clear(); Now_Stream_Count = 0; Message_T.Text = "不要なファイルを削除しています..."; await Task.Delay(50); foreach (string File_Name in Directory.GetFiles(To_Dir, "*", SearchOption.TopDirectoryOnly)) { string Name_Only = Path.GetFileNameWithoutExtension(File_Name); bool IsExsist = false; for (int Number = 0; Number < BNK_FSB_Voices.Count; Number++) { foreach (string Name_Now in BNK_FSB_Voices[Number]) { if (Name_Only == Name_Now) { IsExsist = true; break; } } if (IsExsist) { break; } } if (!IsExsist) { Sub_Code.File_Delete_V2(File_Name); } } File_Name_T.Text = Path.GetFileName(ofd.FileName); Message_Feed_Out(".fsbファイルをロードしました。"); } if (BNK_FSB_Voices[5].Count == 0 && BNK_FSB_Voices[2].Count > 0) { BNK_FSB_Voices[5] = new List <string>(BNK_FSB_Voices[2]); } if (BNK_FSB_Voices[4].Count == 0 && BNK_FSB_Voices[3].Count > 0) { BNK_FSB_Voices[4] = new List <string>(BNK_FSB_Voices[3]); } for (int Number = 0; Number < 34; Number++) { Now_Stream_Count += BNK_FSB_Voices[Number].Count; Voices_L.Items.Add(Voice_Set.Get_Voice_Type_Japanese_Name_V2(Number) + " : " + BNK_FSB_Voices[Number].Count + "個"); } for (int Number_01 = 0; Number_01 < BNK_FSB_Voices.Count; Number_01++) { for (int Number_02 = 0; Number_02 < BNK_FSB_Voices[Number_01].Count; Number_02++) { BNK_FSB_Enable[Number_01].Add(true); } } } catch (Exception e1) { IsBusy = false; Sub_Code.Error_Log_Write(e1.Message); BNK_FSB_Clear(false); Message_Feed_Out("エラーが発生しました。Error_Log.txtを参照してください。"); } } IsBusy = false; }
public void Dispose() { multithread?.Leave(); multithread = null !; }
public MultithreadLock(Multithread multithread) { this.multithread = multithread; this.multithread?.Enter(); }
private async void Change_Volume_B_Click(object sender, RoutedEventArgs e) { if (Sound_List.Items.Count == 0) { Message_Feed_Out(".bnkまたは.pckファイルが選択されていません。"); return; } string Message_01 = ".bnkまたは.pck内のサウンドの長さや量によって処理時間が変わります。\n"; string Message_02 = "処理中はフリーズしたように見えますが、実際はちゃんと処理されているのでご安心ください。"; System.Windows.MessageBox.Show(Message_01 + Message_02); string To_File_Path = BNK_PCK_File; string Ex = ""; if (IsPCKFile) { Ex = ".pck"; } else { Ex = ".bnk"; } if (!IsOverWrite_Checked) { SaveFileDialog ofd = new SaveFileDialog() { Title = "保存先をしていてください。", Filter = Ex + "ファイル|*" + Ex, AddExtension = true }; if (ofd.ShowDialog() == DialogResult.OK) { To_File_Path = ofd.FileName; } else { ofd.Dispose(); Message_Feed_Out("操作をキャンセルしました。"); return; } ofd.Dispose(); } if (!Sub_Code.CanDirectoryAccess(Path.GetDirectoryName(To_File_Path))) { Message_Feed_Out("フォルダにアクセスできませんでした。別の場所を選択してください。"); return; } try { IsMessageShowing = false; Message_T.Text = Ex + "ファイルからサウンドを抽出しています..."; await Task.Delay(50); if (IsPCKFile) { Wwise_Pck.Wwise_Extract_To_OGG_OR_WAV_Directory(Voice_Set.Special_Path + "\\Other\\Extract_To_WAV", true); } else { Wwise_Bnk.Wwise_Extract_To_OGG_OR_WAV_Directory(Voice_Set.Special_Path + "\\Other\\Extract_To_WAV", true); } await Multithread.Convert_OGG_To_Wav(Directory.GetFiles(Voice_Set.Special_Path + "\\Other\\Extract_To_WAV", "*.ogg", SearchOption.TopDirectoryOnly), true); Message_T.Text = "音量を調整しています..."; await Task.Delay(50); string[] WAV_Files = Directory.GetFiles(Voice_Set.Special_Path + "\\Other\\Extract_To_WAV", "*.wav", SearchOption.TopDirectoryOnly); if (!Is_Sync_Checked) { List <double> Volume_Gains = new List <double>(); foreach (string File_Now in WAV_Files) { Volume_Gains.Add(Sub_Code.Get_WAV_Gain(File_Now)); } await Multithread.WAV_Gain(WAV_Files, Volume_Gains.ToArray()); } else { await Multithread.WAV_Gain(WAV_Files, Volume_Sync_Mode - 89); } Message_T.Text = ".wavを.wemファイルに変換しています..."; await Task.Delay(50); string Project_Dir = Voice_Set.Special_Path + "\\Other\\WEM_Create"; if (File.Exists(Project_Dir + "/Actor-Mixer Hierarchy/Backup.tmp")) { File.Copy(Project_Dir + "/Actor-Mixer Hierarchy/Backup.tmp", Project_Dir + "/Actor-Mixer Hierarchy/Default Work Unit.wwu", true); } else { File.Copy(Project_Dir + "/Actor-Mixer Hierarchy/Default Work Unit.wwu", Project_Dir + "/Actor-Mixer Hierarchy/Backup.tmp", true); } List <List <string> > WAV_Limit_List = new List <string>(WAV_Files).Split(199); string Dir = Voice_Set.Special_Path + "\\Other\\WEM_Create\\.cache\\Windows\\SFX"; foreach (List <string> List_Now in WAV_Limit_List) { Wwise_Project_Create Wwise_Project = new Wwise_Project_Create(Project_Dir); foreach (string File_Now in List_Now) { Wwise_Project.Add_Sound("778220130", File_Now, "SFX", false, null, "", 0, false, false); } Wwise_Project.Save(); Wwise_Project.Project_Build("WEM_Create", Voice_Set.Special_Path + "\\Other\\Temp.bnk"); File.Delete(Voice_Set.Special_Path + "\\Other\\Temp.bnk"); foreach (string Name in Directory.GetFiles(Dir, "*.wem", SearchOption.TopDirectoryOnly)) { string Name_Only = Path.GetFileNameWithoutExtension(Name); File.Move(Name, Path.GetDirectoryName(Name) + "\\" + Name_Only.Substring(0, Name_Only.IndexOf('_')) + ".wem"); } Wwise_Project.Clear(false); if (File.Exists(Project_Dir + "/Actor-Mixer Hierarchy/Backup.tmp")) { File.Copy(Project_Dir + "/Actor-Mixer Hierarchy/Backup.tmp", Project_Dir + "/Actor-Mixer Hierarchy/Default Work Unit.wwu", true); } } Message_T.Text = ".bnk内の.wemと交換しています..."; await Task.Delay(50); int Number1 = Sub_Code.r.Next(0, 10000); StreamWriter stw = File.CreateText(Voice_Set.Special_Path + "/Other/Replace_WEM_" + Number1 + ".bat"); stw.WriteLine("chcp 65001"); stw.Write("\"" + Voice_Set.Special_Path + "/Wwise/wwiseutil.exe\" -replace -f \"" + BNK_PCK_File + "\" -t " + Dir + " -o \"" + To_File_Path + "\""); stw.Close(); ProcessStartInfo processStartInfo1 = new ProcessStartInfo { FileName = Voice_Set.Special_Path + "/Other/Replace_WEM_" + Number1 + ".bat", WorkingDirectory = Voice_Set.Special_Path + "\\Other", CreateNoWindow = true, UseShellExecute = false }; Process p = Process.Start(processStartInfo1); p.WaitForExit(); Wwise_Project_Create.Delete_Cache(Project_Dir); File.Delete(Voice_Set.Special_Path + "/Other/Replace_WEM_" + Number1 + ".bat"); Directory.Delete(Voice_Set.Special_Path + "\\Other\\Extract_To_WAV", true); foreach (string Name in Directory.GetFiles(Dir, "*.wem", SearchOption.TopDirectoryOnly)) { Sub_Code.File_Delete_V2(Name); } foreach (string Temp_File in Directory.GetFiles(Voice_Set.Special_Path + "\\Other", "wavegain.tmp*", SearchOption.TopDirectoryOnly)) { Sub_Code.File_Delete_V2(Temp_File); } Message_Feed_Out("完了しました。"); } catch (Exception e1) { Sub_Code.Error_Log_Write(e1.Message); Message_Feed_Out("エラーが発生しました。詳しくはError_Log.txtを参照してください。"); } }
//変換 //fsbからwavファイルを抽出し、ファイル名を変更、adpcmの場合ファイルが破損しているため復元してから.bnkを作成 private async void Chnage_To_Wwise_B_Click(object sender, RoutedEventArgs e) { if (IsClosing || Opacity < 1 || IsOpenDialog) { return; } if (Voice_FSB_File == "") { Message_Feed_Out("FSBファイルが選択されていません。"); return; } try { IsClosing = true; IsOpenDialog = true; BetterFolderBrowser sfd = new BetterFolderBrowser() { Title = "保存先のフォルダを指定してください。", RootFolder = Sub_Code.Get_OpenDirectory_Path(), Multiselect = false }; if (sfd.ShowDialog() == DialogResult.OK) { Sub_Code.Set_Directory_Path(sfd.SelectedFolder); FSB_Details_L.Items[4] = "出力先のフォルダ名:" + sfd.SelectedFolder.Substring(sfd.SelectedFolder.LastIndexOf("\\") + 1); if (Directory.Exists(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices_TMP")) { Directory.Delete(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices_TMP", true); } if (Directory.Exists(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices")) { Directory.Delete(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices", true); } Message_T.Text = "FSBファイルから音声を抽出しています..."; await Task.Delay(50); Fmod_File_Extract_V2.FSB_Extract_To_Directory(Voice_FSB_File, Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices_TMP"); if (BGM_FSB_File != "") { Message_T.Text = "FSBファイルからBGMを抽出しています..."; await Task.Delay(50); Fmod_File_Extract_V2.FSB_Extract_To_Directory(BGM_FSB_File, Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices_TMP"); } Message_T.Text = ".wavファイルをエンコードしています..."; await Task.Delay(50); await Multithread.Convert_To_Wav(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices_TMP", Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices", true, true, false, false); Directory.Delete(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices_TMP", true); if (BGM_Add_Only.Count > 0) { Message_T.Text = "追加されたBGMファイルをwavに変換しています..."; await Task.Delay(50); foreach (string File_Now in BGM_Add_Only) { if (!Sub_Code.Audio_IsWAV(File_Now)) { Sub_Code.Audio_Encode_To_Other(File_Now, Sub_Code.File_Rename_Get_Name(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices/battle_bgm") + ".wav", ".wav", false); } else { File.Copy(File_Now, Sub_Code.File_Rename_Get_Name(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices/battle_bgm") + ".wav", true); } } } Message_T.Text = "音声のファイル名を変更しています..."; await Task.Delay(50); Voice_Set.Voice_BGM_Name_Change_From_FSB(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices"); string[] Reload_Files = Directory.GetFiles(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices", "reload_*", SearchOption.TopDirectoryOnly); foreach (string Reload_Now in Reload_Files) { FileInfo fi_reload = new FileInfo(Reload_Now); if (fi_reload.Length == 290340 || fi_reload.Length == 335796 || fi_reload.Length == 336036 || fi_reload.Length == 445836 || fi_reload.Length == 497268 || fi_reload.Length == 541980) { fi_reload.Delete(); } } string[] Voice_Files = Directory.GetFiles(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices", "*.wav", SearchOption.TopDirectoryOnly); //音声の場合はたいていファイル名の語尾に_01や_02と書いているため、書かれていないファイルは削除する foreach (string Voice_Now in Voice_Files) { if (!Path.GetFileNameWithoutExtension(Voice_Now).Contains("_") || !Sub_Code.IsIncludeInt_From_String(Path.GetFileNameWithoutExtension(Voice_Now), "_")) { File.Delete(Voice_Now); } } if (File.Exists(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices/lock_on.wav")) { File.Delete(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices/lock_on.wav"); } if (BGM_Add_List.Items.Count > 0) { Message_T.Text = ".bnkファイルを作成しています...\nBGMが含まれているため時間がかかります..."; } else { Message_T.Text = ".bnkファイルを作成しています..."; } await Task.Delay(50); FileInfo fi = new FileInfo(Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Default Work Unit.wwu"); if (File.Exists(Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Backup.tmp") && fi.Length >= 800000) { File.Copy(Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Backup.tmp", Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Default Work Unit.wwu", true); } if (!File.Exists(Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Backup.tmp")) { File.Copy(Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Default Work Unit.wwu", Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Backup.tmp", true); } Wwise_Class.Wwise_Project_Create Wwise = new Wwise_Class.Wwise_Project_Create(Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod"); Wwise.Sound_Add_Wwise(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices"); Wwise.Save(); Directory.Delete(Voice_Set.Special_Path + "/Wwise/FSB_Extract_Voices", true); Wwise.Project_Build("voiceover_crew", sfd.SelectedFolder + "/voiceover_crew.bnk"); await Task.Delay(500); Wwise.Project_Build("ui_battle", sfd.SelectedFolder + "/ui_battle.bnk"); await Task.Delay(500); Wwise.Project_Build("ui_battle_basic", sfd.SelectedFolder + "/ui_battle_basic.bnk"); await Task.Delay(500); Wwise.Project_Build("ui_chat_quick_commands", sfd.SelectedFolder + "/ui_chat_quick_commands.bnk"); await Task.Delay(500); Wwise.Project_Build("reload", sfd.SelectedFolder + "/reload.bnk"); Wwise.Clear(); if (File.Exists(Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Backup.tmp")) { File.Copy(Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Backup.tmp", Voice_Set.Special_Path + "/Wwise/WoTB_Sound_Mod/Actor-Mixer Hierarchy/Default Work Unit.wwu", true); } if (DVPL_C.IsChecked.Value) { Message_T.Text = "DVPL化しています..."; await Task.Delay(50); DVPL.DVPL_Pack(sfd.SelectedFolder + "/voiceover_crew.bnk", sfd.SelectedFolder + "/voiceover_crew.bnk.dvpl", true); DVPL.DVPL_Pack(sfd.SelectedFolder + "/ui_battle.bnk", sfd.SelectedFolder + "/ui_battle.bnk.dvpl", true); DVPL.DVPL_Pack(sfd.SelectedFolder + "/ui_battle_basic.bnk", sfd.SelectedFolder + "/ui_battle_basic.bnk.dvpl", true); DVPL.DVPL_Pack(sfd.SelectedFolder + "/ui_chat_quick_commands.bnk", sfd.SelectedFolder + "/ui_chat_quick_commands.bnk.dvpl", true); DVPL.DVPL_Pack(sfd.SelectedFolder + "/reload.bnk", sfd.SelectedFolder + "/reload.bnk.dvpl", true); } if (Install_C.IsChecked.Value) { Message_T.Text = "WoTBに適応しています..."; await Task.Delay(50); Sub_Code.DVPL_File_Delete(Voice_Set.WoTB_Path + "/Data/WwiseSound/ja/voiceover_crew.bnk"); Sub_Code.DVPL_File_Delete(Voice_Set.WoTB_Path + "/Data/WwiseSound/ui_battle.bnk"); Sub_Code.DVPL_File_Delete(Voice_Set.WoTB_Path + "/Data/WwiseSound/ui_chat_quick_commands.bnk"); Sub_Code.DVPL_File_Delete(Voice_Set.WoTB_Path + "/Data/WwiseSound/reload.bnk"); Sub_Code.DVPL_File_Copy(sfd.SelectedFolder + "/voiceover_crew.bnk", Voice_Set.WoTB_Path + "/Data/WwiseSound/ja/voiceover_crew.bnk", true); Sub_Code.DVPL_File_Copy(sfd.SelectedFolder + "/ui_battle.bnk", Voice_Set.WoTB_Path + "/Data/WwiseSound/ui_battle.bnk", true); Sub_Code.DVPL_File_Copy(sfd.SelectedFolder + "/ui_chat_quick_commands.bnk", Voice_Set.WoTB_Path + "/Data/WwiseSound/ui_chat_quick_commands.bnk", true); Sub_Code.DVPL_File_Copy(sfd.SelectedFolder + "/reload.bnk", Voice_Set.WoTB_Path + "/Data/WwiseSound/reload.bnk", true); } Flash.Flash_Start(); Message_Feed_Out("完了しました。\nファイル容量が極端に少ない場合は失敗している可能性があります。"); } } catch (Exception e1) { Sub_Code.Error_Log_Write(e1.Message); Message_Feed_Out("エラーが発生しました。詳しくはLog.txtを参照してください。"); } IsClosing = false; IsOpenDialog = false; }