Showing posts with label sound function in c. Show all posts
Showing posts with label sound function in c. Show all posts

Tuesday, 3 February 2015

Sound in C++

Structure of the problem requirements

The sound exist in windows.h library in C++ program.The Beep function is used to create the sound and this function take 2 parameters. The one parameter take the frequency and the second take the time.

Source Code 

#include<iostream>
#include<windows.h>
using namespace std;
int main ()
{
top : int choice = 0;
cout<<"\t \t \t LEP Tutorials \n \n";
cout<<"\t \t 1. Small Sound \n \n ";
cout<<"\t \t 2. Loud Sound \n \n ";
cout<<"\t \t 3. Very Loud Sound \n \n ";
cout<<"Enter Your Choice to Play the Sound \n \n ";
cin>>choice;
if (choice == 1)
{
cout<<" Small Sound Played \n \n ";
Beep (500,500);
}
if (choice == 2)
{
cout<<" Loud Sound Played \n \n ";
Beep (1000,1000);
}
if (choice == 3)
{
cout<<" Very Loud Sound Played \n \n ";
Beep (3000,3000);
}
else
{
goto top;
}
}

Output of the Program

Sound in C++