New Playroutine - Gemini FM

Por NetNomad

Resident (48)

imagem de NetNomad

16-04-2022, 08:34

With MSXDev having a free format this year, I imagine a lot of people were scratching their heads figuring out what if any expansions to use. You could go for something common and rest assured that plenty of people would be able to enjoy it. You could go for something that gets a lot less use and have a cool uniqueness factor but put a hard limit on your audience. You could implement both, but then you have to worry about finding space for two times as much data and put in two times as much work! What If I told you that you could use one engine to support two incompatible audio device at the same time without much if any extra work?

Gemini FM is a music playroutine for MSX-Music and the SFG Sound Synthesizer Unit. While it does not take full advantage if all of the OPM's capabilities, it does allow you to write a song for the OPLL with some limits (must be in percussion mode and the custom voice is hard-coded) and have it play back on the OPM. The OPM has a set of 16 voices that approximate the OPLL voices, but then it has another bank of 16 voices that take advantage of the it's four operator capabilities. These alternate voices all have equivalent OPLL voices, so whether you use voice 0x06 (Oboe) or 0x16 (Saxophone), you'll hear an Oboe when played back on an FM-PAC. The OPM also plays the drum part on it's two remaining free channels, but this doesn't really mimic the OPLL drums, instead opting to use the OPM's white noise generator.

The easiest way to make Gemini FM data is by using the Gemini FM MIDI Converter. If you go to the page and look at the bottom, it explains the MIDI mapping it expects. Export a MIDI from your editor of choice and upload it to that page and you'll be able to tweak the speed and pitch in your browser. Then download a disk from webMSX or copy a GFMASM listing you can assemble with GFMASM.COM to get the data yourself. Huge huge thank you to Jannone for writing the code to insert data from an HTML text box into a webMSX disk, otherwise making music data would be a much more involved process!

GFM is now 100% working in at least one game which is why I'm officially calling it v1.0. However, I am still actively working to catch bugs (I am hardly a pro, I'm sure there are still plenty to be found!) as well as tweaking OPM instrument volume balance, which at this rate I may still be doing at the end of time. So if anything sounds wrong to you, especially too loud or soft on the OPM side, let me know and I will do my best to fix it! And also let me know if you run into any bugs. The readme on github will hopefully have enough information for you to see how to implement this in your project, but if something is unclear please feel free to ask. Right now it expects you to load the whole thing into RAM at 0xA000, but a ROM-able version should be doable. I've just never done a ROM game so I have no idea where people typically leave RAM and ROM page-wise- I'm open for suggestions! Thank you for reading and I hope this is of some use to you!

P.S. If hearing is believing, the download includes two examples for you to compile and hear on your own. But here's one you won't have to compile... from Compile! OPLL mode and again in OPM mode.

Entrar ou registrar-se para comentar

Por Bengalack

Hero (611)

imagem de Bengalack

16-04-2022, 11:18

Cool. And interesting - Parasol is new to me Smile

Do you have any numbers on performance on this replayer?

Por ARTRAG

Enlighted (6866)

imagem de ARTRAG

16-04-2022, 12:54

Very good! The OPM sounds richer
How does it go about cpu performance?
Have you tried to compare the CPU load with other replayers?

Por NetNomad

Resident (48)

imagem de NetNomad

17-04-2022, 05:01

That's a good question! Because it wasn't written in assembler and was also a learn-as-you-go project, I'd imagine this is sadly probably one of the slower replayers. I do have a few MGSDRV songs I've redone in GFM so I could probably benchmark between those at least- is the openMSX debug device usually how people go about that?

Por Bengalack

Hero (611)

imagem de Bengalack

17-04-2022, 10:30

openmsx can use a profiler-script which can measure timing if it knows an entry-point (/address). I'm no expect in this script, so others should probably explain better how it works (it mostly works for me, but when it doesn't - I'm a bit clueless).

You can also use good ol border coloring. And assume that every line colored is around 227 cycles or so. When doing this, you can also slow down the openmsx execution speed to actually measure, as the coloring likely will fluctuate a lot.

Por Grauw

Ascended (10623)

imagem de Grauw

17-04-2022, 13:48

My profiling script is here.

Por NetNomad

Resident (48)

imagem de NetNomad

19-04-2022, 03:29

Thank you! That's really useful! I did some testing with the old and new versions of the BGM from the Meteor game. The first version was done in MGSDRV and the second in Gemini FM. With an OPLL device inserted and running GEMINIFM.COM, I got an average of 1097.32 frames sampling 60 vblanks. With an OPM device inserted, I got 728.65. That surprised me because the OPM logic is a little more complex but I guess I was overzealous with my waits between OPLL writes? The OPM did have a higher peak of 12820 versus the OPLL's 7166. In both cases, when (I'm assuming) a rest was being processed the main function took 38 frames, which in both cases was 36/60 samples.

Then I stripped the PSG data out of the old MGSDRV version of the song leaving only the OPLL and got an average of 3019.85 frames in MSP.COM. The lowest value was 2181 and 45 samples total were under 2215, so even on rests I guess it burns that many frames just checking to see if it needs to update vibratro or pitch bend or whatever every interrupt, features GFM doesn't have. Peak value there was 14249.