VOGONS

Common searches


First post, by DracoNihil

User metadata
Rank Oldbie
Rank
Oldbie

I have quite a few non game things that can output to PC Speaker in absence of a soundcard, everything from Ken Silverman's MP3 playback in DOS to his Build Engine tech demo. ImpulseTracker and FastTracker 2 can output through PC Speaker and the latter can do two different ways of doing it.

But I've been really curious, what can really push audio out of a real (dynamic\paper cone whatever) speaker? Are there any worthy demonstrations of that?

“I am the dragon without a name…”
― Κυνικός Δράκων

Reply 1 of 14, by Stojke

User metadata
Rank l33t
Rank
l33t

It is just a speaker, all you need is a header for it. CompaQ and HP computers have this feature of an internal speaker.

Note | LLSID | "Big boobs are important!"

Reply 2 of 14, by SquallStrife

User metadata
Rank l33t
Rank
l33t
DracoNihil wrote:

I have quite a few non game things that can output to PC Speaker in absence of a soundcard, everything from Ken Silverman's MP3 playback in DOS to his Build Engine tech demo. ImpulseTracker and FastTracker 2 can output through PC Speaker and the latter can do two different ways of doing it.

But I've been really curious, what can really push audio out of a real (dynamic\paper cone whatever) speaker? Are there any worthy demonstrations of that?

I'm not sure what you're asking.

A speaker is a speaker is a speaker. The "standard" PC speaker as implemented by IBM in 1981 (and probably others before them) is just a garden variety 8 ohm 57mm speaker. They'll vary on quality as all things do, but there'll be ballpark frequency response and distortion properties that will suit most of them.

If maybe you're asking what's the maximum theoretical audio quality you can get using the PWM method?

According to Wikipedia, using the PC Honker in a PWM arrangement effectively gives you a 6-bit DAC. Which isn't terrible, but isn't great. The Intel 8253 imposes a rate limit, but I don't know enough about it to calculate the effective sample rate.

Of course, the higher your playback sample rate, the less CPU time will be available to do other things.

VogonsDrivers.com | Link | News Thread

Reply 3 of 14, by reenigne

User metadata
Rank Oldbie
Rank
Oldbie

The 8253 clock is 1.193MHz (13.125/11), so as a 6-bit DAC your sample rate is 18.643kHz. You can increase the sample rate at the expense of dynamic range (which is a strict quality improvement for properly dithered audio) up to 1-bit 596kHz audio.

However, you don't need to use the 8253 at all - you can bit-bang the speaker using the 8255 PPI which is unclocked so it's only limited by the speed of the CPU. A sufficiently fast CPU could play back 1-bit DSD audio like SACD directly through the PC speaker.

In terms of software demonstrations of PC speaker audio technology, the end credits section of the recent demo 8088 MPH (http://www.pouet.net/prod.php?which=65371) plays back a 4-channel MOD file over the PC speaker at a sample rate of 16.572kHz (synchronized with the DRAM refresh to eliminate jitter). However, it only works properly on a 4.77MHz Intel 8088 machine. Galaxy Player can also play back MOD files over PC speaker, but uses the timer interrupt to output samples at the right time so requires a much more powerful CPU.

Reply 4 of 14, by DracoNihil

User metadata
Rank Oldbie
Rank
Oldbie

reengine understood my question well, and I really appreciate the great response there.

Yeah to better rephrase my question. I'm wondering what the best implementation of "PCM through PC Speaker" exists, quality wise.

Is Galaxy Player related to the same Galaxy that UEngine 1.x games used for audio and module playback? Forgive me if that's a stupid question...

“I am the dragon without a name…”
― Κυνικός Δράκων

Reply 5 of 14, by reenigne

User metadata
Rank Oldbie
Rank
Oldbie
DracoNihil wrote:

Yeah to better rephrase my question. I'm wondering what the best implementation of "PCM through PC Speaker" exists, quality wise.

Programs that use PC speaker PWM for sample playback tend to have pretty similar output in terms of sound quality because almost all of them use the same basic code (in order to be portable to machines of different CPU speed) and similar engineering trade-offs (sample rate vs memory/disk space usage). Programs where you can vary the sample rate (i.e. wave/MP3/tracker players) will tend to win on quality given a fast enough CPU and good enough source material. I don't know if any of them do the proper dithering necessary to get the best quality at the highest sample rates, though.

DracoNihil wrote:

Is Galaxy Player related to the same Galaxy that UEngine 1.x games used for audio and module playback? Forgive me if that's a stupid question...

No, I don't think so. This is much older (circa 1994) - search for glx212.zip to see what I'm talking about.

Reply 6 of 14, by DracoNihil

User metadata
Rank Oldbie
Rank
Oldbie

What kind of CPU speeds would be necessary to drive that 1-bit DSD stuff through bit banging?

“I am the dragon without a name…”
― Κυνικός Δράκων

Reply 7 of 14, by reenigne

User metadata
Rank Oldbie
Rank
Oldbie
DracoNihil wrote:

What kind of CPU speeds would be necessary to drive that 1-bit DSD stuff through bit banging?

Let's see... SACD is 2.8224MHz. I have some code for doing a similar kind of bit-banging on an 8088 which takes about 45 CPU cycles per bit, so you'd need the equivalent of an 8088 running at about 127MHz. Might be possible with a 486/66 or so. Trickiest part is probably trying to get all the bits the same length. There's no hardware timer that fast (and even if there was, interrupt overhead would be a killer) so it's got to be timed by counting CPU cycles, which is harder with more modern CPUs. To avoid jitter you'd have to turn off all interrupts which probably means keeping the entire waveform in memory (~20MB per minute of audio).

Reply 8 of 14, by smeezekitty

User metadata
Rank Oldbie
Rank
Oldbie

The problem with PC speaker sound is it requires a very large amount of CPU usage. Depending on the instructions used, a 486/66 should be much faster than a 8088 at 127MHz.
Here is a list of instructions and how many clock cycles they take: https://zsmith.co/intel.html

Reply 10 of 14, by Jepael

User metadata
Rank Oldbie
Rank
Oldbie

I tried with some old Duron/Athlon machine which still has one ISA slot.
A 64k "rep outsb" done few times in a loop indicates it can do about 630k writes per second to port 61h.
The dumped 64k array contained square wave with 1000 sample period and guitar tuner app on cell phone said about 630 Hz.
The sound was not clean like a pure square wave, it sounded hissy which indicates there is some jitter present.
Disabling interrupts did not clean the jitter, but it did get rid of the timer interrupt causing clicks to the tone.
So in a fast machine with original chips emulated in chipset southbridge, there is some fundamental limit so that you can't get millions of outs per second.
It is possible the emulated speaker port sits on LPC bus, as I also get around 600k writes per second to a parallel port sitting behind a separate super IO chip.

Reply 11 of 14, by MobyGamer

User metadata
Rank Member
Rank
Member
DracoNihil wrote:

Yeah to better rephrase my question. I'm wondering what the best implementation of "PCM through PC Speaker" exists, quality wise.

If you meant "by method", most programers had PWM figured out by 1987, so the obvious examples (ie. Space Racer, games with RealSound like Mean Streets, etc.) all use the same basic PWM method. PWM on the PC was best implemented using timer channels 0 and 2, with 0 (the system timer) firing an interrupt at the desired sample rate; each time it fired, you sent a PCM sample value to PIT 2 which was tied to the speaker output. When PIT 2 got the value, speaker immediately went high, then after the count expired, went low again. Because this is happening at the rate of PIT 0, the PIT 2 manipulation has the effect of manipulating the width of the pulses, hence Pulse Width Modulation (PWM).

The other method was to directly bit-bang the speaker, effectively treating it like a 1-bit PCM device, which earlier titles like Dunzhin used. That method produces very loud audio, but is quite distorted so it's only useful for speech.

I have been planning a PC speaker audio series for about two years but can never find the time to write the text. I've disassembled most significant games with PC speaker digitized audio, from Dunzhin in 1982 up to some titles from the 1990s, and part of the series was going to note which programs used which methods, and how the methods evolved over time. (This was spawned by curiosity into whether or not the RealSound patent should have been issued due to prior art. Long story short: No, it definitely shouldn't have.) I was also going to focus on related topics, such as audio compression methods that are simple enough they can be decompressed and output through the speaker in real time even on a 4.77MHz computer.

Sorry this series isn't done yet, or it would have answered your question...

Reply 12 of 14, by MobyGamer

User metadata
Rank Member
Rank
Member
reenigne wrote:
DracoNihil wrote:

Is Galaxy Player related to the same Galaxy that UEngine 1.x games used for audio and module playback? Forgive me if that's a stupid question...

No, I don't think so. This is much older (circa 1994) - search for glx212.zip to see what I'm talking about.

Actually, they are related. They were both written by the same person, who carried the name over.

Reply 13 of 14, by DracoNihil

User metadata
Rank Oldbie
Rank
Oldbie

Ah I thought so. Galaxy was even used in a MS-DOS title unrelated to the Unreal series apparently. I forgot the name of the game though but it was a graphic adventure of sorts I think.

And I just took a look at the 8088 MPH blog post about PC Speaker MOD playback, really interesting stuff to read.

My motherboard came with a piezoelectric beeper, is it still possible to cannibalize a speaker and wire that up to connect to the same PC Speaker header?

“I am the dragon without a name…”
― Κυνικός Δράκων

Reply 14 of 14, by Scali

User metadata
Rank l33t
Rank
l33t
DracoNihil wrote:

My motherboard came with a piezoelectric beeper, is it still possible to cannibalize a speaker and wire that up to connect to the same PC Speaker header?

Yes it is, I have modified one of my PCs like that once. I had to take off the piezo anyway, because I wanted to run the speaker signal into my Sound Blaster Pro 2.0 mixer.
The piezo-beeper should just run off the standard 5V signal that the speaker is normally connected to, so just a drop-in replacement.

http://scalibq.wordpress.com/just-keeping-it- … ro-programming/