Click here to Skip to main content
Click here to Skip to main content

Another Spectrum Board

, 16 Oct 2003
Rate this:
Please Sign up or sign in to vote.
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

Share

About the Author

Danang Suharno Ngadinegaran
Web Developer
Indonesia Indonesia
No Biography provided

Comments and Discussions

 
QuestionI want to know it! [modified] PinmemberLee, jang-won24-Aug-06 16:00 
QuestionWhat about a resizable spectrum board? Pinmemberrbid5-Jul-04 4:47 
AnswerRe: What about a resizable spectrum board? Pinmemberdunniu17-Dec-11 2:11 
GeneralDangerous define PinmemberSl0n11-Jun-04 7:05 
GeneralRe: Dangerous define PinmemberRick York2-Sep-04 13:47 
QuestionCan you make it slidable? PinmemberGeorgi22-Oct-03 22:51 
I mean this is histogram control, can it work as a graph control?
GeneralSmall memory leak Pinmembersmesser19-Oct-03 13:19 
Generala good start PinmemberAlexander M.18-Oct-03 12:39 
GeneralNice but.... Pinmembersmesser17-Oct-03 8:24 
GeneralNice PinmemberNormski17-Oct-03 8:03 

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

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 17 Oct 2003
Article Copyright 2003 by Danang Suharno Ngadinegaran
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid