PDA

View Full Version : Using PC Speaker and NOT the sound card in a console...



Trauts
01-10-2003, 07:48 PM
Is there a way to make windows think there is no sound card, so that I can make sure using the Beep(Hz,Length) function (MVC++ 6.0 on Windows XP) sends it to the PC Speaker instead of the sound card? the help file says that if a sound card is present that it sends the code to the sound card, so if someone has a sound card I cannot play tones with beep.

moi
01-11-2003, 12:04 PM
this belongs in windows programming f00l

Trauts
01-11-2003, 12:54 PM
Not really, because this is a dos console app.

moi
01-11-2003, 05:29 PM
uh huh :rolleyes:

alright then, ill assume your ignorant retort is right and give you the answer for a dos console app, which by the way, has NO bearing at all on what you're actually doing. use outportb() to control the PC speaker directly.

now sooner or later, you'll realize that msdn refrences no outportb(), windows xp doesnt let you access hardware directly, and what you're really writing is a win32 console app. when that happens, come back here for help.

Waldo2k2
01-12-2003, 01:38 AM
moi, while you are right on all counts, you need to take it easy on him.
He can write a pure DOS app (using something like turbo C) and put command.com in his root. That will have the power to do what he wants. But it can't be run from xp, compiled by msvc. But there are ways such as the above to get around all that.

Trauts
01-13-2003, 09:35 AM
All right, I'm still used to having 98.

How can I get it to work in XP, then? Does outportb() only work for the console, or will it let me access the speaker? Also, I don't seem to have outportb().

Shadow
01-14-2003, 12:15 PM
> Not really, because this is a dos console app.
There's a difference. Console, is console. A dos representation presented by windows. True DOS, is commonly 6.22 or 7. A full operating system that some versions of windows, in turn, can be executed from. I have DOS 6.22, Windows 95, Windows 98SE, Windows Home and Windows XP Professional Edition(with all packs) so I somewhat know there's a difference.

> Is there a way to make windows think there is no sound card
> How can I get it to work in XP
I think your terms are messed up.

If you want true DOS, use the line of Turbo compilers. If you want windows, use mingW or MVC++.

For DOS make sure you have, say, DOS 6.22 on your hard disk and you boot to that operating system before executing your program.

Windows XP is picky about running DOS programs. I have about 50 DOS games, and Windows XP bombs half of them.

Waldo2k2
01-14-2003, 08:48 PM
To add:
16 bit apps (true DOS) wreak havoc in xp. They've always crashed for me (except for extremely simple ones that only print text). you may get lucky, and you may render your windows useless...it's pretty much russian roullete. Do like shadow said, load an true version of DOS onto your computer (or if you can't get your hands on a copy try linux, it's free and I'm sure it will be able to do what you want). Boot from that and run the program, don't do it from xp under any circumstance....trust me.

Trauts
01-15-2003, 09:36 AM
If someone would please move this to the windows board, that would be great.

I was wrong about the problem. Its not my sound card, it is the fact that I cannot directly access the PC Speaker because of security (can't directly access hardware). How can I get around this? Is there a library or something that would make it work?

Thanks!

Waldo2k2
01-15-2003, 02:26 PM
>>How can I get around this? Is there a library or something that would make it work?

You can't get around it, that's the nature of windows, there's no library. If you want to get it to work, get linux.

-KEN-
01-15-2003, 06:05 PM
>>#include <std_disclaimer.h>

I can't - it gives me an error :)

Unimatrix139
02-13-2003, 02:24 PM
This may be stupidly wrong and totally invalid, but have you tried this?


#include <stdio.h>

main()
{
printf("\a");
}

VBprogrammer
02-14-2003, 02:43 PM
The only way I can think of doing it in pure Windows would be to write a VxD driver in Assembly see http://spiff.tripnet.se/~iczelion/tutorials.html for more details.

scott27349
02-17-2003, 08:06 AM
how come i can use this?

#include <iostream>
using namespace std;

int main()
{
cout<<"\a,\a,\a,\a";
return 0;
}

and it works in win 2000 and xp?

Shadow
02-24-2003, 04:27 PM
how come i can use this?
#include <iostream>
using namespace std;
int main()
{
cout<<"\a,\a,\a,\a";
return 0;
}
and it works in win 2000 and xp?What compiler did you do that with?

Trauts
02-24-2003, 04:47 PM
I found the problem with Beep() was I have no PC speaker... which is very weird.

Don't buy compaqs if you like PC speakers.

Beep() DOES work fine on XP... tried it on another machine.

scott27349
02-24-2003, 07:12 PM
MS Visual studio 6

Frobozz
03-11-2003, 08:12 AM
You can't get around it, that's the nature of windows, there's no library. If you want to get it to work, get linux.

You don't neccessarily have to go to the point of using Linux. You could just use a virtual machine like Bochs. It's free and can allow you to run pure DOS on WinXP. It's just a pain to get working.

http://http://bochs.sourceforge.net/ (http://bochs.sourceforge.net/)

DavidP
03-12-2003, 09:29 AM
i cant believe all of you! you dont even know how to make the pc speaker beep!

there is a simple header file called dos.h, it has a function in it called sound() and nosound().

it sends data to the pc speaker.

the syntax is:

sound ( Hz )
nosound ( )
delay ( milliseconds )

Example:

#include <dos.h>

int main ( void )
{
sound ( 100 ); //100 Hz sound
delay ( 5000 ); //play the sound for 5 seconds
nosound ( ); //stops sound
return 0;
}

Trauts
04-09-2003, 08:52 PM
Originally posted by DavidP
i cant believe all of you! you dont even know how to make the pc speaker beep!

there is a simple header file called dos.h, it has a function in it called sound() and nosound().


I know this is an old post, but I just got access to this site at home again... my firewall was blocking it and I just figured it out. I want to point out that MVC++ does NOT have those functions, you have to use beep().