please any body to help me on how to add sound or
go to the extent of adding a sound in a written code...
im on a project to write a code of a rocket launch which counts from 9,8,7,6,5,4,3,2 & 1 to fire that rocket of which i am done with that but how to add the sound to after the count down is my problem now....
If you decide on Qt, the soundEffect object is used for small sound effects like a button getting pressed gets a small confirmation noise. There are several media-player type objects for larger media files.
Each of these libraries have their own quirks, so I can't recommend one over the other. WinApi might be the simplest to get started using, but then your program won't be cross-platform... SFML might be the easiest cross-platform option.
#include <iostream>
#include <cmath>
#include <windows.h>
usingnamespace std;
void sound( double freq, int ms )
{
int ifreq = freq + 0.5; // round to nearest int
Beep( ifreq, ms );
}
int main()
{
double A = 440.0; // tuning fork A;
double semitoneFactor = pow( 2.0, 1.0 / 12.0 ); // factor for a semitone
int steps[] = { 2, 2, 1, 2, 2, 2, 1 }; // intervals in a major scale
int ms = 500; // duration in milliseconds
double freq = A;
sound( freq, ms );
for ( int i = 0; i < 7; i++ )
{
for ( int s = 1; s <= steps[i]; s++ ) freq *= semitoneFactor;
sound( freq, ms );
}
}