Пример #1
0
        private void AddDSP()
        {
            if (this.FChannel != null)
            {
                double dpriority;
                this.FPinInPriority.GetValue(0, out dpriority);

                double denabled;
                this.FPinInEnabled.GetValue(0, out denabled);

                if (this.FChannel.BassHandle.HasValue && denabled >= 0.5)
                {
                    this.FDSPHandle = BassWaDsp.BASS_WADSP_Load(this.FFilename, 5, 5, 100, 100, null);

                    string dspDesc    = BassWaDsp.BASS_WADSP_GetName(this.FDSPHandle);
                    string moduleName = BassWaDsp.BASS_WADSP_GetModuleName(this.FDSPHandle, 0);

                    BassWaDsp.BASS_WADSP_Start(this.FDSPHandle, 0, this.FChannel.BassHandle.Value);

                    BassWaDsp.BASS_WADSP_ChannelSetDSP(this.FDSPHandle, this.FChannel.BassHandle.Value, Convert.ToInt32(dpriority));

                    this.FPinOutFxHandle.SliceCount = 1;
                    this.FPinOutFxHandle.SetValue(0, this.FDSPHandle);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// 加载DSP插件
 /// </summary>
 /// <returns></returns>
 public void LoadDSP()
 {
     dspHandle = BassWaDsp.BASS_WADSP_Load(fileName, 5, 5, 100, 100, null);
     if (dspHandle != 0)
     {
         isLoaded = true;
     }
 }
Пример #3
0
        /// <summary>
        ///     Loads a WinAmp DSP plug-in and applies it to the mixer
        /// </summary>
        /// <param name="location">The file location of the WinAmp DSP DLL</param>
        public WaPlugin LoadWaPlugin(string location)
        {
            if (location == "")
            {
                return(null);
            }

            if (WaPlugin != null && WaPlugin.Location == location)
            {
                return(WaPlugin);
            }

            if (!File.Exists(location))
            {
                return(null);
            }

            BassMix.BASS_Mixer_ChannelPause(ChannelId);

            if (!_waDspLoaded)
            {
                StartWaDspEngine();
            }

            // DebugHelper.WriteLine("Load WAPlugin " + location);
            var id = BassWaDsp.BASS_WADSP_Load(location, 10, 10, 300, 300, null);

            Thread.Sleep(20);

            var plugin = new WaPlugin
            {
                Id     = id,
                Module = 0
            };

            plugin.Name = BassWaDsp.BASS_WADSP_GetName(plugin.Id);
            Thread.Sleep(20);
            plugin.Location = location;

            BassWaDsp.BASS_WADSP_Start(plugin.Id, plugin.Module, ChannelId);
            Thread.Sleep(20);

            BassWaDsp.BASS_WADSP_ChannelSetDSP(plugin.Id, ChannelId, 1);
            Thread.Sleep(20);

            WaPlugin = plugin;

            BassMix.BASS_Mixer_ChannelPlay(ChannelId);
            Thread.Sleep(20);

            return(plugin);
        }
Пример #4
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());
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Attach the various DSP Plugins and effects to the stream
        /// </summary>
        private void AttachDspToStream()
        {
            bool dspActive = Config.DSPActive;

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

            // Attach active DSP effects to the Stream
            if (dspActive)
            {
                // BASS effects
                if (_gain != null)
                {
                    Log.Debug("BASS: Enabling Gain Effect.");
                    _gain.ChannelHandle = _stream;
                    _gain.Start();
                }
                if (_damp != null)
                {
                    Log.Debug("BASS: Enabling Dynamic Amplifier Effect.");
                    int dampHandle = Bass.BASS_ChannelSetFX(_stream, BASSFXType.BASS_FX_BFX_DAMP, _dampPrio);
                    Bass.BASS_FXSetParameters(dampHandle, _damp);
                }
                if (_comp != null)
                {
                    Log.Debug("BASS: Enabling Compressor Effect.");
                    int compHandle = Bass.BASS_ChannelSetFX(_stream, BASSFXType.BASS_FX_BFX_COMPRESSOR, _compPrio);
                    Bass.BASS_FXSetParameters(compHandle, _comp);
                }

                // VST Plugins
                foreach (string plugin in Config.VstPlugins)
                {
                    Log.Debug("BASS: Enabling VST Plugin: {0}", plugin);
                    int vstHandle = BassVst.BASS_VST_ChannelSetDSP(_stream, plugin, BASSVSTDsp.BASS_VST_DEFAULT, 1);
                    // Copy the parameters of the plugin as loaded on from the settings
                    int vstParm = Config.VstHandles[plugin];
                    BassVst.BASS_VST_SetParamCopyParams(vstParm, vstHandle);
                }

                // Init Winamp DSP only if we got a winamp plugin actiavtes
                int waDspPluginHandle = 0;
                if (Player.DSP.Settings.Instance.WinAmpPlugins.Count > 0)
                {
                    foreach (WinAmpPlugin plugins in Player.DSP.Settings.Instance.WinAmpPlugins)
                    {
                        Log.Debug("BASS: Enabling Winamp DSP Plugin: {0}", plugins.PluginDll);
                        waDspPluginHandle = BassWaDsp.BASS_WADSP_Load(plugins.PluginDll, 5, 5, 100, 100, null);
                        if (waDspPluginHandle > 0)
                        {
                            _waDspPlugins[plugins.PluginDll] = waDspPluginHandle;
                            BassWaDsp.BASS_WADSP_Start(waDspPluginHandle, 0, 0);
                        }
                        else
                        {
                            Log.Debug("Couldn't load WinAmp Plugin {0}. Error code: {1}", plugins.PluginDll,
                                      Enum.GetName(typeof(BASSError), Bass.BASS_ErrorGetCode()));
                        }
                    }
                }

                foreach (int waPluginHandle in _waDspPlugins.Values)
                {
                    BassWaDsp.BASS_WADSP_ChannelSetDSP(waPluginHandle, _stream, 1);
                }
            }
        }
Пример #6
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());
                        }
                    }
                }
            }
        }