( Index )
Month

Brief Information about the September 2005 CSIG Meeting

Pink.exe - A Pink Noise Sound Player --- Windows API

by Bruce Arnold

3rd Tuesday of the month. 7:30PM - C/C++ Group, SPRS

Pink Noise Application

Welcome to the C++ Users Group. This group is a "Special Interest Group" of the ACGNJ devoted to discussing programming languages in general and C, C++, and C++ for Windows programming in particular. Each month a small but hopefully useful program (complete with source code) is presented for discussion.

Object of the Pink Noise Player Program: To present a small utility which plays Pink Noise from the computer sound system. Pink Noise is "1/f noise," with a frequency distribution of 1/f, or a 3 dB per octave roll-off. It is generally considered the kind of noise most prevalent in nature. The sample covers the frequency range of 20 to 20,000 Hertz.

Where Applicable

Many of us like to listen to music while doing computer tasks. This can be problematic in an office enviornment because others don't necessarly like the same music. A Pink Noise generator creates an ambient sound that is most like natural office noise. If the volume is adjusted properly then others will not notice it, however it can do a remarkable job of masking random sounds and talking from surrounding locations.

Developer Requirements

The Microsoft Visual C++ 6.0 Visual Studio Complier.

Programming and Language Features

  1. Dialog Box Based.
  2. Microsoft Foundation Classes
  3. Embedded Data
  4. Sound functions
  5. Windows API
  6. Timers
  7. Slider and Button Controls
  8. Colorful backgrounds

At the meeting on Tuesday night we will be discussing the utility and the source code.


SAMPLE CODE
===========
BEGIN_MESSAGE_MAP(CPinkDlg, CDialog)
    //{{AFX_MSG_MAP(CPinkDlg)
    ON_WM_SYSCOMMAND()
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
    ON_BN_CLICKED(IDC_SOUND1, OnSound1)
    ON_WM_HSCROLL()
    ON_WM_TIMER()
    ON_WM_DESTROY()
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPinkDlg message handlers

BOOL CPinkDlg::OnInitDialog()
    {
    CDialog::OnInitDialog();

    // Add "About..." menu item to system menu.

    // IDM_ABOUTBOX must be in the system command range.
    ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
    ASSERT(IDM_ABOUTBOX < 0xF000);

    CMenu* pSysMenu = GetSystemMenu(FALSE);
    if (pSysMenu != NULL)
        {
        CString strAboutMenu;
        strAboutMenu.LoadString(IDS_ABOUTBOX);
        if (!strAboutMenu.IsEmpty())
            {
            pSysMenu->AppendMenu(MF_SEPARATOR);
            pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
            }
        }

    SetIcon(m_hIcon, TRUE);         // Set big icon
    SetIcon(m_hIcon, FALSE);        // Set small icon
    
    // TODO: Add extra initialization here

//  int code = waveOutGetVolume(  HWAVEOUT hwo,   LPDWORD pdwVolume  );
    unsigned long Vol;

    RECT rr; GetClientRect(&rr);
    GetDlgItem(IDC_STATUS)->SetWindowPos(0,0,0,rr.right,rr.bottom,SWP_NOZORDER);

    int code = waveOutGetVolume(0,   &Vol  );
    LeftChanFiltered = 0;
    LeftChanVol = (Vol & 0xFFFF) >> 8;
    m_Slider.SetRange(0, 255);
    m_Slider.SetPos(LeftChanVol);
    m_Slider.SetTicFreq(51);

    LeftChanVol = m_Slider.GetPos();
    SetTimer(1, 20, NULL);

    return TRUE;  // return TRUE  unless you set the focus to a control
    }

"Random Access" questions start at 7:30 Tuesday night. See you there.
September 2005  C/C++ Meeting Random Access Notes
=================================================
 ASUS			RARITAN CENTER
 A-BIT			SEPT 24,25
 MATSONIC		COMPUTER SHOW
 MACH SPEED
 PC POWER AND COOLING

SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page