Subject: Updates on filter simulation

From: alankila
Date: Fri May 5 07:08:58 2006

To: UADE-Developer-discussion
Well well, I finally managed to draw proper pictures of the Amiga's LED filter frequency responses. I had a nasty bug last time I tried this and due to that concluded (in puzzlement) that substracting spectra doesn't work for some reason. Well, it does, and here are the results.

Here are the measurements for Amiga 500 and Amiga 1200 filter responses. Amiga 500 has some kind of noise near 20 kHz which I'm not prepared to explain or model in any fashion:

http://bel.fi/~alankila/led-filter-frequency-response.png

Here is the LED simulation as given by UADE's current CVS code:

http://bel.fi/~alankila/uade-led-difference.png

(This is not a perfect fit. With the cost of some more multiplications, I can make a better match:

http://bel.fi/~alankila/led-improved-patch.png
)

The true LED filter would appear to be an analog 2nd order Butterworth filter. This filter could be simulated digitally but we can't do it at 44.1 kHz sampling rate due to the frequency warping effect of the bilinear transformation. (What this means in non-DSP jargon is that when we take an analog filter design and convert it into digital domain, we come to represent the entire frequency range of analog filter (0 to infinity) in the smaller digital range (0 .. nyquist). The frequency warping is of course nonlinear, but distortion increases rapidly as we approach the nyquist.)

What it means may be even better described by pictures:

http://bel.fi/~alankila/butterworth-at-44100.png
http://bel.fi/~alankila/butterworth-at-96000.png

We could use a more accurate butterworth design if we initially synthesised on another sampling frequency such as 96 kHz or 88.2 kHz and then made all the filtering we need and then threw away every second sample.

-- 
Antti

---

From: alankila
Date: Fri May 5 07:27:57 2006

To: UADE-Developer-discussion
Oh yeah, I also drew a picture of the difference of A1200 and A500 outputs through the same method. The picture is a lot noisier unfortunately, probably all of that is fault of the worse hardware in A500.

http://bel.fi/~alankila/a500-to-a1200.png

This picture reveals the difference in spectra between A500 and A1200 playing the same song. The model for that seems to work quite well. This is clearly a first order filter.

We might go further in our A500 simulation and attempt to model some of these distortion effects, but before there's any point to attempt that, we should make some kind of theory for them. (Theory is an explanation for observed effects, so we should think about whether the D/A sucks, or if the capacitors on the output path are bad, etc.) I'm myself hesitant to do this -- the sound may be more authentic but it would probably not be so pleasing if we added them.

UADE as it currently stands is likely &quot;better&quot; Amiga 500 sound machine than the Amiga 500 itself was.

---

From: mld
Date: Fri May 5 09:38:05 2006

nice work anti!

how costly would those &quot;extra multiplications&quot; be to improve the a1200 filter model? Hope it doesn't require a 64bit machine ;-)

Ok,seriously ... about artficially &quot;deteriorate&quot; the output for the filters? Question is really if it's cheap component causing the signal dirt, and if all a500 behaved the same.
In theory I see a point getting even closer to the real thing, but practically I think it's not useful... (In RL, I'm more a gfx dude, so anything causing artifacts in a pic is something to be filtered out, instead of being filtered in. *g*)

---

From: alankila
Date: Fri May 5 10:28:43 2006

To: UADE-Developer-discussion
Well, we have several strategies on which to continue improving the UADE filter model.

We can continue tweaking the current code, in which case I'd simply add one more filtering step into the A500 and A1200 LED paths and that'd be it. They aren't costly at all -- I mostly mention &quot;a few extra multiplications&quot; to humour shd. We have a long-standing gentlemanny disagreement about this matter. However, this model is not precise.

What I really would like to do is to start from the sinc code and use it to synthesize Amiga output at a high frequency. After giving it some thought, I'd like to synthesize at 3x the output frequency. For instance, if target output frequency is 44.1 kHz, then I'd be synthesizing at 132.3 kHz frequency. This is chosen to be high enough to remove the effects of the bilnear transform from distorting the frequency range below 20 kHz, thus allowing me to run the &quot;correct&quot; filters without any output frequency dependant hand-fitting apart from choosing the correct cutoff frequency, which is trivial.

Because the synthesis to 132 kHz would be done using the sinc-based resampling, the output generated would not contain any frequency components above 20 kHz and it would be safe then to discard 2/3 of the samples and produce a working output at 44.1 kHz which could be fed to the speakers.

I do not think it is necessarily a good idea to model the imperfect components in Amiga in our models. For instance, the LED filter should obviously introduce some kind of noise around -30 dB of the signal level. Perhaps we should do that, for authenticity reasons. But I offer an analogy: even people who sample SID music from actual C64 go to pains to remove electrical noise from the SID chip input. They consider the video chip noise on top of the music to be &quot;accidental&quot; rather than &quot;intrisic&quot;. That would be along my decision as well.

---

From: shd
Date: Fri May 5 12:20:25 2006

To: UADE-Developer-discussion
[quote:97f07496c8="mld"]
In theory I see a point getting even closer to the real thing, but practically I think it's not useful... (In RL, I'm more a gfx dude, so anything causing artifacts in a pic is something to be filtered out, instead of being filtered in. *g*)[/quote:97f07496c8]

I agree. My take is that the code must be as simple as possible with the constraint that there is no audible difference to the real thing. A change in frequency response will probably not improve anything. If there is any problem (do we have any problems?), it's somewhere else. Maybe some analog artifact.

---

From: alankila
Date: Fri May 5 18:53:52 2006

To: UADE-Developer-discussion
There is now an experimental patch that reproduces the filter behaviour as perfectly as I can make it. It should be very accurate now. Here's a typical picture showing the average power spectra of UADE vs. Amiga playing the same song:

http://bel.fi/~alankila/A500-filter.png

(The picture is with LED filter disabled.) The sudden crash in output power after 19.5 kHz is intentional and byproduct of the sinc filter that cuts very steeply into the signal and quiets it for 22 kHz nyquist to avoid aliasing.

The code is very slow because it does a lot of redundant computation per sample. Additionally, it is only worth damn if you run it with the sinc interpolator. It is likely to be detrimental if you use the antialiasing interpolator!

http://bel.fi/~alankila/uade-perfect-filter.diff

The patch introduces the following DSP improvements:

- 3x upsampling for digital filters
- new butterworth LED filter design (should be exact)
- new A500 static filter (should be exact)
- sinc table interpolation for jitter noise removal (reduces noise around 20 kHz)
- 48 kHz mixing frequency (just for test)

The patch removes the old A500S filters as small byproduct. This is not intentional, I merely killed them off from confusing me when I wrote the code.

shd should provide me a version of UADE with choosable output frequency so that I could break this patch into small parts and feed the entire work in small pieces.

We have some known defects. Firstly, Amiga 500 LED filter uses poor components which probably explains why the Amiga 500 LED filter misbehaves slightly. (The model is only accurate to about 0.5 dB for A500.) Additionally, Amiga 1200 seems to leak a bit of current into the LED filter even when the LED filter is off. This causes a very small treble attenuation (around 0.5 dB). The treble attenuation disappears when the LED filter is behaved, realizing ideal Butterworth. Both effects are not modelled.

-- 
Antti

---

From: alankila
Date: Sun May 7 09:10:46 2006

To: UADE-Developer-discussion
Due to changes in the CVS version, a new .diff file was produced and put into the URL above.

The remaining DSP improvements are:

- filter upsampling (2x or 3x depending on chosen output frequency value) when sinc interpolator is in use
- denormal number avoidance (denormals are very small floating point numbers that put FPUs into slow mode and can harm performance)
- sinc table interpolation for slightly improved accuracy at stopband (20 kHz)