Is there a way to make the computer beep without writing a fully fledged sound driver (like write to some port or something) ? Help is appreciated...
Also... I found the realmode way to do it with int 21h... I need a way that works without BIOS interrupts..
Thanks in advance.
How to make them computer beep?
Re:How to make them computer beep?
The system speaker is connected to the PIT. Try searching the internet for ways to reprogram the PIT and to which port it's connected (don't have any books handy right now).Guest wrote: Is there a way to make the computer beep without writing a fully fledged sound driver (like write to some port or something) ? Help is appreciated...
Also... I found the realmode way to do it with int 21h... I need a way that works without BIOS interrupts..
Thanks in advance.
Re:How to make them computer beep?
Hi,
For the PC speaker, there's a 2 bits in I/O port 0x61:
By programming PIT channel 2 and then setting bit 0, you can produce monotonic sounds (a beep). You can initialize PIT channel 2 once during boot and then set/clear bit 0 set get the same sound every time, or you could reprogram the PIT channel each time to allow for different frequency sounds.
For information on programming the PIT, see:
http://www.osdev.org/osfaq2/index.php/PIT
Unfortunately, some computers don't have a PC speaker at all, some (most desktops) use small cheap speakers and some use smaller cheaper peizo's (which have problems generating low frequency sounds) - there's no way to detect what hardware's present or predict what it will sound like.
Cheers,
Brendan
For the PC speaker, there's a 2 bits in I/O port 0x61:
- Bit 0: Connect speaker to PIT channel 2 if set
Bit 1: Speaker state
By programming PIT channel 2 and then setting bit 0, you can produce monotonic sounds (a beep). You can initialize PIT channel 2 once during boot and then set/clear bit 0 set get the same sound every time, or you could reprogram the PIT channel each time to allow for different frequency sounds.
For information on programming the PIT, see:
http://www.osdev.org/osfaq2/index.php/PIT
Unfortunately, some computers don't have a PC speaker at all, some (most desktops) use small cheap speakers and some use smaller cheaper peizo's (which have problems generating low frequency sounds) - there's no way to detect what hardware's present or predict what it will sound like.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re:How to make them computer beep?
Code: Select all
;----------------------------------;
; PC-speaker; beep ;
;----------------------------------;
beep:
push eax
in al, 0x61 ; turn the speaker on.
or al, 3
out 0x61, al
;; delay for 150ms or something here...
in al, 0x61
and al, 0xFC ; some do 0xFD, some 0xFC... :/
out 0x61, al
pop ecx
ret