Complexity of putting music into a game

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: Complexity of putting music into a game

Post by dougeff »

Here's a sample of DPCM code...

Code: Select all

	lda #$0f	;sample rate
	sta $4010	;0f is highest rate, 33144

	lda #$00	;starting address, must be c000-ffc0
			;00 = c000
			;fc = ff00

	sta $4012	;11aa aaaa aa00 0000

	lda #$0e	;length of sample
	sta $4013	;LLLL LLLL 0001, 0e => e1 bytes

	lda #$1f	;write of 0001000 triggers sample
	sta $4015
and...

Code: Select all

ldx #$0f	;turn off last sample
	stx $4015
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
darryl.revok
Posts: 520
Joined: Sat Jul 25, 2015 1:22 pm

Re: Complexity of putting music into a game

Post by darryl.revok »

rainwarrior wrote:The most I've ever seen is 4 8k sample banks, used in Gimmick. (32k)
Just curious, did they use DPCM to make the detuned bass synth in Sophia, or is it actually two oscillators slightly detuned like a Moog baseline?

According to what I was reading, Sunsoft used DPCM a lot to make cool bass sounds. I was also reading though that it works poorly for high pitched sounds, so you might not be satisfied with the results with a female voice.
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: Complexity of putting music into a game

Post by lidnariq »

Sunsoft had so frequently used the DPCM channel for a string or electric bass that we have come to colloquially refer to it here as "sunsoft bass".

The DPCM channel reconstruction is effectively an infinite lowpass filter. ("infinite" in the sense that the corner frequency is 0; for every pair of frequencies f and 2f, f can be represented twice as loud as 2f).
(Obviously at some point the channel saturates. At highest, that's frequencies below 258 Hz. Anyway, I'm ignoring that for now)

This encoding does an adequate job as long as its input is sufficiently bandlimited (say maybe 1kHz from lowest frequency you want to store to highest). The more bandwidth, the worse DPCM is at encoding it.

As an example, here's the first 7 seconds from David Byrne's My Fair Lady on The Wired CD (CC:Sampling+ license). First 7 seconds are post-filtering, second 7 seconds are additionally after encoding and decoding. I've applied a very strong bandpass to retain just the frequency band from 500Hz to 1500Hz.
Attachments
original-and-dpcm-of-narrowband-signal.mp3
(85.16 KiB) Downloaded 139 times
Post Reply