To make an IMF file...

You can discuss anything about fan-made Commander Keen games here.
Post Reply
User avatar
thehackercat
Yorp Doctor
Posts: 669
Joined: Fri Aug 14, 2009 0:05
Location: Slug Village

To make an IMF file...

Post by thehackercat »

Hey! I'm itching to start making Keen music, now that I've got RadTracker. I believe it was Draik, but someone told me that Dosbox could record raw OPL output and that this could be converted to .IMF. Halp? :dead2

Could someone elaborate on how to do this?
Image
User avatar
TerminILL
Skypest
Posts: 589
Joined: Fri Oct 23, 2009 8:59
Location: In a box.
Contact:

Post by TerminILL »

Well, it wasn't me, but I can tell you how.
The DOSBox readme file tells you that CTRL-ALT-F7 is the key combo to record OPL commands to DRO format. Then you can use DRO2IMF from here to convert those to IMF format. And I found all that in 1 minute of looking. Amazing.
Shonikado wrote:Looking back on what we've done and wanting to change it is the first step in becoming a weakling that cannot do anything.
User avatar
thehackercat
Yorp Doctor
Posts: 669
Joined: Fri Aug 14, 2009 0:05
Location: Slug Village

Post by thehackercat »

Draik wrote: And I found all that in 1 minute of looking. Amazing.
I dearly hope that wasn't mockery on your part.

I had dro2midi, and I've recorded some .dro files. However, it says at the prompt that my song uses "multiple OPL chips" and that this isn't supported.

What did I do wrong? The song in question is a radtracker file that uses 3 or 4 channels.
Image
User avatar
TerminILL
Skypest
Posts: 589
Joined: Fri Oct 23, 2009 8:59
Location: In a box.
Contact:

Post by TerminILL »

Well, if you don't elaborate to start, someone's bound to tell you what you already know. Now, DRO2IMF is what you want, unless you desperately need a MIDI for some reason. And I honestly can't help you any further.
Shonikado wrote:Looking back on what we've done and wanting to change it is the first step in becoming a weakling that cannot do anything.
User avatar
Malvineous
Shikadi Webmaster
Posts: 382
Joined: Wed Oct 31, 2007 21:48
Location: Brisbane, Australia
Contact:

Post by Malvineous »

The format for .dro files changed with DOSBox 0.72 I think (or maybe that was the last version that used the original format), and I haven't yet had time to update either DRO2IMF or DRO2MIDI to the new format. I don't even think AdPlug can play the new format yet.

I vaguely recall a program that could convert between the two versions, but failing that the only option is to grab an older version of DOSBox just for recording your .dro files.
User avatar
Levellass
S-Triazine
Posts: 5265
Joined: Tue Sep 23, 2008 6:40

Post by Levellass »

Indeed, it seems likely that you're recording in the wrong format. I stick with DB 0.70 to be safe.

Also, some games *do* use multiple channels if I recall right (And waaaugh! You can't record .midi, .mod or .s3m files, which severely limits the usefulness of this.)
What you really need, not what you think you ought to want.
User avatar
Malvineous
Shikadi Webmaster
Posts: 382
Joined: Wed Oct 31, 2007 21:48
Location: Brisbane, Australia
Contact:

Post by Malvineous »

Some games do use multiple OPL chips (which is different to multiple channels, each OPL chip has nine channels) but IIRC this is rare, because the OPL2 chips were mono, a handful of cards came out with dual OPL2 to give you stereo, but once OPL3 came along it was a single stereo chip everyone started using.

And of course DOSBox only records what gets sent to the final hardware, so you couldn't record .mod or .s3m files because all DOSBox sees is the final PCM .wav data. (Perhaps if there was an Amiga emulator it could record a .mod file from its emulated Paula chip, which was a hardware-accelerated .mod player.) You could just as well argue that DOSBox doesn't support capturing in-game speech to a .txt file :-)

Having said that you *can* record MIDI files, providing you tell the game to use an external MIDI synth (any game that supports MIDI will do this.) You need to select something like "General MIDI" or "MPU401" as the music device in the game's setup, port 330, then in DOSBox press the MIDI capture hotkey (default is Alt+Ctrl+F8 ) and you'll end up with a .mid file of the music. I think this also tells DOSBox to use your PC's MIDI synth as well (instead of the internal OPL synth you get if you set your music device to Adlib, for instance) so you will probably find that the game's music sounds quite different like this.
User avatar
thehackercat
Yorp Doctor
Posts: 669
Joined: Fri Aug 14, 2009 0:05
Location: Slug Village

Post by thehackercat »

Yes, I believe that Dosbox never has used its own emulation for the MIDI sounds; rather, it patches the commands through to your native MIDI hardware. I found this out while trying to set up Duke Nukem 3d. My MacBook played MIDI music quite nicely, but the PC I use for Keening did not.

Incidentally, did you also write a utility that will create .IMF files directly from .DROs?

And could you tell me the specs for .IMFs? (4 note polyphony, how many channels, etc?)

Thank you, and Merry Christmas.
-Ray
Image
Calvero
Vortininja
Posts: 98
Joined: Tue Jan 29, 2008 15:31

Post by Calvero »

User avatar
VikingBoyBilly
Vorticon Elite
Posts: 4158
Joined: Sat Jan 05, 2008 2:06
Location: The spaghetti island of the faces of dinosaur world for a vacation

Post by VikingBoyBilly »

Hey I'm beginning to wonder... why is this in "unofficial keen games"? :dead2
Image
"I don't trust players. Not one bit." - Levellass
User avatar
DaVince
lazy/busy Keener
Posts: 1476
Joined: Thu Nov 01, 2007 15:34
Location: Amsterdam, Netherlands
Contact:

Post by DaVince »

I guess because it's about making music for Keen mods, which are of course unofficial. Kind of the same reason modern game threads occasionally go into "classics", I guess.
Wow look at me I'm lurking
User avatar
Malvineous
Shikadi Webmaster
Posts: 382
Joined: Wed Oct 31, 2007 21:48
Location: Brisbane, Australia
Contact:

Post by Malvineous »

@thehackercat: Yes, DRO2IMF will create IMF files from DRO captures (or did you mean something else?)

The "specs" for IMF as far as music go are the same as the OPL chip itself, as the .imf file only stores commands to send to the OPL chip. So the OPL has two modes - either nine channels or eleven channels (made up of six instrument channels plus five percussion.) You can only play one note/instrument at a time on each channel, and if you change the instrument mid-note it will affect the sound immediately (many games make use of this for sound effects.)

I have never looked at the number of channels IMF files use, but I expect at least one channel will always be left unused by the music so that it is available for Adlib sound effects. Now that I think about it, some IMF files produced by DRO2IMF will probably conflict with this if the original song uses Keen's sound-effect channel. That'd be interesting to find out...

I should also mention that AdPlug has a .RAW writer, which allows you to convert any Adlib music file into .raw format. Not the same as .dro, but it's close :-)
User avatar
Levellass
S-Triazine
Posts: 5265
Joined: Tue Sep 23, 2008 6:40

Post by Levellass »

Hey there,

I've been making a lot of IMF files from copying/pasting 'notes' from existing IMF files, is there any guide to what values are what instruments and such? It gets annoying to have to guess all the time.
What you really need, not what you think you ought to want.
User avatar
Malvineous
Shikadi Webmaster
Posts: 382
Joined: Wed Oct 31, 2007 21:48
Location: Brisbane, Australia
Contact:

Post by Malvineous »

If you want to do it by hand it'll take forever. The frequency for a note is 10-bits so it's split across two bytes in an IMF file, and the instruments are split across about five bytes. There's a handy document floating around that explains what all the registers are (but you'll want to save that file and look at it in DOS so all the line-drawing ASCII characters appear properly.)

IMF files work like this:

<register> <value> <delay> <delay>

Each one of <these> is a byte, and it repeats until the end of the file. The delays are usually zero, which gives IMF files their characteristic look in a hex editor.

If you jump to the "Register Map" section in that document it will list all the values for the <register> byte. For example if <register> is 0xA0 then you will be setting the frequency of the note on channel zero. If you write 0x20 into register 0xB0 you will enable the 'keyon' bit (D5 in the diagram) and start playing a note on channel zero. Of course if you *do* write 0x20 here you will also set the block number (read: octave) and the upper two bits of the note frequency all to zero, which is probably not what you want. So you need to remember what was at register 0xB0 before and just add or subtract 0x20 from it to set or unset the fifth bit.

And that's just to turn a note on and off, it's much worse when setting instruments!

You're far better off composing some music in another format and then using a program to generate the IMF. I would recommend composing the music in MID format, converting it to CMF, using SBTimbre's nice DOS-based GUI to create some interesting sounding instruments for the CMF then convert the CMF to IMF.
Post Reply