The interesting and useful thing about the APU DMC is that it only cares about $4012 and $4013 when a sample is started or loops. You can change them at any other time without immediate effects. This means that you can get seamless transitions from one sample to another, including from one wavetable to another.
So I built a pack of 34 wavetables - 17 byte ones with a period of 68 samples, ranging from 1 "up" and 67 "down" to 34 both directions. To make it clearly audible that there's no artifacts from changing the waveform, I chose something silent - the zapper - to choose which wavetable.
This means it's actually more versatile than "just" wavetables. You could take an arbitrary longer sample and cut it into an arbitrary number of portions: for example, an "attack" sample, a "sustain" loop, and a "release" sample. All that matters is that the hardware doesn't interrupt you when you update the "sample address" and "sample length" registers.
I've been talking about this for a while, and finally got around to making a very simple demonstration ROM. Source is included. I used Tepples's yonoff zapkernel; it's available under the All-Permissive license. My contributions are Public domain or CC0 as desired. Mapper 218, should work on mapper 7 too.
Expected controls: one joypad on player1, zapper on player2 / FC expansion port. Zapper Y coordinate chooses waveshape (and Y coordinate is displayed on the right); joypad buttons choose note (and the result is displayed on the left). Should work on NTSC and Dendy; no compensation is present for running on PAL.
DPCM Wavetables
Moderator: Moderators
DPCM Wavetables
- Attachments
-
- dpcmwavetables.zip
- (12.7 KiB) Downloaded 29 times
Re: DPCM Wavetables
This is really cool. I never understood how that sound channel has always been so unexplored and underappreciated. Definitely this feature needs to make its presence available in trackers. I would really like to hear some chiptunes that take advantage of this. There are totally new sounds to be discovered with this.
Re: DPCM Wavetables
The main reason is that only a couple of notes are available that way, the majority of them being very low. Also not every developer back then had the idea to adapt the other channel's tuning to the DPCM's complicated native tuning.Ben Boldt wrote: ↑Tue Oct 01, 2024 4:09 pm This is really cool. I never understood how that sound channel has always been so unexplored and underappreciated. Definitely this feature needs to make its presence available in trackers. I would really like to hear some chiptunes that take advantage of this. There are totally new sounds to be discovered with this.
Useless, lumbering half-wits don't scare us.
Re: DPCM Wavetables
Great demo. I've played with looped samples before, but never considered that it would change seamlessly like that.
I wonder then, if it could work to permanently enabled looped mode, having one-shot samples transition to a relatively quiet 10101010 loop. That would free up something like 16 CPU cycles per scanline with my DMC raster-timed code, it polls $4015 every scanline to adjust the timing per scanline, to handle the sample ending mid-frame (also adjusted for the worst-case time it took to adjust the timing).
I wonder then, if it could work to permanently enabled looped mode, having one-shot samples transition to a relatively quiet 10101010 loop. That would free up something like 16 CPU cycles per scanline with my DMC raster-timed code, it polls $4015 every scanline to adjust the timing per scanline, to handle the sample ending mid-frame (also adjusted for the worst-case time it took to adjust the timing).
Seems like one limitation would be when changing between samples that have differences in BOTH address and length, the DMC will eventually fetch data based on a partially-updated pair of registers. As for what I wrote above, I suppose it then could require samples to start with silence, then update the address first.