• Please review our updated Terms and Rules here

Please help me to play high-quality audio on XT/286 machine

Nope, I'm referring to rallen's improved SOUND4 attachment. Have a look at the whole thread, there's 2 ways of driving the speaker for digitized sound, 1-bit and 8-bit. And I kind of hate to repeat myself all the time.
 
Nope, I'm referring to rallen's improved SOUND4 attachment. Have a look at the whole thread, there's 2 ways of driving the speaker for digitized sound, 1-bit and 8-bit. And I kind of hate to repeat myself all the time.
Oh ok, well that makes your point clearer. The files I made would never make it into software if they were 8 times larger so there was only one way to do it and get paid - all on or all off - I was paid $100 a phrase - I would record several versions for each. I can tell you that for a starving grad student to be getting that cash at that time, for playing around was a nice hit.

I know nothing about "rallens improved sound4" as these issues are little more than memories from a loooooong time ago. Just thought you might be interested in it for what I recall was going on at the time.
 
It's good enough with some background whine. You won't get the loudness of 1-bit PWM, then again, not the distortion either, which is what you don't want. Unless you're playing loud screams, wacky gunshot noises or Austrian painter's fits of rage. I have a video of that too, but I won't risk the banhammer here. :)
Haha, yeah, let's not risk :LOL:
I wonder if making 1 bit of technique to play high-quality sound is possible. Logically speaking, should switching the speaker on and off at up to 10 kHz be enough to play pretty much anything?

Note that the PCjr only has a small piezospeaker on the mainboard, so its sound is amplified via the monitor. How the piezospeaker sounds by itself can be heard in the last 2 seconds of the video when I turn the volume all the way down. A 5150 or XT has a 1/2-watt classic voice coil speaker, which is louder than a piezospeaker itself - but it's still not amplified unlike what's in the monitor of the PCjr. If you want to experiment I posted some details in my post above, on how to construct a simple "amplifier" (more precisely a switch) with 1 transistor and a 7404 gate, even if the mainboard has a small piezo speaker. But then again, you'll fall down the rabbit hole of reinventing a DAC or a whole sound card in the process. Have a look at the Covox Speech Thing or a Disney Sound Source. Printer port in, speaker sound out - and of better quality and loudness than what comes from the mainboard. I have actually used this circuit to diagnose a faulty parallel port card that failed to allocate an I/O address - by listening to "pops" in the speaker during BIOS POST.
Oh, wow! Okay, that's probably beyond my tech-hardware knowledge but sounds cool! :)
 
rallen said:
I wonder if making 1 bit of technique to play high-quality sound is possible.

Sadly I don't think so, it just doesn't have enough resolution - it's always speaker hard on or off. No dynamics to the sound, and since it's constant amplitude square waves, the resultant distortion from hard clipping.
If you take a look at the source code of PCM2PWM.EXE in my "Tom and Jerry" example you will notice that each byte of the input PCM sample is converted to a bit of 0 or 1 if the current amplitude (instantaneous volume level of the sample) is below 127 or above, i.e. it splits it right in the middle of the wave (the maximum value of a byte is 255).
This is the 14kHz squarewave visualized - it's strictly loud on or off - unlike programming the channel 2 LSB each time IRQ0 is fired, that you do for 8-bit sampling. Compare this to the original TOMJERRY.PCM:

//edit: and when I come to think of it, to further increase the sound "fidelity" you could try to program both LSB and MSB of the timer channel 2 in your ISR, in one go, and use a 16bit sample. The 8253 PIT has 16-bit counters you know :) I.e. lodsw, out port,al, mov al,ah, out port,al. You will need to indicate that you're writing both LSB and MSB the same way you do when programming the sample rate on channel 0 (timer ISR).
Just beware that an uncompressed 16bit mono sample will be, at the same sampling rate and length, be twice in size as the 8-bit one, and sixteen times in size than a 1-bit sample. Remember that in x86 real mode you're stuck to 64K segments, and if you want to access more, you need to compile your application to DOS .EXE and do the segmentation math. On a 386 and above, you can turn unreal mode on by modifying the segment descriptors, getting rid of this boundary, or go straight to protected mode - making your app incompatible with your original approach (the 286 and XT) in one blow. :)
 

Attachments

  • TOMJERRY_PWM.zip
    3.4 KB · Views: 1
Last edited:
I have said:
you could try to program both LSB and MSB of the timer channel 2 in your ISR, in one go

Well, so I thought. If I wire in an unsigned 16bit mono sample and program the speaker timer output channel with 16 bit values each IRQ0 tick, then the result is a complete silence from the speaker. If I switch the endianness or use signed PCM without changing the code, then there's some crackling going on, so it must be doing something - but that's about it. Now, the PCjr also contains an SN76489 for 3 squarewaves and 1 noise generator, like the later Tandy 1000 or Sega, but there were past experiments to play digitized sound over that already. But I'm no sound expert, my knowledge ends somewhere around recording Hello World onto an Edison wax cylinder.

Also, the fastest way to detect a keypress, without slowing down the play routine for the 8088 by calling INT 16h, or hooking IRQ1 which will mess up the Junior due to its unorthodox wireless keyboard handling, is to compare pointers to the cyclic keyboard buffer queue in the BIOS BDA. If these two point to the same offset, then there's no keypress - or else adiós to the DOS prompt.

Oh, and the sound snippet in the experiment below is the "Panzermensch". :)
 

Attachments

  • PANZERMENSCH.ZIP
    193.2 KB · Views: 4
Last edited:
Stumbled on this thread. I was part of writing Pinball Fantasies on PC, we did 4 channel mixed music possible to play on speaker. On a 4.77 it is not possible by interrupt driven routine, though probably possible with just a loop, we were not interested in 4.77 PCs then.

What I remember was that we made "boost tables" tweaking the speaker to perform its best, sacrificing the dynamics to get higher sound.

I do not remember if it works to play with internal speaker on a 8MHz AT, I think so, has such a machine just besides me now, but not hooked up. It though works perfectly to play with a sound blaster and 4 channel music. Internal speaker eats a bit more processor due to the interrupt.

I remember that some PCs had just a small piezo element on the MB, some had a good speaker. If you hooked up a bigger speaker and some simple filtering the internal speaker sound became pretty good. As it is not "pure" PWM, the interrupt is due to performance reasons set up to start the same time, so the PWM is not centered, thus creating a hearable tone in the same frequency as the sample rate. I remember we talked about try to have a dynamic interrupt, but for other reasons this was not possible. If just making a program only playing sound on a 286, it is probably possible to tweak to better sound in that respect.

It is fun to see that some people still coding intel assembly language! :D
 
Well, so I thought. If I wire in an unsigned 16bit mono sample and program the speaker timer output channel with 16 bit values each IRQ0 tick, then the result is a complete silence from the speaker. If I switch the endianness or use signed PCM without changing the code, then there's some crackling going on, so it must be doing something - but that's about it. Now, the PCjr also contains an SN76489 for 3 squarewaves and 1 noise generator, like the later Tandy 1000 or Sega, but there were past experiments to play digitized sound over that already. But I'm no sound expert, my knowledge ends somewhere around recording Hello World onto an Edison wax cylinder.

Also, the fastest way to detect a keypress, without slowing down the play routine for the 8088 by calling INT 16h, or hooking IRQ1 which will mess up the Junior due to its unorthodox wireless keyboard handling, is to compare pointers to the cyclic keyboard buffer queue in the BIOS BDA. If these two point to the same offset, then there's no keypress - or else adiós to the DOS prompt.

Oh, and the sound snippet in the experiment below is the "Panzermensch". :)
May I ask which assembler you use to compile the code? :)
I've tried yasm, tasm, masm, nasm, fasm and none of them was able to compile the sources from your post above :LOL:
 
It's FASM. What kind of errors do you get?
 

Attachments

  • f.png
    f.png
    8.2 KB · Views: 2
Last edited:
It's FASM. What kind of errors do you get?
With FASM it compiles just fine.
However, I've noticed that even 8-bit version (that I guess works properly on your side) doesn't sound quite right on the emulator.
Or maybe I don't know how it is expected to sound. I've played the video on YouTube and don't seem to hear such a section.
Is this how it sounds on your end?
 

Attachments

  • panzer.mp4
    346.2 KB
"Uh... uhh.... Hwat we got heer is.... failure to emulate"... :)

Of course not.

Try switching to "rate" instead of "square wave" generator for channel 0 of the 8253, i.e. change mov al,36h to 34h in the setup_timer routine. That should do it - better yet, use a proper vintage hardware emulator - that DOSBox is still gripping you tight...

Uh... oh... I had to try on my 2nd favorite emulator, and I usually do, but... I failed to emulate :LOL:
DOSBox is not precise, but somehow, in all of the tests of my implementation that I posted before, DOSBox and 86box behaved very closely. 86box was always a bit noisier, which, to me, sounded more like real hardware (as far as I remember it), in contrast to DOSBox, which produced an unrealistically clean and smooth sound. Like it is a SoundBlaster rather than a speaker :)
With your approach, DOSBox is apparently doing something very wrong :LOL:
DOSBox is convenient because it allows the sharing of files between the host and the emulator easily without using a floppy image as an intermediate storage. But yeah, it doesn't have a reputation as the most accurate.
 

Attachments

  • panzer_86box.mp4
    461.1 KB
Here's a direct video and audio hookup from the real hardware Junior to a cheapo USB capture device (the RCA jack contains PC speaker output too, probably through a bandpass filter); compared against the MESS/MAME32 emulator of the same machine, with the same boot floppy and same PANZERMENSCH.ZIP, no modifications. Now from what we heard from your DOSBox, 86box or whatever that spent the night in "the box", you be the judge. Even the little "blip" it makes when the application exists sounds very similar between the Jr and MAME, notwithstanding that the 86box didn't even get the pitch (IRQ0 rate) right.

I rest my case.

:)
 

Attachments

  • realhw_vs_mame.zip
    201.4 KB · Views: 3
Here's a direct video and audio hookup from the real hardware Junior to a cheapo USB capture device (the RCA jack contains PC speaker output too, probably through a bandpass filter); compared against the MESS/MAME32 emulator of the same machine, with the same boot floppy and same PANZERMENSCH.ZIP, no modifications. Now from what we heard from your DOSBox, 86box or whatever that spent the night in "the box", you be the judge. Even the little "blip" it makes when the application exists sounds very similar between the Jr and MAME, notwithstanding that the 86box didn't even get the pitch (IRQ0 rate) right.

I rest my case.

:)

Yes, I agree that MAME sounds much closer to the real machine. The real hardware is still sharper and noisier, though, but if to compare MAME with 86box, well, there is nothing to compare 😂
TBH, I am not a big fan of the way MAME is configured. This is the only thing stopping me from using it. But it looks like I will have to get over it :LOL:
 
Here's a direct video and audio hookup from the real hardware Junior to a cheapo USB capture device (the RCA jack contains PC speaker output too, probably through a bandpass filter); compared against the MESS/MAME32 emulator of the same machine, with the same boot floppy and same PANZERMENSCH.ZIP, no modifications. Now from what we heard from your DOSBox, 86box or whatever that spent the night in "the box", you be the judge. Even the little "blip" it makes when the application exists sounds very similar between the Jr and MAME, notwithstanding that the 86box didn't even get the pitch (IRQ0 rate) right.

I rest my case.

:)
Played with MESS. It is awesome but painful, but awesome :LOL:

To name a few pain points:
1. Realistic FDD speed (soooo.... slooooow....)
2. Realistic limitations of FDD types, supported by specific machines
3. Realistically absent HDD on IBM PC Jr, for example
4. You have to identify and then somehow find and download ROMs manually

I would prefer to change the speed of FDD and HDD, at least :)
Otherwise, it is really sweet, especially its FDD noise simulation, that you mentioned before :)
 
Back
Top