Can anyone help me put better sound in my OS

OS Design, Theory, and Programming

Moderator: Moderators

Can anyone help me put better sound in my OS

Postby JJinga » Thu Apr 27, 2017 2:42 pm

Its my first shot at programing for sound in my Operating system.I have just a beep sound in it.
Can any one advise on how to improve my code below to have some better tune other than just beep sounds.

mov al, 182 ; meaning that we're about to load
out 43h, al ; a new countdown value

mov ax, 2153 ; countdown value is stored in ax. It is calculated by
; dividing 1193180 by the desired frequency (with the
; number being the frequency at which the main system
; oscillator runs
out 42h, al ; Output low byte.
mov al, ah ; Output high byte.
out 42h, al

in al, 61h
; to connect the speaker to timer 2
or al, 00000011b
out 61h, al ; Send the new value
JJinga
 
Posts: 3
Joined: Sat Nov 28, 2015 10:22 am

Re: Can anyone help me put better sound in my OS

Postby Mike » Wed May 03, 2017 2:21 am

Hello,

Many audio devices support the AC'97 and Intel's High Definition Audio (HDA) standards. The AC'97 specification can be found here. The Intel HDA specification can be found here. The OSDev.org Wiki also provides an overview on both of them (AC'97, HDA.) Of course, if the device does not support either standard, you would need to get a copy of the specific datasheet. We are not aware of any nice tutorial, but you can certainly study code from other projects that have implemented it. If you want an easier time, a lot of devices also support the old SoundBlaster, which has a nice programming guide with example code here.

The PC speaker is very limited - all it can do is produce tones at different frequencies. For anything more advanced, you should implement a proper audio support such as one of the above standards. If you do want to stick with the PC speaker though, there is a well known trick that can be used for making different 8 bit tones. Basically, 00000000 is off, 11111111 is on; 10101010 is medium. Please reference the document here since it describes the algorithm in more detail.
User avatar
Mike
Site Admin
 
Posts: 463
Joined: Sat Oct 20, 2007 7:58 pm


Return to Advanced OS Development

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron