A 'scope like and sound input class | CodeGuru

A ‘scope like and sound input class

Description: The SoundIn class provide a set of functions to interface a sound card for input signal. The CSoundIn::OpenMic() function is the main start procedure. It initialise all the parametres or the sound card, create an EVENT object and start the sound thread. The thread procedure is used to signal to the sound class that […]

Written By
CodeGuru Staff
CodeGuru Staff
Nov 8, 1998
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Description:

The SoundIn class provide a set of functions to interface a
sound card for input signal.

The CSoundIn::OpenMic() function
is the main start procedure. It initialise all the parametres or
the sound card,
create an EVENT object and start the sound thread. The thread
procedure is used to signal to the sound class
that a buffer has been filled and that the Win sound system is
ready for a new acquisition.

The thread procedure can’t be included in the SoundIn class so
that it is declared as a global procedure.
The parameter LPARAM which is passed to the thread procedure is
the pointer to the SoundIn class (this).

After the thread is started it wait for the buffer is filled,
awaiting an EVENT with
WaitforsingleObject(). The thread is
then notified by the sound system and call the function CSoundIn::ComputeSample().

This virtual function do praticaly nothing in this base class.
If you want to enhance the sound
class for a specific treatement like Filter or FFT, derive your
own class from this SoundIn class
add your own ComputeSample() virtual procedure and add first a
call the base class ::ComputeSample() procedure.

How to use it

  • Include the 2 Sound class files in ur project
  • The sample demo program use a "quick &
    dirty" global declaration CSoundIn
    SoundIn;
    in CSndApp.cpp.
  • Call the function OpenMic(); in the InitInstance App
    procedure. (the CloseMic() at ExitIntance is optional)

This is all you need to start the Sound process.

In the Demo sample two files have been included Process.cpp
and Process.h. Try to use it to make you own process
If you declare this Process class for the global class instead of
the CSoundIn classe . The parametre (this) passed to the thread
will point to the Process class so it will directly call first
the ComputeSample() function of the Process class.

The Scope View:

This just for representing the signal for the demo sample. It
is drawn directly in the project View. A timer is started
in the OnInitialUpdate() function . When the timer is reached,
the OnTimer() function redraws all the view.

Run the scope demo program:

Before running it, have a look at the reame.txt file included
in the project.

How to compile: … F7 ;-))
!!Don’t forget to add the multimedia library file
"winmm.lib".in your project setup.

Editors note: You can include the mulitmedia library (winmm.lib) by including
the following in your code:

    #pragma comment(lib, “winmm”)

This saves the hassle of having to remember to link it explicitly

Download demo code 30Kb

Posted: August 11, 1998
Last updated: 15 Feb 1999

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.