mamedev / mame

MAME
https://www.mamedev.org/
Other
7.76k stars 1.95k forks source link

MAME synths as VST plugins #3817

Open jariseon opened 5 years ago

jariseon commented 5 years ago

i've implemented a custom osd and a tiny frontend to run MAME synths as DAW plugins (VST2s currently). The proof of concept plugins work well, but i'm unsure if my choice for the architecture is optimal. would be great to hear opinions on how to improve it, and whether there's interest for a pull request.

background: VST2 plugin is a DLL/shared library. hosting DAW loads it dynamically during runtime. my proof of concept VST2 plugin interfaces the host, embeds MAME in the DLL, and runs it in a separate thread. the custom osd/frontend works as follows:

A) osd's audio and midi modules are lock-free ring buffers/queues, thus effectively virtual audio and midi cables. this enables loose coupling with the embedding app (VST2 plugin in this case), and it does not require changes in existing MAME codebase.

B) the gui runs in an embedded webview using MAME core http and websocket servers as backend. external browser app is thus not required. the webview renders a driver-specific html file, or falls back to an xslt'd layout file if html is unavailable. i was inspired by the work of @cbrunschen and @JoakimLarsson (and indeed reused parts of their contributions), but instead of driver-specific approaches i tried to achieve a generic solution: user's input from the webview is routed into driver's INPUT_PORT maps (in a similar way that the existing layout system works), while MAME output (e.g., hd44780 and vfd displays) is forwarded to the webview using MAME's output_manager notification delegates. this requires only minor (if any) changes in driver codebase. the glue code is simple, just couple of methods encapsulated in another custom osd class.

as i'm still very much learning MAME internals, there is probably a better preferred way to architecture these things? any insights greatly appreciated, @rb6502 @cuavas others? many thanks in advance!

jariseon commented 5 years ago

here are couple of VST plugin screenshots snapped from Bitwig DAW (v2.3.4, demo version). i'm going to add more synths soon to see if my current solution really scales across other drivers. Yamaha FB-01:

fb-01

and ensoniq VFX:

vfx-sd
cbrunschen commented 5 years ago

To me, that looks pretty great! And integrating these into a DAW will make them a loit more useful, of course!

But does this augment, or completely replace the current approach? There is a useful aspect of being able to have an external display on which (some of) the UI runs: it allows recreating the control surface by using potentially multiple touch screen tablets placed together with a MIDI keyboard controller to give an experience as similar as you can get to the original without having the same actual hardware buttons.

jariseon commented 5 years ago

excellent point. the front panel html file is read from local file system and can therefore be replaced with an alternative html/css/js implementation. but it would sure make sense to add a frontend gui option to parametrize the URL for control surface specific optimizations. totally missed that cool affordance.

i tried to open one of the proof of concept plugins in a DAW, and then browsed to its main panel URL in chrome. looks like there can be multiple front panels open same time, but my current implementation has a bug: input works from both panels, but output is only updated in one of them. need to loop through all active ws connections :) thanks Christian!

balr0g commented 5 years ago

@jariseon Thanks; any chance you could link your code? That would make it much easier to comment on the design here.

jariseon commented 5 years ago

@balr0g sure, agreed. forked a repo and committed the sources and design thoughts here.

pcky commented 1 year ago

Was anybody ever able to build "AMAME" with the VST plugin? @jariseon I'm very thankful for hints on that topic. Thanks!

GenesisKC commented 1 year ago

A really interesting project and the synths emulated are not widely represented in the world of plugins which makes it even more intriguing. I'm just not too familiar with MAME or programming so I don't know how to set it up. Me and a few friends would be very interested in having a go with this if it is a working project. @jariseon

9Skrip commented 1 year ago

Fantastic I wish more developers join the project

70MM13-actual commented 4 months ago

This needs to be completed, at least to the point where there is a precompiled binary available for musicians who are only interested in making music! Please!

VincyZed commented 2 months ago

I would also love to see a binary. I have compiled the fork but was never able to get a VST plugin anywhere.