Using steady DPCM samples as a 'lead'

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Using steady DPCM samples as a 'lead'
by on (#130641)
The NES' DPCM channel wasn't very reliable for being used as anything more than a drum channel. However, some programmers have managed to use it into the bassline channel (best example being Sunsoft's Fester's Quest and after games), and Skate or Die 2 uses it as a guitar (though presumably they are 7-bit PCM, and only have a few notes to speak). I also came across the Game Boy Color game "Little Nicky", which despite being based on a movie, it seems to be one of the few Game Boy games to use the sample channel at all. To my memory, only Pokemon Yellow, Joe and Mac, and Canon Fodder are the other games that do so. Anyway, the game has music that consists of digitized guitars as well as the square waves and noise channel.

https://www.youtube.com/watch?v=jfmYnCV0gUo

Listening to this, it made me wonder if this would be at all possible to do on the NES. The biggest issue would be memory usage and bankswitching the samples into the music, not to mention how the NES plays back samples at inconsistent pitches. But would something like this be at all possible? Would it produce something good, or would it be undesirable?
Re: Using steady DPCM samples as a 'lead'
by on (#130642)
In any case, with enough memory, one could work around the out-of-tune tuning by storing the notes separately like a Mellotron tape set. What kept it from being used in the NES era was that no licensed NES game's PRG ROM was bigger than 4 Mbit (Dragon Warrior 3 and 4, Kirby's Adventure, Mega Man 4 and 6). But by the Game Boy Color era, Nintendo's minimum cartridge size had become 8 Mbit, leading the developers of The Adventures of Elmo in Grouchland to fill three-fourths of the ROM with padding. So you'll find that Klax and a lot of other Game Boy Color-only games use the sample channel like this.

Nowadays, one practical problem is that it's hard to get 8-bit XIP-capable parallel flash memory bigger than 8 Mbit. The 29F160 (16 Mbit) has an 8-bit mode, but bigger memories are essentially serial and designed for pairing with a sufficiently large RAM. Streaming samples into this buffer might be a pain.

Another problem is that the treble response of the DMC isn't too good because of the limited rate of change of the waveform.
Re: Using steady DPCM samples as a 'lead'
by on (#130643)
As badly mistuned as the DPCM channel is, there are still some rates that are compatible with each other. Unfortunately, it's mostly the slower sample rates.

I made a table about it on the wiki.
Re: Using steady DPCM samples as a 'lead'
by on (#130646)
A while back, I made a little tune experimenting with the available pitches on a looped sample of the shortest length. It kinda just demonstrates the available scale of pitches. The square/triangle tuning is adjusted to match the scale that the DPCM tuning set approximates.
http://rainwarrior.ca/projects/nes/lately_tuned.nsf

Because the DPCM sample lengths have that odd +1 on the end, they're not very useful for the A440 C major scale they appear to be designed around. You get a 17/16 detune on the shortest looped looped sample, so it's more like a B major scale that's not quite tuned to A440.


Rob Hubbard used short looped DPCM for bass drones on The Immortal. This is the only time I've seen it done on a released NES game. He didn't actually deal with the tuning issue, he just lived with a slightly detuned bass. The other channels are still using an A440 tuning:
https://www.youtube.com/watch?v=CzFQdcDMvGU


Chibitech did a really cool tune with DPCM guitars for Famicompo 3:
https://www.youtube.com/watch?v=tcoKY9G-4ss


Necrophageon did one using DPCM for a running arpeggio with echo:
https://www.youtube.com/watch?v=zvCIKdJv5vw


What you can do is limited mainly by how much sample space you can budget, your creativity, and finally the quality of NES DPCM. The best quality is had with a unique sample for each pitch, but you can get a couple of different pitches out of the same sample if you need to, which is how Sunsoft did it, generally.
Re: Using steady DPCM samples as a 'lead'
by on (#130647)
Interesting, thanks for the replies. That chibi-tech song (as much of an anti-fan I am of this person's work) is what I would imagine a "no holds barred" NES soundtrack would sound like, the 2A03 at it's full potential. Problem with that, as tepples said, is that memory would be too expensive, and being able to store a bunch of different variations of the same note. Then again, this is assuming for a functional NES game, so I'm assuming there would be severe compromises made to the game just to accommodate the music. Sunsoft games were ridiculously small, and I'm guessing that's because all the space was used by the bassline samples. Then there's also the issue with the 32K of dedicated music data...
Re: Using steady DPCM samples as a 'lead'
by on (#130648)
For a point of reference, I believe Gimmick! was Sunsoft's game with the biggest soundtrack, and It's under 96k of dedicated music data. 16k of that is DPCM samples, spread over 2 8k banks that are mapped at $C000. This is a good example of a high-end budget for an NES soundtrack, late in the console's lifetime with more advanced mappers (that 8k banking at $C000 is essential). 37% of the game's PRG data is devoted to music, so I think they wanted to do something special here.

32k of music data is a typical upper limit for later NES games. That's about 12% of a 256k PRG. Only a few go above that. Lots have less.

On the other extreme end, Donkey Kong does its music in under 2k. Interestingly, also about 12% of its PRG.
Re: Using steady DPCM samples as a 'lead'
by on (#130650)
What about Recca? I'm fairly certain that Recca has a lot of songs, and each of the songs are in the minutes, not to mention this game has about a dozen samples. What's funny is that these exact same samples were used in (Samurai) Zombie Nation as well as a bassline sample, but ZN has much shorter, albeit crazier, music. And what if the memory (and financial) budget was infinite, or rather very high? Would there be any other limitations that cannot be solved by time and money? You mentioned that memory budget, the artists creativity, and the DPCM's resulting sound quality are the three biggest detriments, so if money was thrown at these problems, surely anything would be possible.
Re: Using steady DPCM samples as a 'lead'
by on (#130651)
It could go as far as "Max 300" by Omega, which I converted several years ago.

Since then I've realized a couple more things I could theoretically do with it to reduce the impact of slope overload. One is to split the spectrum of each 16 ms frame into tonal and non-tonal components, find the closest combination of volume and period that fits the spectral shape of the non-tonal part, and subtract the resulting noise power from the signal. That would at least reduce the amount of treble that the encoder has to deal with, and treble is the one thing delta modulation doesn't do well.
Re: Using steady DPCM samples as a 'lead'
by on (#130653)
That's impressive, but awfully hissy. Would maximizing the usage of the DPCM channel (by any means necessary) produce hissy sounds? I know the answer to that, even Sunsoft's basslines are hissy. Is there a way to eliminate hiss from 1-bit DPCM other than using drum samples?
Re: Using steady DPCM samples as a 'lead'
by on (#130667)
OneCrudeDude wrote:
What about Recca? I'm fairly certain that Recca has a lot of songs, and each of the songs are in the minutes, not to mention this game has about a dozen samples.

The Recca NSF is under 32k, so it's not particularly exceptional here. I don't think the songs are particularly long before they loop, but it is unusual in that it has more songs than come up in gameplay; there is a sound test mode that will let you play them. (I also suspect it had a short/rushed development cycle due to the nature of its release.)

Quote:
And what if the memory (and financial) budget was infinite, or rather very high?

The memory budget is not usually a significant problem for game music today. Lots of big budget games get large music budgets as well, often it hires an orchestra or something. If you mean hypothetically if they still had to use the NES, virt's Shovel Knight soundtrack is a recent example of an NES (+VRC6) soundtrack unconstrained by a memory budget. The NSF is about 600k. If memory isn't a problem, you don't have to use identical loops everywhere, and you can have new material throughout a track. (Though, you may find it interesting that this soundtrack has no DPCM at all, except for an orchestra hit used as a joke in one track.) Cave Story might be another example; it's not NES, but clearly NES inspired, and he worked on it for ~5 years, so you could say he had a somewhat unrestrained amount of time to work on the music.
Re: Using steady DPCM samples as a 'lead'
by on (#130674)
Regarding the orchestra hit, this is important. Is that sample 7-bit PCM, or 1-bit DPCM, and what track? It seems like, while iconic of the era, not many NES games had decent sounding orchestra hits (not to mention not many had them in the first place), possibly due to how 'complex' the sound is. An even more curious case is Top Gun 2 using orchestra hits rapidly increasing in pitch for the selection 'jingle', but used nowhere else in the game.
Re: Using steady DPCM samples as a 'lead'
by on (#130676)
It's DPCM (Famitracker doesn't do PCM), it's the last track of the NSF (51), and it's the classic fairlight "orch5" sample. It's not particularly well made as a DPCM sample either; there's a nasty pop on the end. As I said, I think it's just there for a laugh. I don't think it was even included in the bandcamp soundtrack.
Re: Using steady DPCM samples as a 'lead'
by on (#130678)
OneCrudeDude wrote:
It seems like, while iconic of the era, not many NES games had decent sounding orchestra hits (not to mention not many had them in the first place)

Probably because the orchestra hit fad hadn't yet infected popular music. NES music was largely more rock-influenced than EDM-influenced. But there was Super C.
Re: Using steady DPCM samples as a 'lead'
by on (#130682)
tepples wrote:
OneCrudeDude wrote:
It seems like, while iconic of the era, not many NES games had decent sounding orchestra hits (not to mention not many had them in the first place)

Probably because the orchestra hit fad hadn't yet infected popular music. NES music was largely more rock-influenced than EDM-influenced. But there was Super C.


Orchs were used in 8 games to my memory; Super C, Contra Force, Top Gun 2, Bomberman 2, Fester's Quest, Recca, Doki Doki Yuenchi, and Zombie Nation, the last three sharing the same sample. That said, I wish I could fund the development (be it by winning the lottery or some other shady method) of 'the ultimate NES game', and among other things, the music will have orchestra hits.
Re: Using steady DPCM samples as a 'lead'
by on (#130683)
OneCrudeDude wrote:
That said, I wish I could fund the development (be it by winning the lottery or some other shady method) of 'the ultimate NES game', and among other things, the music will have orchestra hits.

I've tended to do an approximation of orchestra hits using octave arps. I made this cover of "Maxx Unlimited" by Z in a tracker, adhering to 2A03 limits with no DPCM. Also this Balloon Fight-inspired tune, which I made as a reworking of my earlier "Balloon Fever".

But if you have ideas for an NES game, go ahead and write up a design document and make a new topic.
Re: Using steady DPCM samples as a 'lead'
by on (#130692)
I don't have an idea for a game, sadly, at least not yet. All I know is that it would be incredibly ambitious, something that would've come out late in the console's life but did not.

As for non-DPCM orchestra hits, this one guy managed to make an "NES cover" of Pokemon Diamond/Pearl/Platinum's champion theme, in which quickly arpeggiating and downpicthing (are those even words?) square waves make a sound similar to an orchestra hit. "NES cover" is in quotes because this was rendered with FL Studio, not Famitracker or otherwise. I assume this sounds close enough.

https://www.youtube.com/watch?v=GWM3nJm6pKY at 1:12
Re: Using steady DPCM samples as a 'lead'
by on (#130796)
Konami really lost their pants to orchestra hits with the Turtles in Time soundtrack.
Re: Using steady DPCM samples as a 'lead'
by on (#130803)
I rarely tried to use DPCM outside of bass+drums because of the terrible tuning. I did a cover of the Metroid intro with a looped version of my usual bass sample. With zero effort to making it loop properly, it still didn't sound too terrible (other than the tuning, and this is played in PAL format as well) - http://youtu.be/kLfAXNYVTqY?t=17m22s

I never thought of tuning the other channels to match, that's a good idea. The Lately Tuned NSF sounds bad-ass.

Also, one game I know of that uses a looped sample, was The Immortal by Rob Hubbard. I like how it sounds too, I guess I just like lower frequencies in general though, heheh.
Re: Using steady DPCM samples as a 'lead'
by on (#130813)
@mike: Most of their non-NES soundtracks make heavy use of orch hits, be it TMNT 4 or GI Joe or that one game based on that cartoon about Cows turned Cowboys. Orchestra hits were to Konami as to what BAH BAH is to New SMB.

@memblers: I figured that the tuning would've been a big reason why it was avoided, as to have a proper set of instruments would require multiple samples. Though I'm guessing that 'sampled waveforms' might work better ala The Immortal.

That video (actually Chibiteck's cover of Technotris) also reminded me of a related, but eventually off topic quirk I noticed in some NES soundtracks. Why did some NES game soundtracks have a persistent triangle wave that was really low pitched. A game that does this a lot would be Recca; when there's nothing coming from the triangle, this low pitched hum comes out instead. Same could be said for Castle of Dragon, that too fills in triangle 'blanks' with that same sound. Is that a stylistic thing, or a quirk with the sound driver?
Re: Using steady DPCM samples as a 'lead'
by on (#130821)
For some of them, like Recca, it looks like the audio programmer didn't know how to mute the triangle and instead set the triangle to its lowest frequency wherever it was supposed to be silent (sounds as a low A). Through RF output and/or crummy speakers it would be less noticeable, which might explain why it wasn't caught and fixed during production.

Bullet Proof Tetris is an exception though. A lot of tracks play a low C frequently in an odd way, but as far as I can tell it's intentional. The tracks otherwise properly mute the triangle. (Castle Dragon appears to be in the same boat as this.)
Re: Using steady DPCM samples as a 'lead'
by on (#130828)
That makes sense, I thought it had something to do with DPCM screwing up some programming, similar to the corrupted/sporadic input reads which was allegedly fixed for PAL consoles. I could see Nintendo not noticing there was a problem with inputs, as the first game that used them, Wild Gunman, did not use the controller for anything. Same goes for Nintendo's second DPCM game, Gumshoe, even if the DPCM samples only play for one song, exactly 11 times.
Re: Using steady DPCM samples as a 'lead'
by on (#130833)
Donkey Kong 3 (arcade) used two NES CPUs (2A03) as audio coprocessors. One played samples; the other played music and PSG sound effects. The 2A03 CPUs ran a "soundboard" ROM that would let the game CPU start music and sound effects by sending signals that the 2A03 CPUs saw as button presses on a controller. It could have been done with one 2A03, except the samples were put on a separate CPU because Nintendo hadn't yet figured out how to work around the double read glitch.

I have another interesting story to tell about "Technotris" in Tetris by BPS. Before edge cases of length counter behavior were figured out, early emulators played a bunch of low C's on the pulse channels as well, which I initially heard as a more complex bass line.
Re: Using steady DPCM samples as a 'lead'
by on (#130865)
That sounds pretty good actually. You should hack that game to play that song instead, and maybe get rid of the ass backwards controls.

And since Nintendo's arcade games used the same processors as the NES did, I wonder if any things generated by those chips would be possible to replicate at all on the NES. Likewise, I really wonder what a "double NES" setup would sound like. On the same note, I wonder if the PlayChoice10 CPU has any advantages or quirks over the NES one.
Re: Using steady DPCM samples as a 'lead'
by on (#130866)
OneCrudeDude wrote:
That sounds pretty good actually. You should hack that game to play that song instead

I'm done hacking Tetris after a court ruling from two years ago.

Quote:
and maybe get rid of the ass backwards controls.

BPS already did that in Tetris 2 + Bombliss and its Super Famicom Tetris games.

Quote:
And since Nintendo's arcade games used the same processors as the NES did

The pre-Vs. System arcade games mostly used Z80 for gameplay. Only DK3 and Punch-Out!! use NES CPUs for audio.

Quote:
I wonder if any things generated by those chips would be possible to replicate at all on the NES.

There's an NSF of arcade Punch-Out!! floating around.

Quote:
Likewise, I really wonder what a "double NES" setup would sound like.

It'd probably sound a lot like an MMC5. But an NES and a Game Boy together might sound like this.
Re: Using steady DPCM samples as a 'lead'
by on (#130867)
Nintendo made a double NES machine, the VS Dualsystem. Actually years ago for fun I messed around with using audio from both sides, emulating it in MAME. The two CPUs can communicate, though only a few games used that feature. Also, the song is really dumb, and it's not exactly NES-accurate, but I had made this XM module: http://nesdev.com/2A03/nes-x2.zip

The Playchoice, at least the one I have, has an RP2A03E. No differences to the G revision are known. The VS system however (and probably Punchout and Donkey Kong 3) have an RP2A03 (no revision letter), and one known difference is that there is no 'looped noise' mode.
Re: Using steady DPCM samples as a 'lead'
by on (#130870)
The Vs Dualsystem is what I what I actually had in mind when I mentioned the dual NES audio. However, that machine seemed to essentially be two NES hooked up via LAN, with each console displaying something different but playing the same game. Did that only work for simple games (such as Wrecking Crew), or would it be possible to have, say, a version of Contra where each player isn't restricted by the screen? Or would transmitting the information between both CPUs (IE, a bullet that flied past P2's screen being transferred over to P1's screen) be a lot more complex?
Re: Using steady DPCM samples as a 'lead'
by on (#130872)
There is a block of shared memory at $7000 or thereabouts that only one machine can access at once. The first CPU, as I understand it, controls which machine sees it at any given time. A game could send any sort of state updates through that memory, but I'm not sure to what extent the two machines are synchronized in terms of relative vblank timing.
Re: Using steady DPCM samples as a 'lead'
by on (#130875)
tepples wrote:
I'm not sure to what extent the two machines are synchronized in terms of relative vblank timing.
Both PPUs and both CPUs are fed off the same master clock, and both PPUs and both CPUs have all their RESET pins tied together. And there's no short fields on the Vs. System PPUs (always exactly 89342 pixels) ... so as far as I can tell, they should stay perfectly synchronized.
Re: Using steady DPCM samples as a 'lead'
by on (#130913)
OneCrudeDude wrote:
The Vs Dualsystem is what I what I actually had in mind when I mentioned the dual NES audio. However, that machine seemed to essentially be two NES hooked up via LAN, with each console displaying something different but playing the same game. Did that only work for simple games (such as Wrecking Crew), or would it be possible to have, say, a version of Contra where each player isn't restricted by the screen? Or would transmitting the information between both CPUs (IE, a bullet that flied past P2's screen being transferred over to P1's screen) be a lot more complex?


That's certainly possible if the game is designed for it, a game like Contra probably would need non-trivial modifications to allow stuff like the other player to shoot from off-screen, and new enemy spawning situations. Those are potentially gameplay-breaking modifications, but theoretically, if there's not too much data to transfer I'm sure it could handle something like that just fine. It would prevent the annoying deaths on the waterfall level, which would be nice.

BTW, on a somewhat related note (and veering off-topic), it's just a rumor, but supposedly when Codemasters was developing Micro Machines, they had a multiplayer setup with 2 systems liked by the controller port. If true, that would have been pretty cool. I can't remember where I heard that.
Re: Using steady DPCM samples as a 'lead'
by on (#130929)
This particular thread is off topic to begin with, I feel bad for making it in the first place. But I have some curiosities about the console, so yeah.

I don't know how the controller ports could link two consoles and their information together. Maybe they meant the expansion port? And I wouldn't put it past Codemasters, it seemed like English programmers were insanely intuitive. It also helps that Codemasters' games were among the best unlicensed games, good enough to be classified alongside licensed titles. But being English games, they also suffer from various design errors resulting in odd difficulty.
Re: Using steady DPCM samples as a 'lead'
by on (#130940)
The controller port is 3 general-purpose inputs, 1 general-purpose output, 2 pins to power things, and 1 pin that indicates when the NES is reading from the controller port.
It'd be pretty easy to make a "null modem" cable that would connect two NESes together to communicate, although it would be hard to communicate in a manner that was both high bandwidth and allowed anything else to go on at the same time.
Re: Using steady DPCM samples as a 'lead'
by on (#131024)
Hypothetically speaking, how could one make an "NES LAN kit", if at all possible? Perhaps by linking the consoles together by the cartridge slot, or the expansion port, or both?
Re: Using steady DPCM samples as a 'lead'
by on (#131029)
If I were to deign something arbitrarily, I'd probably make something like what the Vs. DualSystem does—basically the highest possible bandwidth for a plain 6502 design without a general purpose data transfer unit (which the NES doesn't have).

The Vs. DualSystem provides 2 KiB of memory that the two CPUs can swap back and forth, with a simple REQ/ACK locking behavior (much like on an old parallel port printer). Anything else would be rather CPU intensive, either involving lots of polling or flurries of interrupts.

In any case, the expansion port of the NES doesn't really provide particularly useful signals; anything that used it would have to also provide a cartridge... and at that point, you may as well put the hardware on a cartridge.
Re: Using steady DPCM samples as a 'lead'
by on (#131036)
Controller port could be fairly decent (and relatively easy to build), with an MCU handling bit-banged (or possibly hardware-based) synchronous communication between a couple systems. Using D3 or D4 as a 'ready' signal would reduce the need for polling, NES could check once per frame and read it out of the MCU's buffer if the data is ready. I've been working on something similar, but more intended for NES to PC communication.

MCUs with ethernet capability are really cheap too, if one really wanted an NES LAN. :) Would be cool, but it seems like the opportunities to use it would be few and far between.
Re: Using steady DPCM samples as a 'lead'
by on (#131228)
Apologies for a bump of an old thread, but I had a question. I was recently playing the second generation of Pokemon games (Gold/Silver/Crystal), and I was wondering if it would be possible to recreate on the NES. More specifically, what if Pokemon was an NES game, but the programmers still wanted to trade and battle their Pokemon? Would it be possible to create a link system between cartridges? What about someone making an NES version of Pokemon, would it be possible to 'trade' Pokemon with the Game Boy games?
Re: Using steady DPCM samples as a 'lead'
by on (#131229)
The wire protocol for NES and Super NES controllers is very similar to the Game Link protocol, except the NES is always the "master" in SPI terms. So yes, NES to Game Boy is probably possible. If I had a flash card for an 8-bit Game Boy, I'd probably already have made a music demo that uses the Game Boy as four extra sound channels.
Re: Using steady DPCM samples as a 'lead'
by on (#131237)
That's interesting. Most development stuff is born out of curiosity, in this case if it's entirely possible for an unofficial Pokemon game on the NES being able to give and receive Pokemon to the GameBoy games. What the games really do is simply delete the Pokemon from one end and copy it to the next end, so it probably would be possible to do. If I was technically competent, I'd do so much.
Re: Using steady DPCM samples as a 'lead'
by on (#131447)
Another bump! Surprised nobody mentioned Strobe: http://battleofthebits.org/arena/Entry/Ziberia/3564/

If you want crazy DPCM usage he's your man!
Re: Using steady DPCM samples as a 'lead'
by on (#131448)
I wonder how something that could be used in a game. The comments on that NSF say it's too big for the PowerPak, whose NSF player is limited to about 200-some KiB, which is just less than one-fourth of NSF's theoretical limit of 1 MiB. So in a practical case, big DPCM samples like that might have to be streamed into RAM during playback from some sort of separate memory on the cart. I wonder how well this would work with the oft-repeated FDS-style idea to store bulk data in SPI flash and stream it into RAM at $C000-$DFFF, as most recently reiterated by infiniteneslives. It would depend on how the SPI flash is implemented. The player has to provide a byte to the DMC every 432 cycles (or 400 on PAL NES) while moving sprites around. An SPI host that relies on the CPU to move a bit at a time, like the existing interface at $4016/$4017, would be unlikely to sustain the required 33 kbps data rate while giving much margin for game logic. It'd probably take a CPLD that uses M2 to clock the flash eight times in a row and then provides all 8 bits on the data bus. This would let the program get in after vblank, grab 69 or so bytes and stash them in RAM, and get out.
Re: Using steady DPCM samples as a 'lead'
by on (#131465)
Another good one that is significantly smaller https://www.youtube.com/watch?v=ZQtGUe55MsA
Re: Using steady DPCM samples as a 'lead'
by on (#131548)
Impressive, but I think Strobe's song is ultimately very messy; it doesn't have much musical quality to it, and then tries to become unmelodious EDM music. That said, I reckon that a DPCM heavy song would play either during the credits (when there's nothing to really push around), or for the soundtrack to be made for a game rather devoid of any action, such as a puzzle game.

At last I truly see, the NES' artifacting is too severe to be used for anything more than short drum beats. However, I love how low-fi and detuned Sunsoft's (and other companies) basslines sound, so I'm conflicted.