コード例 #1
0
ファイル: DSP.cs プロジェクト: CharlosNels/ArzonePlayer
 /// <summary>
 /// 设置DSP插件,显示DSP插件界面
 /// </summary>
 public void ConfigDSP()
 {
     if (dspHandle >= 0 && dspModule >= 0)
     {
         BassWaDsp.BASS_WADSP_Config(dspHandle);
     }
 }
コード例 #2
0
ファイル: MusicStream.cs プロジェクト: thomasr3/MediaPortal-1
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;

            Log.Debug("BASS: Disposing Music Stream {0}", _filePath);
            Bass.BASS_StreamFree(_stream);

            // Free Winamp resources)
            try
            {
                // Some Winamp dsps might raise an exception when closing
                foreach (int waDspPlugin in _waDspPlugins.Values)
                {
                    BassWaDsp.BASS_WADSP_Stop(waDspPlugin);
                }
            }
            catch (Exception) { }

            if (MusicStreamMessage != null)
            {
                MusicStreamMessage(this, StreamAction.Disposed);
            }
        }
コード例 #3
0
        public void Dispose()
        {
            if (_disposedMusicStream)
            {
                return;
            }

            lock (this)
            {
                _disposedMusicStream = true;

                Log.Debug("BASS: Disposing Music Stream {0}", _filePath);

                // Free Winamp resources)
                try
                {
                    // Some Winamp dsps might raise an exception when closing
                    foreach (int waDspPlugin in _waDspPlugins.Values)
                    {
                        BassWaDsp.BASS_WADSP_Stop(waDspPlugin);
                    }
                }
                catch (Exception) { }
            }
        }
コード例 #4
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);
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Stop Playing the active Music File
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btStop_Click(object sender, EventArgs e)
        {
            btPlay.Enabled = true;
            btStop.Enabled = false;
            // Stop the DSP Gain
            if (_gain != null)
            {
                _gain.Stop();
            }

            foreach (DSPPluginInfo dsp in listBoxSelectedPlugins.Items)
            {
                // Save the VST plugin parameters before freeing the stream
                if (dsp.DSPPluginType == DSPPluginInfo.PluginType.VST)
                {
                    _vstHandle = BassVst.BASS_VST_ChannelSetDSP(0, 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);
                    _vstHandles[dsp.Name] = _vstHandle;
                }
                else
                {
                    // Stop the WinAmp DSP
                    _waDspPlugin = _waDspPlugins[dsp.FilePath];
                    BassWaDsp.BASS_WADSP_Stop(_waDspPlugin);
                }
            }
            Bass.BASS_ChannelStop(_stream);
        }
コード例 #6
0
ファイル: DSP.cs プロジェクト: CharlosNels/ArzonePlayer
 /// <summary>
 /// 对于某些DSP插件需要歌曲文件名,需要此方法设置来文件名
 /// </summary>
 /// <param name="fileName">歌曲文件名</param>
 public void SetMusicFileName(string fileName)
 {
     if (!string.IsNullOrEmpty(fileName))
     {
         BassWaDsp.BASS_WADSP_SetFileName(dspHandle, fileName);
     }
 }
コード例 #7
0
ファイル: DSP.cs プロジェクト: CharlosNels/ArzonePlayer
 /// <summary>
 /// 对于某些DSP插件需要歌曲名,需要此方法来设置歌曲名
 /// </summary>
 /// <param name="title">歌曲名</param>
 public void SetMusicTitle(string title)
 {
     if (!string.IsNullOrEmpty(title))
     {
         BassWaDsp.BASS_WADSP_SetSongTitle(dspHandle, title);
     }
 }
コード例 #8
0
 /// <summary>
 ///     Initialises the WinAmp DSP engine
 /// </summary>
 private static void StartWaDspEngine()
 {
     // DebugHelper.WriteLine("StartWADSPEngine");
     BassWaDsp.BASS_WADSP_Init(IntPtr.Zero);
     Thread.Sleep(20);
     _waDspLoaded = true;
 }
コード例 #9
0
        public void ClearWaPlugin()
        {
            if (WaPlugin == null)
            {
                return;
            }

            // DebugHelper.WriteLine("Unload plug-in" + WaPlugin.Name);
            try
            {
                BassWaDsp.BASS_WADSP_Stop(WaPlugin.Id);
                Thread.Sleep(20);

                BassWaDsp.BASS_WADSP_ChannelRemoveDSP(WaPlugin.Id);
                Thread.Sleep(20);

                BassWaDsp.BASS_WADSP_FreeDSP(WaPlugin.Id);
                Thread.Sleep(20);
            }
            catch
            {
                // ignored
            }

            WaPlugin = null;
        }
コード例 #10
0
ファイル: DSP.cs プロジェクト: CharlosNels/ArzonePlayer
 /// <summary>
 /// 释放DSP插件
 /// </summary>
 public void FreeDSP()
 {
     StopDSP();
     if (BassWaDsp.BASS_WADSP_FreeDSP(dspHandle))
     {
         isLoaded = false;
     }
 }
コード例 #11
0
        public MusicDSP(string name)
            : base(name)
        {
            InitializeComponent();

            // Init DSP specific vars
            BassWaDsp.BASS_WADSP_Init(this.Handle);
        }
コード例 #12
0
ファイル: DSP.cs プロジェクト: CharlosNels/ArzonePlayer
 /// <summary>
 /// 加载DSP插件
 /// </summary>
 /// <returns></returns>
 public void LoadDSP()
 {
     dspHandle = BassWaDsp.BASS_WADSP_Load(fileName, 5, 5, 100, 100, null);
     if (dspHandle != 0)
     {
         isLoaded = true;
     }
 }
コード例 #13
0
ファイル: DSP.cs プロジェクト: CharlosNels/ArzonePlayer
        /// <summary>
        /// 设置DSP信道
        /// </summary>
        /// <param name="stream">音频流句柄</param>
        public void SetDSPChannel(int stream)
        {
            this.stream = stream;

            if (Bass.BASS_ChannelIsActive(stream) == BASSActive.BASS_ACTIVE_PLAYING)
            {
                int hDsp = BassWaDsp.BASS_WADSP_ChannelSetDSP(dspHandle, stream, 1);
            }
        }
コード例 #14
0
        /// <summary>
        ///     Shows the WinAmp DSP plug-in configuration screen
        /// </summary>
        /// <param name="plugin">The WinAmp DSP plug-in.</param>
        public static void ShowWaPluginConfig(WaPlugin plugin)
        {
            if (plugin == null)
            {
                return;
            }

            BassWaDsp.BASS_WADSP_Config(plugin.Id);
        }
コード例 #15
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);
        }
コード例 #16
0
        public MusicDSP(string name)
            : base(name)
        {
            InitializeComponent();

            // Init DSP specific vars
            try
            {
                BassWaDsp.BASS_WADSP_Init(this.Handle);
            }
            catch
            {
                Log.Debug("Couldn't Init DSP specific vars");
            }
        }
コード例 #17
0
        private void ClearUp()
        {
            try
            {
                if (this.FChannel.BassHandle.HasValue && this.FDSPHandle != 0)
                {
                    BassWaDsp.BASS_WADSP_Stop(this.FDSPHandle);
                    Bass.BASS_ChannelRemoveDSP(this.FChannel.BassHandle.Value, this.FDSPHandle);
                    BassWaDsp.BASS_WADSP_FreeDSP(this.FDSPHandle);
                }
            }
            catch
            {
            }

            this.FDSPHandle = 0;
        }
コード例 #18
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }

            // Clean up BASS Resources
            try
            {
                // Some Winamp dsps might raise an exception when closing
                BassWaDsp.BASS_WADSP_Free();
            }
            catch {}
            Bass.BASS_Stop();
            Bass.BASS_Free();

            base.Dispose(disposing);
        }
コード例 #19
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());
                }
            }
        }
コード例 #20
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);
            }
        }
コード例 #21
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);
        }
コード例 #22
0
        public void Evaluate(int SpreadMax)
        {
            bool reset = false;

            #region Reset is handle or fconnected change
            if (FConnected != this.FPinInHandle.IsConnected)
            {
                if (this.FPinInHandle.IsConnected)
                {
                    reset = true;
                }
                else
                {
                    this.ClearUp();
                }
                this.FConnected = this.FPinInHandle.IsConnected;
            }
            #endregion

            #region Reset
            if (this.FPinInHandle.PinIsChanged || reset || this.FPinInEnabled.PinIsChanged || this.FPinInFilename.PinIsChanged)
            {
                this.ClearUp();

                if (this.FPinInHandle.IsConnected)
                {
                    if (this.FPinInFilename.SliceCount > 0)
                    {
                        this.FPinInFilename.GetString(0, out this.FFilename);

                        this.FFilename = this.FFilename == null ? "" : this.FFilename;

                        //Just Update the Handle
                        double dhandle;
                        this.FPinInHandle.GetValue(0, out dhandle);
                        int ihandle = Convert.ToInt32(Math.Round(dhandle));


                        if (File.Exists(this.FFilename) && this.FManager.Exists(ihandle))
                        {
                            this.FChannel         = this.FManager.GetChannel(ihandle);
                            this.FChannel.OnInit += new EventHandler(FChannel_OnInit);
                            if (this.FChannel.BassHandle.HasValue)
                            {
                                this.AddDSP();
                            }
                        }
                        else
                        {
                            this.FChannel   = null;
                            this.FDSPHandle = 0;
                        }
                    }
                }
            }
            #endregion


            double dshow;
            this.FPinInShowConfig.GetValue(0, out dshow);
            if (this.FDSPHandle != 0 && dshow >= 0.5)
            {
                BassWaDsp.BASS_WADSP_Config(this.FDSPHandle, 0);
            }
        }
コード例 #23
0
ファイル: DSP.cs プロジェクト: CharlosNels/ArzonePlayer
        /// <summary>
        /// 启动DSP插件
        /// </summary>
        public void StartDSP()
        {
            BassWaDsp.BASS_WADSP_Start(dspHandle, dspModule, 0);

            isActive = true;
        }
コード例 #24
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());
                        }
                    }
                }
            }
        }
コード例 #25
0
ファイル: DSP.cs プロジェクト: CharlosNels/ArzonePlayer
 /// <summary>
 /// 关闭DSP插件
 /// </summary>
 public void StopDSP()
 {
     BassWaDsp.BASS_WADSP_Stop(dspHandle);
     isActive = false;
 }
コード例 #26
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");
            }
        }
コード例 #27
0
ファイル: DSP.cs プロジェクト: CharlosNels/ArzonePlayer
 /// <summary>
 /// 初始化DSP支持模块
 /// </summary>
 /// <param name="FormIntPtr"></param>
 public static void InitDSP(IntPtr FormIntPtr)
 {
     BassWaDsp.BASS_WADSP_Init(FormIntPtr);
 }
コード例 #28
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);
                }
            }
        }
コード例 #29
0
ファイル: DSP.cs プロジェクト: CharlosNels/ArzonePlayer
 /// <summary>
 /// 释放DSP支持模块
 /// </summary>
 public static void Free()
 {
     BassWaDsp.BASS_WADSP_Free();
 }