How to send the cpu sound to my speakers in a c program?

rots17

Distinguished
Jun 18, 2011
1
0
18,510
Hi I am using sound function to generate sounds of certain frequencies.
The sounds generated re coming out from the cpu.
i want them to come out from speakers.
Please suggest me how to do the same.

Here is the code:

#include<iostream.h>
#include
#include<conio.h>
void main()
{
sound(240);
getch();
nosound();
sound(270);
getch();
nosound();sound(300);
getch();
nosound();sound(320);
getch();
nosound();sound(360);
getch();
nosound();sound(400);
getch();
nosound();sound(450);
getch();
nosound();
sound(480);
getch();
nosound();

return;
}
 

Rusting In Peace

Distinguished
Jul 2, 2009
312
0
19,060
By from the CPU I'm guessing you mean it's coming from the motherboard speaker. You're trying to get sound to be emitted by your onboard sound device or via your soundcard.

I don't know the C in question but you probably need to get a handle on the sound device and call the appropriate function by their API.