Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Synth Emulation in MAME (gearspace.com)
124 points by bane on Oct 26, 2023 | hide | past | favorite | 50 comments


MAME is absolutely amazing when doing reverse engineering stuff. For example I'm trying to do it with an old keyboard from the 90s (the Roland D70) and I built an emulator for it in just a day with MAME. Just had to dial in the CPU type, the memory map and the OS rom dump. And boom, the UI of the synth magically appeared in the emulator.

https://github.com/mamedev/mame/pull/11440


It seemed like a natural next step because a lot of sound chips in classic arcade games, like the Yamaha 2151 FM synthesis chip, were also used in some of Yamaha's keyboards including the DX100.

https://en.wikipedia.org/wiki/Yamaha_YM2151


This is the library that probably does it.

https://github.com/aaronsgiles/ymfm

He pulled a lot of the ymfm chips out of MAME put it into that lib then put that lib back into MAME.

The analog chips are a bit more difficult as they in MAMEs case need a netlist made usually. Those can be tricky to get to have any sort of performance. They are fairly accurate though.


Every time I see Aaron Giles on some MAME code I know it's going to be high-quality stuff. This guy is a beast.


pitty the mame crew ran him off


Ain’t no drama like pac man drama.


What the fuck are you talking about?



Oh that. That's more of a rage "quit" because of longstanding disagreements and personal problems with an individual, no "crew" ran them out. Of note it's not like they stopped their drama, it continued on the MAMEWorld forums. And it's not like aarongiles has stopped all MAME related work.

https://www.mameworld.info/ubbthreads/showthreaded.php?Cat=&...

And even if I don't agree with cuavas entirely, they aren't totally in the wrong here either IMHO and they do explain their positions. I happen to agree with their disdain and disingenuity of keeping hoarded roms "safe", Aaron's sanctimony does get annoying at times even if unintentional and I can see how it can rub someone the wrong way, especially with as much effort invested as cuavas. Seriously if MAME was really the shithole a number of (primarily American clique) loudmouths have been saying it is, they should just fork, talk is cheap though


Reminds me of the time in Dec 1999 I wrote a patch to add save files for the NES emulator in MESS because my wife was playing Legend of Zelda and wanted to save.


There's quite a bit of variety between different DX synthesizers in terms of sound, even when they seem to be the same on paper like the DX11 and the TX81z. I bought a bunch of them when they were still cheap but it's hard to get rid of them because they all have quite recognizable signature sound.

This chip is particularly gritty and raw. Getting a DX27 instead of a DX100 will save you a lot of money. Really no clue why the DX100 is so expensive.


> Really no clue why the DX100 is so expensive.

Id think it's the former users who give it a level of desirability which does it, looking at the Wikipedia page for the DX100...


Related - https://github.com/jariseon/amame - MAME Synths as VST instruments.


Ever since the MESS merger, MAME has been emulating anything and everything: old consoles, computers, terminals, LCD games. Synthesizers just seem like a logical next step.

Only drawback seems to be it's gonna be difficult to get performance real-time enough to use as an actual musical instrument. Maybe when MiSTer cores show up for these synths, it'll change that.


There are musicians that would love to use hardware-based emulation for recording and would happily settle for current software-based solutions for live performance. Many professional musicians already do this. Musicians such as Floating Points have studios filled to the brim with large, rare, expensive synthesizers[1] with which they don't travel. Existing VSTs and reproductions get you 90% of the way there, but MAME emulation may be able to bring higher-quality emulation to a wider set of musicians.

[1] https://www.youtube.com/watch?v=75iX1rnW9WQ


> Only drawback seems to be it's gonna be difficult to get performance real-time enough to use as an actual musical instrument.

Is there something specific about the MAME codebase that makes this an issue? There are quite a few software emulations of classic synths, for example Arturia's V Collection or the Plogue's Chipsounds - and those work perfectly well in real time even on lower end machines. Roland's Virtual Analog (I hate that term) and Plug-Out also exists, though I really don't want their cloud subscription just so I can download an instrument into a physical synth. But I'm not familiar enough with the MAME codebase to know if there's something in there that could cause issues.


More that synthesizer. Some are easy to emulate, while others require a lot more CPU cycles.


Computers are really powerful these days, though, it's why physical modeling VSTi are actually usable now. Especially if you do the signal processing on the GPU instead of the CPU (which is thankfully starting to happen as well).


> Computers are really powerful these days, though, it's why physical modeling VSTi are actually usable now.

True, but simulating analog oscillators and filters well with little aliasing and good support for resonance is still quite hard. Current virtual analog synths sound good, but the first time I sat down with a real (but cheap and shitty!) analog synth, I was blown away.

> Especially if you do the signal processing on the GPU instead of the CPU (which is thankfully starting to happen as well).

There's some stuff you can do here, but my understanding is that it's pretty limited. GPUs are designed for wide parallel computation, which makes sense in graphics where pixels are relatively independent of each other. A GPU is trying to calculate many things at a single point in time in parallel.

Audio is about calculating a small number of things (just a few samples) but at a very high frame (sample) rate, and the things you're calculating often depend heavily on the results of previous points in time. There's a lot more fundamentally serial work to do, which makes it hard to map to GPUs.


> Only drawback seems to be it's gonna be difficult to get performance real-time enough to use as an actual musical instrument.

Kinda depends on whether the "sound chip" is emulated. For example, the MOS6581 doesn't seem to be emulated here. You could emulate the UI and controls of an Elektron SIDStation, but you wouldn't be able to get the sounds to play unless you had a real SID chip in there. So in that sense, just running the UI and controls would be fine for an emulator if there was a real MOS chip somewhere to take in audio.


I'm confused. There might not be one in Mame right now, but there's dozens of SID chip emulators. For example this website uses WebSID to play SID tunes in your browser: https://deepsid.chordian.net/


> For example, the MOS6581 doesn't seem to be emulated here.

https://github.com/mamedev/mame/blob/master/src/devices/soun...

The MAME and MESS trees have been reorganized a few times so I can't just track one file back easily but so far I've chased SID entries in MAME back to at least 2006. It's one of the defining features of a very popular platform, of course it's going to have at least some level of support.


MAME emulates the SID but the code dates back to like 2004 and doesn't sound anywhere near as good as the modern SID emulation engines. We prefer BSD or MIT licensed components to GPL ones so there's been some hesitation to just grab one of the popular SID engines (and our base C64 emulation is generally decent if you aren't trying to break the hardware like most demos, but it's also slow because the mapper PLA is emulated in the hot path).


That SID I think it's emulated since the first emulators for the C64 if not before.


Of course the sound chip is emulated. That's the purpose of MAME. It emulates everything in the original hardware, sound included.


For quite a while, MAME didn't always emulate sound chips. A number of games early on worked by way of prerecorded sound samples triggered at the appropriate times.


Does MAME have some kind of latency issue with the synth implementations? Why wouldn't it be real-time already?

The MIDI protocol tops out at ~1000 message/sec and no real synth ever needed control message anywhere near that frequently. Why would you need an FPGA?


The main issue is that in MAME's normal operation it waits for the start of a new video frame, runs all the emulation as quickly as possible, and then sleeps the rest of the frame time. (so-called "hurry to sleep" that became a big deal on phones). That works fine for games and computers and even Game and Watches, but it introduces lag when talking to the outside world.

Even that is OK for serial/parallel and Ethernet comms with emulated machines, but MIDI is a special case where there's enough lag between pressing a key and hearing it that even crappy players like myself get completely discombobulated.

You can record what you want separately as a MIDI sequence and then play it through the synth in MAME to get a .WAV you can paste into a DAW, but MAME as a real-time workflow isn't there yet. Our basic plan is to increase the "frame rate" for synths significantly (to something like 240 Hz) but there are of course complications with that that we need to work through.


I found that Dolphin uses OS sleeping to run the emulation roughly in sync with wall-clock time, and use a dynamic-rate audio resampler to output sound with a bit of added latency. This has the complication that frame delivery is no longer synchronized with monitor refresh, and requires VRR displays (unlike an actual Wii) for low-latency output. I had a draft PR to loosely couple the sleeps with "frame queuing delay", but it didn't get merged.

In the case of writing an audio synth, I think the usual approach is to "hurry to sleep", but synchronized with the audio device/OS mixer's 2-3 audio buffer periods/pages (rather than visual frames), and asynchronously update the UI. Are you planning to use wall-clock time, or the audio sample clock, as the source of truth for timing?


Thanks for commenting. I assume that emulating on a video frame basis is so ingrained in MAME that it's hard to drop?


I guess it's because MAMEis not emulating the software of these devices, it's emulating the whole hardware and then puts the ROMs on top of it. It's like running a synthesizer virtual machine. I understand most commercial vintage synth plugins either use samples of the real stuff --boo! or they emulate the wave functions and effects used on those devices from the manufacturer documentation, but not the exact hardware.


It's been done for the Access Virus, Waldorf MicroQ and some other Motorola 56k synths https://dsp56300.wordpress.com/, all usable as real-time instruments.


Very cool, thanks for the info. I did not mean to say that MAME were the first trying to do exact hardware emulation for synths, just that emulating hardware means a higher workload for the computer. As a note, I see that this project has created its own CPU benchmarks to make sure you can confidently run the emulations with acceptable results so while perhaps their emulation code is more efficient than MAME's --who knows-- the difficulty remains the same.


I wonder if they're strictly emulating just the digital bits of the original hardware.

I mean, the reason we have so many different VSTs for the same devices is that emulating the digital components is the "easy", so to speak, part, while the truly complex and really differentiating part is the software modeling of the analog components - which also explains the difference in price between a free VST replica of the Yamaha DX7 and the circa 199€ Native Instruments and Arturia replicas.


It's true that the analog part is not easy, but from my experience also the digital one can be as complicated. Take for example effect units or samplers, they use a lot of proprietary algorithms running in custom chips which can be very hard to understand from the outside and get right. For example emulating the digital part of the Yamaha FM chips and all their quirks, or the Roland D50 chorus/reverb ICs, or the interpolation algorithms in samplers.

Btw, some MAME components actually try to approximate the analog behavior, like for the CEM filter of the Ensoniq ESQ-1: https://github.com/mamedev/mame/blob/master/src/mame/ensoniq...

Obviously though it's a thing that takes a lot of work to get right though, so it's just a first approximation


The availability of cheap logic analyzers and multi-channel oscilloscopes has been a big help with that kind of thing.


The idea of noodling around in the Fairlight UI is pretty fun. Always nice to get an insight on how various limitations or structures of older instruments led to the music they created.


Not an emulation, but a recreation: https://adamstrange.itch.io/qasarbeach


For any Metroid fans who fondly recall the soundtrack to the original NES game, here is a killer remake using a Korg MS20 Mini.

https://www.youtube.com/watch?v=Q6fceLfjB4s&list=PL50UiFZSGF...


MAME is basically a triumph of human achievement, and one of my go-to examples of why emulation development is useful outside of pirating video games.

Yes, pirating video games is a common usecase of emulators, but it's not like the work preserving old computers is solely useful for games. A MOS 6502 is still a 6502 whether it's playing Mario or BASIC, and games turn out to just be a remarkably good (and fun) way to test accuracy of the emulation.

I think there are lots of unique computers made in the world of synthesizers and game consoles and the like, and I am glad that the MAME project is doing what it can to make sure that these are not forgotten.


MAME = multi arcade machine emulation https://en.m.wikipedia.org/wiki/MAME

DAW = digital audio workstation


MAME stopped being just an arcade emulator, they merged MESS into the project. Now MAME emulates naer anything with a CPU.


Thank You.


Over time, MAME (originally stood for Multiple Arcade Machine Emulator) absorbed the sister-project MESS (Multi Emulator Super System), so MAME now documents a wide variety of (mostly vintage) computers, video game consoles and calculators, in addition to the arcade video games that were its initial focus.


It would be fun to have realistic emulations of digital synths and sampler I used to own, but got rid of. Not for doing anything useful, but just for the nostalgia.

Is there a list somewhere of what synths are already emulated or being worked on?


speaking of yamaha, and old chips....just putting out there the incredible work of ploguesounds (their synths chipsynth, as well as their bit-perfect yamaha dx7 and other yamaha synths are just incredible) - and chipcrusher (bit perfect ADC emulations) are one of the most incredible and inspiring creative tools on my pc. https://www.plogue.com/


We're big fans of Plogue and some of their research has been incorporated into MAME (and vice-versa).


Anyone fancy doing the QY70?


There's a good start at it in the tree ( https://github.com/mamedev/mame/blob/master/src/mame/yamaha/... ) but it's missing the sound generation which is kind of the important part :-)


Oh nice! There's some hope then...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: