| <<< add_16_bytes.ASM | Index | Beep Error Codes >>> |
Command
dumpbin /exports C:\Windows\System32\kernel32.dll
prints a list of windows API functions available to a console application.
The following C++ program demonstrates a loop of 500-millisecond Beeps with rising tone frequency.
One of the APIs is a Beep function, which generates simple tone using the sound card.
The Beep call doesn't wait for the sound card to complete the playback; the tone is generated asynchronously. To synchronize frequency display with the sound, the program pauses by calling Sleep, which waits for the duration of the tone in milliseconds.
The std::flush
output manipulator is making std::cout display the output immediately.
Alltogether the combination of the above steps simulates a synchronous (sequential) output of the frequency and sound.
#include <iostream>
#include <windows.h>
int main()
{
int ms = 500; // sound duration in milliseconds
// frequency (hertz) must be in range 37 through 32767
for ( int frequency = 500; frequency < 2000; frequency += 200 ) {
// display sound frequency in hertz before each tone.
std::cout << frequency << " " << std::flush;
Beep( frequency, ms );
Sleep( ms );
}
return 0;
}
| <<< add_16_bytes.ASM | Index | Beep Error Codes >>> |