Hi I'm fairly new to this forum and NES emulation but I'm looking to make a project for a DSP class I'm taking and thought this would be a good community to look for help. I've spent a couple days reading over different threads involving the DSP involved with the emulation and am looking to implement a fairly basic NES APU entirely in matlab demonstrating topics I've learned in class. I'm well versed in FIR/IIR filters, sampling, nyquist rates and aliasing from a conceptual standpoint but not as much a practical one. Are there any general resources I should take a look at before starting up this project? (Specifically related to implementing this in matlab). Has anyone done this in matlab that can offer some advice on what problems to tackle first? Thanks
If you are primarily interested in just exercising your DSP knowledge, we could just provide a recording of raw APU output and you could filter, down-sample, decimate, etc. that data set.
That would be great. Sorry if this was a relatively simple thing I could have searched for.
What are your requirements?
The project requires the manipulation of any 1D signal. So raw APU output like song files for each channel would work or anything similar that I can mess around with.
Anything from 3-5 .wav or .mp3 files of Super Mario Bros. or similarly recognizable songs from an NES game. Raw output that I can manipulate (pre-filtered, unsampled, possibly seperate channels) would be great
Depending on who you ask, "Raw" might mean a sampling rate of 1,789,773Hz, rather than something sane that you would normally think of for audio.
Correct. On the NES, "raw" means either 315/176 = 1.790 MHz, the fastest rate in the APU, or 315/352 = 0.895 MHz, the "sufficient" rate that is perfect for everything but the triangle channel and $4011 writes and near perfect even for those.
...huh. Just tried telling my NSF player to generate a WAV file at the NES CPU rate, and that is apparently a thing it will do out of the box. Sent Audacious into cardiac arrest when I tried to play it, but the data's there.
Still has all the high-/low-pass filtering on it, but I can hack that out easily enough, if you really want it...?
Rahsennor wrote:
Still has all the high-/low-pass filtering on it, but I can hack that out easily enough, if you really want it...?
If it's not too much that'd work great. Even both so I can mess around with each. I'm just looking to exercise some knowledge to crudely show what the NES would do.
Here's the first 30 seconds of the SMB1 main theme at 1789773 Hz, unfiltered. It's quiet and has a large DC offset because that's what I do to avoid clipping.
I can do more if you want, just let me know what to render.
I though the APU would generate samples at odd CPU clocks only.
Pulse, noise, and DMC autoplayback do operate only every other CPU cycle. Triangle and sta $4011 can change on any cycle, but every other cycle should be enough for those in practice.
So I've started working on systems to filter/downsample all of this data which is giving me a good amount of flexing my knowledge but is there anything the NES does internally before outputting the audio? Also any more data sets/raw song snippets would be great for testing what I already have. Thanks is advance.
kyguy37536 wrote:
So I've started working on systems to filter/downsample all of this data which is giving me a good amount of flexing my knowledge but is there anything the NES does internally before outputting the audio?
There is some nonlinearity in the mixing. The two pulse channels interfere with each other, and the triangle, noise and DMC channels interefere with each other. These two sets are then mixed normally - this is where my emulator output is sampled in the file above.
It then applies a series of high-pass and low-pass filters. You can find all the details
on the wiki.
kyguy37536 wrote:
Also any more data sets/raw song snippets would be great for testing what I already have. Thanks is advance.
Anything in particular you're looking for, or should I just grab tracks at random?
Would it be at all possible to get some tracks before they've been mixed together? If not then a couple of random tracks would work.
Actually, if they could all be tracks from super mario bros for consistency that would work. Thanks is advance. I'm looking to see if I can also implement the mixer as part of the project.
Four more tracks, in 7z format because zip broke the attatchment size limit.
Does the way you sample the output let you just take the pulse, triangle and noise channels separately before they've passed through the DACs?
kyguy37536 wrote:
Does the way you sample the output let you just take the pulse, triangle and noise channels separately before they've passed through the DACs?
Not without significant modifications.
Okay no problem. Thanks for all the help/data. Are there are any ideas off the top of your head that would maybe allow me to improve on the way that the NES processed the audio so I can go a little more in depth on the project?
kyguy37536 wrote:
Okay no problem. Thanks for all the help/data. Are there are any ideas off the top of your head that would maybe allow me to improve on the way that the NES processed the audio so I can go a little more in depth on the project?
My goal as an emulator author is accuracy, so I honestly have no idea.
Do you have the samples of the songs after the filters have been applied?
NES generates those pretty square waves and triangle waves and stuff at sampling rates in the MHz, then everything after that is analog. No more emulation at that point, just simulating the effects of the circuits. Heck, you'd probably need an oscilloscope to see how close the NES's generated waves are to their ideal forms before any other analog stuff happens.
The triangle is certainly going to look a lot less than ideal
Speaking of which, does anybody know the +/- voltage of the channels before and after mixing? Would be good to know when adding in ext. audio from a cart.
kyguy37536 wrote:
Do you have the samples of the songs after the filters have been applied?
No, and I couldn't post them anyway, because it destroys the compression ratio. And my filters aren't hardware-accurate to begin with.