//FModの音声ファイルを選択 private void Voice_Select_B_Click(object sender, RoutedEventArgs e) { if (IsClosing) { return; } OpenFileDialog ofd = new OpenFileDialog() { Title = "Please select an FSB file.", Filter = "FSB File(*.fsb)|*.fsb", InitialDirectory = Sub_Code.Get_OpenFile_Path(), Multiselect = false }; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Sub_Code.Set_OpenFile_Path(Path.GetDirectoryName(ofd.FileName)); bool IsVoiceExist = false; FModChannel.setPaused(true); FModChannel = new FMOD_API.Channel(); SubSound.release(); MainSound.release(); SubSound = new FMOD_API.Sound(); MainSound = new FMOD_API.Sound(); Location_T.Text = "00:00"; Location_S.Value = 0; Location_S.Maximum = 0; FMod_List_Clear(); List <string> Voices = Fmod_Class.FSB_GetNames(ofd.FileName); foreach (string File_Now in Voices) { string File_Now_01 = File_Now.Replace(" ", ""); Voice_Add_List.Items.Add(File_Now_01); 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; } } if (!IsVoiceExist) { Message_Feed_Out("The specified file is not supported."); Voice_Add_List.Items.Clear(); return; } Voice_FSB_File = ofd.FileName; FSB_Details_L.Items[0] = "FSB File:" + Path.GetFileName(ofd.FileName); FSB_Details_L.Items[1] = "Number of voices:" + Voices.Count; Voice_Select_T.Text = Path.GetFileName(ofd.FileName); Voices.Clear(); } }
//選択されている音声を再生 void Sound_Start() { if (Voice_FSB_File == "" || Voice_Add_List.SelectedIndex == -1) { return; } FModChannel.setPaused(true); FModChannel = new FMOD_API.Channel(); SubSound.release(); MainSound.release(); SubSound = new FMOD_API.Sound(); MainSound = new FMOD_API.Sound(); Fmod_System.FModSystem.createSound(Voice_FSB_File, FMOD_API.MODE.CREATESTREAM, ref MainSound); MainSound.getSubSound(Voice_Add_List.SelectedIndex, ref SubSound); Fmod_System.FModSystem.playSound(FMOD_API.CHANNELINDEX.FREE, SubSound, true, ref FModChannel); FModChannel.setVolume((float)(Volume_S.Value / 100)); }
//音声、BGMともに初期化 private void Clear_B_Click(object sender, RoutedEventArgs e) { if (IsClosing) { return; } MessageBoxResult result = System.Windows.MessageBox.Show("Do you want to clear the contents?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Exclamation, MessageBoxResult.No); if (result == MessageBoxResult.Yes) { Voice_FSB_File = ""; FModChannel.setPaused(true); FMod_List_Clear(); Location_S.Value = 0; Location_S.Maximum = 0; Location_T.Text = "00:00"; FModChannel = new FMOD_API.Channel(); } }
//選択されている音声を再生 void Sound_Start() { if (File_Full_Name == "" || FSB_Name_L.SelectedIndex == -1) { return; } FModChannel.setPaused(true); FModChannel = new FMOD_API.Channel(); SubSound.release(); MainSound.release(); SubSound = new FMOD_API.Sound(); MainSound = new FMOD_API.Sound(); Fmod_System.FModSystem.createSound(File_Full_Name, FMOD_API.MODE.CREATESTREAM, ref MainSound); MainSound.getSubSound(FSB_Name_L.SelectedIndex, ref SubSound); Fmod_System.FModSystem.playSound(FMOD_API.CHANNELINDEX.FREE, SubSound, true, ref FModChannel); float Frequency_Now = 44100f; FModChannel.getFrequency(ref Frequency_Now); Sound_Frequency = (int)Frequency_Now / 100; FModChannel.setVolume((float)(Volume_S.Value / (double)100)); FModChannel.setFrequency((float)(Pitch_S.Value * Sound_Frequency)); }
//FSBファイルを選択 private async void FSB_Select_B_Click(object sender, System.Windows.RoutedEventArgs e) { if (IsClosing) { return; } System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog() { Title = "FSBファイルを選択してください。", Filter = "FSBファイル(*.fsb;*.fsb.dvpl)|*.fsb;*.fsb.dvpl", Multiselect = false }; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { bool IsDVPL = false; int Number = 0; if (Path.GetExtension(ofd.FileName) == ".dvpl") { IsDVPL = true; if (!File.Exists(Voice_Set.Special_Path + "/FSB_Select_Temp_01.fsb")) { DVPL.DVPL_UnPack(ofd.FileName, Voice_Set.Special_Path + "/FSB_Select_Temp_01.fsb", false); Number = 1; } else if (!File.Exists(Voice_Set.Special_Path + "/FSB_Select_Temp_02.fsb")) { DVPL.DVPL_UnPack(ofd.FileName, Voice_Set.Special_Path + "/FSB_Select_Temp_02.fsb", false); Number = 2; } else if (!File.Exists(Voice_Set.Special_Path + "/FSB_Select_Temp_03.fsb")) { DVPL.DVPL_UnPack(ofd.FileName, Voice_Set.Special_Path + "/FSB_Select_Temp_03.fsb", false); Number = 3; } } FModChannel.setPaused(true); FModChannel = new FMOD_API.Channel(); SubSound.release(); MainSound.release(); SubSound = new FMOD_API.Sound(); MainSound = new FMOD_API.Sound(); Location_T.Text = "00:00"; Message_T.Text = "FSBファイルを読み込んでいます..."; await Task.Delay(50); FSB_Select_T.Text = Path.GetFileName(ofd.FileName); List <string> Name_List; if (IsDVPL) { File_Full_Name = Voice_Set.Special_Path + "/FSB_Select_Temp_0" + Number + ".fsb"; Name_List = Fmod_Class.FSB_GetNames(Voice_Set.Special_Path + "/FSB_Select_Temp_0" + Number + ".fsb"); } else { File_Full_Name = ofd.FileName; Name_List = Fmod_Class.FSB_GetNames(ofd.FileName); } FSB_Number_T.Text = "ファイル数:" + Name_List.Count + " | 選択:なし"; FSB_Name_L.Items.Clear(); foreach (string Name_Now in Name_List) { FSB_Name_L.Items.Add(Name_Now); } if (Name_List.Count == 0) { Message_Feed_Out("内容を取得できませんでした。"); } else { Message_Feed_Out("読み込みが完了しました。"); } if (Number == 1) { Sub_Code.File_Delete_V2(Voice_Set.Special_Path + "/FSB_Select_Temp_02.fsb"); Sub_Code.File_Delete_V2(Voice_Set.Special_Path + "/FSB_Select_Temp_03.fsb"); } else if (Number == 2) { Sub_Code.File_Delete_V2(Voice_Set.Special_Path + "/FSB_Select_Temp_01.fsb"); Sub_Code.File_Delete_V2(Voice_Set.Special_Path + "/FSB_Select_Temp_03.fsb"); } else if (Number == 3) { Sub_Code.File_Delete_V2(Voice_Set.Special_Path + "/FSB_Select_Temp_01.fsb"); Sub_Code.File_Delete_V2(Voice_Set.Special_Path + "/FSB_Select_Temp_02.fsb"); } } catch (Exception e1) { Message_Feed_Out("エラー:FSBファイルが壊れている可能性があります。"); Sub_Code.Error_Log_Write(e1.Message); } } }