Jump to content
kool kitty89

Using Pulse Density Modulation for 8-bit PCM

Recommended Posts

 

Had several Polish hardware projects not fallen off the earth, I would probably have a PBI driver already written which drives SD carts via SPI, but as it stands the performance is a bit of an unknown quantity. That's why I'm hedging my bets on IDE emulation on some of these newer MCU-based, SD card multi-carts. If you can do IDE emulation in accordance with the ATA specs, then that would be ideal. The only ATA commands used are Identify Device, Set Features, Read Sector and Write Sector (plus device reset). Any IDE emulation need not worry about Atari partitions (the standard being APT), since all partition and logical drive stuff is handled by the 6502 (this is also true of the XEX loader on which the PDM player is based).

 

 

Yeah I'll try doing a minimal IDE->SPI bridge. How should this be exposed to the Atari (register use)? I think doing a full ATA implementation looks complicated but I'm sure the Atari interface must be pretty simple. I mean an 'Atari reg's to SPI bridge is probably easier then Atari regs->ATA->SPI bridge:-)

Edited by foft
  • Like 1

Share this post


Link to post
Share on other sites

If you can crash the loader by invoking a search, I'd be interested to know how to reproduce the issue here, since this is the first I heard of any issue. Even a screenshot of the crash would be useful, since I'm not aware of any problem.

 

If it's the player crashing, then I would not be in the least surprised, meanwhile. icon_smile.gif

 

I test again with the version i downloaded yesterday. Same result pdm.exe loader screen get overwritten in parts over the only part thats still is ok is the upper part with "PDM PLAYER". during the search you can see that the clock symbol get updated. I am not able to select a entry and it not matter if i start it form the SIDE2 loader or the Ultimate1MB loader. Sorry at the moment i am not able to make a screenshot.

Share this post


Link to post
Share on other sites

I need to prepare a document outlining the minimum requirements of IDE emulation since I'm explaining the same thing in multiple locations at the moment. ;) Absolute minimum requirement is the 8 basic IDE registers, and it's useful to be able to reset the device. These are the SIDE2 registers as an example:

IDE_DATA	equ $D5f0
IDE_ERR		equ $D5f1
IDE_SCNT	equ $D5f2
IDE_SNUM	equ $D5f3		; LBA 0
IDE_CYLL	equ $D5f4		; LBA 1
IDE_CYLH	equ $D5f5		; LBA 2
IDE_HEAD	equ $D5f6		; LBA 3 ($Ex)
IDE_STAT	equ $D5f7
IDE_CTRL	equ $D5f8		; Device control (used for device reset)

One could implement a latched sixteen bit data register to do away with the need for 8-bit PIO mode, but I'm not sure off the top of my head how that would work with the PDM Player (since I didn't code up an IDE Plus 2.0 version yet).

 

Bare minimum required commands are read (0x20), write (0x30), Indentify device (0xEC) and Set Features (0xEF, if no sixteen bit data bus is provided). Only the following information from the Identify Device buffer is employed by APT tools:

1	Number of logical cylinders
3	Number of logical heads
5	Number of logical sectors per track
10-19	Serial number (20 ASCII characters)
23-26	Firware revision (8 ASCII characters)
27-46	Model number (40 ASCII characters)
60-61	Total number of user addressable sectors (LBA mode only)

CHS data is used by the partition editor when laying out the MBR. The three strings can be populated with generic place-holder information if necessary.

 

Of course I'm not delving into the entire APT implementation here, which ideally requires a PBI device ROM.

  • Like 3

Share this post


Link to post
Share on other sites

I test again with the version i downloaded yesterday. Same result pdm.exe loader screen get overwritten in parts over the only part thats still is ok is the upper part with "PDM PLAYER". during the search you can see that the clock symbol get updated. I am not able to select a entry and it not matter if i start it form the SIDE2 loader or the Ultimate1MB loader. Sorry at the moment i am not able to make a screenshot.

OK - as long as it's not the loader's search function that's crashing, I'm not over concerned at this moment in time. Likely some issues with the display code, which was subject to aggressive modification during adaptation from the SIDE loader. Workaround would be not to invoke the search function if it's causing you problems. Since the player only lists PDM files (and folders) and there is to the best of my knowledge only one PDM file currently in existence, hopefully issues with the search facility aren't too much of an impedance.

Share this post


Link to post
Share on other sites

A long time, probably. I'd have to read up on the SCSI protocol and invest time I don't currently have in testing it.

 

 

attachicon.gifU1MB_Xuel.zip

 

Go to System->Configure System->Firmware->Firmware Manager, then "Add", navigate to U1MB.ROM, and set the type to Ultimate 1MB, making sure you "Set as default".

 

Your VHD should be formatted FAT16 or FAT32, without or without MBR partition table, and should have the player and the sample file in it. Boot the emulated machine, pressing 'L' to start the loader. Go to the Options menu in the loader and turn off internal BASIC, then in the launcher menu (rocket), hit enter on PDM.XEX and then use a very similar interface inside the player to do the same thing with the sample file.

I think I followed these instructions and verified BASIC is disabled but I'm still getting a corrupted screen:

 

post-21021-0-65206500-1527193343.png

 

Probably doing something silly. Maybe I'll PM you for remedial education. :)

Share this post


Link to post
Share on other sites

I think I followed these instructions and verified BASIC is disabled but I'm still getting a corrupted screen:

I can achieve the exact same result by going to System->Console Switches and enabling "Cart SDX", which would explain the ROM where the screen data should be. If you disable the aforementioned setting, all should be well, although output it not optimised for Altirra's POKEY emulation.

 

As well as disabling SIDE's SDX ROM, by the way, you might enable the PBI HDD which suppresses the external loader ROM and allows proper access to the hard disk via the OS.

Edited by flashjazzcat
  • Like 1

Share this post


Link to post
Share on other sites

I believe I'm having the same issue as Xuel but my screen corruption is different.

 

I'm sure my environment is different. linux (Knoppix live)/wine/Altirra/real CF card (2GB).

 

post-9154-0-57254100-1527199678_thumb.png

post-9154-0-25023100-1527199572_thumb.png

Edited by a8isa1

Share this post


Link to post
Share on other sites

No joy with SIDE 2 + U1MB but without U1MB I can run PDM.XEX from an ATR (D1:)

 

I'm not a SIDE 2 or U1MB owner. Probably doing some silly n00b thing.

Edited by a8isa1

Share this post


Link to post
Share on other sites

PDM Stereo: Is this a possibility?

 

I asked this question a while back, and didn't see a reply.

 

Could this be implemented for Stereo Pokey boards, and if so what would get compromised if anything?

PDM Stereo would be even more incredible!

  • Like 2

Share this post


Link to post
Share on other sites

I can achieve the exact same result by going to System->Console Switches and enabling "Cart SDX", which would explain the ROM where the screen data should be. If you disable the aforementioned setting, all should be well, although output it not optimised for Altirra's POKEY emulation.

That was it! Thanks! Sounds good in Altirra with the following hacks: "e 44df d" "e 44e4 c".

  • Like 2

Share this post


Link to post
Share on other sites

No joy with SIDE 2 + U1MB but without U1MB I can run PDM.XEX from an ATR (D1:)

 

I'm not a SIDE 2 or U1MB owner. Probably doing some silly n00b thing.

 

Yes: PDM.XEX is a standard binary which works from DOS but it has rather an obnoxious load address at the moment ($1000). The salient point here which I should probably have underlined is that it simply needs to run with internal BASIC off and no cartridge ROM present, but since SIDE2 is a cart, SIDE2's ROM must also be disabled. You can do so by enabling the PBI HDD on an U1MB/SIDE setup, since the PBI BIOS will then suppress the SIDE loader ROM at all times. But you could also run the player from the loader on the SIDE cart itself on a stock 64K machine with no U1MB present. This would also guarantee that BASIC and the SIDE ROM are disabled (since the SIDE loader turns its own ROM off when it loads an XEX).

 

 

That was it! Thanks! Sounds good in Altirra with the following hacks: "e 44df d" "e 44e4 c".

 

I should probably add an emulation on/off option. I'm thinking of storing options in a plain text config file on the FAT. The user would simply need to create an empty file and the player would then update it on the fly.

 

PDM Stereo would be even more incredible!

 

To jog this discussion along a bit: I wondered how bad things would sound if we simply interleaved left and right channel data and drove both at half the bitrate. It takes 20 machine cycles to play eight bits of sample data, and each iteration must not exceed 37 cycles at the currently implemented bitrate. Most of the other 17 cycles are already consumed by the IDE buffering mechanism required to maintain uninterrupted playback.

  • Like 3

Share this post


Link to post
Share on other sites

I did a quick test with the same song playing in both channels (left / right) and at least in emulation it seems alright.

So, can someone test the "_rh" versions in real hardware (1 MB carts for NTSC or PAL)?

Probably would try to do a real stereo test later (is a little more complicated, but should not be much more).

The "_emu" versions sound good in Altirra with the stereo configuration (and louder than mono).

 

monox2.zip

Edited by NRV
  • Like 5

Share this post


Link to post
Share on other sites

Those wonderful moments where you are finishing your code and try a final improvement, that just move your critical path code over the 105 cycles per line.

Then you cannot live with the imperfection.. so you end moving all the code to page 0 just for 6 extra cycles.

 

First, the pal version of the previous file, that I forgot:

stereo.zip

 

Then a new sample (from Marble Madness arcade), that clearly shows the stereo effect.

Check the ntsc version in the emulator if you can, the wave visualization is nice :)

 

stereo2.zip

 

I tried to have the smaller delay between changing the left and right channels, but I really don't know if that delay could produce some kind of audio artifact or not.

  • Like 5

Share this post


Link to post
Share on other sites

Request - Roadblasters music. Atari did some great arcade music and effects with the higher end Yamaha chips in the late 80s.

 

I downloaded from this video and used Mediacoder to rip the relevant section. Of course unlikely the whole thing will fit in. The includeds section are part of Goal 1 and Goal 2 - YT original here www.youtube.com/watch?v=X02VJO67cQg

 

ROAD BLASTERS Sound Track 360p.wav

  • Like 1

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. Yes you'd get noise at low sample rates (more and more audible below 11 kHz) but that's true to some extent for harmonics of low sample rate PCM in general. (and not the same sort of squeal and noise as 1-bit PDM/PWM on a PC speaker or beeper or whatnot)

The problem here is that you (wrongly) assume that the output amplitude of Pokey would depend linearly on the volume setting. It does not. If it would, tricks like the "triangle wave" (which isn't really a triangle) wouldn't work. In order to keep distortions low, you would need to carefully calibrate the process to individual chips.

Share this post


Link to post
Share on other sites

The problem here is that you (wrongly) assume that the output amplitude of Pokey would depend linearly on the volume setting. It does not. If it would, tricks like the "triangle wave" (which isn't really a triangle) wouldn't work. In order to keep distortions low, you would need to carefully calibrate the process to individual chips.

A total mixup of different things. The resolution isn't really built on the bits, it's also built on the pulse width/Pulse Density. The resulting power package is the clue here.

Also. The volume problem of the Generators is not the same. As the waves of different channel add physically together on the generated wave (phase , shift... positive negative signal addition) ...

 

OK just some imagination helper...

 

The short "phaser FX" before the tune changes after 0:33 , is showing that POKEY is able to do manipulations that influences the analog output to create "analog signals" without any digitizing noise....

 

 

The way to a solution for the best "sound" is to get the channels 100% in co-relation.

Edited by emkay
  • Like 1

Share this post


Link to post
Share on other sites

Hello guys

 

How do I turn .bin into .car? My Ultimate Cart doesn't show .bin files.

 

Sincerely

 

Mathy

Share this post


Link to post
Share on other sites

How do I turn .bin into .car? My Ultimate Cart doesn't show .bin files.

You can mount a BIN file as a cart in Altirra and save it as a CAR file, although I assume many other stand-alone tools exist which will do the same job. Renaming the file won't work since CAR files include a 16 byte header which contains a cart type descriptor. BIN files don't have this header.

Share this post


Link to post
Share on other sites

Yes, in the case of my examples first you need to mount the bin in Altirra as a cart type "42*: MaxFlash 1M .. (bank 127)".

After that you go to "Save Firmware / Save Cartridge" and save it as a ".car" file.

 

You can also mount my examples in Altirra as type "*MaxFlash 1M .. (bank 0)", but then you cannot save them as a ".car" later.

  • Like 1

Share this post


Link to post
Share on other sites

mmlv6_pal_rh sounds pretty impressive on real hardware: just tested it on the 1088XEL using my Ultimate Cart. I'll try to record it through the capture dongle if I get time, since the camera hasn't really been doing these things justice. Background noise is pretty low.

 

Any chance of some raw stereo files for the IDE player or some code samples? I doubt I can do better than 44KHz per channel, so stereo on the IDE player may require the bitrate to be chopped in half on each channel.

Share this post


Link to post
Share on other sites

Hello guys

 

How do I load a file into Altirra? I'm running a bottled version on my iMac.

 

Sincerely

 

Mathy

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