Namco 163 techniques (ftm inside)

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Namco 163 techniques (ftm inside)
by on (#200005)
Since i've got my eyes opened for the flexibility of the N163, it has become an enjoyable diversion. This will be a thread where i post ftm:s with various techniques as i find them. You can add yours too if you want to.

First try with N163. Main thing to show:
-Mono, single channel delay built into instrument with a more "natural" wobbling between low and high harmonic content than you can achieve on square channels.

With more channels, you could make more elaborate and impressive delays, but at the cost of brightness/fidelity and wave size. You could also smooth the effect with more waves.

Flip through wave # 4-6 to see how dark and bright harmonic content (represented by different lengths of hi and lo) shift back and forth in dynamic range, besides any other changes. Note how these are cycled in a loop, and amplitude shaped via the volume envelope.

Other, more mundane things to note:

-Waves #1-4 (mainly) morph the harmonic content from resonant to less resonant, approximating a bit of a filter.
-I "crushed" the lowest/longest harmonic content into much shorter widths in wave #0 to give it a bit of a bright bite for the attack.


I'm planning to add the following in new song snippets:
-A better attempt at mimicking synced oscillators set at different rates (this started out as one but then went another route when i discovered other things that were more readily doable).
-An attempt to mimic tonewheel synthesis (electric organs).

Some things i'd like to discuss further:
-Can the technique be refined?
-Am i getting it right that the CPU would have quite the job to do hotswapping waveforms like this? That's what is happening, right?
-What's your favourite N163 techniques, if any?
Re: Namco 163 techniques (ftm inside)
by on (#200007)
Yeah, the N163 audio literally is configured with "sample start" and "sample length", so every aspect of the envelope has to be swapped out by the CPU. (However, to make it clear, the CPU doesn't have to dynamically update the wavetable contents itself)

The interesting thing is that there's actually a single literal 128-to-240-nybble long waveform, and that for each channel, the 163 is configured to play a subset of this waveform. For something like the formant sweep you're using here, one could start with a single sample and continuously move the loop points within that sample.

However, Famitracker (justifiably!) decided that exposing this is awkward, and instead lets you only pick one of a subset of aligned waveforms.
Re: Namco 163 techniques (ftm inside)
by on (#200008)
Thanks for the info; that's a very good thing to know - that it's in theory possible to sweep/scan/jump the waveform memory as one would like. That'd be a very neat basis to knit around for a more dedicated wave table synth application.
Re: Namco 163 techniques (ftm inside)
by on (#200049)
In a game (provided that the sampling rate is not too high), any N163 channel could be easily used to play 4-bit PCM data with volume control by having the channel set to a 4-step wavetable, with all steps of that wavetable always being equal. To avoid potential noise coming from the little time delay between writing two wavetable bytes to change the volume, the frequency could be set to 0 and if that's not really possible, then set to such a low amount that the PCM update would happen too fast, which should also reset the wave phase to 0 just to make sure.

Alternatively (and this may be potentially much less CPU-intensive and better in pretty much every way) the same trick could be used to play samples as on the Gameboy. The wavetable serves as a buffer, and is set to a desired frequency, while the 163 also generates IRQs at the same rate, so that when the wavetable cycles through once, the CPU rewrites the wavetable with the next chunk of data. This only requires attention from the CPU when a new data chunk is needed (sadly rules out melodic samples because of OAM DMA in a game)

I'd also definitely generate pulse waves with different widths on the fly if I were to write an N163 sound engine. (Or use the trick where two flipped and slightly detuned sawtooth waves cancel out into a PWM sweeping pulse wave)
Re: Namco 163 techniques (ftm inside)
by on (#200054)
The trick with two sawtooths:
This is a neat trick because it's very easy to control via FamiTracker.
It is also neat because you can control cross-blend between PWM wave and sawtooth by lowering/increasing the volume of the contrahent so that it's off balance. Now, unfiltered sawtooth waves aren't very pleasant when sustained, but you could always have the edges rounded off to get the same effect as a non-resonant LPF.
Starting off with a saw and quickly moving into PWM will keep the attack of the note consistent regardless the free-running detune setting.

Or if you want to use just the one channel for PWM, you could have a range of 64 samples (or less/more) and simply sweep the offset position 0...31 for a ~3% to
~97% PWM, if the engine would allow it.