示例#1
0
        public override bool SetOutputContext(OutputContextType outputType)
        {
            if (VisualizationWindow == null)
            {
                return(false);
            }

            if (_Initialized && !firstRun)
            {
                return(true);
            }

            // If width or height are 0 the call to BASS_SONIQUEVIS_CreateVis will fail.
            // If width or height are 1 the window is in transition so we can ignore it.
            if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1)
            {
                return(false);
            }

            if (VizPluginInfo == null || VizPluginInfo.FilePath.Length == 0 || !File.Exists(VizPluginInfo.FilePath))
            {
                return(false);
            }

            string vizPath    = VizPluginInfo.FilePath;
            string configFile = Path.Combine(Path.GetDirectoryName(vizPath), "vis.ini");

            if (_visParam.VisHandle != 0)
            {
                try
                {
                    BassVis.BASSVIS_Free(_visParam, ref _baseVisParam);
                }
                catch (AccessViolationException) {}

                _visParam.VisHandle = 0;
            }

            try
            {
                visExec = new BASSVIS_EXEC(vizPath);
                visExec.SON_ConfigFile  = configFile;
                visExec.SON_Flags       = BASSVISFlags.BASSVIS_DEFAULT;
                visExec.SON_PaintHandle = VisualizationWindow.CompatibleDC;
                visExec.Width           = VisualizationWindow.Width;
                visExec.Height          = VisualizationWindow.Height;
                visExec.Left            = VisualizationWindow.Left;
                visExec.Top             = VisualizationWindow.Top;
                BassVis.BASSVIS_ExecutePlugin(visExec, _visParam);
            }
            catch (Exception) {}
            firstRun = false;
            return(_visParam.VisHandle != 0);
        }
示例#2
0
    public override bool SetOutputContext(OutputContextType outputType)
    {
      if (VisualizationWindow == null)
      {
        return false;
      }

      if (_Initialized && !firstRun)
      {
        return true;
      }

      // If width or height are 0 the call to CreateVis will fail.  
      // If width or height are 1 the window is in transition so we can ignore it.
      if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1)
      {
        return false;
      }

      if (VizPluginInfo == null || VizPluginInfo.FilePath.Length == 0 || !File.Exists(VizPluginInfo.FilePath))
      {
        return false;
      }

      string vizPath = VizPluginInfo.FilePath;
      string configFile = Path.Combine(System.Windows.Forms.Application.StartupPath, @"musicplayer\plugins\visualizations\Sonique\vis.ini");     

      try
      {
        // Call Play befor use BASSVIS_ExecutePlugin (moved here)
        BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.Play);

        using (Profile.Settings xmlreader = new Profile.MPSettings())
        {
          VizPluginInfo.UseOpenGL = xmlreader.GetValueAsBool("musicvisualization", "useOpenGL", true);
          VizPluginInfo.UseCover = xmlreader.GetValueAsBool("musicvisualization", "useCover", true);
          VizPluginInfo.RenderTiming = xmlreader.GetValueAsInt("musicvisualization", "renderTiming", 25);
          VizPluginInfo.ViewPortSize = xmlreader.GetValueAsInt("musicvisualization", "viewPort", 0);
        }

        // Create the Visualisation
        visExec = new BASSVIS_EXEC(vizPath);
        visExec.SON_ConfigFile = configFile;
        visExec.SON_ParentHandle = VisualizationWindow.Handle;
        visExec.Width = VisualizationWindow.Width;
        visExec.Height = VisualizationWindow.Height;
        visExec.SON_UseOpenGL = VizPluginInfo.UseOpenGL;
        visExec.SON_ViewportWidth = VizPluginInfo.ViewPortSizeX;
        visExec.SON_ViewportHeight = VizPluginInfo.ViewPortSizeY;
        visExec.Left = VisualizationWindow.Left;
        visExec.Top = VisualizationWindow.Top;
        visExec.SON_ShowFPS = true;
        // can not check IsRadio on first start
        // so ProgressBar and Cover Visible state will hide after change to the next Plugin to
        if (Bass.IsRadio)
        {
          // no duration deactivate ProgressBar
          visExec.SON_ShowPrgBar = false;
          // Cover-Support used only on first start if VizPluginInfo.UseCover = true
          // after or change the plugin in FullScreen, Cover-Support will disable for RadioStreams
          visExec.SON_UseCover = false; 
        }
        else
        {
          visExec.SON_ShowPrgBar = true;
          visExec.SON_UseCover = VizPluginInfo.UseCover; 
        }

        BassVis.BASSVIS_ExecutePlugin(visExec, _visParam);

        if (_visParam.VisHandle != 0)
        {
          // Config Settings
          BassVis.BASSVIS_SetOption(_visParam, BASSVIS_CONFIGFLAGS.BASSVIS_SONIQUEVIS_CONFIG_RENDERTIMING, VizPluginInfo.RenderTiming);
          BassVis.BASSVIS_SetOption(_visParam, BASSVIS_CONFIGFLAGS.BASSVIS_SONIQUEVIS_CONFIG_USESLOWFADE, 1);
          BassVis.BASSVIS_SetOption(_visParam, BASSVIS_CONFIGFLAGS.BASSVIS_SONIQUEVIS_CONFIG_SLOWFADE, 5);
          BassVis.BASSVIS_SetOption(_visParam, BASSVIS_CONFIGFLAGS.BASSVIS_CONFIG_FFTAMP, 5);
          
          // SetForegroundWindow
          GUIGraphicsContext.form.Activate();
        }
        firstRun = false;
      }
      catch (Exception ex)
      {
        Log.Error(
          "Visualization Manager: Sonique visualization engine initialization failed with the following exception {0}",
          ex);
      }
      _Initialized = _visParam.VisHandle != 0;
      return _visParam.VisHandle != 0;
    }
        /// <summary>
        /// Search the Visaulation Path for supported Vis
        /// </summary>
        /// <returns></returns>
        public List <VisualizationInfo> GetVisualizationPluginsInfo()
        {
            _VisualizationPluginsInfo.Clear();
            try
            {
                _VisualizationPluginsInfo.Add(new VisualizationInfo("None", true));

                // Close any Visualisation, which we may have running, because of VizManager Init
                CloseCurrentVisualization();

                string skinFolderPath = Path.Combine(Application.StartupPath, @"musicplayer\plugins\visualizations");

                // Search for Sonique and Winamp Plugins
                string[] soniqueVisPaths = BassVis.BASSVIS_FindPlugins(BASSVISKind.BASSVISKIND_SONIQUE, skinFolderPath, true);

                // Note: Recursive Searches for Winamp Plugins are not supported
                // Winamp plugins expect itself to be stored in a folder named Plugins in the root of the executable. This is where we will search
                // So this is the folder where all the MP Plugins are stored as well
                skinFolderPath = Path.Combine(Application.StartupPath, @"plugins");
                string[] winampVisPaths = BassVis.BASSVIS_FindPlugins(BASSVISKind.BASSVISKIND_WINAMP, skinFolderPath, true);

                List <VisualizationInfo> wmpPluginsInfo = GetWMPPluginInfo();

                if (IsGForceInstalled())
                {
                    VisualizationInfo vizInfo = new VisualizationInfo(VisualizationInfo.PluginType.GForce, string.Empty, "G-Force",
                                                                      string.Empty, null);
                    _VisualizationPluginsInfo.Add(vizInfo);
                }

                if (IsWhiteCapInstalled())
                {
                    VisualizationInfo vizInfo = new VisualizationInfo(VisualizationInfo.PluginType.WhiteCap, string.Empty,
                                                                      "WhiteCap", string.Empty, null);
                    _VisualizationPluginsInfo.Add(vizInfo);
                }

                if (IsSoftSkiesInstalled())
                {
                    VisualizationInfo vizInfo = new VisualizationInfo(VisualizationInfo.PluginType.SoftSkies, string.Empty,
                                                                      "SoftSkies", string.Empty, null);
                    _VisualizationPluginsInfo.Add(vizInfo);
                }

                if (wmpPluginsInfo != null)
                {
                    for (int i = 0; i < wmpPluginsInfo.Count; i++)
                    {
                        _VisualizationPluginsInfo.Add(wmpPluginsInfo[i]);
                    }
                }

                if (soniqueVisPaths != null && soniqueVisPaths[0] != "")
                {
                    BassVis.BASSVIS_Init(BASSVISKind.BASSVISKIND_SONIQUE, VizRenderWindow.Handle);
                    _visParam = new BASSVIS_PARAM(BASSVISKind.BASSVISKIND_SONIQUE);
                    for (int i = 0; i < soniqueVisPaths.Length; i++)
                    {
                        string       filePath = soniqueVisPaths[i];
                        string       name     = Path.GetFileNameWithoutExtension(filePath);
                        BASSVIS_EXEC visExec  = new BASSVIS_EXEC(filePath);
                        visExec.SON_Flags      = BASSVISFlags.BASSVIS_NOINIT; // don't execute the plugin yet
                        visExec.SON_ConfigFile = Path.Combine(Path.GetDirectoryName(filePath), "vis.ini");

                        if (_visParam.VisHandle != 0)
                        {
                            int counter = 0;

                            bool bFree = BassVis.BASSVIS_Free(_visParam);
                            while ((!bFree) && (counter <= 10))
                            {
                                bFree = BassVis.BASSVIS_IsFree(_visParam);
                                System.Windows.Forms.Application.DoEvents();
                                counter++;
                            }
                            _visParam.VisHandle = 0;
                        }

                        BassVis.BASSVIS_ExecutePlugin(visExec, _visParam);

                        string pluginname = BassVis.BASSVIS_GetPluginName(_visParam);
                        if (pluginname != null)
                        {
                            name = pluginname;
                        }

                        VisualizationInfo vizInfo = new VisualizationInfo(VisualizationInfo.PluginType.Sonique, filePath, name,
                                                                          string.Empty, null);
                        _VisualizationPluginsInfo.Add(vizInfo);
                    }
                    BassVis.BASSVIS_Quit(_visParam);
                }

                if (winampVisPaths != null && winampVisPaths[0] != "")
                {
                    _visParam = new BASSVIS_PARAM(BASSVISKind.BASSVISKIND_WINAMP);
                    for (int i = 0; i < winampVisPaths.Length; i++)
                    {
                        List <string> presets  = new List <string>();
                        string        filePath = winampVisPaths[i];
                        string        name     = Path.GetFileNameWithoutExtension(filePath);
                        _visParam.VisHandle = BassVis.BASSVIS_GetPluginHandle(BASSVISKind.BASSVISKIND_WINAMP, filePath);

                        string pluginname = BassVis.BASSVIS_GetPluginName(_visParam);
                        if (pluginname != null)
                        {
                            name = pluginname;
                        }

                        // Get modules
                        int numModules = BassVis.BASSVIS_GetModulePresetCount(_visParam, filePath);
                        if (numModules > 0)
                        {
                            if (numModules > 0)
                            {
                                for (int j = 0; j < numModules; j++)
                                {
                                    presets.Add(BassVis.BASSVIS_GetModulePresetName(_visParam, j, filePath));
                                }
                            }
                            VisualizationInfo vizInfo = new VisualizationInfo(VisualizationInfo.PluginType.Winamp, filePath, name,
                                                                              string.Empty, presets);
                            if (!vizInfo.IsBlackListed)
                            {
                                _VisualizationPluginsInfo.Add(vizInfo);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("VisualisationManager: Failed to get viz plugins - {0}", ex.ToString());
            }
            return(_VisualizationPluginsInfo);
        }
示例#4
0
    public override bool SetOutputContext(OutputContextType outputType)
    {
      if (VisualizationWindow == null)
      {
        return false;
      }

      if (_Initialized && !firstRun)
      {
        return true;
      }

      // If width or height are 0 the call to CreateVis will fail.  
      // If width or height are 1 the window is in transition so we can ignore it.
      if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1)
      {
        return false;
      }

      if (VizPluginInfo == null)
      {
        return false;
      }

      try
      {
        BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.Play);

        visExec = new BASSVIS_EXEC(BASSVISKind.BASSVISKIND_WMP.ToString());
        visExec.WMP_PluginIndex = VizPluginInfo.PlgIndex -1;
        visExec.WMP_PresetIndex = VizPluginInfo.PresetIndex;
        visExec.WMP_SrcVisHandle = VisualizationWindow.Handle;
        visExec.Left = 0;
        visExec.Top = 0;
        visExec.Width = VisualizationWindow.Width;
        visExec.Height = VisualizationWindow.Height;

        BassVis.BASSVIS_ExecutePlugin(visExec, _visParam);
        BassVis.BASSVIS_SetModulePreset(_visParam, VizPluginInfo.PresetIndex);
        BassVis.BASSVIS_SetOption(_visParam, BASSVIS_CONFIGFLAGS.BASSVIS_CONFIG_FFTAMP, 128);

        if (_visParam.VisHandle != 0)
        {
          // SetForegroundWindow
          GUIGraphicsContext.form.Activate();
        }
        firstRun = false;
      }
      catch (Exception ex)
      {
        Log.Error(
          "Visualization Manager: WMP visualization engine initialization failed with the following exception {0}",
          ex);
      }
      _Initialized = _visParam.VisHandle != 0;
      return _visParam.VisHandle != 0;
    }
示例#5
0
        public override bool SetOutputContext(OutputContextType outputType)
        {
            if (VisualizationWindow == null)
            {
                return(false);
            }

            if (_Initialized && !firstRun)
            {
                return(true);
            }

            // If width or height are 0 the call to CreateVis will fail.
            // If width or height are 1 the window is in transition so we can ignore it.
            if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1)
            {
                return(false);
            }

            if (VizPluginInfo == null || VizPluginInfo.FilePath.Length == 0 || !File.Exists(VizPluginInfo.FilePath))
            {
                return(false);
            }

            if (_visParam.VisHandle != 0)
            {
                RenderStarted = false;

                int counter = 0;

                bool bFree = BassVis.BASSVIS_Free(_visParam);
                while ((!bFree) && (counter <= 10))
                {
                    bFree = BassVis.BASSVIS_IsFree(_visParam);
                    System.Windows.Forms.Application.DoEvents();
                    counter++;
                }
                _visParam.VisHandle = 0;
            }


            try
            {
                //Remove existing CallBacks
                BassVis.BASSVIS_WINAMPRemoveCallback();
                // Create the Visualisation
                BASSVIS_EXEC visExec = new BASSVIS_EXEC(VizPluginInfo.FilePath);
                visExec.AMP_ModuleIndex = VizPluginInfo.PresetIndex;
                visExec.AMP_UseOwnW1    = 1;
                visExec.AMP_UseOwnW2    = 1;
                BassVis.BASSVIS_ExecutePlugin(visExec, _visParam);
                if (_visParam.VisHandle != 0)
                {
                    BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.Play);

                    // Set the visualization window that was taken over from BASSVIS_ExecutePlugin
                    BassVis.BASSVIS_SetVisPort(_visParam,
                                               _visParam.VisGenWinHandle,
                                               VisualizationWindow.Handle,
                                               0,
                                               0,
                                               VisualizationWindow.Width,
                                               VisualizationWindow.Height);

                    // Set CallBack for PlayState
                    _visCallback = BASSVIS_StateCallback;
                    BassVis.BASSVIS_WINAMPSetStateCallback(_visCallback);
                    BassVis.BASSVIS_SetOption(_visParam, BASSVIS_CONFIGFLAGS.BASSVIS_CONFIG_FFTAMP, 128);
                }

                // The Winamp Plugin has stolen focus on the MP window. Bring it back to froeground
                Win32API.SetForegroundWindow(GUIGraphicsContext.form.Handle);

                firstRun = false;
            }
            catch (Exception ex)
            {
                Log.Error(
                    "Visualization Manager: Winamp visualization engine initialization failed with the following exception {0}",
                    ex);
            }
            _Initialized = _visParam.VisHandle != 0;
            return(_visParam.VisHandle != 0);
        }
示例#6
0
    public override bool SetOutputContext(OutputContextType outputType)
    {
      if (VisualizationWindow == null)
      {
        return false;
      }

      if (_Initialized && !firstRun)
      {
        return true;
      }

      // If width or height are 0 the call to CreateVis will fail.  
      // If width or height are 1 the window is in transition so we can ignore it.
      if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1)
      {
        return false;
      }

      if (VizPluginInfo == null || VizPluginInfo.FilePath.Length == 0 || !File.Exists(VizPluginInfo.FilePath))
      {
        return false;
      }

      try
      {
        using (Profile.Settings xmlreader = new Profile.MPSettings())
        {
          VizPluginInfo.FFTSensitivity = xmlreader.GetValueAsInt("musicvisualization", "fftSensitivity", 36);
          VizPluginInfo.PresetIndex = xmlreader.GetValueAsInt("musicvisualization", "preset", 0);
        }

        //Remove existing CallBacks
        BassVis.BASSVIS_WINAMPRemoveCallback();

        // Call Play befor use BASSVIS_ExecutePlugin (moved here)
        BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.Play);

        // Set CallBack for PlayState
        _visCallback = BASSVIS_StateCallback;
        BassVis.BASSVIS_WINAMPSetStateCallback(_visCallback);

        // Hide the Viswindow, so that we don't see it, befor any Render
        Win32API.ShowWindow(VisualizationWindow.Handle, Win32API.ShowWindowFlags.Hide);

        // Create the Visualisation 
        BASSVIS_EXEC visExec = new BASSVIS_EXEC(VizPluginInfo.FilePath);
        visExec.AMP_ModuleIndex = VizPluginInfo.PresetIndex;
        visExec.AMP_UseOwnW1 = 1;
        visExec.AMP_UseOwnW2 = 1;
        // The flag below is needed for the Vis to have it's own message queue
        // Thus it is avoided that it steals focus from MP.
        visExec.AMP_UseFakeWindow = true; 
        
        BassVis.BASSVIS_ExecutePlugin(visExec, _visParam);
        
        if (_visParam.VisHandle != 0)
        {

          // Set the visualization window that was taken over from BASSVIS_ExecutePlugin
          BassVis.BASSVIS_SetVisPort(_visParam,
                                     _visParam.VisGenWinHandle,
                                     VisualizationWindow.Handle,
                                     0,
                                     0,
                                     VisualizationWindow.Width,
                                     VisualizationWindow.Height);

          BassVis.BASSVIS_SetOption(_visParam, BASSVIS_CONFIGFLAGS.BASSVIS_CONFIG_FFTAMP, VizPluginInfo.FFTSensitivity); 

          // SetForegroundWindow
          GUIGraphicsContext.form.Activate();
        }

        firstRun = false;
      }
      catch (Exception ex)
      {
        Log.Error(
          "Visualization Manager: Winamp visualization engine initialization failed with the following exception {0}",
          ex);
      }
      _Initialized = _visParam.VisHandle != 0;
      return _visParam.VisHandle != 0;
    }
示例#7
0
    public override bool SetOutputContext(OutputContextType outputType)
    {
      if (VisualizationWindow == null)
      {
        return false;
      }

      if (_Initialized && !firstRun)
      {
        return true;
      }

      // If width or height are 0 the call to CreateVis will fail.  
      // If width or height are 1 the window is in transition so we can ignore it.
      if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1)
      {
        return false;
      }

      if (VizPluginInfo == null || VizPluginInfo.FilePath.Length == 0 || !File.Exists(VizPluginInfo.FilePath))
      {
        return false;
      }

      if (_visParam.VisHandle != 0)
      {
        RenderStarted = false;

        int counter = 0;

        bool bFree = BassVis.BASSVIS_Free(_visParam);
        while ((!bFree) && (counter <= 10))
        {
          bFree = BassVis.BASSVIS_IsFree(_visParam);
          System.Windows.Forms.Application.DoEvents();
          counter++;
        }
        _visParam.VisHandle = 0;
      }


      try
      {
        //Remove existing CallBacks
        BassVis.BASSVIS_WINAMPRemoveCallback();
        // Create the Visualisation
        BASSVIS_EXEC visExec = new BASSVIS_EXEC(VizPluginInfo.FilePath);
        visExec.AMP_ModuleIndex = VizPluginInfo.PresetIndex;
        visExec.AMP_UseOwnW1 = 1;
        visExec.AMP_UseOwnW2 = 1;
        BassVis.BASSVIS_ExecutePlugin(visExec, _visParam);
        if (_visParam.VisHandle != 0)
        {
          BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.Play);

          // Set the visualization window that was taken over from BASSVIS_ExecutePlugin
          BassVis.BASSVIS_SetVisPort(_visParam,
                                     _visParam.VisGenWinHandle,
                                     VisualizationWindow.Handle,
                                     0,
                                     0,
                                     VisualizationWindow.Width,
                                     VisualizationWindow.Height);

          // Set CallBack for PlayState
          _visCallback = BASSVIS_StateCallback;
          BassVis.BASSVIS_WINAMPSetStateCallback(_visCallback);
          BassVis.BASSVIS_SetOption(_visParam, BASSVIS_CONFIGFLAGS.BASSVIS_CONFIG_FFTAMP, 128);
        }

        // The Winamp Plugin has stolen focus on the MP window. Bring it back to froeground
        Win32API.SetForegroundWindow(GUIGraphicsContext.form.Handle);

        firstRun = false;
      }
      catch (Exception ex)
      {
        Log.Error(
          "Visualization Manager: Winamp visualization engine initialization failed with the following exception {0}",
          ex);
      }
      _Initialized = _visParam.VisHandle != 0;
      return _visParam.VisHandle != 0;
    }
示例#8
0
    public override bool SetOutputContext(OutputContextType outputType)
    {
      if (VisualizationWindow == null)
      {
        return false;
      }

      if (_Initialized && !firstRun)
      {
        return true;
      }

      // If width or height are 0 the call to CreateVis will fail.  
      // If width or height are 1 the window is in transition so we can ignore it.
      if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1)
      {
        return false;
      }

      if (VizPluginInfo == null || VizPluginInfo.FilePath.Length == 0 || !File.Exists(VizPluginInfo.FilePath))
      {
        return false;
      }

      try
      {
        BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.Play);
        string vizPath = VizPluginInfo.FilePath;

        visExec = new BASSVIS_EXEC(vizPath);
        visExec.PluginFile = vizPath;
        visExec.BB_Flags = BASSVISFlags.BASSVIS_DEFAULT;
        visExec.BB_ParentHandle = VisualizationWindow.Handle;
        visExec.BB_ShowFPS = true;
        // can not check IsRadio on first start
        // so ProgressBar Visible State will hide after change to the next Plugin to
        if (Bass.IsRadio)
        {
          // no duration deactivate ProgressBar
          visExec.BB_ShowPrgBar = false;
        }
        else
        {
          visExec.BB_ShowPrgBar = true;
        }
        visExec.Left = 0;
        visExec.Top = 0;
        visExec.Width = VisualizationWindow.Width;
        visExec.Height = VisualizationWindow.Height;

        BassVis.BASSVIS_ExecutePlugin(visExec, _visParam);

        if (_visParam.VisHandle != 0)
        {
          // SetForegroundWindow
          GUIGraphicsContext.form.Activate();
        }
        firstRun = false;
      }
      catch (Exception ex)
      {
        Log.Error(
          "Visualization Manager: Bassbox visualization engine initialization failed with the following exception {0}",
          ex);
      }
      _Initialized = _visParam.VisHandle != 0;
      return _visParam.VisHandle != 0;
    }
示例#9
0
        public override bool SetOutputContext(OutputContextType outputType)
        {
            if (VisualizationWindow == null)
            {
                return(false);
            }

            if (_Initialized && !firstRun)
            {
                return(true);
            }

            // If width or height are 0 the call to CreateVis will fail.
            // If width or height are 1 the window is in transition so we can ignore it.
            if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1)
            {
                return(false);
            }

            if (VizPluginInfo == null || VizPluginInfo.FilePath.Length == 0 || !File.Exists(VizPluginInfo.FilePath))
            {
                return(false);
            }

            if (_visParam.VisHandle != 0)
            {
                BassVis.BASSVIS_Free(_visParam, ref _baseVisParam);
                _visParam.VisHandle = 0;
                RenderStarted       = false;
            }

            // Set Dummy Information for the plugin, before creating it
            _mediaInfo.SongTitle   = "";
            _mediaInfo.SongFile    = "";
            _mediaInfo.Position    = 0;
            _mediaInfo.Duration    = 0;
            _mediaInfo.PlaylistPos = 0;
            _mediaInfo.PlaylistLen = 0;
            BassVis.BASSVIS_SetInfo(_visParam, _mediaInfo);

            try
            {
                // Create the Visualisation
                BASSVIS_EXEC visExec = new BASSVIS_EXEC(VizPluginInfo.FilePath);
                visExec.AMP_ModuleIndex = VizPluginInfo.PresetIndex;
                visExec.AMP_UseOwnW1    = 1;
                visExec.AMP_UseOwnW2    = 1;
                BassVis.BASSVIS_ExecutePlugin(visExec, _visParam);
                if (_visParam.VisGenWinHandle != IntPtr.Zero)
                {
                    hwndChild = Win32API.GetWindow(VisualizationWindow.Handle, Win32API.ShowWindowFlags.Show);
                    if (hwndChild != IntPtr.Zero)
                    {
                        Win32API.MoveWindow(hwndChild, 0, 0, VisualizationWindow.Width, VisualizationWindow.Height, true);
                    }

                    BassVis.BASSVIS_SetVisPort(_visParam,
                                               _visParam.VisGenWinHandle,
                                               VisualizationWindow.Handle,
                                               0,
                                               0,
                                               VisualizationWindow.Width,
                                               VisualizationWindow.Height);

                    BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.Play);
                }
                else
                {
                    BassVis.BASSVIS_SetVisPort(_visParam,
                                               _visParam.VisGenWinHandle,
                                               IntPtr.Zero,
                                               0,
                                               0,
                                               0,
                                               0);
                }

                // The Winamp Plugin has stolen focus on the MP window. Bring it back to froeground
                Win32API.SetForegroundWindow(GUIGraphicsContext.form.Handle);

                firstRun = false;
            }
            catch (Exception ex)
            {
                Log.Error(
                    "Visualization Manager: Winamp visualization engine initialization failed with the following exception {0}",
                    ex);
            }
            _Initialized = _visParam.VisHandle != 0;
            return(_visParam.VisHandle != 0);
        }
    /// <summary>
    /// Search the Visaulation Path for supported Vis
    /// </summary>
    /// <returns></returns>
    public List<VisualizationInfo> GetVisualizationPluginsInfo()
    {

      _VisualizationPluginsInfo.Clear();
      try
      {
        _VisualizationPluginsInfo.Add(new VisualizationInfo("None", true));

        // Close any Visualisation, which we may have running, because of VizManager Init
        CloseCurrentVisualization();

        string skinFolderPath = Path.Combine(Application.StartupPath, @"musicplayer\plugins\visualizations");

        // Search for Sonique and Winamp Plugins
        string[] soniqueVisPaths = BassVis.BASSVIS_FindPlugins(BASSVISKind.BASSVISKIND_SONIQUE, skinFolderPath, true);

        // Note: Recursive Searches for Winamp Plugins are not supported
        // Winamp plugins expect itself to be stored in a folder named Plugins in the root of the executable. This is where we will search
        // So this is the folder where all the MP Plugins are stored as well
        skinFolderPath = Path.Combine(Application.StartupPath, @"plugins");
        string[] winampVisPaths = BassVis.BASSVIS_FindPlugins(BASSVISKind.BASSVISKIND_WINAMP, skinFolderPath, true);

        List<VisualizationInfo> wmpPluginsInfo = GetWMPPluginInfo();

        if (IsGForceInstalled())
        {
          VisualizationInfo vizInfo = new VisualizationInfo(VisualizationInfo.PluginType.GForce, string.Empty, "G-Force",
                                                            string.Empty, null);
          _VisualizationPluginsInfo.Add(vizInfo);
        }

        if (IsWhiteCapInstalled())
        {
          VisualizationInfo vizInfo = new VisualizationInfo(VisualizationInfo.PluginType.WhiteCap, string.Empty,
                                                            "WhiteCap", string.Empty, null);
          _VisualizationPluginsInfo.Add(vizInfo);
        }

        if (IsSoftSkiesInstalled())
        {
          VisualizationInfo vizInfo = new VisualizationInfo(VisualizationInfo.PluginType.SoftSkies, string.Empty,
                                                            "SoftSkies", string.Empty, null);
          _VisualizationPluginsInfo.Add(vizInfo);
        }

        if (wmpPluginsInfo != null)
        {
          for (int i = 0; i < wmpPluginsInfo.Count; i++)
          {
            _VisualizationPluginsInfo.Add(wmpPluginsInfo[i]);
          }
        }

        if (soniqueVisPaths != null && soniqueVisPaths[0] != "")
        {
          BassVis.BASSVIS_Init(BASSVISKind.BASSVISKIND_SONIQUE, VizRenderWindow.Handle);
          _visParam = new BASSVIS_PARAM(BASSVISKind.BASSVISKIND_SONIQUE);
          for (int i = 0; i < soniqueVisPaths.Length; i++)
          {
            string filePath = soniqueVisPaths[i];
            string name = Path.GetFileNameWithoutExtension(filePath);
            BASSVIS_EXEC visExec = new BASSVIS_EXEC(filePath);
            visExec.SON_Flags = BASSVISFlags.BASSVIS_NOINIT; // don't execute the plugin yet
            visExec.SON_ConfigFile = Path.Combine(Path.GetDirectoryName(filePath), "vis.ini");

            if (_visParam.VisHandle != 0)
            {
              int counter = 0;

              bool bFree = BassVis.BASSVIS_Free(_visParam);
              while ((!bFree) && (counter <= 10))
              {
                bFree = BassVis.BASSVIS_IsFree(_visParam);
                System.Windows.Forms.Application.DoEvents();
                counter++;
              }
              _visParam.VisHandle = 0;
            }

            BassVis.BASSVIS_ExecutePlugin(visExec, _visParam);

            string pluginname = BassVis.BASSVIS_GetPluginName(_visParam);
            if (pluginname != null)
            {
              name = pluginname;
            }

            VisualizationInfo vizInfo = new VisualizationInfo(VisualizationInfo.PluginType.Sonique, filePath, name,
                                                              string.Empty, null);
            _VisualizationPluginsInfo.Add(vizInfo);
          }
          BassVis.BASSVIS_Quit(_visParam);
        }

        if (winampVisPaths != null && winampVisPaths[0] != "")
        {
          _visParam = new BASSVIS_PARAM(BASSVISKind.BASSVISKIND_WINAMP);
          for (int i = 0; i < winampVisPaths.Length; i++)
          {
            List<string> presets = new List<string>();
            string filePath = winampVisPaths[i];
            string name = Path.GetFileNameWithoutExtension(filePath);
            _visParam.VisHandle = BassVis.BASSVIS_GetPluginHandle(BASSVISKind.BASSVISKIND_WINAMP, filePath);

            string pluginname = BassVis.BASSVIS_GetPluginName(_visParam);
            if (pluginname != null)
              name = pluginname;

            // Get modules
            int numModules = BassVis.BASSVIS_GetModulePresetCount(_visParam, filePath);
            if (numModules > 0)
            {
              if (numModules > 0)
              {
                for (int j = 0; j < numModules; j++)
                {
                  presets.Add(BassVis.BASSVIS_GetModulePresetName(_visParam, j, filePath));
                }
              }
              VisualizationInfo vizInfo = new VisualizationInfo(VisualizationInfo.PluginType.Winamp, filePath, name,
                                                                string.Empty, presets);
              if (!vizInfo.IsBlackListed)
              {
                _VisualizationPluginsInfo.Add(vizInfo);
              }
            }
          }
        }
      }
      catch (Exception ex)
      {
        Log.Error("VisualisationManager: Failed to get viz plugins - {0}", ex.ToString());
      }
      return _VisualizationPluginsInfo;
    }
示例#11
0
    public override bool SetOutputContext(OutputContextType outputType)
    {
      if (VisualizationWindow == null)
      {
        return false;
      }

      if (_Initialized && !firstRun)
      {
        return true;
      }

      // If width or height are 0 the call to BASS_SONIQUEVIS_CreateVis will fail.  
      // If width or height are 1 the window is in transition so we can ignore it.
      if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1)
      {
        return false;
      }

      if (VizPluginInfo == null || VizPluginInfo.FilePath.Length == 0 || !File.Exists(VizPluginInfo.FilePath))
      {
        return false;
      }

      string vizPath = VizPluginInfo.FilePath;
      string configFile = Path.Combine(Path.GetDirectoryName(vizPath), "vis.ini");

      if (_visParam.VisHandle != 0)
      {
        try
        {
          BassVis.BASSVIS_Free(_visParam, ref _baseVisParam);
        }
        catch (AccessViolationException) {}

        _visParam.VisHandle = 0;
      }

      try
      {
        visExec = new BASSVIS_EXEC(vizPath);
        visExec.SON_ConfigFile = configFile;
        visExec.SON_Flags = BASSVISFlags.BASSVIS_DEFAULT;
        visExec.SON_PaintHandle = VisualizationWindow.CompatibleDC;
        visExec.Width = VisualizationWindow.Width;
        visExec.Height = VisualizationWindow.Height;
        visExec.Left = VisualizationWindow.Left;
        visExec.Top = VisualizationWindow.Top;
        BassVis.BASSVIS_ExecutePlugin(visExec, _visParam);
      }
      catch (Exception) {}
      firstRun = false;
      return _visParam.VisHandle != 0;
    }
示例#12
0
        public override bool SetOutputContext(OutputContextType outputType)
        {
            if (VisualizationWindow == null)
            {
                return(false);
            }

            if (_Initialized && !firstRun)
            {
                return(true);
            }

            // If width or height are 0 the call to CreateVis will fail.
            // If width or height are 1 the window is in transition so we can ignore it.
            if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1)
            {
                return(false);
            }

            if (VizPluginInfo == null || VizPluginInfo.FilePath.Length == 0 || !File.Exists(VizPluginInfo.FilePath))
            {
                return(false);
            }

            string vizPath    = VizPluginInfo.FilePath;
            string configFile = Path.Combine(System.Windows.Forms.Application.StartupPath, @"musicplayer\plugins\visualizations\Sonique\vis.ini");

            try
            {
                // Call Play befor use BASSVIS_ExecutePlugin (moved here)
                BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.Play);

                using (Profile.Settings xmlreader = new Profile.MPSettings())
                {
                    VizPluginInfo.UseOpenGL    = xmlreader.GetValueAsBool("musicvisualization", "useOpenGL", true);
                    VizPluginInfo.UseCover     = xmlreader.GetValueAsBool("musicvisualization", "useCover", true);
                    VizPluginInfo.RenderTiming = xmlreader.GetValueAsInt("musicvisualization", "renderTiming", 25);
                    VizPluginInfo.ViewPortSize = xmlreader.GetValueAsInt("musicvisualization", "viewPort", 0);
                }

                // Create the Visualisation
                visExec = new BASSVIS_EXEC(vizPath);
                visExec.SON_ConfigFile     = configFile;
                visExec.SON_Flags          = BASSVISFlags.BASSVIS_DEFAULT;
                visExec.SON_ParentHandle   = VisualizationWindow.Handle;
                visExec.Width              = VisualizationWindow.Width;
                visExec.Height             = VisualizationWindow.Height;
                visExec.SON_UseOpenGL      = VizPluginInfo.UseOpenGL;
                visExec.SON_ViewportWidth  = VizPluginInfo.ViewPortSizeX;
                visExec.SON_ViewportHeight = VizPluginInfo.ViewPortSizeY;
                visExec.Left        = VisualizationWindow.Left;
                visExec.Top         = VisualizationWindow.Top;
                visExec.SON_ShowFPS = true;
                // can not check IsRadio on first start
                // so ProgressBar and Cover Visible state will hide after change to the next Plugin to
                if (Bass.IsRadio)
                {
                    // no duration deactivate ProgressBar
                    visExec.SON_ShowPrgBar = false;
                    // Cover-Support used only on first start if VizPluginInfo.UseCover = true
                    // after or change the plugin in FullScreen, Cover-Support will disable for RadioStreams
                    visExec.SON_UseCover = false;
                }
                else
                {
                    visExec.SON_ShowPrgBar = true;
                    visExec.SON_UseCover   = VizPluginInfo.UseCover;
                }

                BassVis.BASSVIS_ExecutePlugin(visExec, _visParam);

                if (_visParam.VisHandle != 0)
                {
                    // Config Settings
                    BassVis.BASSVIS_SetOption(_visParam, BASSVIS_CONFIGFLAGS.BASSVIS_SONIQUEVIS_CONFIG_RENDERTIMING, VizPluginInfo.RenderTiming);
                    BassVis.BASSVIS_SetOption(_visParam, BASSVIS_CONFIGFLAGS.BASSVIS_SONIQUEVIS_CONFIG_USESLOWFADE, 1);
                    BassVis.BASSVIS_SetOption(_visParam, BASSVIS_CONFIGFLAGS.BASSVIS_SONIQUEVIS_CONFIG_SLOWFADE, 5);
                    BassVis.BASSVIS_SetOption(_visParam, BASSVIS_CONFIGFLAGS.BASSVIS_CONFIG_FFTAMP, 5);

                    Win32API.ShowWindow(VisualizationWindow.Handle, Win32API.ShowWindowFlags.Hide);

                    // SetForegroundWindow
                    GUIGraphicsContext.form.Activate();
                }
                firstRun = false;
            }
            catch (Exception ex)
            {
                Log.Error(
                    "Visualization Manager: Sonique visualization engine initialization failed with the following exception {0}",
                    ex);
            }
            _Initialized = _visParam.VisHandle != 0;
            return(_visParam.VisHandle != 0);
        }
示例#13
0
        public override bool SetOutputContext(OutputContextType outputType)
        {
            if (VisualizationWindow == null)
            {
                return(false);
            }

            if (_Initialized && !firstRun)
            {
                return(true);
            }

            // If width or height are 0 the call to CreateVis will fail.
            // If width or height are 1 the window is in transition so we can ignore it.
            if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1)
            {
                return(false);
            }

            if (VizPluginInfo == null || VizPluginInfo.FilePath.Length == 0 || !File.Exists(VizPluginInfo.FilePath))
            {
                return(false);
            }

            try
            {
                using (Profile.Settings xmlreader = new Profile.MPSettings())
                {
                    VizPluginInfo.FFTSensitivity = xmlreader.GetValueAsInt("musicvisualization", "fftSensitivity", 36);
                    VizPluginInfo.PresetIndex    = xmlreader.GetValueAsInt("musicvisualization", "preset", 0);
                }

                //Remove existing CallBacks
                BassVis.BASSVIS_WINAMPRemoveCallback();

                // Call Play befor use BASSVIS_ExecutePlugin (moved here)
                BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.Play);

                // Set CallBack for PlayState
                _visCallback = BASSVIS_StateCallback;
                BassVis.BASSVIS_WINAMPSetStateCallback(_visCallback);

                // Hide the Viswindow, so that we don't see it, befor any Render
                Win32API.ShowWindow(VisualizationWindow.Handle, Win32API.ShowWindowFlags.Hide);

                // Create the Visualisation
                BASSVIS_EXEC visExec = new BASSVIS_EXEC(VizPluginInfo.FilePath);
                visExec.AMP_ModuleIndex = VizPluginInfo.PresetIndex;
                visExec.AMP_UseOwnW1    = 1;
                visExec.AMP_UseOwnW2    = 1;
                // The flag below is needed for the Vis to have it's own message queue
                // Thus it is avoided that it steals focus from MP.
                visExec.AMP_UseFakeWindow = true;

                BassVis.BASSVIS_ExecutePlugin(visExec, _visParam);

                if (_visParam.VisHandle != 0)
                {
                    // Set the visualization window that was taken over from BASSVIS_ExecutePlugin
                    BassVis.BASSVIS_SetVisPort(_visParam,
                                               _visParam.VisGenWinHandle,
                                               VisualizationWindow.Handle,
                                               0,
                                               0,
                                               VisualizationWindow.Width,
                                               VisualizationWindow.Height);

                    BassVis.BASSVIS_SetOption(_visParam, BASSVIS_CONFIGFLAGS.BASSVIS_CONFIG_FFTAMP, VizPluginInfo.FFTSensitivity);

                    // SetForegroundWindow
                    GUIGraphicsContext.form.Activate();
                }

                firstRun = false;
            }
            catch (Exception ex)
            {
                Log.Error(
                    "Visualization Manager: Winamp visualization engine initialization failed with the following exception {0}",
                    ex);
            }
            _Initialized = _visParam.VisHandle != 0;
            return(_visParam.VisHandle != 0);
        }
示例#14
0
        public override bool SetOutputContext(OutputContextType outputType)
        {
            if (VisualizationWindow == null)
            {
                return(false);
            }

            if (_Initialized && !firstRun)
            {
                return(true);
            }

            // If width or height are 0 the call to CreateVis will fail.
            // If width or height are 1 the window is in transition so we can ignore it.
            if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1)
            {
                return(false);
            }

            if (VizPluginInfo == null || VizPluginInfo.FilePath.Length == 0 || !File.Exists(VizPluginInfo.FilePath))
            {
                return(false);
            }

            try
            {
                BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.Play);
                string vizPath = VizPluginInfo.FilePath;

                visExec                 = new BASSVIS_EXEC(vizPath);
                visExec.PluginFile      = vizPath;
                visExec.BB_Flags        = BASSVISFlags.BASSVIS_DEFAULT;
                visExec.BB_ParentHandle = VisualizationWindow.Handle;
                visExec.BB_ShowFPS      = true;
                // can not check IsRadio on first start
                // so ProgressBar Visible State will hide after change to the next Plugin to
                if (Bass.IsRadio)
                {
                    // no duration deactivate ProgressBar
                    visExec.BB_ShowPrgBar = false;
                }
                else
                {
                    visExec.BB_ShowPrgBar = true;
                }
                visExec.Left   = 0;
                visExec.Top    = 0;
                visExec.Width  = VisualizationWindow.Width;
                visExec.Height = VisualizationWindow.Height;

                BassVis.BASSVIS_ExecutePlugin(visExec, _visParam);

                if (_visParam.VisHandle != 0)
                {
                    // SetForegroundWindow
                    GUIGraphicsContext.form.Activate();
                }
                firstRun = false;
            }
            catch (Exception ex)
            {
                Log.Error(
                    "Visualization Manager: Bassbox visualization engine initialization failed with the following exception {0}",
                    ex);
            }
            _Initialized = _visParam.VisHandle != 0;
            return(_visParam.VisHandle != 0);
        }
示例#15
0
    public override bool SetOutputContext(OutputContextType outputType)
    {
      if (VisualizationWindow == null)
      {
        return false;
      }

      if (_Initialized && !firstRun)
      {
        return true;
      }

      // If width or height are 0 the call to CreateVis will fail.  
      // If width or height are 1 the window is in transition so we can ignore it.
      if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1)
      {
        return false;
      }

      if (VizPluginInfo == null || VizPluginInfo.FilePath.Length == 0 || !File.Exists(VizPluginInfo.FilePath))
      {
        return false;
      }

      if (_visParam.VisHandle != 0)
      {
        BassVis.BASSVIS_Free(_visParam, ref _baseVisParam);
        _visParam.VisHandle = 0;
        RenderStarted = false;
      }

      // Set Dummy Information for the plugin, before creating it
      _mediaInfo.SongTitle = "";
      _mediaInfo.SongFile = "";
      _mediaInfo.Position = 0;
      _mediaInfo.Duration = 0;
      _mediaInfo.PlaylistPos = 0;
      _mediaInfo.PlaylistLen = 0;
      BassVis.BASSVIS_SetInfo(_visParam, _mediaInfo);

      try
      {
        // Create the Visualisation
        BASSVIS_EXEC visExec = new BASSVIS_EXEC(VizPluginInfo.FilePath);
        visExec.AMP_ModuleIndex = VizPluginInfo.PresetIndex;
        visExec.AMP_UseOwnW1 = 1;
        visExec.AMP_UseOwnW2 = 1;
        BassVis.BASSVIS_ExecutePlugin(visExec, _visParam);
        if (_visParam.VisGenWinHandle != IntPtr.Zero)
        {
          hwndChild = Win32API.GetWindow(VisualizationWindow.Handle, Win32API.ShowWindowFlags.Show);
          if (hwndChild != IntPtr.Zero)
          {
            Win32API.MoveWindow(hwndChild, 0, 0, VisualizationWindow.Width, VisualizationWindow.Height, true);
          }

          BassVis.BASSVIS_SetVisPort(_visParam,
                                     _visParam.VisGenWinHandle,
                                     VisualizationWindow.Handle,
                                     0,
                                     0,
                                     VisualizationWindow.Width,
                                     VisualizationWindow.Height);

          BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.Play);
        }
        else
        {
          BassVis.BASSVIS_SetVisPort(_visParam,
                                     _visParam.VisGenWinHandle,
                                     IntPtr.Zero,
                                     0,
                                     0,
                                     0,
                                     0);
        }

        // The Winamp Plugin has stolen focus on the MP window. Bring it back to froeground
        Win32API.SetForegroundWindow(GUIGraphicsContext.form.Handle);

        firstRun = false;
      }
      catch (Exception ex)
      {
        Log.Error(
          "Visualization Manager: Winamp visualization engine initialization failed with the following exception {0}",
          ex);
      }
      _Initialized = _visParam.VisHandle != 0;
      return _visParam.VisHandle != 0;
    }