Hi,
I am playing a little with feeding the DAC of my SoundBlaster card with
raw samples that I am trying to time accurately.
The "obvious" way to do such thing is to use DMA transfers and
let the SoundBlaster chip control the sampling. That's not what I am
doing for the moment. I use the SoundBlaster DAC directly and write 8
bit samples to it in real time. Yes, it is not CPU-efficient, does not
allow to play things in background, etc. but please indulge me and
consider this a thought exercise.
So here's the question: Is there any kind of timer available on the PC
that would allow to generate some 8 kHz samples? I mean, besides the
obvious PIT of course. Some hidden VGA register maybe? A way to abuse a
timer in the SoundBlaster or Adlib hardware? Some creative
polling of a port or keyboard controller?
So far, the timers I know about are those:
- VGA VSYNC (tied to screen's refresh rate, ie. 50-60 Hz or so)
- calibrated busy loop (meh)
- PIT (18.2 Hz default, changing it doesn't work under Windows)
- BIOS "system clock" (sourced by the PIT, really)
- TSC (requires a Pentium+ CPU)
- APIC (modern CPUs only)
- CMOS RTC clock (ports 0x70 & 0x71, fixed at 1024 Hz)*
Anything else?
Mateusz
*a pretty nice article about abusing the RTC clock here: https://web.archive.org/web/20150514074601/http://www.nondot.org/sabre/os/files/MiscHW/CMOSTimer.html
So here's the question: Is there any kind of timer available on the PC
that would allow to generate some 8 kHz samples?
- PIT (18.2 Hz default, changing it doesn't work under Windows)
- PIT (18.2 Hz default, changing it doesn't work under Windows)
Changing it works just fine under Windows, as demonstrated by countless >MS-DOS games.
Digging a little deaper, while Windows 9x does let MS-DOS applications
change the PIT timer interval, it doesn't let you set a timer
frequency faster than 1 kHz.
Anything else is likey to not work on Windows and/or not as as wide of
a range of hardware as the PIT or TSC.
I did some archaeology and it appears that so far whenever people
wanted or needed to generate real-time audio data on PCs, they were
simply resorting to PIT reprogramming.
I tested it and it works as expected, although results are quite
jittery due to the relatively poor precision of interrupts firing. DMA transfers are vastly superior in this regard.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 405 |
Nodes: | 16 (3 / 13) |
Uptime: | 53:05:00 |
Calls: | 8,499 |
Calls today: | 12 |
Files: | 13,203 |
Messages: | 5,916,957 |
Posted today: | 1 |