Piano programming in C

Intel / Xyz
January 28, 2009 at 00:12:42
Specs: Windows XP, Pentium 4
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.

See More: Piano programming in C

Report •

February 8, 2009 at 10:42:19
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
Sleep(1000);//Pauses the program for 1 second


The 'Beep(,);' function will sound a frequency in

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).

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!

Report •
Related Solutions

Ask Question