Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I want to develop a ‘Piano’ using C/C++/VBasic. But, I can not generate sound. I will be very grateful if anyone suggest me ‘how can I generate a sound of a required frequency & amplitude?’ such as ‘sa’ or ‘re’, etc. Actually, is there any function in C/C++/VBasic which has minimum two input arguments for select frequency and amplitude of a sound?
I am anxiously waiting for kind co-operation.

I had the very same problem, luckily I found a
solution. Although I am still learning c++!Here is an example:
#include "iostream.h"
#include "windows.h"using namespace std;
int main()
{
Beep(440,100);//This is note A
Beep(495,100);//B
Beep(528,100);//C
Beep(594,100);//D
Beep(660,100);//E
Beep(704,100);//F
Beep(783,100);//G
Sleep(1000);//Pauses the program for 1 second
}Overview--
The 'Beep(,);' function will sound a frequency in
hertz.In the 'Beep(100,100);' function their are 2 numbers,
the first number is the frequency. And the second
number is the time it lasts in milliseconds. So 1000 milliseconds will be 1 second.The frequency in hertz is 1(really high pitched) to
about a few thousand (really low).NOTE-
The noise that will sound will come from inside the
computers case, from the computers pizo-electric
speaker on its motherboard.(not all computers have
one, I think). You can't change the volume(I think).
This Beep function was is still used, normally as your
computer tuns on it will beep!

![]() |
DOS - Replace Environment...
|
Need help with backup bat...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |