Click here to Skip to main content
15,887,361 members
Articles / Desktop Programming / MFC
Article

Morse code. Some examples of how to produce sounds.

Rate me:
Please Sign up or sign in to vote.
4.64/5 (16 votes)
3 Apr 2001 132.4K   2.6K   66   13
Several classes demonstrating how to fill audio buffer and how to produce sound using waveOut* API

This program demonstrates how to use the waveOut APIs to produce sounds of different frequencies. Two classes can play sounds asynchronously (with some differences in implementation), and one show works in plain synchronous mode.

The sample program takes a string you supply, converts it into Morse code, and then plays this code. You can customize the frequency and duration of the sounds produced.

 [Sample Image - 33K]

Using the asynchronous classes, it is possible to change frequency smoothly when sounds are playing, but sound quality is not very good.

This code was tested only on VC++ 6.0 and Windows 98.

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 SEO
Russian Federation Russian Federation
AlexF's Blog in Russian
Owner Spy competition analysis
Rating Burner Rating of blogs

Comments and Discussions

 
GeneralGreat article! Pin
DrABELL16-Sep-09 15:31
DrABELL16-Sep-09 15:31 
GeneralSir, I want to change a existed wav's frequency, can you give me some advice or some code? Thank you. Pin
wangmike51816-Jan-08 3:31
wangmike51816-Jan-08 3:31 
Generalmultichannel rather than stereo Pin
walkerjiao2-Dec-03 14:10
walkerjiao2-Dec-03 14:10 
QuestionHow to Store 16 Bit PCM Wave Pin
Maria Jothi5-May-02 19:41
Maria Jothi5-May-02 19:41 
GeneralMuch static Pin
Michael S. Scherotter14-May-01 9:58
Michael S. Scherotter14-May-01 9:58 
GeneralTimed Event Pin
UkJay13-May-01 13:32
UkJay13-May-01 13:32 
GeneralRe: Timed Event Pin
MyGoddess22-Jun-01 2:59
MyGoddess22-Jun-01 2:59 
To do a timer event use the function 'SetTimer' which created a WM_TIMER message a the time interval you have specified.
With this function, Windows place only one WM_TIMER message in message list of the program for the ID which identify the Timer event.
You also have to create a 'TimerProc' wich receive an int as parametre which is ID of timer event.
If you work with MFC you can create the TimerProc with ClassWizard by select the message WM_TIMER.
In this case, you don't have to specify a TimerProc in the call.
To kill a timer event use 'KillTimer(int nIDEvent)' for class and 'KillTimer(HWND hWnd,int nIDEvent)' for global.

SetTimer exist in these class (parameters) :
'global' UINT( HWND hWnd,// handle of window for timer messages
UINT nIDEvent,// timer identifier
UINT nElapse,// time-out value
TIMERPROC lpTimerFunction)// address of timer procedure
CWnd UINT( UINT nIDEvent,
UINT nElapse,
void(CALLBACK EXPORT* lpfnTimer)(HWND,UINT,UINT,DWORD));//NULL if message is handled by CWnd Object
CWindow UINT(UINT nIDEvent,UINT nElapse)
& the child class...

TIMERPROC have these parametres : ( HWND hWnd,// handle of window for timer messages
UINT uMsg,/*=WM_TIMER*/
UINT idEvent,// timer identifier
DWORD dwTime)/*current system time*/ TIMERPROC;
GeneralPhone Tones Pin
22-Jan-01 22:19
suss22-Jan-01 22:19 
GeneralRe: Phone Tones Pin
29-Jan-01 9:50
suss29-Jan-01 9:50 
GeneralRe: Phone Tones Pin
4-Jun-01 15:46
suss4-Jun-01 15:46 
GeneralRe: Phone Tones Pin
Alexandru Savescu27-Nov-01 22:52
Alexandru Savescu27-Nov-01 22:52 
GeneralRe: Phone Tones Pin
Anonymous20-May-04 22:35
Anonymous20-May-04 22:35 
GeneralRe: Phone Tones Pin
robbor1814-Aug-05 16:43
robbor1814-Aug-05 16:43 

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.