indigodarkwolf / box16

A fork of the official X16 emulator, converted to C++20 and with a bunch of features tweaked and added.
MIT License
42 stars 18 forks source link

Feature Request: Export VGM file #7

Open indigodarkwolf opened 3 years ago

indigodarkwolf commented 3 years ago

It would be nice to have an option to capture writes to audio and export them to a VGM file. Export should be able to be enabled, but timing should only start with the first subsequent write to audio devices (e.g. trim any "dead air" that occurs before music is being played).

Bonus points if MIDI is implemented and this can export writes resulting from MIDI input in addition to vanilla writes to the audio devices. Something to consider when implementing, or perhaps means issue #2 should be implemented before this.

akumanatt commented 3 years ago

Also, VGM file doesn't support VERA (obviously). PSG register writes could use unused 0xA1-0xAF commands or emulated with other wavetable chips. PCM could be emulated with 32X PWM, which is the only chip with DAC writes besides the (8-bit mono-only) YM2612.

indigodarkwolf commented 3 years ago

Yeah, there'd undoubtedly be some limitations from mapping from the X16's capabilities to their closest analogies in the VGM format. I figured most likely in the number of PSG channels supported since I guess I was expecting there'd be something that could replicate at least some of the VERA's PSG's channels. Or if not, well, hrm. Suppose we could always go the route of a proprietary format and leave it to folks to write their own plugins for whatever music player they want to listen with.

ZeroByteOrg commented 2 years ago

Another option would be to find an unused "chip command" "opcode" (like 0x54 = YM2151) and use that for VERA PSG. I'd think that a 2-byte operand for this "opcode" would make the most sense. For instance, command opcode 0xDF is currently unused in the reference player library. 0xDF rr dd = write value dd to VeraPCM on register rr, where rr = offset from 0x1F9C0. Thus 0xDF 0x01 0x0B --> write 0B to the FRQ_HI on voice 0.

ZeroByteOrg commented 2 years ago

Also, VGM file doesn't support VERA (obviously). PSG register writes could use unused 0xA1-0xAF commands or emulated with other wavetable chips. PCM could be emulated with 32X PWM, which is the only chip with DAC writes besides the (8-bit mono-only) YM2612.

A1-AF are not unused. In dual-chip tunes, the 2nd YM-family chip is accessed using Ax instead of 5x. E.g. 54=YM2151, A4 = second YM2151.

ZeroByteOrg commented 2 years ago

The real problem with VGM output is that it wouldn't be very useful, as no software would be able to play it back because there are no emu cores for VERA PCM and VERA PSG, and any unused commands used to encapsulate the messages would be skipped by all existing players / renderers.