An A-SID trip, part 4

Posted by Stefano at 15/07/2022, 10:25:55 UTC.

After all it's however 2022 and musicians/producers want the affordability and ease of use of today's technology, understandably. Here's how we modeled the MOS 8580 SID chip and "ported" everything to the modern world.

Measuring

As said, the chip had already been reverse engineered to the point of having internal schematics available that looked structurally plausible. In both versions of the chip we have a multimode state variable filter of 2nd order (12 dB/oct) with digitally-controlled cutoff and resonance, followed by a digitally-controlled gain stage (volume) and some simple buffering/DC removal circuitry. The main difference between the two chips lies in how opamps are realized: the 8580 has real opamps implmented in silicon, while the 6581 uses relatively "primitive" inverters.

Given the limited amount of time available, the limited resonance amount in 8580s, and the fact that I didn't feel like abusing such chips as long as they were still implanted in working C64s, I opted for a linear model of the filter. Indeed, as it happens with most such circuits, given small enough input signals and not touching controls they behave approximately as linear time-invariant systems, which can be fully characterized by impulse responses.

Then I wrote a small BASIC program to set the analog part of the SID to given cutoff, resonance, volume, and filter mode values while performing measurements. Here's the obligatory screenshot.

I used the famous logarithmically-swept sine technique to measure such impulse responses. In this repository you can find all recordings and impulse responses can be extracted using this GNU Octave script I wrote specifically. Here are some of the magnitude responses obtained at fixed resonance and varying cutoff and viceversa (notice mains hum at multiples of 50 Hz).

Modeling

Those measurements could have been more or less quickly translated into code by using common digital filter structures, e.g., biquad filters. However, one of the most important lessons I learnt while developing virtual analog models, is that structure matters, at least for stability and transient behavior. So I decided instead to proceed from schematics and use the measurements to tune component values to match empirical observations.

Here are the schematics of the 8580 filter from the libsidplayfp wiki (LTspice file available in the A-SID git repository).

All resistance values are estimated. Badly. Resistances in the feedback part, in particular, are blatantly wrong (resonance would not be monotonically increasing if those were accurate, even if just proportionally). With such values it's impossible to match real-world measurements.

The situation improved dramatically when I removed many of those resistances in places where I wouldn't have expected them and tuning some of their values. Here's a circuit that is probably much closer to what is in the real device.

I then studied how frequency DAC-controlled conductance, and hence cutoff, and feedback gain would change w.r.t. SID frequency and resonance parameters assuming "my circuit" was correct, and it seems to me I got coherent results (shown below). I therefore concluded that it's likely that those resistance values are at least "proportionally accurate" to a good extent. It would perhaps be possible to actually also investigate absolute values, but that was beyond the scope of the project. The regressions I performed clearly allow to have the model optionally work on continuous parameter ranges, unlike the original device.

Finally, the output gain stage was trivial enough that it doesn't deserve more than a mention. For the output buffer, instead, I used a modeling method I came up with a few years ago that allows to solve certain transcendental equations naturally occurring due to the BJT transistor in there. This last part adds a tiny bit of distortion that makes the sound a bit warmer.

In the A-SID repository you'll find a GNU Octave file that simulates the filter and output circuitry and implements all of this.

Emulating

I translated the GNU Octave MOS 8580 model to C, which was absolutely straightforward, and wrote the equivalent of the audio part of A-SID using the same lookup tables and analogous computations. The result sounds close to the original to me, except it doesn't have mains hum and other background noises. I haven't conducted more rigorous comparisons as there was no time for that.

With such code we have produced two "modern" versions, really. One is a 64-bit Windows VST3 plugin, which we will also start to port to macOS and Linux soon, and another is a Web Audio/WASM version that you can try directly on the product page — yes, it's the same C code running there. CPU consumption was so low that we haven't even been able to measure it on our machines.

Both GUIs are fully resizable and we used this color palette in both cases (yeah, I know, PAL, CRTs, etc. — I don't care). We preferred to use nearest neighbour interpolation (a.k.a, no interpolation) for the VST3 GUI, even though the repo also contains code for bilinear interpolation (it can be activated by editing a preprocessor definition). The drawing/rendering techniques are, of course, quite different from the C64 ones.

In the meanwhile, we also developed some minimal amount of code and a shell script to build VST3s outside of Steinberg's overwhelming SDK tree and without CMake. Feel free to grab it from the A-SID repository (alternatives I know of: vst3-again-simple and Jamba).

Finalising

I asked a few friends to provide us some short loops to showcase A-SID on the website. I take the occasion to thank again for that Jean-Baptiste Arthus, an ex colleague of mine at Arturia who is an extremely talented musician and sound designer, Michele Duscio, who has been really kind to us, and my favourite co-author of scientific papers Leonardo Gabrielli.

Finally, I also want to thank again Luca Romano for turning my crazy fantasies into an astonishing illustration/cover for A-SID.

Conclusions

As said on the product page, this has been a work of love and we expect nothing in return. Feel free to download the VST and use as you please (no registration/data requested, there's a straight download link).

If you'd like us to develop other consumer products in the future, you could spread the word about A-SID and Orastron, and if you want to keep updated you might want to subscribe our low-volume newsletter.

If you managed to get this far reading, I want to thank you for your patience and attention.

Legal

VST is a registered trademark of Steinberg Media Technologies GmbH.

All trademarks and registered marks are properties of their respective owners. All company, product, and service names used in this page are for identification purposes only. Use of these names, trademarks, and brands does not imply endorsement.