Exemplo n.º 1
0
 /// <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();
 }
Exemplo n.º 2
0
 /// <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);
 }
Exemplo n.º 3
0
        public void VST_DISABLE(string del)
        {
            BassVst.BASS_VST_ChannelRemoveDSP(_Stream, getHAndle(del));

            remove_workLIST(del, ref work_list_vst);
            remove_VST(del, ref data.workVST);
            data.UpdateLIST();
        }
Exemplo n.º 4
0
        private void RemoveVstPlugin(VstPlugin plugin)
        {
            if (plugin == null)
            {
                return;
            }
            // DebugHelper.WriteLine("Unload plug-in" + plugin.Name);
            if (plugin.Form != null)
            {
                if (!plugin.Form.IsDisposed)
                {
                    plugin.Form.CanClose = true;
                    plugin.Form.Close();
                    plugin.Form.Dispose();
                    plugin.Form = null;
                }
            }

            BassVst.BASS_VST_ChannelRemoveDSP(ChannelId, plugin.Id);
        }
Exemplo n.º 5
0
 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);
         }
     }
 }
Exemplo n.º 6
0
        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;
            }
        }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Don't use the selected VST Plugin anymore
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonPluginRemove_Click(object sender, EventArgs e)
        {
            DSPPluginInfo pluginInfo = (DSPPluginInfo)listBoxSelectedPlugins.SelectedItem;

            if (pluginInfo == null)
            {
                return;
            }

            if (pluginInfo.DSPPluginType == DSPPluginInfo.PluginType.VST)
            {
                // Remove VST Handle
                BassVst.BASS_VST_ChannelRemoveDSP(0, _vstHandles[pluginInfo.Name]);
                _vstHandles.Remove(pluginInfo.Name);
            }
            else
            {
                // Remove Winamp Handle
                BassWaDsp.BASS_WADSP_FreeDSP(_waDspPlugins[pluginInfo.FilePath]);
                _waDspPlugins.Remove(pluginInfo.Name);
            }
            listBoxFoundPlugins.Items.Add(listBoxSelectedPlugins.SelectedItem);
            listBoxSelectedPlugins.Items.RemoveAt(listBoxSelectedPlugins.SelectedIndex);
        }
Exemplo n.º 9
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();
            }
        }
Exemplo n.º 10
0
        private void LoadVST(ref String VSTDLL, ref String VSTDLLDesc, ref Label Desc, ref Button Unload, ref 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(Languages.Parse("LegalWarningVSTi"), String.Format("{0} {1} - {2}", Program.Who, Program.Title, Languages.Parse("Warning")), MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                            if (dialogResult == DialogResult.Yes)
                            {
                                Properties.Settings.Default.VSTiDisclaimer = false;
                                Properties.Settings.Default.Save();
                                status = 2;
                                MessageBox.Show(Languages.Parse("VSTiModeOnLegal"), String.Format("{0} {1} - {2}", Program.Who, Program.Title, Languages.Parse("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(Languages.Parse("VSTiModeOn"), String.Format("{0} {1} - {2}", Program.Who, Program.Title, Languages.Parse("Warning")), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        status = 0;
                    }
                }

                InitStartDirectory();
                if (VSTImportDialog.ShowDialog() == DialogResult.OK)
                {
                    if (status == 1)
                    {
                        VSTDLL     = VSTImportDialog.FileName;
                        VSTDLLDesc = String.Format("{0} - ({1})", VSTImportDialog.FileName, Languages.Parse("NotVerified"));
                        Desc.Text  = String.Format("{0} - ({1})", VSTImportDialog.FileName, Languages.Parse("NotVerified"));
                        Bass.BASS_Free();
                        Unload.Enabled = true;
                        Load.Enabled   = false;
                        SaveDirectory(VSTImportDialog.FileName);
                    }
                    else if (status == 2)
                    {
                        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);
                        MainWindow.VSTs.VSTInfo[NumVST - 1] = new BASS_VST_INFO();
                        bool Success = BassVst.BASS_VST_GetInfo(VSTiTester, MainWindow.VSTs.VSTInfo[NumVST - 1]);
                        Bass.BASS_Free();
                        if (Success)
                        {
                            String Lab = String.Format(Languages.Parse("VSTNameAndVersion"), MainWindow.VSTs.VSTInfo[NumVST - 1].productName, MainWindow.VSTs.VSTInfo[NumVST - 1].vendorName, MainWindow.VSTs.VSTInfo[NumVST - 1].vendorVersion);
                            VSTDLL         = VSTImportDialog.FileName;
                            VSTDLLDesc     = Lab;
                            Desc.Text      = Lab;
                            Unload.Enabled = true;
                            Load.Enabled   = false;
                            SaveDirectory(VSTImportDialog.FileName);
                        }
                        else
                        {
                            MessageBox.Show(String.Format(Languages.Parse("InvalidVSTLoaded"), Path.GetFileNameWithoutExtension(VSTImportDialog.FileName), bitreq, bitnow), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        }
                    }
                    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, MainWindow.VSTs.VSTInfo[NumVST - 1]);
                        if (Success)
                        {
                            VSTDLL     = VSTImportDialog.FileName;
                            VSTDLLDesc = String.Format(Languages.Parse("VSTNameAndVersion"), MainWindow.VSTs.VSTInfo[NumVST - 1].productName, MainWindow.VSTs.VSTInfo[NumVST - 1].vendorName, MainWindow.VSTs.VSTInfo[NumVST - 1].vendorVersion);
                            Desc.Text  = String.Format(Languages.Parse("VSTNameAndVersion"), MainWindow.VSTs.VSTInfo[NumVST - 1].productName, MainWindow.VSTs.VSTInfo[NumVST - 1].vendorName, MainWindow.VSTs.VSTInfo[NumVST - 1].vendorVersion);
                            Bass.BASS_Free();
                            Unload.Enabled = true;
                            Load.Enabled   = false;
                            SaveDirectory(VSTImportDialog.FileName);
                        }
                        else
                        {
                            MessageBox.Show(String.Format(Languages.Parse("InvalidVSTLoaded"), 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(Languages.Parse("Error"), ex.ToString(), 0, 1);
                errordialog.ShowDialog();
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Load Effects Settings
        /// </summary>
        public override void LoadSettings()
        {
            _initialMusicDirectory = Settings.Instance.MusicDirectory;

            // BASS DSP/FX
            foreach (BassEffect basseffect in Settings.Instance.BassEffects)
            {
                foreach (BassEffectParm parameter in basseffect.Parameter)
                {
                    setBassDSP(basseffect.EffectName, parameter.Name, parameter.Value);
                }
            }

            DirectoryInfo di = new DirectoryInfo(pluginPath);

            FileInfo[] fi = di.GetFiles("*.dll", SearchOption.AllDirectories);
            foreach (FileInfo vstplugin in fi)
            {
                try
                {
                    BASS_VST_INFO vstInfo = new BASS_VST_INFO();
                    _vstHandle = BassVst.BASS_VST_ChannelSetDSP(0, vstplugin.FullName, BASSVSTDsp.BASS_VST_DEFAULT, 1);
                    // When Handle > 0 this Vst Plugin is a DSP Plugin
                    if (_vstHandle > 0)
                    {
                        DSPPluginInfo pluginInfo = new DSPPluginInfo(DSPPluginInfo.PluginType.VST, vstplugin.FullName,
                                                                     vstplugin.Name);
                        if (pluginInfo.IsBlackListed)
                        {
                            Log.Info("DSP Plugin {0} may not be used, as it is known for causing problems.", vstplugin.Name);
                        }
                        else
                        {
                            listBoxFoundPlugins.Items.Add(pluginInfo);
                        }
                    }
                    BassVst.BASS_VST_ChannelRemoveDSP(0, _vstHandle);
                }
                catch (Exception ex)
                {
                    Log.Error("Error reading VST Plugin Information: {0}", ex.Message);
                }
            }

            // VST Plugins
            foreach (VSTPlugin plugins in Settings.Instance.VSTPlugins)
            {
                // Get the vst handle and enable it
                string plugin = String.Format(@"{0}\{1}", pluginPath, plugins.PluginDll);
                _vstHandle = BassVst.BASS_VST_ChannelSetDSP(0, plugin, BASSVSTDsp.BASS_VST_DEFAULT, 1);
                if (_vstHandle > 0)
                {
                    DSPPluginInfo pluginInfo = new DSPPluginInfo(DSPPluginInfo.PluginType.VST, plugin, plugins.PluginDll);
                    listBoxSelectedPlugins.Items.Add(pluginInfo);
                    _vstHandles[plugins.PluginDll] = _vstHandle;
                    // Set all parameters for the plugin
                    foreach (VSTPluginParm paramter in plugins.Parameter)
                    {
                        NumberFormatInfo format = new NumberFormatInfo();
                        format.NumberDecimalSeparator = ".";
                        try
                        {
                            BassVst.BASS_VST_SetParam(_vstHandle, paramter.Index, float.Parse(paramter.Value));
                        }
                        catch (Exception) {}
                    }
                }
                else
                {
                    Log.Debug("Couldn't load VST Plugin {0}. Error code: {1}", plugin, Bass.BASS_ErrorGetCode());
                }
            }
            // Now remove those already selected from the found listbox
            foreach (VSTPlugin plugins in Settings.Instance.VSTPlugins)
            {
                for (int i = 0; i < listBoxFoundPlugins.Items.Count; i++)
                {
                    DSPPluginInfo dsp = (DSPPluginInfo)listBoxFoundPlugins.Items[i];
                    if (dsp.DSPPluginType == DSPPluginInfo.PluginType.VST && dsp.Name == plugins.PluginDll)
                    {
                        listBoxFoundPlugins.Items.RemoveAt(i);
                    }
                }
            }

            // WinAmp Plugins

            // Get the available plugins in the directory and fill the found listbox
            WINAMP_DSP.FindPlugins(pluginPath);
            foreach (WINAMP_DSP winampPlugin in WINAMP_DSP.PlugIns)
            {
                DSPPluginInfo pluginInfo = new DSPPluginInfo(DSPPluginInfo.PluginType.Winamp, winampPlugin.File,
                                                             winampPlugin.Description);
                if (pluginInfo.IsBlackListed)
                {
                    Log.Info("DSP Plugin {0} may not be used, as it is known for causing problems.", pluginInfo.FilePath);
                }
                else
                {
                    listBoxFoundPlugins.Items.Add(pluginInfo);
                }
            }
            // Now remove those already selected from the found listbox
            foreach (WinAmpPlugin plugins in Settings.Instance.WinAmpPlugins)
            {
                for (int i = 0; i < listBoxFoundPlugins.Items.Count; i++)
                {
                    DSPPluginInfo dsp = (DSPPluginInfo)listBoxFoundPlugins.Items[i];
                    if (dsp.DSPPluginType == DSPPluginInfo.PluginType.Winamp && dsp.FilePath == plugins.PluginDll)
                    {
                        listBoxFoundPlugins.Items.RemoveAt(i);
                        _waDspPlugin = BassWaDsp.BASS_WADSP_Load(plugins.PluginDll, 5, 5, 100, 100, null);
                        if (_waDspPlugin > 0)
                        {
                            listBoxSelectedPlugins.Items.Add(dsp);
                            _waDspPlugins[plugins.PluginDll] = _waDspPlugin;
                            break;
                        }
                        else
                        {
                            Log.Debug("Couldn't load WinAmp Plugin {0}. Error code: {1}", plugins.PluginDll, Bass.BASS_ErrorGetCode());
                        }
                    }
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Play the selected Music File
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btPlay_Click(object sender, EventArgs e)
        {
            if (File.Exists(textBoxMusicFile.Text))
            {
                // Init BASS
                BassAudioEngine bassEngine = BassMusicPlayer.Player;
                if (bassEngine.BassFreed)
                {
                    bassEngine.InitBass();
                }

                _stream = Bass.BASS_StreamCreateFile(textBoxMusicFile.Text, 0, 0,
                                                     BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_AUTOFREE |
                                                     BASSFlag.BASS_SAMPLE_SOFTWARE);
                if (_stream != 0)
                {
                    // Attach the BASS DSP Effects to the stream
                    if (_gain != null)
                    {
                        _gain.ChannelHandle = _stream;
                        _gain.Start();
                    }

                    if (checkBoxDAmp.Checked)
                    {
                        _dampHandle = Bass.BASS_ChannelSetFX(_stream, BASSFXType.BASS_FX_BFX_DAMP, _dampPrio);
                        Bass.BASS_FXSetParameters(_dampHandle, _damp);
                    }

                    if (checkBoxCompressor.Checked)
                    {
                        _compHandle = Bass.BASS_ChannelSetFX(_stream, BASSFXType.BASS_FX_BFX_COMPRESSOR, _compPrio);
                        Bass.BASS_FXSetParameters(_compHandle, _comp);
                    }

                    // Attach the plugins to the stream
                    foreach (DSPPluginInfo dsp in listBoxSelectedPlugins.Items)
                    {
                        if (dsp.DSPPluginType == DSPPluginInfo.PluginType.VST)
                        {
                            _vstHandle = BassVst.BASS_VST_ChannelSetDSP(_stream, dsp.FilePath, BASSVSTDsp.BASS_VST_DEFAULT, 1);
                            // Copy the parameters of the old handle
                            int vstold = _vstHandles[dsp.Name];
                            BassVst.BASS_VST_SetParamCopyParams(vstold, _vstHandle);
                            // Now find out to which stream the old handle was assigned and free it
                            BASS_VST_INFO bassvstinfo = new BASS_VST_INFO();
                            BassVst.BASS_VST_GetInfo(vstold, bassvstinfo);
                            BassVst.BASS_VST_ChannelRemoveDSP(bassvstinfo.channelHandle, vstold);
                            _vstHandles[dsp.Name] = _vstHandle;
                        }
                        else
                        {
                            _waDspPlugin = _waDspPlugins[dsp.FilePath];
                            BassWaDsp.BASS_WADSP_Start(_waDspPlugin, 0, 0);
                            BassWaDsp.BASS_WADSP_ChannelSetDSP(_waDspPlugin, _stream, 1);
                        }
                    }
                    btPlay.Enabled = false;
                    btStop.Enabled = true;
                    Bass.BASS_ChannelPlay(_stream, false);
                }
                else
                {
                    MessageBox.Show("Can't play file. Probably not a valid music file");
                }
            }
            else
            {
                MessageBox.Show("File specified does not exist");
            }
        }