Click here to Skip to main content
15,860,972 members
Articles / Desktop Programming / MFC
Article

Another Spectrum Board

Rate me:
Please Sign up or sign in to vote.
4.78/5 (16 votes)
16 Oct 20031 min read 82K   2.8K   60   10
MFC Spectrum Board control

Introduction

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:
    m_spectrum.DisplayArray(iPtrNilai);

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

Conclusion

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

License

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


Written By
Web Developer
Indonesia Indonesia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionI want to know it! [modified] Pin
Lee, jang-won24-Aug-06 16:00
Lee, jang-won24-Aug-06 16:00 
QuestionWhat about a resizable spectrum board? Pin
rbid5-Jul-04 4:47
rbid5-Jul-04 4:47 
AnswerRe: What about a resizable spectrum board? Pin
dunniu17-Dec-11 2:11
dunniu17-Dec-11 2:11 
GeneralDangerous define Pin
AntonGogolev11-Jun-04 7:05
AntonGogolev11-Jun-04 7:05 
GeneralRe: Dangerous define Pin
Rick York2-Sep-04 13:47
mveRick York2-Sep-04 13:47 
QuestionCan you make it slidable? Pin
Georgi Petrov22-Oct-03 22:51
Georgi Petrov22-Oct-03 22:51 
GeneralSmall memory leak Pin
Steve Messer19-Oct-03 13:19
Steve Messer19-Oct-03 13:19 
Generala good start Pin
Alexander M.,18-Oct-03 12:39
Alexander M.,18-Oct-03 12:39 
GeneralNice but.... Pin
Steve Messer17-Oct-03 8:24
Steve Messer17-Oct-03 8:24 
GeneralNice Pin
NormDroid17-Oct-03 8:03
professionalNormDroid17-Oct-03 8: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.