No Comments
PeakMeterCS.zip - 37K PeakMeterMFC.zip - 38K
Introduction
Ever since I've been using Winamp, I've always been a big fan of their PeakMeter area.
This is the main reason of this control. It is also one of the few PeakMeter that you can find over web.
This is the main reason of this control. It is also one of the few PeakMeter that you can find over web.
Description
Using PeakMeter in MFC
There are two versions of this control depending on whether you are using MFC or .NET. The new .NET version offers more features.
To use in MFC application, you can subclass a STATIC control or you can create it directly with
To use in MFC application, you can subclass a STATIC control or you can create it directly with
Create()
.// define a member variable in your header file CPeakMeterCtrl m_PeakMeter1; // in your .cpp, use DataExchange to subclass void CPeakMeterDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPeakMeterDlg) DDX_Control(pDX, IDC_PMC_HORZ, m_PeakMeter1); //}}AFX_DATA_MAP }
// Create this control with create m_PeakMeter2.Create(WS_CHILD|WS_VISIBLE, rc, this, IDC_PMC_VERT); // note: call SetMeterStyle to change meter style m_PeakMeter2.SetMeterStyle(PMS_VERTICAL); m_PeakMeter2.SetMeterBands(10, 15); m_PeakMeter2.Start(1000/20); // 20 fps
Using PeakMeter in .NET
You can use .NET version of this control in WinForms applications. Just add it to your toolbox and drag and drop it to your WinForm canvas. Here's a summary of the properties for this controlPeakMeterControl Properties
Property | Description |
MeterStyle | Show Meter bands in Horizontal (PMS_Horizontal) or Vertical (PMS_Vertical) |
ShowGrid | Show meter background grid |
ColoredGrid | Show meter backgroung grid using color schemes |
GridColor | Background grid color (when ColoredGrid property is false) |
ColorNormal | Low range color |
ColorNormalBack | Low range color Background (ColoredGrid=1) |
ColorMedium | Medium range color |
ColorMediumBack | Medium range color Background (ColoredGrid=1) |
ColorHigh | High range color |
ColorHighBack | High range color Background (ColoredGrid=1) |
BandsCount | Number of bands |
LEDCount | Number of LED per bands (when 1, band is smooth) |
FalloffSpeed | Falloff effect speed (1=fast, 10=normal, 100=slow) |
FalloffEffect | Enable falloff effect, call Start() to run |
FalloffColor | Falloff line color |
PeakMeterControl Methods
Name | Description |
bool Start(int delay) | Start animation (delay in ms). Can be called from non-UI thread. |
bool Stop() | Stop animation. Can be called from non-UI thread. |
void SetMeterBands(int bands, int led) | Set meter bands properties and number of LED in one call |
void SetRange(int min, int med, int max) | Change meter control default range |
bool SetData(int[] values, int offset, int size) | Set peak meter data. Can be called from non-UI thread. |
History
05/24/2008: First revision for .NET
08/10/2008: Update control