It is currently Sun Jun 24, 2018 11:16 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Sun Feb 25, 2018 9:08 pm 
Offline

Joined: Sat May 13, 2017 7:54 pm
Posts: 27
Earlier, I tried to ask a similar question about GBC ROMS that I was having trouble with, but nobody answered (it should be somewhere on GBDev, so feel free to help if you are interested and have the skill), so I thought I'd make a much more relevant topic here.

Basically, in general, how are PCM samples ripped from ROMS? I know a lot of NSFs have PCM samples, so how do they rip them and add them to the NSFs?
Specifically, what I'm talking about is "raw" (non-DPCM) PCM. There are at least a couple of games in mind that I would particularly like to rip from (Star Wars Episode V, Hammerin' Harry, and Gauntlet II), but can't find a reliable way to do so.

What I want to know is the following: Does the process usually involve reverse-engineering of the sound engine? Are the sample table offsets randomly found? How is the precise sample rate found? Do you use data/code logger or whatever it is from FCEUX to do so? How is the format (number of bits, endianness) figured out? Also, although not as important: is there a reliable way to extract DPCM samples from NES ROMs (not necessarily NSFs)?

So, I apologize if I'm being too broad here, but I must say that for some reason, I am fascinated with the sample data of old systems, especially NES and Game Boy.


Top
 Profile  
 
PostPosted: Sun Feb 25, 2018 9:41 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6354
Location: Canada
Endian concerns don't matter until you have 16-bit samples, which would probably never happen in an 8-bit game.

Most often a PCM sample is just encoded as a raw 8-bit PCM, you can just open a ROM in a sound editor as raw PCM and play it and you'll hear the samples in it.

Sometimes the samples are signed or unsigned, but that just means you have to listen to it twice.

On more rare occasions, PCM samples might be compressed into some other format.

Big Bird's Hide and Speak had a strange compression format: http://forums.nesdev.com/viewtopic.php?t=8675

Bayou Billy even has PCM output by software decoding from NES format DPCM samples: https://forums.nesdev.com/viewtopic.php?p=211224#p211224

There are a lot of ways to compress sound, though. Nowadays most sound compression method is some variation of a fourier transform to convert waves to frequencies, and then discarding the less important frequencies, but before we had hardware that could do this effectively there were many other techniques experimented with. Tepples wrote an article on Forrest Mozer's compression technique used in some C64 games.


Last edited by rainwarrior on Sun Feb 25, 2018 9:43 pm, edited 2 times in total.

Top
 Profile  
 
PostPosted: Sun Feb 25, 2018 9:42 pm 
Offline
User avatar

Joined: Tue May 06, 2014 1:50 pm
Posts: 529
Location: Szeged, Hungary
You rip the samples just like music.
You have to find their respective play and init entry points, and after you ripped it, you have add it to the music + sfx nsf via the bankswithching.
The PCM NSFs can be very big since they eat up a lot of CPU time, and because of this, most of the time the samples are located on multiple banks (like Skate Or Die, Mickey Mouse Letterland + NumberLand), or sometimes you have to design your own engine bankswitch since for example Dirty Harry changes the samples during playback.

I actually ripped a few samples for Hammerin' Harry a while ago.

_________________
http://mrnorbert1994.uw.hu/


Last edited by MrNorbert1994 on Sun Feb 25, 2018 9:48 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sun Feb 25, 2018 9:47 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6354
Location: Canada
Twenty years ago I wanted to make a Doom theme for Tetrinet, and I opened the WAD file as a raw PCM to extract a bunch of sound effects.

The other "easy" way to rip these samples is to mute all the channels its not playing on, and then just record the sound output of the emulator, especially if you can disable highpass/lowpass filters on the output. With some careful resampling and quantization you might be able to get back the original PCM exactly. With some less careful work, you at least have it it in a recorded form that you can use.


If you're trying to make an NSF play the sample, though, you don't need to worry about its samplerate or how its encoded, the task is really just to find the code routine that plays it and get it to run. The code will take care of the reset.


Top
 Profile  
 
PostPosted: Mon Feb 26, 2018 8:02 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20168
Location: NE Indiana, USA (NTSC)
rainwarrior wrote:
Endian concerns don't matter until you have 16-bit samples, which would probably never happen in an 8-bit game.

4-bit samples stored in an 8-bit memory have endianness. For example, the Game Boy wavetable channel is opposite the Namco 163. And I've found that a lot of NES games using PCM use 4-bit PCM.

rainwarrior wrote:
Bayou Billy even has PCM output by software decoding from NES format DPCM samples: https://forums.nesdev.com/viewtopic.php?p=211224#p211224

As does Blades of Steel for "face off" and the like.


Top
 Profile  
 
PostPosted: Mon Feb 26, 2018 11:15 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6354
Location: Canada
tepples wrote:
4-bit samples stored in an 8-bit memory have endianness. For example, the Game Boy wavetable channel is opposite the Namco 163. And I've found that a lot of NES games using PCM use 4-bit PCM.

Fair enough. I wouldn''t have called that "endian" in the traditional sense, but sure it would fit some definitions.

What games use 4-bit PCM? (Excluding N163.)


Top
 Profile  
 
PostPosted: Mon Feb 26, 2018 11:18 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20168
Location: NE Indiana, USA (NTSC)
Skate or Die 2 is the one that comes to mind first.
In this post, tepples wrote:
SoD2's samples are 4-bit linear PCM (or as linear as the APU DMC DAC allows). Years ago, I wrote an extractor that turns the whole ROM into a wave file; it shouldn't be too hard to write your own if you know any PC programming language.

I forget which others there were. But if you're curious, I could write a Python program that runs heuristics on a PRG ROM to see what parts look like 4-bit linear PCM (and which nibble order).


Top
 Profile  
 
PostPosted: Mon Feb 26, 2018 11:26 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6354
Location: Canada
I'm not asking for you to write a program, but I'm curious what your heuristic is to decide if some data is a sound sample? A high number of successive values that differ by a small number from each other?


Top
 Profile  
 
PostPosted: Mon Feb 26, 2018 11:32 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20168
Location: NE Indiana, USA (NTSC)
rainwarrior wrote:
I'm curious what your heuristic is to decide if some data is a sound sample? A high number of successive values that differ by a small number from each other?

That'd be the first thing I try, related to lag 1 autocorrelation. If I were actually writing a PCM finder, I would have refined it based on metrics gathered from test data.


Top
 Profile  
 
PostPosted: Tue Mar 13, 2018 1:33 pm 
Offline

Joined: Sat May 13, 2017 7:54 pm
Posts: 27
tepples wrote:
Skate or Die 2 is the one that comes to mind first.
In this post, tepples wrote:
SoD2's samples are 4-bit linear PCM (or as linear as the APU DMC DAC allows). Years ago, I wrote an extractor that turns the whole ROM into a wave file; it shouldn't be too hard to write your own if you know any PC programming language.

I forget which others there were. But if you're curious, I could write a Python program that runs heuristics on a PRG ROM to see what parts look like 4-bit linear PCM (and which nibble order).



Sorry I'm late, but I would appreciate if you wrote that program sometime in the future. It would also be very useful to tell which Game Boy or Game Boy Color games use PCM as well. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group