piano using frequencies doesn't sound

Hi:

My mechanics waves teacher left an assignment to make a piano using frequencies and I am using Turbo C++, the problem is that it does compile with no errors and all that stuff but the speakers don't sound with the frequency that i put.

I don't know if it's because of windows vista which sucks by the way, here is a little piece of the code:


# include <stdlib.h>
# include <stdio.h>
# include <conio.h>
# include <dos.h>


void main ()
{
int x;
printf("piano in c++ \n ");
printf("give me a number from 0 to 9: ");
scanf("%d", &x);

switch(x)
{
case 1:

sound(440);
delay(2000);
nosound();
break;
}
getch();

}

I don't know what's going on, y tried it on a friend's computer with XP and still got nothing, can someone please help out, I'd really appreciate it.

See ya!!
It is because 4.01+ windows systems don't emulate DOS very well, and a lot of hardware access is forbidden.

Either #include <windows.h> and use the Beep() function
http://msdn.microsoft.com/en-us/library/ms679277(VS.85).aspx

or get a better DOS emulator, like DOSBox
http://www.dosbox.com/

Good luck!
Mmmmmm, now that clears my mind a lot, dang i hate vista, i tried to put xp on my laptop but some drivers are not available for xp, i'm getting a lenovo with xp to solve my issues.

By the way the DOSbox link is not working.

thanks for the advice, see ya
Clear your browser's cache and try again.
(But I still prefer the Beep() solution --it requires much less overhead.)
but Beep uses the internal speakers... how to play a sound in a win32 console application?... a wav-file e.g.?...
> but Beep uses the internal speakers...

...which is what the OP wants.

If you want to play a WAV file
http://www.cplusplus.com/forum/windows/3374/page1.html#msg13952

Hope this helps.
oh, thx... i think i would be better off, reading the posts slowly^^... but i don“t see him using the word "internal speakers" :P... the term speakers - in my opinion- refers to normal desktop speakers^^... sorry for my know-it-all-attitude ^^...
Don't appologize. It has nothing to do with the exact words he used. sound(), delay() and nosound() are old Borland functions to operate the PC beeper. ;-)
aye... but are there any ways to spit out single sounds like with beep() about the box/d speakers?....
Yes, but I've never done it so I don't know how. You need to be able to directly control the soundcard, or generate the output waveform yourself.
Topic archived. No new replies allowed.