Jump to content
kool kitty89

Using Pulse Density Modulation for 8-bit PCM

Recommended Posts

Just a small request: Would you guys consider posting a video or audio file, even attach an MP3? I have an NTSC and I can't run the PAL stuff that I would so like to hear.

 

Thanks.

Share this post


Link to post
Share on other sites

Just a small request: Would you guys consider posting a video or audio file, even attach an MP3? I have an NTSC and I can't run the PAL stuff that I would so like to hear.

 

Thanks.

 

The PAL files should work on NTSC. They'll just sound slightly higher pitched than they should. Vice versa going from NTSC to PAL.

  • Like 1

Share this post


Link to post
Share on other sites

Hello Kyle

 

Just a small request: Would you guys consider posting a video or audio file, even attach an MP3? I have an NTSC and I can't run the PAL stuff that I would so like to hear.

 

Check out message Nr. 193 in this thread.

 

Sincerely

 

Mathy

Edited by Mathy
  • Like 1

Share this post


Link to post
Share on other sites

Since a few people have emailed asking for the 1088XEL version of the PDM player, here's a ZIP file containing both the SIDE and XEL-CF versions of the player until I get a dedicated page set up on my website:

 

pdm.zip

 

I realise the player is in need of updates, including all the file handling fixes and improvements I've made to the XEX loader on which the player is closely based, stereo support, etc. It's on the to-do list. :)

 

  • Like 10

Share this post


Link to post
Share on other sites

I hope the problem with Incognito will get solved soon...

Share this post


Link to post
Share on other sites

I'm doing little something with digital playback, and I decided to finally try this trick by myself. It seems to work nicely in current Altirra, I use values 3,5 or 1,3.

But what is the consensus about the real hardware ? Is it reliable enough among all the machines ? Is there some new development ? I don't remember seeing anything new in this are for like a year.

Share this post


Link to post
Share on other sites

Supposedly Pokey's are much the same regardless of source although the external circuitry does affect the resultant waveform and might be different among models.

But I'd regard it as reliable enough to guarantee consistent results.

If it was the fact that there were differences we'd probably be able to work them out and document them to the point of knowing adjustment values per machine (though deducing exact machine model isn't an automatic thing - we can reasonably deduce if a computer is 400/800 but not which of those, XEGS due to ROM and memory control difference, 130XE due to extra RAM though throwing a spanner in the works there is expansions like 3rd party memory and U1Meg which can make a base machine appear different)

 

Probably the biggest audio inconsistencies are GTIA audio (speaker vs piped through) and the playback by tape motor control toggle having a different result depending on if it's a 410 or 1010 attached (I don't know about other models or 3rd party decks).

Share this post


Link to post
Share on other sites
52 minutes ago, R0ger said:

I'm doing little something with digital playback, and I decided to finally try this trick by myself. It seems to work nicely in current Altirra, I use values 3,5 or 1,3.

But what is the consensus about the real hardware ? Is it reliable enough among all the machines ? Is there some new development ? I don't remember seeing anything new in this are for like a year.

Well, there is the recent research done in this thread, starting from this post:

 

 

But I haven't seen anyone talking about important differences, between different machines..

 

Share this post


Link to post
Share on other sites

I should probably post about this on Spritesmind or something (I'm not sure I even have an account on there), but might as well mention it here given the conceptual overlap and on the off-chance any of the Atari 8-bit computer coders out there are also messing with PC Engine stuff. (I've seen a couple people doing that in the past, 6502 code heads and all) And heck, I've had this in my head for over 6 years now and haven't really talked about it anywhere.

 

 

 

 

But it seems to me you can use the 32x5-bit wave sample buffers in the Hu6280 CPU/Sound chip to store 5-bit PDM information, so you get the 32 amplitude levels from each 5-bit word, plus 32 additional linear levels from the pulse density (hypothetically more than that with more complex noise shaping, but I'm thinking simpler than that but still nicer sounding than straight PWM) so an effective 10-bit output.

 

In this case I think it's more literally PDM and not sort of twisting the definition as I did with my starting post for this topic. It's sort of like pushing bits through a serial shift register in loop mode at a high idle clock rate, but you're shifting out 5 bit words rather than 1 bit. (so in effect you're spitting out a looping, oversampled high frequency multi-pulse waveform that gets effectively filtered down to a linear amplitude sample)

 

You'd need to double buffer samples using 2 of the sound channels intermittently, muting the back buffer and loading it, then waiting to update the sample output (via cycle counted code or a timer interrupt). I was mostly thinking in terms of timer interrupts here since this method could allow similar sample rates to the other 10-bit PCM hack (using 2 channels and a volume offset for upper and lower 5-bit values, or less of an offset for just 8-bit resolution, but in any case requiring the CPU to set every single sample manually, so one interrupt per sample played if using an interrupt driven routine).

 

So with the onboard timer interrupt, you get approximately 6.99 kHz or an integer division of that. So that'd be 6.99 kHz 10-bit PCM output, potentially with software-mixing of multiple 8-bit channels, ADPCM or DPCM decoded samples, etc (with a look-up table to convert 10-bit linear PCM to the appropriate 32x5-bit register data). But more useful/less CPU intensive than that would be to chop the 32x5-bit buffer into 4 chunks of 8x5-bits for 4x 8-bit resolution interleaved/multiplexed channels. (useful for simplified code and low overhead mixing of 8-bit samples, or compressed samples decoded to 8 bits, plus additional software mixing on any of those 4 channels to 8-bit saturation: also lighter since pure 8-bit math is faster than mixing to 16 bits and clipping to 10)

 

Further, if you could synchronize the timer interrupt with the wave buffer playback frequency, so rather than looping the sample only plays once per interrupt, you could also potentially use the same basic technique to achieve 27.96 kHz 8-bit playback with that same 6.99 kHz interrupt. (worst case you'd still have some 6.99 kHz carrier tone aliasing where the idle high looping technique oversamples those overtones out of the audible range) You could also use slower timer intervals for less overhead, but then the aliasing falls more and more into the audible and nasty range.

 

Since the wave generator and timer are based on the same source clock, I'd think you could synchronize them as such, but not sure.

 

The oversampling 'whole 32x5-bit buffer as a single amplitude sample' seems like the more foolproof option, and the one that seems more like 'why didn't someone do that back in the 90s' sort of thing. Plus it's got the advantage of leaving the 4-bit logarithmic volume control totally free, so you can play with master volume on the simulated-PCM channel(s) by just setting the volume register as normal. (or potentially do Amiga-style extended resolution by modulating that volume level on top of everything else: something that does work on the PC Engine, but requires intermittent channel use to avoid clicks/pops when the volume register is set, which is irrelevant if you're already using 2 channels in a double buffered set-up)

 

Or take another 2 channels (for double buffering) and use the same mechanism there for 10-bit output, then use a volume offset to allow that to be added with the first channel for 20-bit output. Of course, that's kind of pointless at 7 kHz, and more interesting if you could get the ~28 kHz 8-bit synchronized method working and used the volume offset for low+high 8-bits and 28 kHz 16-bit mono output. (which would be pretty nice, potentially a lot nicer and more flexible for streaming compressed or uncompressed PCM audio from the CD Unit than trying to buffer into the hardware ADPCM decoder:  useful compared to straight redbook audio even with 16-bit 28 kHz LPCM since it takes up less space on disc and could allow more dynamic uses of sound/music data and interspersed game data loading, but also much more useful for software mixing multiple sampled SFX channels rather than choppy single-channel ADPCM SFX)

 

**that and this leads into another topic regarding how the ADPCM decoder in the CD-ROM module was kind of pointless and would've been nicer to have a full 128kB of program RAM instead of the separate 64kB of ADPCM buffer RAM. 

 

 

 

 

 

 

** on a side note, a typical 8-bit shift register in loop mode could be used for 1-bit PDM with effective 3-bit linear amplitude per byte loaded. (I looked into that a while back for potentially hacking VIA or ACIA type chips for sampled sound output, but their max bitrate seemed too low to be really useful for that: though using them for looping 1x8-bit sample, complex pulse tone/noise waveforms seemed a little more interesting)

I'd think POKEY's serial data output could also be hacked similarly, for what that's worth.

 

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)
7 hours ago, kool kitty89 said:

I'd think POKEY's serial data output could also be hacked similarly, for what that's worth.

Funny you mention this. I thought about this once, too. Never got any further, but it could be a nice project. Especially if you put a 400-500kHz clock on clock-in. I think the start and stopbits won't interfere. Run serial out through a low-pass filter, amp and you have line-out :)

 

Edit: or loop back to audio-in!

Edited by ivop

Share this post


Link to post
Share on other sites

Here's an "old-skool" sketch which could turn Pokey into a high speed 1-bit DAC.

 

sio-dac-sketch.thumb.png.317faa12f02414691a9d833a69755a53.png

 

There's a Don't Dead Open Inside in there ;)

 

But seriously, any opinions, improvements, thoughts on this?

 

The start and stop bits might have to be mitigated for in software. And what should the oscillator's frequency be? 32MHz would lead to 250kHz on pin G (/128). 40MHz is 312.5kHz. Not sure how fast is possible. I know Mr. Atari did experiments with externally clocked SIO at around 500kHz for reading and around 400kHz for writing that worked. But in this case the audio data has to be streamed from somewhere, too, which also takes time, so 312.5kHz might even be on the high side. 250kHz might be possible. Double of what Pokey can generate itself.

 

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...