Patch to improve OPL captures

Developer's Forum, for discussion of bugs, code, and other developmental aspects of DOSBox.

Patch to improve OPL captures

Postby Malvineous » 2007-7-28 @ 03:59

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.

Code: Select all
--- 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!)
User avatar
Malvineous
Member
 
Posts: 464
Joined: 2006-6-11 @ 02:24
Location: Brisbane, Australia

Re: Patch to improve OPL captures

Postby Qbix » 2007-7-28 @ 07:57

you are disabling
Code: Select all
if (!(val&0x20))  return;

Is this intentional ?
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10413
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: Patch to improve OPL captures

Postby Malvineous » 2007-7-28 @ 09:52

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.
User avatar
Malvineous
Member
 
Posts: 464
Joined: 2006-6-11 @ 02:24
Location: Brisbane, Australia

Re: Patch to improve OPL captures

Postby ObbleDe » 2008-8-30 @ 06:48

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.
ObbleDe
Newbie
 
Posts: 3
Joined: 2008-8-28 @ 18:29

Re: Patch to improve OPL captures

Postby wd » 2008-8-30 @ 08:34

It's already fixed.
wd
DOSBox Author
 
Posts: 10818
Joined: 2003-12-03 @ 21:23

Re: Patch to improve OPL captures

Postby ObbleDe » 2008-8-30 @ 10:08

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.
ObbleDe
Newbie
 
Posts: 3
Joined: 2008-8-28 @ 18:29

Re: Patch to improve OPL captures

Postby wd » 2008-8-30 @ 10:23

It's not in 0.72. Also i'm not sure if adplug can handle the new dro format yet.
wd
DOSBox Author
 
Posts: 10818
Joined: 2003-12-03 @ 21:23

Re: Patch to improve OPL captures

Postby ObbleDe » 2008-8-30 @ 10:32

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.
ObbleDe
Newbie
 
Posts: 3
Joined: 2008-8-28 @ 18:29

Re: Patch to improve OPL captures

Postby wd » 2008-8-30 @ 10:36

Just use a recent build (yesterday/today). The commit by Harekiet was quite
a few weeks ago though.
wd
DOSBox Author
 
Posts: 10818
Joined: 2003-12-03 @ 21:23

Re: Patch to improve OPL captures

Postby Qbix » 2008-8-30 @ 11:08

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!
User avatar
Qbix
DOSBox Author
 
Posts: 10413
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: Patch to improve OPL captures

Postby wd » 2008-8-30 @ 11:13

Yes but recording is SO much more fun than playing it back :)
wd
DOSBox Author
 
Posts: 10818
Joined: 2003-12-03 @ 21:23

Re: Patch to improve OPL captures

Postby lightmaster » 2008-8-30 @ 13:28

thanks
Image
User avatar
lightmaster
Oldbie
 
Posts: 603
Joined: 2005-10-01 @ 12:09
Location: Sol III(¡¿

Re: Patch to improve OPL captures

Postby leileilol » 2008-8-30 @ 15:55

adplay/adplug can't play alot of formats properly, not even cmf :(
User avatar
leileilol
l33t++
 
Posts: 8721
Joined: 2006-12-16 @ 18:03

Re: Patch to improve OPL captures

Postby wd » 2008-8-30 @ 16:43

Did you send cmf files that it doesn't play correctly to the author?
wd
DOSBox Author
 
Posts: 10818
Joined: 2003-12-03 @ 21:23

Re: Patch to improve OPL captures

Postby ripa » 2008-8-31 @ 12:24

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

TD2192 ?-)
ripa
Oldbie
 
Posts: 544
Joined: 2005-4-18 @ 00:53
Location: Finland

Re: Patch to improve OPL captures

Postby leileilol » 2008-8-31 @ 14:03

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!!
User avatar
leileilol
l33t++
 
Posts: 8721
Joined: 2006-12-16 @ 18:03

Re: Patch to improve OPL captures

Postby wd » 2008-8-31 @ 16:20

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.
wd
DOSBox Author
 
Posts: 10818
Joined: 2003-12-03 @ 21:23

Re: Patch to improve OPL captures

Postby Malvineous » 2008-9-27 @ 02:52

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?
User avatar
Malvineous
Member
 
Posts: 464
Joined: 2006-6-11 @ 02:24
Location: Brisbane, Australia

Re: Patch to improve OPL captures

Postby Qbix » 2008-9-27 @ 06:52

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!
User avatar
Qbix
DOSBox Author
 
Posts: 10413
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: Patch to improve OPL captures

Postby Hexacorde » 2008-10-24 @ 23:42

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...
Hexacorde
Newbie
 
Posts: 11
Joined: 2008-10-01 @ 04:08

Next

Return to DOSBox Development

Who is online

Users browsing this forum: No registered users and 2 guests