Re: PC speaker driver (fwd)

From: David Woodhouse (dwmw2@infradead.org)
Date: Wed May 10 2000 - 09:10:25 EST


volodya@mindspring.com said:
> Most computers that I saw have a small nice speaker (the sort you
> could see in radios couple decades ago). The problem however is not
> with speaker but with the way it is driven (on and off if I remember
> correctly). That is the speaker can either be told to emit a square
> wave at a certain frequency (which is used for beeps) or you can drive
> that square wave with cpu. Hence unlike sound cards that have from 256
> to 65536 gradations (or more) pc speaker has 2.

True. The speaker is attached to a single digital output line from a
one-shot timer, IIRC.

However, we're not quite as limited as you suggest. As you can expect a
small amount of capacitance, you can divide your time into small units,
and for each time unit, you allow the line to be set high for a percentage
of that time proportional to the desired analogue signal level at that
point.

As the speaker is actually connected to the output of a one-shot timer, life
is made relatively easy for us. The default setup of the PC speaker driver
is to set up an 18.4 KHz timer interrupt, then at each interrupt, you set
the one-shot timer for a length proportional to the line level you desire
at that time.

It's far from perfect quality, but it's quite effective.

However, it does involve nicking the 8253 timer from the system interrupt
and reprogramming it for 18KHz, then calling the old system interrupt
routine once in every 183(ish) times our new IRQ handler is called. This
isn't particularly clean, so it'd be nice to shift the system timer onto
the RTC when the PC speaker driver is in use.

--
dwmw2

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon May 15 2000 - 21:00:16 EST