NotSo Fatso bandlimited synth?

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
Richter X
Posts: 11
Joined: Mon Aug 01, 2005 11:39 am
Location: Hagan, GA, USA

NotSo Fatso bandlimited synth?

Post by Richter X »

Is anyone gonna come out with a Bandlimited version of NotSo Fatso or at least add its stereo panning ability to foo_gep? It would be awesome either way. Also, I noticed some audio plugins (mostly for MSX) use an RC (Resistor/Capacitor?) Filter instead of Highpass and lowpass, are they the same thing?
User avatar
kyuusaku
Posts: 1665
Joined: Mon Sep 27, 2004 2:13 pm

Post by kyuusaku »

High pass and low pass are RC filters. By defining the component values, you're defining the bandwidth/frequency response.
User avatar
blargg
Posts: 3717
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

I'll try bothering Kode54 to provide a front-end to channel panning. The Game_Music_Emu library itself allows independent handling of every channel, so it's just a matter of getting the front-end written. Anything beyond panning that you're interested in?

I know Disch has re-implemented his APU and other sound chips for Schpune using my band-limited algorithm (but his own code), so he'd be in the best position to port these back to NotSoFatso. Or he could post the source to his latest version of Schpune so someone else could do it.

An R/C filter is one possible way to implement a filter in an electronic circuit. High-pass and low-pass refer to what portion of frequencies are passed by the filter, without regard to how it achieves this. In software, filtering is achieved by adding attenuated, delayed versions of the signal to itself.
User avatar
kode54
Posts: 67
Joined: Mon Jun 06, 2005 12:47 pm
Contact:

Post by kode54 »

Oh joy, I can't wait to steal the panning configuration dialog template and code from NotSo Fatso and shove it in my preferences somewhere in a lame attempt to avoid designing yet another dialog and writing the backend code for it. Wait, scratch that, I can write the code, I just hate designing dialogs.

Scratch that again, I just don't feel like adding things I won't use myself, like VGM tempo control. And I suppose that panning control will be expected per format as well. And fully configurable echo/reverb like Game_Music_Emu already supports. Also per format no doubt.
User avatar
Bregalad
Posts: 8036
Joined: Fri Nov 12, 2004 2:49 pm
Location: Caen, France

Post by Bregalad »

In software, filtering is achieved by adding attenuated, delayed versions of the signal to itself.
Well, I've always asked myself how it was possible to implement a digital filter algorithm. What you describe sounds more like echo than filter, and I've trouble seeing how it works. Is that a lowpass or highpass filter ? I think it would be a highpass filter, because if you substract a shortly delayed version, all frequencies that match the delay will be attenuated, but that would only work for one precise frequency and it will only attenuate or distortion other frequencies.
Totally out of topic, but I'm curious.
Useless, lumbering half-wits don't scare us.
User avatar
blargg
Posts: 3717
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

Think of how quickly a wave is changing. If you output the current and previous samples added together, this will result in more cancellation for quickly changing waves than slowly changing waves. This results in a low-pass filter. If you output the difference between the current and previous, you get the opposite effect, a high-pass filter, since quickly changing waves have larger differences between each sample. More complex filters are built by adding several recent input samples together, each attenuated (multiplied) by a different amount.

One thing I wanted to mention regarding band-limited synthesis and filtering is that they are similar things but serve different purposes. The NES effectively has a 1790 kHz sampling rate, much higher than the typical 48 kHz rate of a PC. Band-limited synthesis has its bandwidth sharply limited to a certain maximum (i.e. it's a low-pass filter) in order to fit within the limit of the sampling rate the host PC is using; without the limiting, frequencies would go above the limit and "fold over" into aliasing distortion. This is an artifact of the way modern sound works, unrelated to NES sound. Low-pass filtering and high-pass filtering are done to match the what the NES audio circuitry does. A lack of this wouldn't result in aliasing, but would result in a sound that has more bass and is more crisp than a NES sounds. Finally, for efficiency a digital signal processing algorithm can combine the bandwidth limiting and NES low-pass filtering into one step due to the way the mathematics work.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

User avatar
85cocoa
Posts: 96
Joined: Sat Jul 22, 2006 12:06 pm
Location: USA

Post by 85cocoa »

How much high-pass filtering does the NES have (i.e., approximate cutoff frequency and slope)?
Warning: I am not a serious developer (yet), but CS and EE really interest me.
I was -_pentium5.1_- until I screwed up. This is why I screwed up. ^_^
User avatar
Bregalad
Posts: 8036
Joined: Fri Nov 12, 2004 2:49 pm
Location: Caen, France

Post by Bregalad »

Thanks for the link tepples.
Useless, lumbering half-wits don't scare us.
NewRisingSun
Posts: 1312
Joined: Thu May 19, 2005 11:30 am

Post by NewRisingSun »

I understand that for good quality emulated audio, one would either have to compute the sound output at the clock rate (1.7 MHz or so for the NES), then resample/low-pass-filter to 48 kHz (or whatever), or compute the band-limited output directly. The first approach makes the computation code extremely straightforward, the second approach however is a lot faster.

How would one speed up the emulation of sound channels whose output is directly controlled by the program, like direct DAC writes, or for example the speaker in the Apple II, without artifacts?
User avatar
blargg
Posts: 3717
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

Start with an amplitude step sampled at say 441 kHz. Low-pass filter this with a roll-off around 20 kHz. Now you have a band-limited step that you can take every 10th sample of to get an alias-free 44.1 kHz step from. By altering which sample you start with, you can adjust the step's fractional position in tenths. Scale and add one of these steps every time your emulated amplitude changes. This shows the waveforms you'd get if you has four fractional positions rather than ten as above:

Band-limited sound synthesis: implementation

This works and is extremely efficient, and allows for a high-level interface where you specify the time index and change in amplitude, in any order. Blip_Buffer implements this in a C and C++ library.

ALSO this animation of a band-limited step being sampled at different phases pretty much sums up everything:

Image

This is what you get at the edges of a square wave on the NES that is sampled on a PC as the exact time of the transition slowly moves between the points that the PC takes samples.
Last edited by blargg on Tue Jan 13, 2009 3:34 pm, edited 1 time in total.
mattmatteh
Posts: 345
Joined: Fri Jul 29, 2005 3:40 pm
Location: near chicago

Post by mattmatteh »

blargg, do you still have this animation ?
Post Reply