|
-
Apr 16th, 2008, 04:18 AM
#1
Thread Starter
Member
How to play sound EXACTLY from PC Internal Speaker (not from sound card)?!!
Hi all professionals,
Its a great problem:
I have searched too much in VBForums, Planetsourcecode,... and all over the internet, but can't find a solution to make a sound (only a beep!) from internal PC Speaker (located on system motherboard).
There is 2 problems using BEEP Api:
1. If your mixer settings (Windows Volume control), not MUTE the 'PC Speaker', all PC Speaker sounds will play via sound card (even using BEEP api function) and you will hear it from sound card speakers (not internal pc speaker)
2. If you remotely connected to a PC (Remote Desktop with /CONSOLE parameter) all sounds will play from your PC, Not remote PC; and your sound card speakers play sound instead of remote internal PC speaker!!
How can I do it? In DOS old days, we use PORT &h60 or &h61 (i can't remember which one!) to make a bit 0 or 1. and make sound exactly from internal PC Speaker.
Now how can I do it in WIndows XP? Is this only solution to be sure the internal pc speaker sounds? Is this solution performable under Windiws XP (in Win9x easily you can do it by QBasic!)
Thanks a lot
Last edited by fatehi; Apr 16th, 2008 at 04:28 AM.
A.B.Fatehi
Microsoft Certified Professional
-
Apr 16th, 2008, 05:03 AM
#2
Re: How to play sound EXACTLY from PC Internal Speaker (not from sound card)?!!
Declare Function Beep Lib "kernel32.dll" (dwFreq As Integer, _
dwDuration As Integer) As Boolean
You tried this and it does not play from the speaker?
Last edited by sapator; Apr 16th, 2008 at 05:25 AM.
-
Apr 16th, 2008, 06:40 AM
#3
Thread Starter
Member
Re: How to play sound EXACTLY from PC Internal Speaker (not from sound card)?!!
 Originally Posted by sapator
Declare Function Beep Lib "kernel32.dll" (dwFreq As Integer, _
dwDuration As Integer) As Boolean
You tried this and it does not play from the speaker?
Thanks for your reply.
I know BEEP Api.
As I said in the previous post, my problem is BEEP Api function, that is not always sound a beep from internal pc speaker. some times it plays a sound from sound card speakers instead.
I want another solution to sound a beep exactly from internal pc speaker on local machine (the system that the application is ruuning on it!).
A.B.Fatehi
Microsoft Certified Professional
-
Apr 16th, 2008, 06:44 AM
#4
Re: How to play sound EXACTLY from PC Internal Speaker (not from sound card)?!!
If nothing on win api's don't work then you can make a C++ or assembly program that beeps the PC speaker and import it.
(or is it possible to make a qbasic program and import it? That i never thought of )
-
Apr 16th, 2008, 06:50 AM
#5
Thread Starter
Member
Re: How to play sound EXACTLY from PC Internal Speaker (not from sound card)?!!
 Originally Posted by sapator
If nothing on win api's don't work then you can make a C++ or assembly program that beeps the PC speaker and import it.
(or is it possible to make a qbasic program and import it? That i never thought of  )
Yes! But windows XP (and other NT based Windows) prevent direct accessing PORTs! So you can't do this easily. I donno how to directly using PORTs under Windows XP. even may be impossible to do this under WinXP! I donno more!
A.B.Fatehi
Microsoft Certified Professional
-
Apr 16th, 2008, 07:08 AM
#6
Re: How to play sound EXACTLY from PC Internal Speaker (not from sound card)?!!
Good ol assembly
I don't know either... But if c++ can do it somehow different?
Hmmm. Yes i can't think of something else...
-
Apr 18th, 2008, 09:39 AM
#7
PowerPoster
Re: How to play sound EXACTLY from PC Internal Speaker (not from sound card)?!!
My guess is that once the sound card is installed it overrides any output to the internal speaker. Can't recall if there is an interrupt assigned that may be redirected -- to the sound card -- once a board is installed.
-
May 13th, 2008, 03:57 AM
#8
New Member
Re: How to play sound EXACTLY from PC Internal Speaker (not from sound card)?!!
here is how you make the internal speaker beep at a given frequency
// tell timer 2 that we want to modify the count down
send value 0B6h to port 43h
// send the value of the new count down low byte first high byte last
// important that this is done as quickly as possible
send low byte to port 42h
send high byte to port 42h
// connect speaker to timer 2 by setting bits 0&1
in [value],61h
or [value],3 ; set bits 0&1 to connect to timer 2
send value to port 61h
that will make the speaker beep at whatever frequency timer 2 is set to. to stop the speaker from beeping you simply disconnect it from timer 2
// stop the speaker by disconnecting it from timer 2 (clear bits 0&1)
in [value],61h
and [value],0FCh ;clear bits 0&1
send [value],61h
its a good idea to preserve the original value at port 42h after your done
to make the pc speaker make real music is more involved as the speaker can only produce square waves (fully on or fully off) real sound is never so cut and dry so you must stop the speaker at some point between fully on and off this is impossible under XP and under DOS it is required to create your own custom interrupt 8 handler that waits x clocks then disconnects the speaker not an easy task. here is a good link you may be interested in
http://fly.cc.fer.hr/GDM/articles/sndmus/index.html
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|