Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - FM soundtrack/drivers for homebrew

Reply to topic
Author Message
  • Joined: 18 Jul 2020
  • Posts: 367
Reply with quote
FM soundtrack/drivers for homebrew
Post Posted: Mon Jan 30, 2023 7:58 pm
[Admin: FM driver discussion split from https://www.smspower.org/forums/19386-SMSCastlevaniaHomebrew ]

--------------------------

NewHorizon wrote

Yes, I think making a stable port of the original game will be a major achievement and one that I am really looking forward to. What I have seen graphically is gorgeous and the music is kicking! :) If an FM soundtrack was supported alongside the standard SMS soundtrack, that would be even more amazing...especially if it worked on real hardware. I have the SMS FM module from the etim website.


Devkit SMS does support FM output. Also, Louis has a FM version of the Vampire Killer track here:

Getting it into the game seems complicated at this point. As the supported format is moonsound. From what I surmised, it requires you to create the tracks with the Moonblaster tracker, a MSX application.

I would say that's probably less than ideal to create the tracks in, versus something like, creating the tracks in whatever the artist is comfortable using.

VGM seems like a popular/common output format. Maybe if there's a conversion from VGM to MBM?

Another option is maybe grabbing another FM driver, and using that? I'm not entirely sure. There seems to be a lot of requests for FM music though.

I could be wrong about all of this. There are way more knowledgeable people on this topic than me. I've only just got my toes wet on the subject in the last two weeks or so. After being inspired by Louis's SOR 2 stage 01 music. Might as well link that too :P



Also, ironically, I just bought the etim module, and it's coming next Tuesday. Awesome! 😊 So I am committed to doing what I can for FM tracks. Devkit SMS has some great functions for detecting FM support.
  View user's profile Send private message
  • Joined: 21 Mar 2021
  • Posts: 7
  • Location: Budapest, Hungary
Reply with quote
Post Posted: Mon Jan 30, 2023 8:14 pm
Hi, I think there's a lot to this project. The graphics are amazing, and the music is pretty decent, though I would personally make the bass sustain on a louder volume, it kind of gets lost because the SN76489 has a logarithmic volume curve.

If there is any intent for an FM soundtrack I'm happy to get involved if needed, heck I'm happy to write a custom sound engine for it. I have only written assembly code for 6502-based CPUs but I've read through a lot of Z80 and SMS documentation so I'm aware of how it's different exactly.

There's been a recent discovery that makes the OPLL much more versatile than originally thought with the preset instruments. All it takes is switching the selected instrument number while the sound is playing, which updates some parameters of the sound instantly, but not others. This can unlock different combination sounds that don't exist among the 15 hardcoded instruments including static noise and pure sine waves, which are great for more sound variety and percussion without having to use the kind of underwhelming "drums mode" of the chip.

I have made such a cover of a song from Mega Man X3.

This does not use the "drums mode" or the custom instrument at all. So if you'd like to have an FM soundtrack like this for the port, I'd be up for it. If the SN76489 can be used along with it, it can potentially sound even better, but I suppose at some point you'd have to stick to simpler sound design to not use up too much CPU time to run the music engine.
  View user's profile Send private message Visit poster's website
  • Joined: 18 Jul 2020
  • Posts: 367
Reply with quote
Post Posted: Mon Jan 30, 2023 8:53 pm
Vuurniac wrote

If there is any intent for an FM soundtrack I'm happy to get involved if needed, heck I'm happy to write a custom sound engine for it. I have only written assembly code for 6502-based CPUs but I've read through a lot of Z80 and SMS documentation so I'm aware of how it's different exactly.


I'm not entirely sure tbh. I guess I'm waiting on more of the community to give their thoughts. I'm currently using Devkit SMS to create this game. I have tested running PSG and Moonsound (FM) sources together, while stress testing actual game processing. It seems to have good performance. So I know that works well.

But if this is less than ideal from a media creation stand point. Then adding an efficient flexible audio driver might be the way to go. I can't help but think that this hasn't been discussed in detail on this forum. So there's got to be more history behind why the Moonsound format was chosen.

I guess the short answer is yes, FM music for this game would be great, but need more information to choose the best fit.
  View user's profile Send private message
  • Joined: 01 Feb 2014
  • Posts: 844
Reply with quote
Post Posted: Mon Jan 30, 2023 9:06 pm
xfixium wrote
Getting it into the game seems complicated at this point. As the supported format is moonsound. From what I surmised, it requires you to create the tracks with the Moonblaster tracker, a MSX application.

I would say that's probably less than ideal to create the tracks in, versus something like, creating the tracks in whatever the artist is comfortable using.

It’s really not so bad. You can run Moonblaster in Emulicious which lets you mount folders as disks, so it’s not a whole lot different from using a native tracker. Of course you’ll still have to wrestle with Moonblaster's peculiarities and its clunky UI. It’s a capable tracker, but it definitely needs some getting used to.

If you consider including FM sound, you’ll have to think about which systems you want to support, as the Mark III + FM unit combination can’t use FM and PSG at the same time, so you need to provide additional FM sound effects for this setup.

I think you’re off to a great start with the fantastic sounding PSG tracks, so even if you decide that FM sound is too much of a hassle, your project will have a stellar soundtrack.
  View user's profile Send private message
  • Joined: 29 Jan 2023
  • Posts: 11
Reply with quote
Post Posted: Mon Jan 30, 2023 9:54 pm
xfixium wrote
NewHorizon wrote

Yes, I think making a stable port of the original game will be a major achievement and one that I am really looking forward to. What I have seen graphically is gorgeous and the music is kicking! :) If an FM soundtrack was supported alongside the standard SMS soundtrack, that would be even more amazing...especially if it worked on real hardware. I have the SMS FM module from the etim website.


Devkit SMS does support FM output. Also, Louis has a FM version of the Vampire Killer track here:

Getting it into the game seems complicated at this point. As the supported format is moonsound. From what I surmised, it requires you to create the tracks with the Moonblaster tracker, a MSX application.

I would say that's probably less than ideal to create the tracks in, versus something like, creating the tracks in whatever the artist is comfortable using.

VGM seems like a popular/common output format. Maybe if there's a conversion from VGM to MBM?

Another option is maybe grabbing another FM driver, and using that? I'm not entirely sure. There seems to be a lot of requests for FM music though.

I could be wrong about all of this. There are way more knowledgeable people on this topic than me. I've only just got my toes wet on the subject in the last two weeks or so. After being inspired by Louis's SOR 2 stage 01 music. Might as well link that too :P



Also, ironically, I just bought the etim module, and it's coming next Tuesday. Awesome! 😊 So I am committed to doing what I can for FM tracks. Devkit SMS has some great functions for detecting FM support.

From what I know, the Moonsound is a OPL4 soundcard for the MSX that is capable of both FM Synth and PCM. You can find more info here: https://en.wikipedia.org/wiki/Moonsound
https://www.msx.org/wiki/Sunrise_MoonSound
  View user's profile Send private message
  • Joined: 18 Jul 2020
  • Posts: 367
Reply with quote
Post Posted: Tue Jan 31, 2023 12:58 am
Kagesan wrote

It’s really not so bad. You can run Moonblaster in Emulicious which lets you mount folders as disks, so it’s not a whole lot different from using a native tracker. Of course you’ll still have to wrestle with Moonblaster's peculiarities and its clunky UI. It’s a capable tracker, but it definitely needs some getting used to.

If you consider including FM sound, you’ll have to think about which systems you want to support, as the Mark III + FM unit combination can’t use FM and PSG at the same time, so you need to provide additional FM sound effects for this setup.


Thanks for the info. I guess the concern is using the Moonblaster UI. How much of a hassle that'd be for artists creating the tracks. Versuses using any environment that exports to a supported YM2613 VGM format, and just converting it to moonsound. If conversion is even possible. I guess I'm looking at it from a graphics editor point of view. Like Photoshop vs MS Paint 🤔
  View user's profile Send private message
  • Joined: 30 Jan 2023
  • Posts: 53
  • Location: Manchester, England
Reply with quote
Post Posted: Tue Jan 31, 2023 2:36 am
xfixium wrote
Kagesan wrote

It’s really not so bad. You can run Moonblaster in Emulicious which lets you mount folders as disks, so it’s not a whole lot different from using a native tracker. Of course you’ll still have to wrestle with Moonblaster's peculiarities and its clunky UI. It’s a capable tracker, but it definitely needs some getting used to.

If you consider including FM sound, you’ll have to think about which systems you want to support, as the Mark III + FM unit combination can’t use FM and PSG at the same time, so you need to provide additional FM sound effects for this setup.


Thanks for the info. I guess the concern is using the Moonblaster UI. How much of a hassle that'd be for artists creating the tracks. Versuses using any environment that exports to a supported YM2613 VGM format, and just converting it to moonsound. If conversion is even possible. I guess I'm looking at it from a graphics editor point of view. Like Photoshop vs MS Paint 🤔


When I first became interested in making YM2413 music I stumbled across Moonblaster since I didn't want to pay for Deflemask. I never did anything with it though as I couldn't for the life of me figure out how to use it and not long after I stumbled across 1tracker instead. The UI for that was also very basic and limited but it served me well until Furnace came onto the scene.
  View user's profile Send private message Visit poster's website
  • Joined: 01 Feb 2014
  • Posts: 844
Reply with quote
Post Posted: Tue Jan 31, 2023 8:08 am
xfixium wrote
I guess the concern is using the Moonblaster UI. How much of a hassle that'd be for artists creating the tracks. Versuses using any environment that exports to a supported YM2613 VGM format, and just converting it to moonsound. If conversion is even possible.

Unfortunately, it’s not. Among other things, one of Moonblaster's idiosyncrasies is the use of a fixed length for all its patterns, plus there's a finite number of total patterns. Shoehorning regular tracker data into that structure simply won’t work. And that’s not even touching the issue of custom instruments. The other way round might be possible, but that way the result would be a module that's quite limited, so why would anyone want to do that?

If you want to familiarize yourself with past discussion on the topic, there’s an exhaustive thread here. And some more information here.

Mooblaster format was chosen mainly because we weren’t exactly spoiled for choice regarding trackers supporting the YM2413 at all, and MBM had a solid replayer available in z80 asm, even though some adjustments had to be made to make it run on the SMS. The format has also been in use in the MSX community since forever, so there’s a lot of information that can be found there.

I haven’t really followed the development of TriloTracker recently. Back then it was still in its infancy, but maybe today it’s a viable option.

If someone wants to take the plunge and get into using Moonblaster, there's some decent documentation here.
  View user's profile Send private message
  • Joined: 29 Mar 2012
  • Posts: 879
  • Location: Spain
Reply with quote
Post Posted: Tue Jan 31, 2023 9:07 am
+1 to Kagesan's summary.

In short, we've been waiting for a decade for the definitive fm driver, but we only have moonblaster....
  View user's profile Send private message
  • Joined: 18 Jul 2020
  • Posts: 367
Reply with quote
Post Posted: Tue Jan 31, 2023 5:46 pm
Kagesan wrote

Unfortunately, it’s not. Among other things, one of Moonblaster's idiosyncrasies is the use of a fixed length for all its patterns, plus there's a finite number of total patterns. Shoehorning regular tracker data into that structure simply won’t work. And that’s not even touching the issue of custom instruments. The other way round might be possible, but that way the result would be a module that's quite limited, so why would anyone want to do that?

If you want to familiarize yourself with past discussion on the topic, there’s an exhaustive thread here. And some more information here.

Mooblaster format was chosen mainly because we weren’t exactly spoiled for choice regarding trackers supporting the YM2413 at all, and MBM had a solid replayer available in z80 asm, even though some adjustments had to be made to make it run on the SMS. The format has also been in use in the MSX community since forever, so there’s a lot of information that can be found there.

I haven’t really followed the development of TriloTracker recently. Back then it was still in its infancy, but maybe today it’s a viable option.

If someone wants to take the plunge and get into using Moonblaster, there's some decent documentation here.


Thanks for all the information. I had attempted to look through the forum for information, but there's so much of it, I didn't really know what was still valid presently. I'll have to dig through those threads.

kusfo wrote
+1 to Kagesan's summary.

In short, we've been waiting for a decade for the definitive fm driver, but we only have moonblaster....


That, is quite a long time. I'm curious, drivers that are in games that support FM sound, and say something from the Sonic FM hack, they aren't viable? Or is it not that simple?

segarule wrote
Based in Kasesan´s knowledge i think that is better put all effort in preliminary version only with PSG and after with everything working well think about a FM version. I hope that SMS Castlevania can be submitted in 2023 Compettition!


Agreed, and it's the path I'm on, but FM audio questions come up frequently.

Not sure I'd have this presentable by the deadline. Maybe I'll do something next year, as I'd want to do a game from the ground up in the given time frame. Not a game I have already worked on.
  View user's profile Send private message
  • Joined: 01 Feb 2014
  • Posts: 844
Reply with quote
Post Posted: Tue Jan 31, 2023 6:32 pm
xfixium wrote
I'm curious, drivers that are in games that support FM sound, and say something from the Sonic FM hack, they aren't viable? Or is it not that simple?

None of the commercially released SMS games that supported FM sound used all of its features. ROM space was expensive and developers couldn’t justify wasting large parts of it on two separate soundtracks, so PSG and FM drivers played the same music data, they just mapped it to different instruments (or "instruments" in the PSG's case). The 3 voices of the PSG were usually doubled to fill the 6 melodic voices of the FM percussion mode and the drums were played on the remaining channel(s). I’m not sure if the Sonic FM hack does the same, but I think so.
As far as I know, the 9 channel mode of the YM2413 has never been used at all back in the day.

Of course, nowadays it’s no problem having a bigger ROM, so we can easily afford using both sound chips to their fullest.


However, I think the most important thing will be getting the gameplay just right, even though tweaking it to perfection is traditionally the least fun part of development.

Castlevania is a much-beloved game and there are plenty of knowledgeable active players who will mercilessly point out any inaccuracies they encounter. Even after several years, I still occasionally get mails from people who complain about things they think I got wrong in my Bruce Lee remake, and that’s a game with lots of things that are open for interpretation due to being not nearly as tightly designed as Castlevania.
  View user's profile Send private message
  • Joined: 18 Jul 2020
  • Posts: 367
Reply with quote
Post Posted: Tue Jan 31, 2023 6:42 pm
Kagesan wrote

However, I think the most important thing will be getting the gameplay just right, even though tweaking it to perfection is traditionally the least fun part of development.

Castlevania is a much-beloved game and there are plenty of knowledgeable active players who will mercilessly point out any inaccuracies they encounter. Even after several years, I still occasionally get mails from people who complain about things they think I got wrong in my Bruce Lee remake, and that’s a game with lots of things that are open for interpretation due to being not nearly as tightly designed as Castlevania.


lol I fully expect this. I spent tweaking the jump to hit the right amount of pixels/speed/hang time, and I still don't think it's perfect. This is without delta timing, as well. I'm gonna try and get it as accurate as possible, but I'm also not going to get caught up in things of that nature. I'll give it my best shot, that's all I can do.

There will always be people unhappy with with this or that. It'll be open source, they can always fix it themselves if it bothers them that much.
  View user's profile Send private message
  • Joined: 16 May 2002
  • Posts: 1355
  • Location: italy
Reply with quote
Post Posted: Tue Jan 31, 2023 7:15 pm
xfixium wrote
I would say that's probably less than ideal to create the tracks in, versus something like, creating the tracks in whatever the artist is comfortable using.
As you're probably going to see anyway if you delve in the older discussions, I offered several times to write a dedicated FM tracker, but I always got turned down for various reasons, ranging from "moonblaster works fine enough" to "some other tracker is on its way". As much as I'd like to offer my help again and support your talented composer with some bespoke tools, my current job as a math teacher in a high school doesn't leave me much free time, so I just can't.

Kagesan wrote
I’m not sure if the Sonic FM hack does the same, but I think so.
No, the short answer is: ValleyBell overhauled everything. He wrote new music from scratch, with a custom sound engine.
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2012
  • Posts: 879
  • Location: Spain
Reply with quote
Post Posted: Tue Jan 31, 2023 8:55 pm
Kagesan wrote

As far as I know, the 9 channel mode of the YM2413 has never been used at all back in the day.

It was used (plus the 3 PSG channels) in the Japanese Master System Bios, wasn't it?


@Tom
The main problem is not as much lacking a modern platform tracker (we already have Furnace or 1tracker) as much as the lack of driver for their formats (or some intermediate format).
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14687
  • Location: London
Reply with quote
Post Posted: Wed Feb 01, 2023 7:54 am
I’ve yet to find a VGM soundtrack using more than six tone channels. Most games have three tone channels, maybe extended to six for extra sound depth (eg a slightly delayed echo of a main channel). This is almost certainly because (1) sharing the music data between FM and PSG saves a lot of ROM space and (2) percussion is kind of useful even if it’s limited.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3761
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Wed Feb 01, 2023 9:55 am
Tom wrote
[...] ValleyBell overhauled everything. He wrote new music from scratch, with a custom sound engine.


Wait, I had totally missed that. So it turns out we have another FM engine available?
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2012
  • Posts: 879
  • Location: Spain
Reply with quote
Post Posted: Thu Feb 02, 2023 11:41 am
sverx wrote
Tom wrote
[...] ValleyBell overhauled everything. He wrote new music from scratch, with a custom sound engine.


Wait, I had totally missed that. So it turns out we have another FM engine available?


I took a look at the source code package and the format seems pretty compact, and it works over vgms converted...maybe the solution was just in front of us for such a long time.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3761
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Thu Feb 02, 2023 1:18 pm
kusfo wrote
I took a look at the source code package and the format seems pretty compact, and it works over vgms converted...maybe the solution was just in front of us for such a long time.


I couldn't find the sources. Link please? :)

Also @Maxim (or any mod) - could you split this discussion into a new topic?
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2012
  • Posts: 879
  • Location: Spain
Reply with quote
Post Posted: Thu Feb 02, 2023 2:10 pm
Link here: https://forums.sonicretro.org/index.php?threads/sonic-1-fm-full-source.34827/
Direct link to the source: https://www.mediafire.com/download/uix7wl2ec4abgwa/Sonic1SMS_full_source.7z
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3761
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Thu Feb 02, 2023 3:21 pm
kusfo wrote
I took a look at the source code package and the format seems pretty compact, and it works over vgms converted...maybe the solution was just in front of us for such a long time.


So, if I understand correctly what I'm reading from the sources, this is a modified SMPS audio engine, more efficient in terms of used ROM space per song. Songs are event-based (play this note, wait, change octave, etc) and stored as separate channels, notes use (shared) instruments definitions that include envelopes and other details.
Not sure if this drops or adds any feature from the original engine.
Songs seems to be hand-coded, not a simple conversion from VGM (but likely not impossible to convert to this from a tracked format).

Any hint @ValleyBell? :)
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2012
  • Posts: 879
  • Location: Spain
Reply with quote
Post Posted: Thu Feb 02, 2023 3:28 pm
There's a couple of c source files of some converting utilities. I only did a brief glimpse (today I'm in the office), so I'm not sure if they convert from Midi to VGM or also from VGM to the song format
  View user's profile Send private message
  • Joined: 09 Jun 2014
  • Posts: 362
Reply with quote
Post Posted: Thu Feb 02, 2023 3:42 pm
This is what valleybell told me when i asked him how he changed the music:

Quote

For Sonic 1 FM, I recoded parts of the sound driver to support the OPLL chip.
Then I converted the MIDIs to an assembly-like format and these ASM files I compiled into the ROM.
The process was basically: MIDI -> ASM -> binary -> ROM.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3761
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Thu Feb 02, 2023 3:46 pm
So it's from MIDI, I see now why they're event based and separated by channel. But a conversion from a tracked format is still feasible I guess.
  View user's profile Send private message Visit poster's website
  • Joined: 15 Sep 2009
  • Posts: 377
Reply with quote
Post Posted: Fri Feb 03, 2023 10:52 pm
There is a page on our SMSPower wiki about Sonic 1 FM and it includes the source code:
https://www.smspower.org/Hacks/SonicTheHedgehog-SMS-FM-Mod

About the sound driver:
I took the original PSG sound driver and recoded the sequence format parser. Then I added FM functions to it.
The frequency/volume effect processing was mostly kept from the original sound driver, so it is only a partial rewrite. (and thus not suitable for commercial use)
I think I didn't drop any features, except for in-song volume envelope definitions. I just added lots of things on top of it. (FM-specific things and sequence subroutines)

The original version of Sonic 1 does not use SMPS, btw. It uses a custom sound driver. (maybe it is used in other games developed by Ancient?)
The sound format doesn't seem to resemble Koshiro's Music LALF or Mucom formats.


About the song format:
I wanted to fit everything into the existing space, so I developed a pretty compact sound format. The original format always used 2 bytes for each note and rest. I reduced it to 1 byte per note in most cases.

The format consists of a PSG or FM song header (it is just a list of track pointers) and per-channel "sequence data".
Most sequence commands have separate parameters for PSG and FM, allowing for shared data between PSG and FM versions of the same song.
The "instrument" command even lets you specify a separate FM instrument for the channel group 1..3 and 4..6 for easy layering.
"NewFormat/Format_inc.asm" contains a list of all commands as ASM macros with basic descriptions of the parameters.


Existing songs I converted from the original binary Sonic 1 sound format to the new driver's binary format. (S1_Conv.c) The resulting files were then converted to ASM. (S1_Cmds.c with definition file NewFormat/S1_Cmds.txt)
Those I modified to add FM-specific parts.
The intention behind this process was to keep the original sequence's structure intact. I thought that this would make size-optimization easier.


I only made one completely "new" song for Sonic 1 FM: an OPLL version of the Space Harrier/Sonic Retro Theme (And this one wasn't even included in the ROM due to various reasons.)
In that case, I took a MID file and converted it to ASM directly. I wrote the converter tool for another (custom) sound driver though, so that tool is not part of the source code release.


I never converted VGM files directly to anything but MID files. (I always clean vgm2mid conversions up afterwards.)
I usually use MID files as basis for further conversion. Most of my conversion tool assume monophonic channels (except drums), allowing for a fairly direct mapping between MIDI channels and FM/PSG hardware channels.
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!