MiSTer-devel / MegaDrive_MiSTer

Sega Megadrive for MiSTer
44 stars 14 forks source link

WiP: Audio resampler based on jotego's implementation #19

Closed birdybro closed 9 months ago

birdybro commented 9 months ago

Work in progress. Not adjusted for gain levels yet, not tested yet.

Not sure if this is the right approach or not, but this is my attempt to begin resolving the MDFourier inaccuracies shown in --> https://github.com/MiSTer-devel/MegaDrive_MiSTer/issues/5

The exact number of stages and depths for the CIC filtering may need to be adjusted quite a bit because the output of nukey's audio modules is different, so the effect on DC bias and gain will be impacted. The SMS FM audio should be synced with this to avoid aliasing upon upsampling along with the PSG audio (which has to be synced to FM audio sample rate), so I added those input and steps too.

I sort of rewrote jotego's modules to simplify it to my eyes (and it helped me learn what it's doing) It's just a slightly different coding style, one is not better than the other. I added a TYPE parameter to the CIC interp/decim step so one module could be used instead of two.

Unfortunately... to solve this issue of ringing and aliasing, the effect looks to be a large increase in long chains which does increase the negative slack to the point of effecting the falling edge of the master clock's slack (which is probably very BAD for BRAM read/write timing...). The logic increase is also too sizable, ~5% ALM usage increase...

Doing a draft PR to stimulate a conversation about how best to move forward. I'm sure there are better ways to optimize this. Hopefully the outline shows how to solve this and helps get the ball rolling.

birdybro commented 9 months ago

Phew, accidentally deleted the branch :P

birdybro commented 9 months ago

Closing this draft PR. The root cause cannot be solved through filtering, only obscured, and the cost of filtering it is too great in terms of resources and timing impact currently. The fix for the ringing artifacts resides in the ym7101 module. It would have to be modified much in the same way emulators already do this.