Hi Jimmy,
I found some old code snippets and put them together to an example that works with Visual C++ 6.
I am sure there is an easier way but this one works however.
#include <conio.h>
void sound(unsigned);
void nosound(void);
int main(void)
{
sound(440); // play "a"
for(unsigned long l=0;l<1000000;++l); // wait some time
nosound(); // stop beeping
return 0;
}
void sound(unsigned frequency) // freq = Hz
{
const long F = 0x1234dc; // clock frequency
unsigned t = F / frequency;
_outpw(0x43,0xb6);
_outpw(0x42,t & 0xff);
_outpw(0x42,t >> 8);
_outpw(0x61,_inpw(0x61) | 3);
}
void nosound(void) // turn off speaker
{
_outpw(0x61,_inpw(0x61) & ~3);
}
You may change the frequency and the pause to get better results. Hope this helps.
-- ralf