Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 2
0
        /// <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);
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
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);
                }
            }
        }
Ejemplo n.º 5
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");
            }
        }