Replacing music and sounds

Technical discussion for those interested in Supermodel development and Model 3 reverse engineering. Prospective contributors welcome.
Forum rules
Keep it classy!

  • No ROM requests or links.
  • Do not ask to be a play tester.
  • Do not ask about release dates.
  • No drama!

Replacing music and sounds

Postby Shekel » Mon May 30, 2016 4:20 pm

I've been looking into editing MAME sounds and music and couldn't find much info on it. People seem far more interested in hacking console game ROMs, so there doesn't seem to be a relevant tutorial around but there was one video which was really interesting and they swapped out game music for CD tracks and somehow got MAME to read flac files.

Is anything like that possible in Supermodel? That would be great, really.
User avatar
Shekel
 
Posts: 345
Joined: Wed Mar 16, 2016 12:45 pm

Re: Replacing music and sounds

Postby Ian » Mon May 30, 2016 4:24 pm

try it and report back :p
I know sega rally has mp2 audio tracks
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: Replacing music and sounds

Postby Shekel » Mon May 30, 2016 4:51 pm

Think I looked at those once. If the audio files were edited and re-saved, wouldn't Supermodel find an error with them? I was thinking that the smarter way would be to edit the code somewhere and have it point to a different file instead. But I know shit about this sorta stuff.
User avatar
Shekel
 
Posts: 345
Joined: Wed Mar 16, 2016 12:45 pm

Re: Replacing music and sounds

Postby Bart » Mon May 30, 2016 6:48 pm

It's certainly possible and can be done in a number of ways. Unfortunately, for anything non-trivial, you would need to modify the code. Probably the best way to do it would be for Supermodel to include a scripting language, as Nebula Model 2 does, to allow you to intercept audio commands and play your own sound effects. The audio boards are actually quite independent. The main CPU just passes high-level commands which can be as short as 3 bytes. These usually indicate which sound to play. If a scripting engine were permitted to intercept these, it would have complete control over audio playback. Supermodel's audio subsystem is kind of crappy and it would take a bit of work to get it up to snuff, though. I would need to implement proper audio mixing and add normal playback channels that operate independently of the per-frame audio emulation.

You're correct that Supermodel will barf if you modify any of the ROMs. That's because it loads ROMs based on their check sum rather than file name. I thought this was a smart idea when I came up with it because when I sat down to rewrite Supermodel in 2010, MAME had changed the names of the old ROM sets that I had, and which were still floating around. I figured that the file name is unimportant and ultimately the CRC32 is what matters. What I should probably do is rewrite the ROM loading system at some point to support loading by standardized MAME name as well, even if the check sums are bad. Not a very difficult change to make.

Sound effects are stored in ROM ICs 22-25. You should be able to load them up directly in an audio editor like GoldWave as raw PCM data. I think they are usually 16-bit audio (byte swapped) but the SCSP supports 8-bit samples as well.

I wonder if a future direction for Supermodel should be to become a multi-platform 90's 3D arcade emulator with support for game-enhancing/hacking features. I would like to eventually add support for exporting models, textures, and maybe even entire scenes. If a scripting engine is added in the future, it would be possible to import new data as well, although it would be a lot of software engineering and refactoring to get it working. I don't think any other platform is as amenable as Model 3 to this sort of hacking. Model 3 is unique in that its 3D graphics are database-driven and operate on entire meshes at a time that reside in fixed locations in memory. This is quite different from typical 3D architectures that consume arbitrary lists of triangles. It would be entirely possible to swap out whole meshes, although it would still require a lot of work on the part of the hacker. A typical game object is actually composed of lots of small sub-meshes, and each of those would have to be replaced.

Textures would be fairly easy, though.
User avatar
Bart
Site Admin
 
Posts: 3086
Joined: Thu Sep 01, 2011 2:13 pm
Location: Reno, Nevada

Re: Replacing music and sounds

Postby artman999999 » Tue May 31, 2016 10:11 am

Interesting. I had initially thought the audio/video sync issue on the LA Machineguns intro was caused by the audio being incorrect (too long, perhaps due to a dump issue from the source). There is an odd stutter in the intro, as the invading helicopters are first shown, that seemed out of place. But watching the actual arcade footage against SuperModel shows it to be an issue with the speed of the intro audio. The music/sounds (I assume they are on the same track for simplicity) start on cue, but the sounds of the robots' jets are about a second delayed. By the time the villain has the gloating chuckle over the (literally) fallen President, it's about 3 seconds off. I had considered trying to rip out this audio track, re-record it at a 1.1x or 1.2x speed to see if this band-aided the problem, but it will almost certainly impact the checksum on the re-encoding.

I went through the audio code with my limited programming knowledge and could follow where the mpeg module would pull a frame of audio. But I couldn't see how it determines it's speed (aside from bitrate). Without that tie-in, you can't just "speed it up" to match the video.

On a whim - tried adjusting the PowerPC settings very high and very low, but no impact to the A/V sync.
artman999999
 
Posts: 44
Joined: Wed Apr 27, 2016 9:36 am

Re: Replacing music and sounds

Postby Shekel » Tue May 31, 2016 10:44 am

Hmm, so is it almost impossible to clone a checksum and make one of these audio files pass the verification? I saw an app that you rename CRCs but couldn't see a way for checksums.
User avatar
Shekel
 
Posts: 345
Joined: Wed Mar 16, 2016 12:45 pm

Re: Replacing music and sounds

Postby Bart » Tue May 31, 2016 10:47 am

LA Machineguns doesn't use MPEG audio. The music is generated by the SCSP. At some point I will integrate MAME's SCSP emulator. The SCSP timers are not emulated correctly, which is probably the source of numerous problems. Additionally, Supermodel is running too fast. The real frame rate was likely closer to 57.5 FPS rather than 60, a 4.2% difference.
User avatar
Bart
Site Admin
 
Posts: 3086
Joined: Thu Sep 01, 2011 2:13 pm
Location: Reno, Nevada

Re: Replacing music and sounds

Postby Bart » Tue May 31, 2016 10:48 am

Shekel wrote:Hmm, so is it almost impossible to clone a checksum and make one of these audio files pass the verification? I saw an app that you rename CRCs but couldn't see a way for checksums.


Checksums are computed from the ROM data when the file is zipped. If you know how to compile Supermodel, you could do the following in the meantime: edit the sample ROM, add it to the ROM set zip archive, then obtain the new CRC32 (you can obtain it in Windows by right-clicking and looking at properties) and modify Games.cpp to use it.

Since I need to update Supermodel to support the official MAME ROM set, I might rewrite the ROM loading system entirely next week and add support for loading by file name. A third possibility is to switch to an XML-based system where an external config file describes the supported ROM sets. This would be a little more work but certainly doable. It would also allow for ROM patches to be added without recompiling.
User avatar
Bart
Site Admin
 
Posts: 3086
Joined: Thu Sep 01, 2011 2:13 pm
Location: Reno, Nevada

Re: Replacing music and sounds

Postby Shekel » Tue May 31, 2016 12:45 pm

Thanks again, just stuck with one thing and I think it'll boot, the file in the ROM needs to be 4,096 KB exactly otherwise it won't work. Do you know how I could do that?

Edit: No worries, fixed it with a hex editor. Now I've got Sega Rally 2's intro only playing one track.
Last edited by Shekel on Tue May 31, 2016 1:40 pm, edited 1 time in total.
User avatar
Shekel
 
Posts: 345
Joined: Wed Mar 16, 2016 12:45 pm

Re: Replacing music and sounds

Postby Ian » Tue May 31, 2016 12:58 pm

Bart wrote:LA Machineguns doesn't use MPEG audio. The music is generated by the SCSP. At some point I will integrate MAME's SCSP emulator. The SCSP timers are not emulated correctly, which is probably the source of numerous problems. Additionally, Supermodel is running too fast. The real frame rate was likely closer to 57.5 FPS rather than 60, a 4.2% difference.


57fps ??? I would have thought they would have used something like NTSC, which is 59.97 fields per second. Ocean hunter, the text looks interlaced.
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Next

Return to The Dark Room

Who is online

Users browsing this forum: No registered users and 1 guest

cron