FBFMlib - An easy-to-use OPL2 FM-synth library for FreeBASIC DOS.

DOS specific questions.
Post Reply
Adigun A. Polack
Posts: 234
Joined: May 27, 2005 15:14
Contact:

FBFMlib - An easy-to-use OPL2 FM-synth library for FreeBASIC DOS.

Post by Adigun A. Polack »

A splendid hello once more to you quite awesome FreeBASIC community!!! :D

Deep as i was currently still working on putting the finishing touches on AFlib III as well as ironing out quite a few sneaky, hard-to-discover bugs as I speak, it *precisely* got me thinking of also creating an important DOS-based library from scratch that lets you take FULL advantage of the OPL2 sound chip (and all of its nine (9) sound channels!!) and makes it quite easier to use in the creation of especially your own brand-new, modern-day DOS games/demos in FreeBASIC. Ladies and gentlemen, I now give you...

FBFMlib — FreeBASIC FM-Synth Library

Image
Image

Debuting right now at version 0.20b as such a special initial preview from me of this lib in FreeBASIC DOS, it is in its RATHER VERY early stages here, as I have only just gotten started on making it happen for you amazing people indeed. Plus, I plan on making your all-new FM-synth music creations using this lib a whole, *whole* lot easier with a music creation tool that I am aiming to program into this lib itself. All that and more, as I plan very seriously on making things definitely better for you in order for us to make such smooth sailing from this one, too!!! ;)

You can download my initial beta version of FBFMlib right here.

And, please do not forget to run my sample program in this one to see the amazing things from the OPL2 sound chip that this lib is easily capable of, breaking right through the confines of that tinny ‘ol PC-speaker in a nutshell.

I have thoroughly tested the lib myself using SBEMU on real hardware, and also using a Yamaha-XG YMF724 PCI Sound Card on another computer of mine called the HP Thin Client T5710, as well as under emulation using DOSbox Staging v0.81.0... and they all worked brilliantly 100% as a few examples!! However, it did not work under the OPL3LPT device for some strange reason... though, on most any Sound Blaster or compatible sound card that has built-in OPL2 support at the very least, it should work, I must reckon!

In the meantime, do enjoy my very special beginnings of an all-new OPL2-themed music/sfx creation library in FreeBASIC DOS, and any new music/sounds that you create using it, show ‘em right here; I would love to see what you can do with it, even though the functions there are quite rudimentary right now...

Again, it is such a profound joy working with you rather wonderful FreeBASIC community, for sure!!!
angros47
Posts: 2331
Joined: Jun 21, 2005 19:04

Re: FBFMlib - An easy-to-use OPL2 FM-synth library for FreeBASIC DOS.

Post by angros47 »

The OPL2 chip can be emulated via software on systems that don't have it:
viewtopic.php?p=192395#p192395
Adigun A. Polack
Posts: 234
Joined: May 27, 2005 15:14
Contact:

Re: FBFMlib - An easy-to-use OPL2 FM-synth library for FreeBASIC DOS.

Post by Adigun A. Polack »

angros47 wrote: Apr 18, 2024 20:33 The OPL2 chip can be emulated via software on systems that don't have it:
viewtopic.php?p=192395#p192395

Right up front now, angros47, so wonderful to meet you; I have *really* been out of the loop in these FreeBASIC forums and the happenings that went on for so long, perhaps years! I TRULY as such need to catch up on all those recent happenings myself, as I have only in very recent months been checking out your sound lib in FB called FBSFX which did a wonderful job in both Windows and Linux when I tested it on both those OSes there. I have even tried it on MS-DOS/FreeDOS on real hardware using two of my computers as well as an HP Thin Client t5710 as my third, and these were the results I discovered on the DOS version, right here.

Now, going to that “ADLIBEMU.C” program in your link that you just showed me, I am DEFINITELY looking into it, for if my memory serves, that code can be adapted for use to replicate a true-quality emulation of the OPL2 chip in both Windows and Linux... but there is one problem though. This will create a dependency in the form of either a library file or a .dll file, and in my current FBFMlib, I am trying to get an OPL2 to finally create sound and music using FreeBASIC natively in DOS without any dependencies al all, which poses quite a dilemma for me in setting it up on those other two OSes than DOS, even since I am not good at C or C++ much at all so far, quite sadly...

But, with your FBSFX, I could find a way to get the possible, custom, and perhaps built-in FM-Synthesis sound driver to work in FreeBASIC on Windows and Linux as I dig into the ins-and-outs of your included source code deep enough as well as how it all works, so is it OK of I do that, giving you full credit when I adapt it into my lib should I get a chance at converting FBFMlib to both Windows and Linux indeed somewhere down the road soon?

All these possibilities... and even as I am trying to wrap my head around them myself, I thank you so much for showing my the good ropes on how it is all done; absolutely appreciated, angros47, and I love your FBSFX lib so far!!! :D
angros47
Posts: 2331
Joined: Jun 21, 2005 19:04

Re: FBFMlib - An easy-to-use OPL2 FM-synth library for FreeBASIC DOS.

Post by angros47 »

Adigun A. Polack wrote: Apr 22, 2024 6:33 Now, going to that “ADLIBEMU.C” program in your link that you just showed me, I am DEFINITELY looking into it, for if my memory serves, that code can be adapted for use to replicate a true-quality emulation of the OPL2 chip in both Windows and Linux... but there is one problem though. This will create a dependency in the form of either a library file or a .dll file
No, it won't. All you need to do is to compile it with gcc and the "-c" parameter, to obtain the file adlibemu.o, and that file can be linked to your own code at compile time, obtaining a single file executable with no external dependency. This is possible because the object format of FreeBasic and gcc is the same.

In origin, my plan was to use that code for FBSFX, to implement the PLAY command: in that way, I could have used the same code in DOS (using a real OPL2 chip) or in Linux (emulating it). The reason I didn't is that Adlibemu has the same limits of the original chip: only 9 channels... and that can be a limit when I wanted to play multiple notes on a single instrument. Sure, there were workarounds... but there was no point in adding unnecessary limits and then trying to workaround them. So, in the end I used the code from fmmidi by yuno, that dynamically allocates memory and has no limit on the number of notes that can be played at the same time.
But, with your FBSFX, I could find a way to get the possible, custom, and perhaps built-in FM-Synthesis sound driver to work in FreeBASIC on Windows and Linux as I dig into the ins-and-outs of your included source code deep enough as well as how it all works, so is it OK of I do that, giving you full credit when I adapt it into my lib should I get a chance at converting FBFMlib to both Windows and Linux indeed somewhere down the road soon?
Of course you can, that's why I published it, after all.
The only condition is that, if you use a modified version of my code, you have to make the source code available to others, just like mine was available to you. I am sure this won't be a problem, but if you have any question feel free to ask.
All these possibilities... and even as I am trying to wrap my head around them myself, I thank you so much for showing my the good ropes on how it is all done; absolutely appreciated, angros47, and I love your FBSFX lib so far!!! :D
Thank you!
Post Reply