Example #1
0
        /// <summary>
        /// Add the selected VST plugin(s) to the Selected Plugin Listbox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonPluginAdd_Click(object sender, EventArgs e)
        {
            DSPPluginInfo pluginInfo = (DSPPluginInfo)listBoxFoundPlugins.SelectedItem;

            if (pluginInfo == null)
            {
                return;
            }

            if (pluginInfo.DSPPluginType == DSPPluginInfo.PluginType.VST)
            {
                // Get the VST handle and enable it
                _vstHandle = BassVst.BASS_VST_ChannelSetDSP(0, pluginInfo.FilePath, BASSVSTDsp.BASS_VST_DEFAULT, 1);
                if (_vstHandle > 0)
                {
                    _vstHandles[pluginInfo.Name] = _vstHandle;
                    listBoxSelectedPlugins.Items.Add(listBoxFoundPlugins.SelectedItem);
                    listBoxFoundPlugins.Items.RemoveAt(listBoxFoundPlugins.SelectedIndex);
                }
                else
                {
                    MessageBox.Show("Error loading VST Plugin. Probably not valid", "VST Plugin", MessageBoxButtons.OK);
                    Log.Debug("Couldn't load VST Plugin {0}. Error code: {1}", pluginInfo.Name, Bass.BASS_ErrorGetCode());
                }
            }
            else
            {
                // Get the winamp handle and enable it
                _waDspPlugin = BassWaDsp.BASS_WADSP_Load(pluginInfo.FilePath, 5, 5, 100, 100, null);
                if (_waDspPlugin > 0)
                {
                    _waDspPlugins[pluginInfo.FilePath] = _waDspPlugin;
                    listBoxSelectedPlugins.Items.Add(listBoxFoundPlugins.SelectedItem);
                    listBoxFoundPlugins.Items.RemoveAt(listBoxFoundPlugins.SelectedIndex);
                }
                else
                {
                    MessageBox.Show("Error loading WinAmp Plugin. Probably not valid", "WinAmp Plugin", MessageBoxButtons.OK);
                    Log.Debug("Couldn't load WinAmp Plugin {0}. Error code: {1}", pluginInfo.FilePath, Bass.BASS_ErrorGetCode());
                }
            }
        }
Example #2
0
        /// <summary>
        /// Open VST Plugin Configuration window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ShowConfigWindow()
        {
            DSPPluginInfo pluginInfo = (DSPPluginInfo)listBoxSelectedPlugins.SelectedItem;

            if (pluginInfo == null)
            {
                return;
            }

            if (pluginInfo.DSPPluginType == DSPPluginInfo.PluginType.VST)
            {
                _vstHandle = _vstHandles[pluginInfo.Name];
                BASS_VST_INFO vstInfo = new BASS_VST_INFO();
                if (BassVst.BASS_VST_GetInfo(_vstHandle, vstInfo) && vstInfo.hasEditor)
                {
                    // Set a handle to the callback procedure
                    _vstProc = new VSTPROC(vstEditorCallBack);
                    BassVst.BASS_VST_SetCallback(_vstHandle, _vstProc, IntPtr.Zero);
                    // create a new System.Windows.Forms.Form
                    Form f = new MPConfigForm();
                    f.Width    = vstInfo.editorWidth + 4;
                    f.Height   = vstInfo.editorHeight + 34;
                    f.Closing += new CancelEventHandler(f_Closing);
                    f.Text     = vstInfo.effectName;
                    BassVst.BASS_VST_EmbedEditor(_vstHandle, f.Handle);
                    f.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Plugin has no Configuration");
                }
            }
            else
            {
                _waDspPlugin = _waDspPlugins[pluginInfo.FilePath];
                BassWaDsp.BASS_WADSP_Start(_waDspPlugin, 0, 0);
                BassWaDsp.BASS_WADSP_Config(_waDspPlugin);
            }
        }
Example #3
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);
        }
Example #4
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());
                        }
                    }
                }
            }
        }