internal void PlaybackDone()
        {
            DoneSpectrumTimer();
            DonePlayer();
            DoneSpectrumProperties();
            SpectrumImage.ClearImages();

            if (Utils.SpectrumDebug)
            {
                logger.Debug("Playback done.");
            }
        }
        internal void PlaybackInit(bool force = false)
        {
            InitSpectrumProperties();
            InitPlayer(force);
            InitSpectrumTimer();
            SpectrumImage.InitSpectrumImages();

            if (Utils.SpectrumDebug)
            {
                logger.Debug("Playback init.");
            }
        }
        public void RMSLevel()
        {
            double dBlevelL = 0.0;
            double dBlevelR = 0.0;

            if (!IsPlaying)
            {
                Utils.SetProperty("vumeterLtext", Utils.VUMeterEmptyText);
                Utils.SetProperty("vumeterRtext", Utils.VUMeterEmptyText);
                return;
            }

            GetRMSLevel(out dBlevelL, out dBlevelR);

            if (!Double.IsInfinity(dBlevelL))
            {
                Utils.SetProperty("vumeterLtext", string.Format(Utils.VUMeterText, dBlevelL));
                if (Utils.SpectrumDebug)
                {
                    minL = (minL > dBlevelL) ? dBlevelL : minL;
                    maxL = (maxL < dBlevelL) ? dBlevelL : maxL;
                }
            }
            else
            {
                Utils.SetProperty("vumeterLtext", Utils.VUMeterEmptyText);
            }

            if (!Double.IsInfinity(dBlevelR))
            {
                Utils.SetProperty("vumeterRtext", string.Format(Utils.VUMeterText, dBlevelR));
                if (Utils.SpectrumDebug)
                {
                    minR = (minR > dBlevelR) ? dBlevelR : minR;
                    maxR = (maxR < dBlevelR) ? dBlevelR : maxR;
                }
            }
            else
            {
                Utils.SetProperty("vumeterRtext", Utils.VUMeterEmptyText);
            }

            if (_spectrumdbpeaktime >= _spectrumdbpeakfall)
            {
                _spectrumvulpeak    = dBlevelL;
                _spectrumvurpeak    = dBlevelR;
                _spectrumdbpeaktime = 0;
            }
            else
            {
                _spectrumvulpeak = Utils.CalcPeak(dBlevelL, _spectrumvulpeak);
                _spectrumvurpeak = Utils.CalcPeak(dBlevelR, _spectrumvurpeak);
            }

            int iLeft      = Utils.CalcdB(dBlevelL, _spectrummin, _spectrummax);
            int iLeftPeak  = Utils.CalcdB(_spectrumvulpeak, _spectrummin, _spectrummax);
            int iRight     = Utils.CalcdB(dBlevelR, _spectrummin, _spectrummax);
            int iRightPeak = Utils.CalcdB(_spectrumvurpeak, _spectrummin, _spectrummax);

            if (ShowSpectrum == Utils.Spectrum.Both || ShowSpectrum == Utils.Spectrum.Multi)
            {
                Utils.SetProperty("vumeterL", "VU" + iLeft + ".png");
                Utils.SetProperty("vumeterLPeak", "VU" + Utils.CalcdB(_spectrumvulpeak, _spectrummin, _spectrummax).ToString() + "Peak.png");
                Utils.SetProperty("vumeterR", "VU" + Utils.CalcdB(dBlevelR, _spectrummin, _spectrummax).ToString() + ".png");
                Utils.SetProperty("vumeterRPeak", "VU" + Utils.CalcdB(_spectrumvurpeak, _spectrummin, _spectrummax).ToString() + "Peak.png");
            }
            if (ShowSpectrum == Utils.Spectrum.Both || ShowSpectrum == Utils.Spectrum.Single)
            {
                List <int> vumeter = new List <int>()
                {
                    iLeft, iRight
                };
                List <int> vumeterpeak = new List <int>()
                {
                    iLeft, iRight
                };
                Utils.SetProperty("vumeter", SpectrumImage.BuildConcatVUMeterImage(vumeter, vumeterpeak, _spectrumdbspacing, _spectrumdbmin, _spectrumdbmax));
            }

            unchecked { _spectrumdbpeaktime = (ushort)(_spectrumdbpeaktime + _spectrumtimer); };
        }
        public bool Spectrum()
        {
            bool _spectrumpresent = false;

            if (!IsPlaying)
            {
                return(_spectrumpresent);
            }

            _spectrumpresent = GetSpectrum();

            if (_spectrumpresent)
            {
                for (int i = 1; i <= _spectrumcount; i++)
                {
                    if (!IsPlaying)
                    {
                        return(false);
                    }

                    if (ShowSpectrum == Utils.Spectrum.Both || ShowSpectrum == Utils.Spectrum.Multi)
                    {
                        Utils.SetProperty("#VUSpectrum" + i, @"VU" + _spectrum[i - 1] + ".png");
                    }
                    if (Utils.SpectrumPeakEnabled)
                    {
                        if (_spectrumpeaktime >= _spectrumpeakfall)
                        {
                            _spectrumpeak[i - 1] = _spectrum[i - 1];
                            _spectrumpeaktime    = 0;
                        }
                        else
                        {
                            _spectrumpeak[i - 1] = Utils.CalcPeak(_spectrum[i - 1], _spectrumpeak[i - 1]);
                        }
                        if (ShowSpectrum == Utils.Spectrum.Both || ShowSpectrum == Utils.Spectrum.Multi)
                        {
                            Utils.SetProperty("#VUSpectrumPeak" + i, @"VU" + _spectrumpeak[i - 1] + "Peak.png");
                        }
                    }
                }

                if (IsPlaying)
                {
                    if (ShowSpectrum == Utils.Spectrum.Both || ShowSpectrum == Utils.Spectrum.Single)
                    {
                        Utils.SetProperty("#VUSpectrum", SpectrumImage.BuildConcatSpectrumImage(_spectrum, _spectrumpeak, _spectrumcount, _spectrumspacing, _spectrummin, _spectrummax));
                    }
                }

                if (Utils.SpectrumPeakEnabled)
                {
                    unchecked { _spectrumpeaktime = (ushort)(_spectrumpeaktime + _spectrumtimer); };
                }
            }
            else
            {
                InitSpectrumProperties();
            }

            return(_spectrumpresent);
        }