/// <summary> /// 触发DestroyHandle事件 /// </summary> protected override void DestroyHandle() { BassVst.BASS_VST_ChannelRemoveDSP(stream, vstHandle); BassVst.BASS_VST_ChannelFree(vstHandle); BassVst.BASS_VST_ChannelFree(vstDummy); base.DestroyHandle(); }
/// <summary> /// 设置VST信道 /// </summary> /// <param name="stream">音频流句柄</param> public void SetVSTChannel(int stream) { this.stream = stream; BassVst.BASS_VST_ChannelFree(vstHandle); vstHandle = BassVst.BASS_VST_ChannelSetDSP(stream, fileName, BASSVSTDsp.BASS_VST_DEFAULT, 1); VSTEditorCallback(vstDummy, BASSVSTAction.BASS_VST_PARAM_CHANGED, 0, 0, IntPtr.Zero); }
/// <summary> /// 关闭VST插件 /// </summary> public void RemoveVSTChannel() { BassVst.BASS_VST_ChannelRemoveDSP(stream, vstHandle); isActive = false; Hide(); BassVst.BASS_VST_ChannelFree(vstHandle); BassVst.BASS_VST_ChannelFree(vstDummy); }
public static void BASSVSTShowDialog(bool vsti, int towhichstream, int whichvst, BASS_VST_INFO vstInfo) { try { if (vstInfo.hasEditor && !MainWindow.KMCGlobals.VSTSkipSettings) { Form f = new Form(); f.Width = vstInfo.editorWidth + 4; f.Height = vstInfo.editorHeight + 34; f.ClientSize = new Size(vstInfo.editorWidth, vstInfo.editorHeight); f.FormBorderStyle = FormBorderStyle.FixedToolWindow; f.StartPosition = FormStartPosition.CenterScreen; f.Text = String.Format("{0} {1}", Languages.Parse("DSPSettings"), vstInfo.effectName); BassVst.BASS_VST_EmbedEditor(whichvst, f.Handle); f.ShowDialog(); BassVst.BASS_VST_EmbedEditor(whichvst, IntPtr.Zero); } } catch (Exception ex) { StringBuilder sb = new StringBuilder(); sb.AppendLine("==== Start of Keppy's MIDI Converter Error ===="); sb.AppendLine(ex.ToString()); sb.AppendLine("==== End of Keppy's MIDI Converter Error ===="); Thread thread = new Thread(() => Clipboard.SetText(sb.ToString())); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); ErrorHandler errordialog = new ErrorHandler(Languages.Parse("VSTInvalidCallTitle"), Languages.Parse("VSTInvalidCallError"), 0, 0); errordialog.ShowDialog(); if (!vsti) { BassVst.BASS_VST_ChannelRemoveDSP(towhichstream, whichvst); } else { BassVst.BASS_VST_ChannelFree(MainWindow.VSTs._VSTiHandle); } } }
public static void ReleaseResources(bool StillRendering, bool Closing) { foreach (Int32 Stream in MainWindow.VSTs._DummyVSTHandles) { BassVst.BASS_VST_ChannelRemoveDSP(0, Stream); } if (MainWindow.KMCGlobals.SoundFonts != null) { foreach (BASS_MIDI_FONTEX pr in MainWindow.KMCGlobals.SoundFonts) { BassMidi.BASS_MIDI_FontFree(pr.font); } } BassVst.BASS_VST_ChannelRemoveDSP(0, MainWindow.VSTs._DummyLoudMaxHan); MainWindow.KMCGlobals.DoNotCountNotes = false; BassWasapi.BASS_WASAPI_Stop(true); BassWasapi.BASS_WASAPI_Free(); Bass.BASS_StreamFree(MainWindow.KMCGlobals._recHandle); BassVst.BASS_VST_ChannelFree(MainWindow.VSTs._VSTiHandle); MainWindow.KMCStatus.IsKMCBusy = StillRendering; MainWindow.KMCStatus.IsKMCNowExporting = false; MainWindow.KMCGlobals.eventc = 0; MainWindow.KMCGlobals.events = null; if (Closing) { Bass.BASS_Free(); MainWindow.KMCGlobals.ActiveVoicesInt = 0; MainWindow.KMCStatus.IsKMCBusy = false; MainWindow.KMCGlobals.NewWindowName = null; MainWindow.KMCStatus.RenderingMode = false; RTF.CPUUsage = 0.0f; RTF.ActiveVoices = 0.0f; } }
/// <summary> /// 设置VST信道,启动VST插件 /// </summary> /// <param name="stream">音频流句柄</param> public void StartVST(int stream) { this.stream = stream; //先释放原来的VST BassVst.BASS_VST_ChannelFree(vstHandle); BassVst.BASS_VST_ChannelFree(vstDummy); vstHandle = BassVst.BASS_VST_ChannelSetDSP(stream, fileName, BASSVSTDsp.BASS_VST_DEFAULT, 1); vstDummy = BassVst.BASS_VST_ChannelSetDSP(0, fileName, BASSVSTDsp.BASS_VST_DEFAULT, 1); //设置回调函数 myVstProc = new VSTPROC(VSTEditorCallback); BassVst.BASS_VST_SetCallback(vstDummy, myVstProc, IntPtr.Zero); BassVst.BASS_VST_GetInfo(vstDummy, vstInfo); Text = vstInfo.effectName; isActive = true; BassVst.BASS_VST_EmbedEditor(vstDummy, this.Handle); Width = vstInfo.editorWidth + 10; Height = vstInfo.editorHeight + 35; }
private void ClearUp() { try { if (this.FChannel.BassHandle.HasValue && this.FDSPHandle != 0) { BassVst.BASS_VST_ChannelRemoveDSP(this.FChannel.BassHandle.Value, this.FDSPHandle); BassVst.BASS_VST_ChannelFree(this.FDSPHandle); if (this.FEditor != null) { this.FEditor.Close(); if (this.FEditor != null) { this.FEditor.Dispose(); this.FEditor = null; } } } } catch { } this.FDSPHandle = 0; }
private void LoadVST(ref String VSTDLL, ref String VSTDLLDesc, Label Desc, Button Unload, Button Load, Int32 NumVST) { try { int status = 0; if (ModifierKeys == Keys.Shift) { status = 1; } else if (ModifierKeys == Keys.Control) { if (NumVST == 1) { if (Properties.Settings.Default.VSTiDisclaimer) { DialogResult dialogResult = MessageBox.Show("By clicking 'Yes', you agree not to abuse the 'VST instrument' feature to create, disseminate, or make accessible anything exploiting the copyrighted/protected samples or files included within a VST (\"Visual Studio Technology\" plugin).\n\nSuch resultant files could include (but are not limited to):\nSoundFonts, VSTs, or any other usable tool that commits copyright infringement.\n\nSimply put it, you may not use this tool to commit piracy on a copyrighted/trademarked/protected VST, free or paid, unless you have permission from the developer.\nYou may create audio at will from the VST, but DO NOT use this export feature to extract/\"rip\" samples from the VST.\n\nThe author assumes no legal responsibility from the use of this tool.", "Keppy's MIDI Converter - Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { Properties.Settings.Default.VSTiDisclaimer = false; Properties.Settings.Default.Save(); status = 2; MessageBox.Show("VSTi mode activated.", "Keppy's MIDI Converter - Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (dialogResult == DialogResult.No) { Properties.Settings.Default.VSTiDisclaimer = true; Properties.Settings.Default.Save(); return; } } else { status = 2; MessageBox.Show("VSTi mode activated.", "Keppy's MIDI Converter - Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { status = 0; } } InitStartDirectory(); if (VSTImportDialog.ShowDialog() == DialogResult.OK) { BASS_VST_INFO VSTInfo = new BASS_VST_INFO(); if (status == 1) { VSTDLL = VSTImportDialog.FileName; VSTDLLDesc = VSTImportDialog.FileName + " (Not verified)"; Desc.Text = VSTImportDialog.FileName + " (Not verified)"; Bass.BASS_Free(); Unload.Enabled = true; Load.Enabled = false; SaveDirectory(VSTImportDialog.FileName); } else if (status == 2) { Un4seen.Bass.Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_NOSPEAKER, IntPtr.Zero); int VSTiTester = BassVst.BASS_VST_ChannelCreate(44100, 2, VSTImportDialog.FileName, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT); MainWindow.KMCGlobals.vstIInfo = new BASS_VST_INFO(); bool Success = BassVst.BASS_VST_GetInfo(VSTiTester, MainWindow.KMCGlobals.vstIInfo); if (Success) { String Lab = String.Format("{0} by {1} (Version number: {2}", MainWindow.KMCGlobals.vstIInfo.productName, MainWindow.KMCGlobals.vstIInfo.vendorName, MainWindow.KMCGlobals.vstIInfo.vendorVersion); VSTDLL = VSTImportDialog.FileName; VSTDLLDesc = MainWindow.KMCGlobals.vstIInfo.productName + " by " + MainWindow.KMCGlobals.vstIInfo.vendorName + " (Version: " + MainWindow.KMCGlobals.vstIInfo.vendorVersion + ")"; Desc.Text = MainWindow.KMCGlobals.vstIInfo.productName + " by " + MainWindow.KMCGlobals.vstIInfo.vendorName + " (Version: " + MainWindow.KMCGlobals.vstIInfo.vendorVersion + ")"; Unload.Enabled = true; Load.Enabled = false; SaveDirectory(VSTImportDialog.FileName); BassVst.BASS_VST_ChannelFree(VSTiTester); Bass.BASS_Free(); } else { MessageBox.Show(String.Format(MainWindow.res_man.GetString("InvalidVSTLoaded", MainWindow.cul), Path.GetFileNameWithoutExtension(VSTImportDialog.FileName), bitreq, bitnow), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); BassVst.BASS_VST_ChannelFree(VSTiTester); Bass.BASS_Free(); } } else { Un4seen.Bass.Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_NOSPEAKER, IntPtr.Zero); int Test = Bass.BASS_StreamCreateDummy(44100, 2, BASSFlag.BASS_STREAM_DECODE, IntPtr.Zero); int VSTTester = BassVst.BASS_VST_ChannelSetDSP(Test, VSTImportDialog.FileName, BASSVSTDsp.BASS_VST_DEFAULT, 1); bool Success = BassVst.BASS_VST_GetInfo(VSTTester, VSTInfo); if (Success) { VSTDLL = VSTImportDialog.FileName; VSTDLLDesc = VSTInfo.productName + " by " + VSTInfo.vendorName + " (Version: " + VSTInfo.vendorVersion + ")"; Desc.Text = VSTInfo.productName + " by " + VSTInfo.vendorName + " (Version: " + VSTInfo.vendorVersion + ")"; Bass.BASS_Free(); Unload.Enabled = true; Load.Enabled = false; SaveDirectory(VSTImportDialog.FileName); BassVst.BASS_VST_ChannelRemoveDSP(Test, VSTTester); Bass.BASS_StreamFree(Test); Bass.BASS_Free(); } else { MessageBox.Show(String.Format(MainWindow.res_man.GetString("InvalidVSTLoaded", MainWindow.cul), Path.GetFileNameWithoutExtension(VSTImportDialog.FileName), bitreq, bitnow), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); BassVst.BASS_VST_ChannelRemoveDSP(Test, VSTTester); Bass.BASS_StreamFree(Test); Bass.BASS_Free(); } } } } catch (Exception ex) { KeppyMIDIConverter.ErrorHandler errordialog = new KeppyMIDIConverter.ErrorHandler(MainWindow.res_man.GetString("Error", MainWindow.cul), ex.ToString(), 0, 1); errordialog.ShowDialog(); } }