pcspeaker outports//inports ? How to

Started by
2 comments, last by NexusOrganicus 20 years, 11 months ago
Hi gurus need some help about making sounds with the pc speaker maybe you could tell me how ? ore you have a link for me where i can read throuh ? I remember that there are some strange ports outport and inport but i don´t know the exact hexa dezi ________ thanks nxo
_______D___
Advertisement
i forgot to say that i work with borland c/c++
and only under DOS
sry
nXo
_______D___
http://www.ddj.com/ftp/1996/1996.05/directio.zip/TSTIO/TSTIO.C

all i had off hand.
basically you need to get very cozy with the intel 8254 PIT (programmable interutp timer) or atleast ports 0 and 2.

you need to then output the frequency of the sound to timer port2.

the freq is set in hertz, (the basis for a divsor is, 1193180hz, 4.77/4mhz)
the output value should be 1193180 / hz. (this of course gives you the cycle rate in seconds (or tiny fraction thereof), which is important, becuase the switcing is done by a timer)

out 43h, 0xb6 (10100110b)the reason for this (or more accuratly the meaning of the bits) is explained http://www.geocities.com/SiliconValley/Sector/7256/tutor/MHEART.TXT

to turn the speaker on you need to binary or port 61h with 0x03
in al, 61h
or al, 0x03
out 61h, 0x03

to turn it off you clear those bits.
mov bl, 0x03
not bl
and al, bl


[edited by - Freidog on April 29, 2003 5:28:24 AM]
oh thank goodness somebody answered
i sat all night searchig the net for some tutorials about the pc speaker
thank you for your advice
i´ll try it in a second
thanks again
NxO
_______D___

This topic is closed to new replies.

Advertisement