flipacholas / Architecture-of-consoles

Technical articles about console architecture
https://www.copetti.org/writings/consoles/
Creative Commons Attribution 4.0 International
850 stars 57 forks source link

Sega Master System page: "Decaying" audio is actually a software highpass #27

Open Dwedit opened 3 years ago

Dwedit commented 3 years ago

In the section of the Sega Master System page titled "Emulation accuracy" that is referring to audio

We have a screenshot of a NES showing the wave "decaying", vs a Master System which has no "decay". You see the square wave kind of "tilt" towards the center.

It turns out this "decay" is actually a simple highpass filter intentionally added to perform DC cancellation. It only uses additions, subtractions, and bit shifts, so it's really cheap and fast.

I don't quite remember what the formula was though.

flipacholas commented 3 years ago

For the NES recording I used towave (source), while the Master System one was recorded using Game Emu Player (source), a plugin for foobar.

It makes sense, I'm just checking now the nes apu implementation to see if I can find the line of code confirming it.

flipacholas commented 3 years ago

Findings (for now):

to be continued

flipacholas commented 3 years ago

This is really a wide topic, so I guess the questions I'm trying to address now are:

Dwedit commented 3 years ago

According to lidnariq's comment on a NesDev forum post, you get a Simple IIR highpass with this formula:

out[n] = out[n-1]*(1024-1)/1024 + in[n] - in[n-1]

In this formula, the corner frequency (cutoff frequency) is the sampling rate divided by 1024, or 43Hz. I think doubling the constant 1024 may cut the corner frequency in half.

This filter is very cheap to compute, as it doesn't need any multiplications or divisions, just bitshifts, additions and subtractions.

flipacholas commented 2 years ago

Sorry for the long silence, I'm still interested in amending the article with this, it's just that I got more questions surrounding the effect of the filters (from a hardware level) that I'd like to understand before correcting the article. I'll revisit this after I finish the current article I'm working on (PS3). Thanks.

flipacholas commented 1 year ago

Well, it's been a long time since my last comment. But I've made some progress, starting with a re-write of the NES' APU part of the article. I did this to provide a starting point for a future comparison with the Master System's audio (and possibly other consoles as well).

First, I've expanded the Audio section of the NES article to provide more info about each channel. This will be used as a reference for future information.

To provide a better foundation and tools for audio comparisons, I've introduced a new study that makes use of spectrograms to analyse the APU. I'm not fluent in these types of analysis so any kind of feedback will be very welcomed.

If this goes well, I'll use the same techniques to analyse other audio chips as well.