public override bool SetOutputContext(OutputContextType outputType)
        {
            if (VisualizationWindow == null)
            {
                return(false);
            }

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

            RECT rect = new RECT();

            rect.left   = 0;
            rect.top    = 0;
            rect.right  = VisualizationWindow.Width;
            rect.bottom = VisualizationWindow.Height;

            bool result = SoundSpectrumInterop.SetOutput(SSVisualizationName, outputType, VisualizationWindow.CompatibleDC,
                                                         ref rect);

            // Soundspectrum Graphics always show the cursor, so let's hide it here
            if (GUIGraphicsContext.Fullscreen && _autoHideMouse)
            {
                Cursor.Hide();
            }

            return(result);
        }
Example #2
0
        public override bool Initialize()
        {
            bool result = false;

            try
            {
                Log.Info("  Visualization Manager: Initializing WMP visualization...");

                RECT rect = new RECT();
                rect.left   = 0;
                rect.top    = 0;
                rect.right  = VisualizationWindow.Width;
                rect.bottom = VisualizationWindow.Height;

                OutputContextType outputType = VisualizationWindow.OutputContextType;
                result = WMPInterop.InitWMPEngine(VizPluginInfo.CLSID, VizPluginInfo.PresetIndex, OutputContextType.WindowHandle,
                                                  IntPtr.Zero,
                                                  VisualizationWindow.Handle, ref rect);
                _Initialized = result;
                Log.Info("  Visualization Manager: WMP visualization initialization {0}", (result ? "succeeded." : "failed!"));
            }

            catch (Exception ex)
            {
                Console.WriteLine("CreateGForceVisualization failed with the following exception: {0}", ex);
                Log.Error(
                    "  Visualization Manager: WMP visualization engine initialization failed with the following exception {0}", ex);
                return(false);
            }

            return(result);
        }
Example #3
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);
        }
Example #4
0
        public override bool SetOutputContext(OutputContextType outputType)
        {
            if (VisualizationWindow == null)
            {
                return(false);
            }

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

            bool result = WMPInterop.SetOutputWMP(outputType, VisualizationWindow.Handle);

            return(result);
        }
        public override bool Initialize()
        {
            bool result = false;

            try
            {
                DateTime dt = DateTime.Now;
                Log.Info("Visualization Manager: Initializing {0} visualization engine...", VizPluginInfo.Name);

                RECT rect = new RECT();
                rect.left   = 0;
                rect.top    = 0;
                rect.right  = VisualizationWindow.Width;
                rect.bottom = VisualizationWindow.Height;

                OutputContextType outputType = VisualizationWindow.OutputContextType;
                result = SoundSpectrumInterop.InitEngine(SSVisualizationName, outputType, SoundSpectrumInterop.SSCallback,
                                                         VisualizationWindow.CompatibleDC, ref rect);

                // Soundspectrum Graphics always show the cursor, so let's hide it here
                if (GUIGraphicsContext.Fullscreen && _autoHideMouse)
                {
                    Cursor.Hide();
                }

                Log.Info("Visualization Manager: {0} visualization engine initialization {1}", VizPluginInfo.Name,
                         (result ? "succeeded." : "failed!"));
            }

            catch (Exception ex)
            {
                Console.WriteLine("CreateGForceVisualization failed with the following exception: {0}", ex);
                Log.Error(
                    "  Visualization Manager: {0} visualization engine initialization failed with the following exception {1}",
                    VizPluginInfo.Name, ex);
                return(false);
            }

            return(result);
        }
Example #6
0
 public virtual bool SetOutputContext(OutputContextType outputType)
 {
     return(false);
 }
    public override bool SetOutputContext(OutputContextType outputType)
    {
      if (VisualizationWindow == null)
      {
        return false;
      }

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

      RECT rect = new RECT();
      rect.left = 0;
      rect.top = 0;
      rect.right = VisualizationWindow.Width;
      rect.bottom = VisualizationWindow.Height;

      bool result = SoundSpectrumInterop.SetOutput(SSVisualizationName, outputType, VisualizationWindow.CompatibleDC,
                                                   ref rect);

      // Soundspectrum Graphics always show the cursor, so let's hide it here
      if (GUIGraphicsContext.Fullscreen && _autoHideMouse)
      {
        Cursor.Hide();
      }

      return result;
    }
Example #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)
      {
        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;
    }
Example #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)
            {
                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);
        }
Example #10
0
    public override bool SetOutputContext(OutputContextType outputType)
    {
      if (VisualizationWindow == null)
      {
        return false;
      }

      // If width or height are 0 the call will fail.  If width or height are 1 the window is in transition
      if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1)
      {
        return false;
      }
      if (GUIGraphicsContext.IsFullScreenVideo)
      {
        VisualizationWindow.Width = GUIGraphicsContext.form.ClientRectangle.Width;
        VisualizationWindow.Height = GUIGraphicsContext.form.ClientRectangle.Height;
      }
      
      bool result = WMPInterop.SetOutputWMP(outputType, VisualizationWindow.Handle);
      return result;
    }
Example #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 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;
    }
Example #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);
            }

            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);
        }
Example #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
      {
        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;
    }
Example #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);
        }
 public virtual bool SetOutputContext(OutputContextType outputType)
 {
   return false;
 }
Example #16
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;
    }
Example #17
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);
        }
Example #18
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);
        }
Example #19
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;
    }
Example #20
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;
    }
Example #21
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;
    }