Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

As of next Tuesday, C will be flushed in favor of COBOL. Please update your programs.


devel / comp.os.msdos.programmer / is there a high-frequency timer available on the PC? (besides the PIT)

SubjectAuthor
* is there a high-frequency timer available on the PC? (besides theMateusz Viste
+- is there a high-frequency timer available on the PC? (besidesJohann Klammer
`* is there a high-frequency timer available on the PC? (besides theRoss Ridge
 `* is there a high-frequency timer available on the PC? (besides theRoss Ridge
  `* is there a high-frequency timer available on the PC? (besidesMateusz Viste
   `- is there a high-frequency timer available on the PC? (besides the PIT)Alexei A. Frounze

1
is there a high-frequency timer available on the PC? (besides the PIT)

<tdieam$4gt$1@gioia.aioe.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=634&group=comp.os.msdos.programmer#634

  copy link   Newsgroups: comp.os.msdos.programmer
Path: i2pn2.org!i2pn.org!aioe.org!xVfaAYnW1Uimsb6QZpGQeg.user.46.165.242.75.POSTED!not-for-mail
From: mateusz@xyz.invalid (Mateusz Viste)
Newsgroups: comp.os.msdos.programmer
Subject: is there a high-frequency timer available on the PC? (besides the
PIT)
Date: Wed, 17 Aug 2022 12:01:58 +0200
Organization: . . .
Message-ID: <tdieam$4gt$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="4637"; posting-host="xVfaAYnW1Uimsb6QZpGQeg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
 by: Mateusz Viste - Wed, 17 Aug 2022 10:01 UTC

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

Re: is there a high-frequency timer available on the PC? (besides the PIT)

<tdj6v2$1h8$1@gioia.aioe.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=635&group=comp.os.msdos.programmer#635

  copy link   Newsgroups: comp.os.msdos.programmer
Path: i2pn2.org!i2pn.org!aioe.org!jMQFYg/ec8vT6zD9+rskUA.user.46.165.242.91.POSTED!not-for-mail
From: klammerj@NOSPAM.a1.net (Johann Klammer)
Newsgroups: comp.os.msdos.programmer
Subject: Re: is there a high-frequency timer available on the PC? (besides
the PIT)
Date: Wed, 17 Aug 2022 19:02:14 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tdj6v2$1h8$1@gioia.aioe.org>
References: <tdieam$4gt$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="1576"; posting-host="jMQFYg/ec8vT6zD9+rskUA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Icedove/24.5.0
X-Notice: Filtered by postfilter v. 0.9.2
 by: Johann Klammer - Wed, 17 Aug 2022 17:02 UTC

On 08/17/2022 12:01 PM, Mateusz Viste wrote:
> 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
>
some have what they call a HPET, but Idunno if it's available on your specific box. or
in portspace.
https://en.wikipedia.org/wiki/High_Precision_Event_Timer

Re: is there a high-frequency timer available on the PC? (besides the PIT)

<tdoa0p$1831$1@gioia.aioe.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=640&group=comp.os.msdos.programmer#640

  copy link   Newsgroups: comp.os.msdos.programmer
Path: i2pn2.org!i2pn.org!aioe.org!KXbBc4ULTQkOrJWDYZpgOA.user.46.165.242.91.POSTED!not-for-mail
From: rridge@csclub.uwaterloo.ca (Ross Ridge)
Newsgroups: comp.os.msdos.programmer
Subject: Re: is there a high-frequency timer available on the PC? (besides the
PIT)
Date: Fri, 19 Aug 2022 15:25:13 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <tdoa0p$1831$1@gioia.aioe.org>
References: <tdieam$4gt$1@gioia.aioe.org>
Injection-Info: gioia.aioe.org; logging-data="41057"; posting-host="KXbBc4ULTQkOrJWDYZpgOA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: rridge@csclub.uwaterloo.ca (Ross Ridge)
 by: Ross Ridge - Fri, 19 Aug 2022 15:25 UTC

Mateusz Viste <mateusz@xyz.invalid> wrote:
>So here's the question: Is there any kind of timer available on the PC
>that would allow to generate some 8 kHz samples?

Yes, the PIT. You can't generate a 8000 kHz timer exactly, but you can
come close enough (8008 Hz).

> - 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. Try Star Control 2 for example, it uses tracker based
music, mixed in real-time on the CPU on most soundcards. Probably a
lot like what you're trying to do.

One important thing do is to chain the original BIOS handler at the rate
it expects. The easest way to do this it add your PIT reload value
(149 for 8kHz if I've done my math correctly) to a 16-bit variable on
every interrupt and then call the old handler when it overflows.

--
l/ // Ross Ridge -- The Great HTMU
[oo][oo] rridge@csclub.uwaterloo.ca
-()-/()/ http://www.csclub.uwaterloo.ca:11068/
db //

Re: is there a high-frequency timer available on the PC? (besides the PIT)

<tdop79$1s7f$1@gioia.aioe.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=641&group=comp.os.msdos.programmer#641

  copy link   Newsgroups: comp.os.msdos.programmer
Path: i2pn2.org!i2pn.org!aioe.org!KXbBc4ULTQkOrJWDYZpgOA.user.46.165.242.91.POSTED!not-for-mail
From: rridge@csclub.uwaterloo.ca (Ross Ridge)
Newsgroups: comp.os.msdos.programmer
Subject: Re: is there a high-frequency timer available on the PC? (besides the
PIT)
Date: Fri, 19 Aug 2022 19:44:41 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <tdop79$1s7f$1@gioia.aioe.org>
References: <tdieam$4gt$1@gioia.aioe.org> <tdoa0p$1831$1@gioia.aioe.org>
Injection-Info: gioia.aioe.org; logging-data="61679"; posting-host="KXbBc4ULTQkOrJWDYZpgOA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: rridge@csclub.uwaterloo.ca (Ross Ridge)
X-Notice: Filtered by postfilter v. 0.9.2
 by: Ross Ridge - Fri, 19 Aug 2022 19:44 UTC

Mateusz Viste <mateusz@xyz.invalid> wrote:
> - PIT (18.2 Hz default, changing it doesn't work under Windows)

Ross Ridge <rridge@csclub.uwaterloo.ca> wrote:
>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. Still this is probably your best bet if you want a
wide range of hardware support and don't mine sacrificing Windows support.

Otherwise, your next best option is the Pentium TSC, but in addition to
not working on earlier processors, using it on certain newer processors
can be tricky. You wouldn't have to worry about different cores of
a multi-core CPU keeping different counts, but it might break an CPUs
with dynamically changing frequencies and that don't support the newer
frequency invariant TSC.

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.

--
l/ // Ross Ridge -- The Great HTMU
[oo][oo] rridge@csclub.uwaterloo.ca
-()-/()/ http://www.csclub.uwaterloo.ca:11068/
db //

Re: is there a high-frequency timer available on the PC? (besides the PIT)

<tdor27$8qs$1@gioia.aioe.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=642&group=comp.os.msdos.programmer#642

  copy link   Newsgroups: comp.os.msdos.programmer
Path: i2pn2.org!i2pn.org!aioe.org!xVfaAYnW1Uimsb6QZpGQeg.user.46.165.242.75.POSTED!not-for-mail
From: mateusz@xyz.invalid (Mateusz Viste)
Newsgroups: comp.os.msdos.programmer
Subject: Re: is there a high-frequency timer available on the PC? (besides
the PIT)
Date: Fri, 19 Aug 2022 22:16:07 +0200
Organization: . . .
Message-ID: <tdor27$8qs$1@gioia.aioe.org>
References: <tdieam$4gt$1@gioia.aioe.org>
<tdoa0p$1831$1@gioia.aioe.org>
<tdop79$1s7f$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="9052"; posting-host="xVfaAYnW1Uimsb6QZpGQeg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
 by: Mateusz Viste - Fri, 19 Aug 2022 20:16 UTC

2022-08-19 at 19:44 -0000, Ross Ridge wrote:
> 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.

Not very useful for audio generation. :)

> 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.

Thanks, that's indeed what I think as well. I was silently hoping for
some exotic "under the hood" tricks like "reading port x or y takes
between 33-37 microseconds on all PCs" or something alike. Yes, wishful
thinking, I know.

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.

Mateusz

Re: is there a high-frequency timer available on the PC? (besides the PIT)

<0aab2011-49a9-4a8c-918e-df5e548f4c76n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=643&group=comp.os.msdos.programmer#643

  copy link   Newsgroups: comp.os.msdos.programmer
X-Received: by 2002:a05:620a:4310:b0:6ac:f9df:178d with SMTP id u16-20020a05620a431000b006acf9df178dmr7322684qko.773.1660969227651;
Fri, 19 Aug 2022 21:20:27 -0700 (PDT)
X-Received: by 2002:a05:6870:148c:b0:10e:aeeb:8e1a with SMTP id
k12-20020a056870148c00b0010eaeeb8e1amr8023255oab.133.1660969227413; Fri, 19
Aug 2022 21:20:27 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.os.msdos.programmer
Date: Fri, 19 Aug 2022 21:20:27 -0700 (PDT)
In-Reply-To: <tdor27$8qs$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=98.47.8.185; posting-account=r_UqYQoAAADroB0Qe_EzH25J5Oyuce4G
NNTP-Posting-Host: 98.47.8.185
References: <tdieam$4gt$1@gioia.aioe.org> <tdoa0p$1831$1@gioia.aioe.org>
<tdop79$1s7f$1@gioia.aioe.org> <tdor27$8qs$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0aab2011-49a9-4a8c-918e-df5e548f4c76n@googlegroups.com>
Subject: Re: is there a high-frequency timer available on the PC? (besides the PIT)
From: alexfrunews@gmail.com (Alexei A. Frounze)
Injection-Date: Sat, 20 Aug 2022 04:20:27 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1789
 by: Alexei A. Frounze - Sat, 20 Aug 2022 04:20 UTC

On Friday, August 19, 2022 at 1:16:09 PM UTC-7, Mateusz Viste wrote:
.....
> 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.

At one point I looked deeper into it and discovered that part of the
jitter was due to SMIs.

Alex

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor