Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Dwedit opened this issue Feb 26, 2021 · 6 comments
Open
Labels
correction Article needs fixing

Comments

@Dwedit
Copy link

Dwedit commented Feb 26, 2021

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
Copy link
Owner

flipacholas commented Feb 27, 2021

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 flipacholas added the correction Article needs fixing label Feb 27, 2021
@flipacholas
Copy link
Owner

Findings (for now):

  • The APU emulator depends on Blip_Buffer.
  • Blip_Buffer implements band-limited synthesis so we can play square waves on our sample-based sound cards with the most accurate result.
  • ... but it also provides an adjustable low pass filter and DC cancellation.

to be continued

@flipacholas
Copy link
Owner

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

  • How accurate is the pulse waveform of the NES & Master System on those emulators -> I guess an oscilloscope will confirm that.
  • So the sn76489 doesn't exhibit that 'decaying' effect, is this consequent of not using a high-pass filter for DC cancellation? (I'm guessing something more sophisticate?)

@Dwedit
Copy link
Author

Dwedit commented May 30, 2021

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
Copy link
Owner

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
correction Article needs fixing
Projects
None yet
Development

No branches or pull requests

2 participants