It is currently Mon Oct 23, 2017 7:10 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Sun Feb 07, 2016 6:53 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1787
Location: DIGDUG
Still not 100% clear, but the drums in SMB3 are DMC samples.

I was able to fit 32 DMC samples of OK quality into an NROM game (NEStalk), each about .25 seconds, that's about 8 seconds. A better mapping could fit 8x as much, for a total of 64 seconds at an OK sample rate. At the best sample rate, half that... So, about 30 seconds of high quality sound could fit in a normal game.

(Correct me if I'm wrong, guys).

My current method for DMC sound samples, is to get a MONO 44100 rate audio sample, cut it down to abou 0.2- 0.5 seconds, import it into Famitracker, and save it as a DMC file (which can be included into a the game code).

I find that DMC is much better at low to mid range frequencies, as the upper range is lost in DMC hum noise (artifacts of the DMC sample rate being in the audible spectrum). The highest sample rate has the least noticeable hum/noise.

Also, DMC sounds tend to be much quieter than other channels, which will have to be volumed down to balance this issue.

DMC is also the only way to get really low Bass notes.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sun Feb 07, 2016 7:38 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19122
Location: NE Indiana, USA (NTSC)
DPCM = delta pulse code modulation
DMC = delta modulation channel

The DMC has a 7-bit "current value" register. Raw PCM playback feeds individual samples to this register. A program may also write once to this register before starting background playback of a DPCM sample, producing the pops common in Konami NSFs.

I've written tools to encode and decode DPCM in Python. This should give you an idea of exactly how it would sound. Are you capable of running Python programs on your computer? What operating system (Windows, Linux, or OS X) does your computer run?


Top
 Profile  
 
PostPosted: Sun Feb 07, 2016 8:26 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6303
Location: Seattle
dougeff wrote:
I find that DMC is much better at low to mid range frequencies, as the upper range is lost in DMC hum noise (artifacts of the DMC sample rate being in the audible spectrum). The highest sample rate has the least noticeable hum/noise.
The DMC playback is equivalent to a first-order lowpass at frequency 0 (i.e. it's an integrator). Frequency X can be represented as twice as loud as frequency 2X.

So as you found, it's good for bass guitars, bass drums, toms, and deep rumbly synth samples, and it's rather suboptimal at cymbals, high hats, and other broadband noise sources. (Fortunately, there's the noise channel)

Quote:
Also, DMC sounds tend to be much quieter than other channels, which will have to be volumed down to balance this issue.
Each individual step in DPCM is pretty close to the quietest pulse channel volume; 15 steps are close to pulse channel maximum volume. The triangle channel is equivalent in volume to a DPCM stream of 20 ↑ followed by 20 ↓ (and repeat).

IME, I found that companding the audio first is vital towards getting good volume (and lack of hiss) out of DPCM-encoded recordings.


Top
 Profile  
 
PostPosted: Mon Feb 08, 2016 1:19 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5736
Location: Canada
Marscaleb wrote:
So with THAT in mind, to what sort of quality would I need to convert a wave file to in order for it to be played during normal gameplay? And about how much room would a normal game from 1989-1991 (with probably an MMC3) be able to reasonably devote to storing this PCM-like audio? I'm not talking about a game that makes a special effort because it needs special sound, but just a game that wants a few sound effects that sound better.

The most DPCM I've seen in an NES game was Gimmick! which has less than 32k (4 x 8k banks) dedicated to samples. It had a mapper that could swap out the C000-DFFF region which helps a lot there. Most of these samples are used for a DPCM bass instrument that plays constantly. Sunsoft put DPCM bass in several games (look up "sunsoft bass"); Journey to Silius makes do with a much smaller collection of DPCM samples in a single bank (MMC1), but its bassline is less varied and a bit out of tune compared to their later games which afforded more data to it.

The majority of DPCM using games just use them for a couple of percussion sounds (e.g. bass drum, snare drum), and often they are sharing precious space in a fixed bank with important code. The amount of data devoted too samples tends to be rather small. A couple of kilobytes, maybe ~2k or so? 8k would probably be excessive if you can't bankswitch $C000-DFFF.

Really there is a wide variety of options available, what games did was about how they wanted to manage their resources. Sunsoft wanted their soundtracks to stand out, and they certainly paid for it in their game's data budget.


Top
 Profile  
 
PostPosted: Mon Feb 08, 2016 11:43 am 
Offline
User avatar

Joined: Fri Sep 11, 2015 10:39 am
Posts: 106
tepples wrote:
DMC = delta modulation channel

Ooooohhhhhhh!! That makes sense.

tepples wrote:
The DMC has a 7-bit "current value" register. Raw PCM playback feeds individual samples to this register.


When I read that i thought... Could you feed the DMC the result of an algorithm to produce another simple wave, like another square or another sawtooth, to get an extra channel but without the expense that an actual DPCM file would carry?

tepples wrote:
Are you capable of running Python programs on your computer? What operating system (Windows, Linux, or OS X) does your computer run?

Probably. I run Windows 7 64-bit.

(Redacted)


Last edited by Marscaleb on Mon Feb 08, 2016 1:04 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Mon Feb 08, 2016 11:53 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5736
Location: Canada
Marscaleb wrote:
tepples wrote:
The DMC has a 7-bit "current value" register. Raw PCM playback feeds individual samples to this register.

When I read that i thought... Could you feed the DMC the result of an algorithm to produce another simple wave, like another square or another sawtooth, to get an extra channel but without the expense that an actual DPCM file would carry?

PCM is the expensive one, not DPCM. So, no. This is backwards.

Marscaleb wrote:
rainwarrior wrote:
The most DPCM I've seen in an NES game was Gimmick! which has less than 32k (4 x 8k banks) dedicated to samples.

Gimmick, Gauntlet II, Sesame Speak and Spell...
Did any game that DIDN'T suck do anything impressive with PCM?

Gimmick! was an example of DPCM, not PCM, and also if you think it sucks I don't know what game you would think is impressive.


Top
 Profile  
 
PostPosted: Mon Feb 08, 2016 12:04 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19122
Location: NE Indiana, USA (NTSC)
Marscaleb wrote:
Could you feed the DMC the result of an algorithm to produce another simple wave, like another square or another sawtooth, to get an extra channel but without the expense that an actual DPCM file would carry?

That would need one of two things: a mapper that maps RAM to $C000-$DFFF (which means Famicom Disk System or MMC5), or feeding one byte at a time through (ab)use of the completion IRQ as in blargg's saw demo.

Marscaleb wrote:
tepples wrote:
Are you capable of running Python programs on your computer? What operating system (Windows, Linux, or OS X) does your computer run?

Probably. I run Windows 7 64-bit.

Are you also familiar with the Windows command prompt? If so, try the Python installation instructions and let me know what messes up.

Marscaleb wrote:
rainwarrior wrote:
The most DPCM I've seen in an NES game was Gimmick! which has less than 32k (4 x 8k banks) dedicated to samples.

Gimmick, Gauntlet II, Sesame Speak and Spell...
Did any game that DIDN'T suck do anything impressive with PCM?

Does Wheel of Fortune also suck? Does SCAT suck? And do the two community multicarts known as Action 53 (volume 1 and volume 2) also suck? All three use PCM. Usually if a game could afford to stop the action for speech, it would use PCM for higher quality.


Top
 Profile  
 
PostPosted: Mon Feb 08, 2016 12:57 pm 
Offline
User avatar

Joined: Fri Jan 24, 2014 9:05 am
Posts: 133
Location: Hungary
I've made a square wave generator using the DMC IRQ. I play a 1-byte sample, which is the value $AA, so an alternating bit pattern of 1s and 0s. I play the sample at the fastest possible DMC sampling rate. This is so that the DPCM sample doesn't interfere with the rest of the sound more than it has to. You get an inaudibly high, very quiet square wave as an artifact, which is no big deal, and if I remember correctly it takes about 3500 cycles per frame to handle this, with the cost getting lower, the lower you go with the frequency. The issue is that in a game this would be interrupted by OAM DMA, and you'd get a 60Hz buzz in the sound. So the only practical use of this would be an extra channel for sound effects, or tone drums where the interference doesn't matter that much.
I screwed up something with the controller routine so sometimes you get dropped input, and sometimes you get double reads. Couldn't be bothered to fix it because this is just a proof of concept-type thing.

Every x IRQs the state bit of the "sequencer" is flipped, and I write a zero to the "current value" or the current volume based on this bit, which makes a square wave.

Up-Down changes the divisor value, Left-Right changes the volume.
It might work incorrectly if your emulator doesn't have accurate DMC IRQ emulation.
Edit: Got the code here that makes it happen, not very complex...


Attachments:
DPCM Square generator.nes [40.02 KiB]
Downloaded 60 times
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 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