diff -r e5f85a895a62 -r 920fea7a6427 Server/Spectrum/LineSpectrum.cs --- a/Server/Spectrum/LineSpectrum.cs Mon Jan 02 18:43:45 2017 +0100 +++ b/Server/Spectrum/LineSpectrum.cs Wed Jan 04 18:43:28 2017 +0100 @@ -13,10 +13,11 @@ private double _barSpacing; private double _barWidth; private Size _currentSize; - + + public LineSpectrum(FftSize fftSize) { - FftSize = fftSize; + FftSize = fftSize; } [Browsable(false)] @@ -67,38 +68,54 @@ } } + /// + /// Update our math. + /// + /// + public bool Update() + { + return SpectrumProvider.GetFftData(iFftBuffer, this); + } + public Bitmap CreateSpectrumLine(Size size, Brush brush, Color background, bool highQuality) { if (!UpdateFrequencyMappingIfNessesary(size)) + { return null; + } - var fftBuffer = new float[(int)FftSize]; + //get the fft result from the spectrum provider + using (var pen = new Pen(brush, (float)_barWidth)) + { + var bitmap = new Bitmap(size.Width, size.Height); - //get the fft result from the spectrum provider - if (SpectrumProvider.GetFftData(fftBuffer, this)) - { - using (var pen = new Pen(brush, (float)_barWidth)) + using (Graphics graphics = Graphics.FromImage(bitmap)) { - var bitmap = new Bitmap(size.Width, size.Height); + PrepareGraphics(graphics, highQuality); + graphics.Clear(background); - using (Graphics graphics = Graphics.FromImage(bitmap)) - { - PrepareGraphics(graphics, highQuality); - graphics.Clear(background); + CreateSpectrumLineInternal(graphics, pen, iFftBuffer, size); + } - CreateSpectrumLineInternal(graphics, pen, fftBuffer, size); - } - - return bitmap; - } - } - return null; + return bitmap; + } } - public Bitmap CreateSpectrumLine(Size size, Color color1, Color color2, Color background, bool highQuality) + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Bitmap Render(Size size, Color color1, Color color2, Color background, bool highQuality) { if (!UpdateFrequencyMappingIfNessesary(size)) + { return null; + } using ( Brush brush = new LinearGradientBrush(new RectangleF(0, 0, (float)_barWidth, size.Height), color2,