nesdev.com
http://forums.nesdev.com/

NES APU in Matlab
http://forums.nesdev.com/viewtopic.php?f=3&t=15082
Page 1 of 2

Author:  kyguy37536 [ Mon Nov 07, 2016 10:13 am ]
Post subject:  NES APU in Matlab

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

Author:  zeroone [ Mon Nov 07, 2016 10:41 am ]
Post subject:  Re: NES APU in Matlab

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.

Author:  kyguy37536 [ Mon Nov 07, 2016 1:45 pm ]
Post subject:  Re: NES APU in Matlab

That would be great. Sorry if this was a relatively simple thing I could have searched for.

Author:  zeroone [ Mon Nov 07, 2016 2:13 pm ]
Post subject:  Re: NES APU in Matlab

What are your requirements?

Author:  kyguy37536 [ Tue Nov 08, 2016 7:36 am ]
Post subject:  Re: NES APU in Matlab

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.

Author:  kyguy37536 [ Thu Nov 10, 2016 12:25 pm ]
Post subject:  Re: NES APU in Matlab

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

Author:  Dwedit [ Thu Nov 10, 2016 4:23 pm ]
Post subject:  Re: NES APU in Matlab

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.

Author:  tepples [ Thu Nov 10, 2016 5:19 pm ]
Post subject:  Re: NES APU in Matlab

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.

Author:  Rahsennor [ Thu Nov 10, 2016 7:53 pm ]
Post subject:  Re: NES APU in Matlab

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

Author:  kyguy37536 [ Thu Nov 10, 2016 8:46 pm ]
Post subject:  Re: NES APU in Matlab

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.

Author:  Rahsennor [ Fri Nov 11, 2016 3:05 am ]
Post subject:  Re: NES APU in Matlab

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.

Attachments:
File comment: WARNING: 107 MB uncompressed
smb-raw.zip [524.61 KiB]
Downloaded 73 times

Author:  Zepper [ Fri Nov 11, 2016 1:43 pm ]
Post subject:  Re: NES APU in Matlab

I though the APU would generate samples at odd CPU clocks only.

Author:  tepples [ Fri Nov 11, 2016 2:03 pm ]
Post subject:  Re: NES APU in Matlab

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.

Author:  kyguy37536 [ Mon Nov 14, 2016 5:53 pm ]
Post subject:  Re: NES APU in Matlab

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.

Author:  Rahsennor [ Mon Nov 14, 2016 7:35 pm ]
Post subject:  Re: NES APU in Matlab

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?

Page 1 of 2 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/