protected override void InnerDraw(Graphics g, int useLength)
        {
            int   lastBand      = -1; //последний активный столбик
            float maxInLastBand = 0f; //максимальное значение частоты в последнем столбике

            for (int i = 0; i < useLength; i++)
            {
                int band = (int)((float)i / useLength * BandsCount);

                if (band > lastBand) //если сменился столбик
                {
                    //обнуляем показатель
                    lastBand      = band;
                    maxInLastBand = 0f;
                }

                float analogValue = DisplayRectangle.NormalizedHeight(SpectrumValues[i]);
                if (analogValue > maxInLastBand)
                {
                    maxInLastBand = analogValue; //пересохраняем частоту

                    DrawBand(g, band, analogValue);
                }
            }
        }
Ejemplo n.º 2
0
 protected override void InnerDraw(Graphics g, int useLength)
 {
     for (int i = 0; i < useLength; i++)
     {
         float x      = DisplayRectangle.NormalizedWidth((float)i / useLength);
         float height =
             DisplayRectangle.NormalizedHeight(SpectrumValues[i]);
         g.FillRectangle(Brush, DisplayRectangle.Left + x, DisplayRectangle.Bottom - height, 1, height);
     }
 }
Ejemplo n.º 3
0
        public override void Draw(Graphics g)
        {
            var heightL = DisplayRectangle.NormalizedHeight(NormalizedVolumeL);
            var heightR = DisplayRectangle.NormalizedHeight(NormalizedVolumeR);

            g.FillRectangle(LeftBrush, DisplayRectangle.Left, DisplayRectangle.Bottom - heightL,
                            DisplayRectangle.CenterW, heightL);

            g.FillRectangle(RightBrush, DisplayRectangle.CenterW, DisplayRectangle.Bottom - heightR,
                            DisplayRectangle.CenterW, heightR);
        }
Ejemplo n.º 4
0
        protected override void InnerDraw(Graphics g, int useLength)
        {
            float lastX = 0f;
            float lastY = DisplayRectangle.Bottom;

            for (int i = 0; i < useLength; i++)
            {
                float x      = DisplayRectangle.NormalizedWidth((float)i / useLength);
                float height =
                    DisplayRectangle.NormalizedHeight(SpectrumValues[i]);
                var y = DisplayRectangle.Bottom - height;
                g.DrawLine(_pen, lastX, lastY, x, y);

                lastX = x;
                lastY = y;
            }
        }
Ejemplo n.º 5
0
        public override void Recreate()
        {
            int useSamples = SpectrumSamples >> 1;

            if (ApplyTimeThinning)
            {
                useSamples >>= 1;
            }

            useSamples = (int)(useSamples * TrimmingFrequency / 20000f);

            Task.Run(() =>
            {
                Parallel.For(0, (int)DisplayRectangle.Width, (i, loopState) =>
                {
                    float[] heightPixels = new float[(int)DisplayRectangle.Height + 1];
                    if (Canceled)
                    {
                        loopState.Break();
                        return;
                    }

                    float realPosition = Math.Min(i / DisplayRectangle.Width,
                                                  (float)(FileData.samplesCount - SpectrumSamples) / FileData.samplesCount);

                    float[] spectrum;
                    lock (FftProvider)
                    {
                        spectrum = FileData.GetSpectrumForPosition(realPosition, FftProvider);
                    }

                    for (int j = 0; j < useSamples; j++)
                    {
                        int yPosition = (int)(DisplayRectangle.Height -
                                              DisplayRectangle.NormalizedHeight((float)j / useSamples));
                        heightPixels[yPosition] = spectrum[j];
                    }

                    for (int j = 0; j < (int)DisplayRectangle.Height; j++)
                    {
                        Diagram.SetPixel(i, j, IntensityToArgb(heightPixels[j]));
                    }
                });
            });
        }