Click here to Skip to main content
13,249,813 members (66,442 online)
Click here to Skip to main content
Add your own
alternative version


59 bookmarked
Posted 16 Oct 2003

Another Spectrum Board

Rate this:
Please Sign up or sign in to vote.
MFC Spectrum Board control


This is another simple Spectrum/Bar Histogram control which can be easily incorporated in your multimedia project or something similar. They usually display an array of FFT generated value from decoded PCM sequence value of compressed audio data.

How to use it

There are only few steps to use this control:

  • Include two files, SpectrumCtrl.h and SpectrumCtrl.cpp in your project
  • Create a Picture box (Frame) in your form/dialog
  • Change it's ID to whatever you want
  • Include SpectrumCtrl.h in the class declaration of your form/dialog
  • Put this in your dialog/form class:
    CSpectrumCtrl   m_spectrumboard;
  • Create an instance of CSpectrumCtrl class in your application
    CWnd *m_pWnd;
  • Initialize the control, usually within OnInitDialog() in dialog or OnInitialUpdate() in form:
    m_pWnd = (CWnd*) GetDlgItem(IDC_STATIC_PICTURE_BOX_ID);
    m_spectrumboard.Create(JUMLAH_ELEMENT_ARRAY, 20, &CSize(4, 1), 
       WS_VISIBLE | WS_CHILD | WS_TABSTOP, m_pWnd, this, 1000);

    CSize(4, 1) means the size of the block/cell element in the spectrum board is 4 pixel width and 1 pixel height

  • Call the following method to visualize an integer array:

You can modify the following constants in the source code for visual appearance customization:

#define SPASI_ANTAR_CELL     1
#define PEAK_DROP_SPEED      1
#define PEAK_HEIGHT          1
#define MAX_PEAK_LIVE_TIME   7
#define PEAK_TOLERANT        2 // 2 blocks

Description of each constant

  • SPASI_ANTAR_CELL is the blank space between cells/blocks in the spectrum board
  • PEAK_DROP_SPEED is the gravitation value for the peaks
  • PEAK_HEIGHT is height of the peaks in pixel
  • MAX_PEAK_LIVE_TIME is the number to suspend peaks before get affected by gravitation
  • PEAK_TOLERANT is the restricted blocks/cells area at top of the spectrum board


This class will have it's own window size by modifying your picture box place holder at run-time. Cheers!


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Danang Suharno Ngadinegaran
Web Developer
Indonesia Indonesia
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionI want to know it! [modified] Pin
Lee, jang-won24-Aug-06 17:00
memberLee, jang-won24-Aug-06 17:00 
QuestionWhat about a resizable spectrum board? Pin
rbid5-Jul-04 5:47
memberrbid5-Jul-04 5:47 
AnswerRe: What about a resizable spectrum board? Pin
dunniu17-Dec-11 3:11
memberdunniu17-Dec-11 3:11 
GeneralDangerous define Pin
Sl0n11-Jun-04 8:05
memberSl0n11-Jun-04 8:05 
I'm not sure if there is such a line in your code (haven't downloaded it yet) but this is a potentially dangerous thing:
#define MAX_PEAK_LIVE_TIME   7
#define PEAK_TOLERANT        2 // 2 blocks

Consider this thing, for example

The ]; thing will be commented out. Just a warning - nothing personal Smile | :) ...
Great article. Got my 5.
GeneralRe: Dangerous define Pin
Rick York2-Sep-04 14:47
memberRick York2-Sep-04 14:47 
QuestionCan you make it slidable? Pin
Georgi22-Oct-03 23:51
memberGeorgi22-Oct-03 23:51 
GeneralSmall memory leak Pin
smesser19-Oct-03 14:19
membersmesser19-Oct-03 14:19 
Generala good start Pin
Alexander M.18-Oct-03 13:39
memberAlexander M.18-Oct-03 13:39 
GeneralNice but.... Pin
smesser17-Oct-03 9:24
membersmesser17-Oct-03 9:24 
GeneralNice Pin
Normski17-Oct-03 9:03
memberNormski17-Oct-03 9:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171114.1 | Last Updated 17 Oct 2003
Article Copyright 2003 by Danang Suharno Ngadinegaran
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid