Thread: Using PC Speaker and NOT the sound card in a console...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    417

    Using PC Speaker and NOT the sound card in a console...

    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.

  2. #2
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    this belongs in windows programming f00l
    hello, internet!

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    417
    Not really, because this is a dos console app.

  4. #4
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    uh huh

    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.
    hello, internet!

  5. #5
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    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.
    PHP and XML
    Let's talk about SAX

  6. #6
    Registered User
    Join Date
    Sep 2002
    Posts
    417
    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().

  7. #7
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    > 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.
    The world is waiting. I must leave you now.

  8. #8
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    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.
    PHP and XML
    Let's talk about SAX

  9. #9
    Registered User
    Join Date
    Sep 2002
    Posts
    417
    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!
    Last edited by Trauts; 01-15-2003 at 01:20 PM.

  10. #10
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    >>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.
    PHP and XML
    Let's talk about SAX

  11. #11
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    >>#include <std_disclaimer.h>

    I can't - it gives me an error

  12. #12
    Registered User Unimatrix139's Avatar
    Join Date
    Jun 2002
    Posts
    55

    ASCII 7

    This may be stupidly wrong and totally invalid, but have you tried this?
    Code:
    #include <stdio.h>
    
    main()
    {
    printf("\a");
    }
    Kree'ta Tau'ri! Chaapa'ai!

  13. #13
    Registered User VBprogrammer's Avatar
    Join Date
    Mar 2002
    Posts
    175
    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.
    VC++ 6

  14. #14
    Registered User
    Join Date
    Feb 2002
    Posts
    98
    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?

  15. #15
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765

    I know it's an old thread, but it's still only half way down the page

    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?
    The world is waiting. I must leave you now.

Popular pages Recent additions subscribe to a feed