Jump to content
kool kitty89

Using Pulse Density Modulation for 8-bit PCM

Recommended Posts

Did some preliminary timing tests and I'm afraid there's not much chance of a new AtariSid version incorporating this new sample playing method. The main culprit is that I need to switch to timer 4 for the 15kHz timer, but then I'll lose the 'inc IRQEN' trick to reset the timer. Also, I'd have to drop the noise generators and switch back to random noise samples (which sound metalic). Some very fast player routines might still work (Laxity's for example), but Jeroen Tel's player is definitely too slow...

 

BTW I did a PWM version back when phaeron published his experiments. It worked, but I really can't stand the carrier tone.

  • Like 2

Share this post


Link to post
Share on other sites

BTW2 I see that you disable dither on your sox commands. I guess, for songs with little to no silent parts, it might help enable dither and use triangular noise shaping to avoid the most noticeable frequency bands, in order to expand the dynamic range somewhat more.

  • Like 2

Share this post


Link to post
Share on other sites

I went back and did my last "megamix" in pdm 8 bits at 15.7Khz.

I was already using one byte per sample so the memory consumption is the same and there is no carrier frequency.

I don't know about real hardware, but in emulation it sounds reeeeally nice.

 

Come one.. what's next.. a 320x200 mode with 16 colors?

Stop moving the goalpost guys :D

 

mixpdm.zip

  • Like 8

Share this post


Link to post
Share on other sites

I went back and did my last "megamix" in pdm 8 bits at 15.7Khz.

I was already using one byte per sample so the memory consumption is the same and there is no carrier frequency.

I don't know about real hardware, but in emulation it sounds reeeeally nice.

 

Sounds excellent!

 

So amazing that this method has been there in POKEY this whole time and we're just now realizing it, amiright?! Huge kudos to kool kitty89 for showing us the light. :)

  • Like 5

Share this post


Link to post
Share on other sites

I'm not sure if this technique is ever actually used in existing games or demos, but using 2 POKEY channels and two timers, it should be possible to get 8-bit linear PCM output through POKEY. Set one timer to the desired sample rate and set one 4-bit volume level for the upper 4 bits of a sample while the lower 4 bits go to the other channel. The second channel gets its volume then cut again to 1/16 by using the second timer to set the duration of the pulse to 1/16 of a sample period.

 

Is this method something you've seen used elsewhere? What gave you the idea?

 

It's so obvious now that I know it but I would have never come up with it on my own. Thanks for the mind expansion. :)

  • Like 4

Share this post


Link to post
Share on other sites

This is exciting stuff, of course I am ignorant of the vast majority of the sound tech speak here. Now, would this process be limited to just two voice channels due to processing overhead, or could this be enhanced further with a second two voices doing the same thing, and possibly further enhanced with a second POKEY chip too?

Share this post


Link to post
Share on other sites

Hmmm,

could this trick be used for MOD-players as well ?!? Afaik, most MOD players playback MOD with 4bit, 5bit or max. 6bit resolution, only with Covox they can playback with 8bit resolution. But if this trick would also work with MOD-players (that would have to be programmed then), it would make the Covox device more or less obsolete...

 

Maybe something for TeBe and his Inertia (MOD) player or for Epi and his Neotracker...

Edited by CharlieChaplin
  • Like 2

Share this post


Link to post
Share on other sites

This is exciting stuff, of course I am ignorant of the vast majority of the sound tech speak here. Now, would this process be limited to just two voice channels due to processing overhead, or could this be enhanced further with a second two voices doing the same thing, and possibly further enhanced with a second POKEY chip too?

 

The new method actually requires three channels, either 1,2,3 or 1,3,4. Channel 2 or 4 plays the high 4-bits. Then both 1.79Mhz channels (1+3) are paired via the high pass filter to create the 1/16 signal (effectively DC at 1/16 VCC) for the low 4-bits. That leaves one channel that could play normal 15KHz or 64KHz sound or 4-bit PCM.

 

You could definitely use a second POKEY to achieve stereo. I've actually experimented with that using PWM but I'll save that for a different thread some other time. :)

 

BTW, I share kool kitty89's reservations about calling this new method PDM since the pulse density is actually constant, not modulated. What shall we call this new method? PCM44?

 

BTW, another thing I realized is that you could vary the pulse signal from 1/16 to 16/16 as a master volume control on a 4-bit PCM sample. Kinda interesting. Not sure how useful it is since it would only work for one channel.

  • Like 1

Share this post


Link to post
Share on other sites

PCM44 because of the 44KHz rate?, could be..

Well you could do it at other rates also... PCMX?, the X could be for extra, extended, xuel.. :D

 

Hope you document all your ideas at some point (could be in the wiki).

Maybe some of them doesn't have an application now, but you never know who could use them later :)

Share this post


Link to post
Share on other sites

I loaded this onto a MaxFlash cart and am getting some noise during playback:

 

post-16457-0-94414800-1525757093_thumb.png

 

Top is line-in recording from 800XL, bottom is 64KHz audio tap from Altirra. Looks like the LSBs are playing at too high of a volume and chopping the MSB wave. In contrast, the PWM demos match much more closely:

 

post-16457-0-51296400-1525757100_thumb.png

 

Not sure what's going on specifically yet... not enough resolution to see what's going on with the audio input and too chaotic to use the scope. Have to check whether high-pass timing might differ between the 800XL and 130XE. Unfortunately, only one MaxFlash cart makes switching between the two demos kind of painful.

 

  • Like 5

Share this post


Link to post
Share on other sites

I share kool kitty89's reservations about calling this new method PDM since the pulse density is actually constant, not modulated. What shall we call this new method? PCM44?

Because it works by multiplying 4-bit PCM by 1/16 PWM, it could be called PCM × PWM 1/16 or PCM × 1/16 or PCM * 1/16.

Share this post


Link to post
Share on other sites

Not sure what's going on specifically yet... not enough resolution to see what's going on with the audio input and too chaotic to use the scope. Have to check whether high-pass timing might differ between the 800XL and 130XE. Unfortunately, only one MaxFlash cart makes switching between the two demos kind of painful.

Ugh. Hopefully not the nail in the coffin for getting this to work on real hardware.

 

Here's a calibration program:

 

calibrate.xex

 

Maybe a different setting for Pulse Y would fix it on real hardware? I used 12 and 13 for X and Y in the original code. The X/Y values are used as follows:

 

    ; Set up 1/16 dutycycle HiPass on 1+3
    mvx optpulsex AUDF1
    mva optpulsey AUDF3
    sta STIMER
    stx AUDF3

Full code here.

  • Like 1

Share this post


Link to post
Share on other sites

For the love of me I can't seem to make anything with this thing.
The furthest I got was to get waveform.bin, and some form of .obx, but that crashes in emu (duh)
I could make a cart on my own with supplied tools, but there's no bank0.bin

Share this post


Link to post
Share on other sites

Why don't you use AUDC3 for $1x coarse level ($x0) sample part instead of AUDC2 (AUDC3 is using to dutycycle control of AUDC1 wave and is always deaf)? I think your method could use only two channels: AUDC1 for fine 1/16 sublevels and AUDC3 for coarse level and left AUDC2 and AUDC4 for other sound (it's a shame that they can't be clocked by 1.77MHz :/, however what do you think about using 64kHz and 1/3 carrier for them?).

Edited by mono
  • Like 1

Share this post


Link to post
Share on other sites

PCM44 because of the 44KHz rate?, could be..

Well you could do it at other rates also... PCMX?, the X could be for extra, extended, xuel.. :D

 

Hope you document all your ideas at some point (could be in the wiki).

Maybe some of them doesn't have an application now, but you never know who could use them later :)

I was thinking of PCM44 as a reference to 4-bit PCM for MSB and 4-bit PCM for LSB. How about PCM4+4 to disambiguate?

 

Because it works by multiplying 4-bit PCM by 1/16 PWM, it could be called PCM × PWM 1/16 or PCM × 1/16 or PCM * 1/16.

I hesitate to call the LSB PWM since the pulse width isn't being modulated, only the amplitude.

Share this post


Link to post
Share on other sites

For the love of me I can't seem to make anything with this thing.

The furthest I got was to get waveform.bin, and some form of .obx, but that crashes in emu (duh)

I could make a cart on my own with supplied tools, but there's no bank0.bin

 

What environment are you using? You need a unix-like environment with Perl, make, xasm and sox. Cygwin works well for me on Windows. Edit the Makefile and replace "Demovibes11.raw" with "XXX.raw" where XXX.mp3 is the name of your .mp3 file. Then you can type "make thecart.car". PM me if you still are having trouble.

Share this post


Link to post
Share on other sites

Why don't you use AUDC3 for $1x coarse level ($x0) sample part instead of AUDC2 (AUDC3 is using to dutycycle control of AUDC1 wave and is always deaf)? I think your method could use only two channels: AUDC1 for fine 1/16 sublevels and AUDC3 for coarse level and left AUDC2 and AUDC4 for other sound (it's a shame that they can't be clocked by 1.77MHz :/, however what do you think about using 64kHz and 1/3 carrier for them?).

 

Great idea! Works like a charm:

 

calibrate.xex

 

Could you elaborate on the 64kHz 1/3 carrier idea?

 

  • Like 1

Share this post


Link to post
Share on other sites

Oh, didn't know about that you need to provide parameters, wasn't described anywhere
works now, cheers!

 

Also, how hard would it be to make a version for use with shorter mp3s that actually could be loaded onto computers expanded to 1MB?

Edited by Mr_Mary

Share this post


Link to post
Share on other sites

So it looks like on a real hardware to get 1/16 duty cycle we need to do this

    mvx #12 AUDF1
    mva #14 AUDF3
    sta STIMER
    stx AUDF3

In other words, in calibrate.xex program set Pulse Y parameter to 14 and Pulse X to 12

Edited by antrykot
  • Like 2

Share this post


Link to post
Share on other sites

I try to use all *.car from this toppic with Ultimate Cart and it do not work on real atari. It wrote Unsuported car format. Should it wokrs on real atari?

  • Like 1

Share this post


Link to post
Share on other sites

Not sure what's going on specifically yet... not enough resolution to see what's going on with the audio input and too chaotic to use the scope. Have to check whether high-pass timing might differ between the 800XL and 130XE. Unfortunately, only one MaxFlash cart makes switching between the two demos kind of painful.

Have you checked the response time? As far as I know, POKEY needs around 32 cycles to act on the generators. Possibly it's the same with the volume and the interrupts.

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