Beispiel #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            try
            {
                SpectrumData spec = this.spectrum;

                if (spec != null)
                {
                    float h;

                    spec.Translate();

                    if (ShowGrid)
                    {
                        for (int i = baseline; i > TOP_MARGIN; i -= 12)
                        {
                            if (i > greenZone)
                            {
                                e.Graphics.DrawLine(Styles.SpectrumGreenPen, leftMargin, i, rightMargin, i);
                            }
                            else if (i > yellowZone)
                            {
                                e.Graphics.DrawLine(Styles.SpectrumYellowPen, leftMargin, i, rightMargin, i);
                            }
                            else
                            {
                                e.Graphics.DrawLine(Styles.SpectrumRedPen, leftMargin, i, rightMargin, i);
                            }
                        }
                    }

                    h = Math.Min(scale, spec.LeftVUTranslated * gainTimesScale);
                    e.Graphics.FillRectangle(leftBrush, leftMargin, baseline - h, vuPixels, h);

                    h = Math.Min(scale, spec.RightVUTranslated * gainTimesScale);
                    e.Graphics.FillRectangle(rightBrush, leftMargin + vuPixels + CHANNEL_MARGIN, baseline - h, vuPixels, h);

                    for (int i = 0; i < spec.NumBandsTranslated; i++)
                    {
                        h = Math.Min(scale, spec.LeftSpectrumTranslated[i] * gainTimesScale);
                        e.Graphics.FillRectangle(leftBrush, bandPosn[i], baseline - h, bandPixels, h);

                        h = Math.Min(scale, spec.RightSpectrumTranslated[i] * gainTimesScale);
                        e.Graphics.FillRectangle(rightBrush, bandPosn[i] + rightChannelOffset, baseline - h, bandPixels, h);
                    }

                    // PEAK LINES

                    h = baseline - Math.Min(scale, spec.LeftVUPeak * gainTimesScale);
                    e.Graphics.DrawLine(Styles.SpectrumPeakPen, leftMargin, h, leftMargin + vuPixels - 1, h);

                    h = baseline - Math.Min(scale, spec.RightVUPeak * gainTimesScale);
                    e.Graphics.DrawLine(Styles.SpectrumPeakPen, leftMargin + vuPixels + CHANNEL_MARGIN, h, leftMargin + vuPixels + vuPixels + CHANNEL_MARGIN - 1, h);

                    for (int i = 0; i < spec.NumBandsTranslated; i++)
                    {
                        h = baseline - Math.Min(scale, spec.LeftSpectrumPeak[i] * gainTimesScale);
                        e.Graphics.DrawLine(Styles.SpectrumPeakPen, bandPosn[i], h, bandPosn[i] + bandPixels - 1, h);

                        h = baseline - Math.Min(scale, spec.RightSpectrumPeak[i] * gainTimesScale);
                        e.Graphics.DrawLine(Styles.SpectrumPeakPen, bandPosn[i] + bandPixels + 1, h, bandPosn[i] + rightChannelOffsetPeak, h);
                    }
                    if (!spectrumRectangle.Contains(e.ClipRectangle))
                    {
                        // FREQUENCY MARKERS

                        for (int i = 0; i < freqMarkers.Length; i++)
                        {
                            TextRenderer.DrawText(e.Graphics,
                                                  freqMarkers[i],
                                                  Styles.FontSmall,
                                                  freqMarkerPositions[i],
                                                  Color.White,
                                                  tff);
                        }

                        // DB MARKERS

                        for (int i = 0; i < dbMarkers.Length; i++)
                        {
                            TextRenderer.DrawText(e.Graphics,
                                                  dbMarkers[i],
                                                  Styles.FontSmall,
                                                  dbMarkerPositions[i],
                                                  Color.White,
                                                  tffr);
                        }
                    }
                }
            }
            catch { }
        }
Beispiel #2
0
 private void createSpectrumData()
 {
     spectrum = new SpectrumData(spectrumSampleSize / 2, (float)(output.Frequency / 2), spectrumMode);
 }