ScummVM OPL emulator differs from AdPlug?

General chat related to ScummVM, adventure gaming, and so on.

Moderator: ScummVM Team

Post Reply
elmonotremendo
Posts: 7
Joined: Fri Nov 04, 2011 10:43 pm
Location: Argentina

ScummVM OPL emulator differs from AdPlug?

Post by elmonotremendo » Fri Nov 04, 2011 11:37 pm

The reason I post this time is because I've been searching a lot to get the Monkey Island original music -the one that came out through the SoundBlaster soundcard- (not the MT-32 version) . and the research resulted interesting in matter of emulators, because i don't have one, but ScummVM integrates a very good emulation of the OPL chip (MAME OPL Adlib, i think) , even better (imo) than the DOSBox OPL emulation.

I managed to get something closeeee but I'm still not satisfied. I've got the .laa files (Lucas Arts Adlib file format) of the Monkey Island 1, and downloaded the AdPlug which also seems to have MAME OPL emulation.
The AdPlug sounds like this one (check in the Examples, there are .laa files): http://opl3.cozendey.com/

But it does NOT sound like as in the ScummVM does...
Is it possible to get access to your OPL emulator?
Why is it different from the Adplug if both uses MAME OPL emulator?

This is the intro of The Secret of Monkey Island through the ScummVM OPL emulator, as you know : http://www.youtube.com/watch?v=WjvD3C_nvBk

User avatar
eriktorbjorn
ScummVM Developer
Posts: 3316
Joined: Mon Oct 31, 2005 7:39 am

Re: ScummVM OPL emulator differs from AdPlug?

Post by eriktorbjorn » Sat Nov 05, 2011 7:45 am

elmonotremendo wrote: Why is it different from the Adplug if both uses MAME OPL emulator?
ScummVM includes two different OPL emulators: One from MAME and one from DOSBox. As far as I know, both ScummVM and AdPlug use the same ancient MAME version, since they're not compatible with the license of newer (and supposedly more accurate) versions. Of course, there may have been tweaks made over the years (e.g. ScummVM has a workaround to prevent strange notes in Legend of Kyrandia), but they should at least be basically the same.

However, the emulation of the sound chip is just one part of the puzzle. Another one is interpreting the music data. (Incidentally, that appears to be the bit that the Java applet you linked to borrows from AdPlug. The actual OPL emulator apparently wasn't.) From what I understand, the .laa is just a dump of the music data from the games, but it's very possible that ScummVM and AdPlug interpret them in a different way. I couldn't say what the difference is, though. There's quite a lot of code in the SCUMM engine related to sound, because it supports a lot of games written over a number of years so it's not obvious what it does.

elmonotremendo
Posts: 7
Joined: Fri Nov 04, 2011 10:43 pm
Location: Argentina

Post by elmonotremendo » Sat Nov 05, 2011 6:30 pm

Yes, it might be impossible to determine the difference. I didn't know that thing about interpretation, so it's not enough with the OPL emulator.

I guess I'll be recording the direct audio output while playing the whole game through Scumm, with the MAME OPL emulator.

Is it possible to play the .laa files through the Scumm sound engine?

User avatar
eriktorbjorn
ScummVM Developer
Posts: 3316
Joined: Mon Oct 31, 2005 7:39 am

Post by eriktorbjorn » Sat Nov 05, 2011 9:05 pm

elmonotremendo wrote: Is it possible to play the .laa files through the Scumm sound engine?
Not without making modifications to the ScummVM source code, I guess.

jepael
Posts: 26
Joined: Sat Oct 25, 2008 8:16 pm

Post by jepael » Sun Nov 06, 2011 8:42 am

I have been studying a bit about the OPL and different emulators - even written an emulator of some sort myself, by reverse-engineering a real OPL3 chip with logic analyzer. My emulator aims to be very accurate compared to real chip.

As far as I know, the .LAA files have some sequencing and note information, so they are somewhat like .MID files. So .LAA files do not contain direct OPL register data to write, the .LAA file has to be "interpreted" or played and then the OPL card controlled with the register data.

Yes there are many OPL chip emulations available, but because they have various different goals and needs they must make compromises on other aspects.Like if speed is important, it is gained by loosing emulation accuracy. Another aspect is being real-time, like in DosBox, where it works asynchronously so that a bunch of samples like 48 is generated every 1ms to get the wanted mixing rate, but the software may be in the middle of updating registers during that time, so it may use the wrong register set to generate the samples.

Players like AdPlug can work more synchronously so that if the file being played has a 70Hz timer for advancing the note data, then it is known that the registers do not get updated except every 70Hz, and thus the registers can be used for 710 samples to generate almost the native frequency for the chip.

At least the MAME emulator seems to very accurate in modeling the internal workings of the chip, but I do not know about the GPL version used in projects like ScummVM or DosBox. But it's weakness is how it adapts the native OPL chip sampling rate to requested mixing rate by skipping (or duplicating) samples, and since the native sampling rate is not an integer, it is almost impossible to request a sample stream that matches the native frequency, without modifying the initialization code. Skipping (or duplicating) samples affects the operator feedback values. Anyway, to request maximum faithfulness to the original chip, the mixing rate of MAME emulator should be set to 49716 Hz and then externally resampled to the user requested mixing rate of 44100 or 48000. It will be slower though.

I have been thinking about trying my own emulator by using my code in place of the ScummVM or DosBox code, but it is not mature enough for that yet.

elmonotremendo
Posts: 7
Joined: Fri Nov 04, 2011 10:43 pm
Location: Argentina

Post by elmonotremendo » Sun Nov 06, 2011 8:20 pm

By the way, is it possible to extract the audio files -I mean, the soundtrack- with some software, without playing the game? (ScummVM tools 1.3, ScummVM toolBox, Scumm Revisted, LucasHack... ?)

User avatar
eriktorbjorn
ScummVM Developer
Posts: 3316
Joined: Mon Oct 31, 2005 7:39 am

Post by eriktorbjorn » Mon Nov 07, 2011 7:18 pm

elmonotremendo wrote:By the way, is it possible to extract the audio files -I mean, the soundtrack- with some software, without playing the game?
I assume so, but I have no personal experience of it. Also, it can apparently be a lot of work, judging by HighLand Productions FAQ.

jepael
Posts: 26
Joined: Sat Oct 25, 2008 8:16 pm

Post by jepael » Wed Nov 09, 2011 5:20 pm

By the way, AdPlug release notes say that for LAA files the volumes are a bit off. LAA file playing is handled by mid.cpp, which is a sign that LAA files are handled or played somewhat like MID files.

I do not think there is a single tool to do what you want, if AdPlug is not good for you. There are tools to extract the music files (LAA), then it is a matter of finding a good enough player for those files.

Well the files are there already so there is no need to extract those anymore.

DosBox can output OPL register writes into a .DRO file, and you can store the OPL emulator audio output into a .WAV file. Perhaps it is easy to make ScummVM dump the audio into .WAV file too?

User avatar
LordHoto
ScummVM Developer
Posts: 1030
Joined: Sun Oct 30, 2005 3:58 pm
Location: Germany

Post by LordHoto » Wed Nov 09, 2011 5:28 pm

jepael wrote:By the way, AdPlug release notes say that for LAA files the volumes are a bit off. LAA file playing is handled by mid.cpp, which is a sign that LAA files are handled or played somewhat like MID files.

I do not think there is a single tool to do what you want, if AdPlug is not good for you. There are tools to extract the music files (LAA), then it is a matter of finding a good enough player for those files.
The music format used in SCUMM games till v5, i.e. Indy3, Loom and MI1, is basically a block containing the instrument definitions and another one containing MIDI commands. I am not sure why AdPlug named the format LAA though, it isn't named like that in the original, in fact the original only uses a block name of "AD" for the resource blocks containing the AdLib sound data. It might also be noteworthy that the sound effects have a different format, but are still in blocks of the same name.

Post Reply