VOGONS


Patch to improve OPL captures

Topic actions

First post, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie

Hi everyone,

I recently discovered that when capturing OPL music with DOSBox, it doesn't always start the capture with the first note played (although it's supposed to.)

I found out that this is because it only monitors one of the "noteon" ports on the OPL chip, whereas there are actually six of these (one for normal notes and five for percussion.) If the song starts off with percussion, the capture won't begin until the first "real" note is played. (For example, the first ~10 seconds of the song is lost when capturing the level music in Episode 2 of Monster Bash.)

This small change fixes the problem, by allowing percussive sounds to also trigger the capture.

--- src/hardware/adlib.cpp.orig 2007-07-28 13:52:20.000000000 +1000
+++ src/hardware/adlib.cpp 2007-07-28 13:35:52.000000000 +1000
@@ -206,8 +206,9 @@
if (cmd == 4 && !index) return;
/* Check if we have yet to start */
if (!opl.raw.handle) {
- if (cmd<0xb0 || cmd>0xb8) return;
- if (!(val&0x20)) return;
+ if ((cmd<0xb0 || cmd>0xb8) // ports 0xb0-0xb8 contain the "noteon" bit
+ && !((cmd == 0xbd) && (val & 0x1f))) return; // bits 0-4 on port 0xbd are used for sounding percussion
+// if (!(val&0x20)) return;
Bitu i;
opl.raw.last=PIC_Ticks;
opl.raw.start=PIC_Ticks;

(I hope the patch applies properly, I don't do these very often!)

Reply 1 of 29, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

you are disabling

if (!(val&0x20))  return;

Is this intentional ?

Water flows down the stream
How to ask questions the smart way!

Reply 2 of 29, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie

Yes, I'm not entirely sure why it's there - I *think* the logic is wrong (the "!" isn't meant to be there) in which case enabling the percussive instruments would trigger the recording, but this would mean that in most cases it would start too early. (Not to mention a whole bunch of other unrelated OPL settings would trigger the recording to start early as well.)

The extra condition I added is a more accurate replacement for that line, had it been correct to start off with. Feel free to remove that line altogether if you'd prefer.

EDIT: No wait, sorry, the logic is correct, but that first line renders it useless. 0x20 is only important when cmd==0xbd, but as you can see from the first condition the code will never reach that line when cmd==0xbd. My original points about starting the recording too early still apply though.

Reply 3 of 29, by ObbleDe

User metadata
Rank Newbie
Rank
Newbie

I apologize in advance for whatever inconveniences I may cause in reviving this thread, but I'm experiencing the exact error in my OPL captures which Malvineous' patch addresses. I'm acquainted with DosBox itself, but pertaining to programming knowledge, I possess none thereof to attempt applying his patch. Therefore, I wanted to inquire as to if his patch will ever be incorporated into future versions of DosBox, or if someone gracious enough could assemble Malvineous' patch. Thank you.

Reply 4 of 29, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

It's already fixed.

Reply 5 of 29, by ObbleDe

User metadata
Rank Newbie
Rank
Newbie

I'm using DosBox 0.72 on Windows Vista 64-bit, and use Adplug for Winamp as playback for the recorded OPL. I'm unsure whatever could be the source of the problem, as I've been experimenting with different versions of Adplug, and aside from this error, everything's functional on Vista 64-bit.

Reply 6 of 29, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

It's not in 0.72. Also i'm not sure if adplug can handle the new dro format yet.

Reply 7 of 29, by ObbleDe

User metadata
Rank Newbie
Rank
Newbie

Could you possibly redirect me to either an official or unofficial DosBox build that contains the patch?

Adplug seems to work fine with the .dro, but on rare occasions, the speed of the music is slower than average, which is usually corrected by reverting to an earlier version of AdPlug.

Reply 8 of 29, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Just use a recent build (yesterday/today). The commit by Harekiet was quite
a few weeks ago though.

Reply 9 of 29, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

adplug probably can't play the files though. as the format has been changed significantly

Water flows down the stream
How to ask questions the smart way!

Reply 10 of 29, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Yes but recording is SO much more fun than playing it back 😀

Reply 11 of 29, by lightmaster

User metadata
Rank Oldbie
Rank
Oldbie

thanks

25071588525_735097840e_b.jpg

Reply 12 of 29, by leileilol

User metadata
Rank l33t++
Rank
l33t++

adplay/adplug can't play alot of formats properly, not even cmf 🙁

apsosig.png
long live PCem

Reply 13 of 29, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Did you send cmf files that it doesn't play correctly to the author?

Reply 14 of 29, by ripa

User metadata
Rank Oldbie
Rank
Oldbie

"adplay/adplug can't play alot of formats properly, not even cmf"

TD2192 ?-)

Reply 15 of 29, by leileilol

User metadata
Rank l33t++
Rank
l33t++
wd wrote:

Did you send cmf files that it doesn't play correctly to the author?

...every cmf file? I can't find one that plays remotely correctly.
Maybe he needs playcmf for reference
a real very obvious bugger is funky.cmf. no drums!!

apsosig.png
long live PCem

Reply 16 of 29, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Maybe check the sources where the cmf player comes from/if it's the same
format that you're feeding it/if there are notes that it's working/complete/whatever.

Reply 17 of 29, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie

Funny I should stumble across this again - I actually fixed the CMF playback problem a week or two ago and sent a patch to the AdPlug author - it's in CVS now, so the next release will play funky.cmf and the others properly. (Or you could build the CVS version of course!)

I also might be to blame with the .dro speed issue. I found a little while back that the .dro format had changed (the header became one byte longer or something) and I sent a patch through to fix this in AdPlug. I think the side effect was that older .dro files had tempo issues, but IIRC all new .dros were using the newer format so we stuck with the patch.

Has the .dro format changed again?

Reply 18 of 29, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

the dro version number has changed i think. A lot of changes have happened to it since 0.72

Water flows down the stream
How to ask questions the smart way!

Reply 19 of 29, by Hexacorde

User metadata
Rank Newbie
Rank
Newbie

Hi friends,

I downloaded a recent build, with the new dro format.

Although the capturing routine is much better than the earlier version, I still cannot capture the demo and intro from Dune 1 properly...