Lately Tuned - short looped DPCM sample tuning experiment

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Lately Tuned - short looped DPCM sample tuning experiment
by on (#219747)
This is an archival post of an experiment I made in 2012 and originally posted at the Famitracker forums at that time.

The idea came from this discussion: http://forums.nesdev.com/viewtopic.php?f=6&t=5473

We determined that the tuning scheme of the DPCM playback frequencies appeared intended to play a C major scale and a few other notes tuned to A440. However, there also appears to be a mistake in how they implemented sample lengths, causing them to read 1 extra byte at the end of the sample. For looped samples this causes the pitch to lower by that relative length, so in the case of the smallest practical looped sample that could have been used (16+1 bytes) the intended playback pitch is lowered by a ratio of 16/17. This is close to a semitone, but not quite equivalent.


As an experiment, I composed this piece in Famitracker, with accompanying tracks one semitone lower, but then replaced the tuning tables to correct the rest of that tuning difference between 16/17 and 100 cents. The NSF plays with this corrected tuning table, and the Famitracker FTM will play at the original semitone approximation.

Overall the result isn't that compelling, mainly because the DPCM tuning is very imprecise to begin with. Matching its A440 scheme kind of centres the error, but it's still not very well in tune, especially on PAL where two of the frequencies are further off than they should be. It was intended only as a exploration of how close I could get under ideal circumstances.


Another thread that might be useful information, where other possible sample lengths are explored:
https://forums.nesdev.com/viewtopic.php?f=6&t=13169
Re: Lately Tuned - short looped DPCM sample tuning experimen
by on (#219766)
Heheheh, that's nice. Looped samples are tough indeed.

A long time ago, I wrote a interactive (cli) tool to convert WAV files to DMC. It had a high quality resampler (and optional dither?), and it was possible to adjust the gain and pitch (octave, scale, cents) prior to conversion, and then the converted sample could be heard. Basic DMC emulation was done: the non-linearity of the 2A03 sound was simulated, the 16 playback speeds can be selected and changed anytime, the sample can be looped and the start and length of the sample can be changed too, according to the limitations of the DMC channels.

That was a great tool to make looped samples: with a script that searched (by brute force) loop lengths that can result in perfect loops according to a detuning tolerance, I could naturally convert slightly detuned samples that looped perfectly.

I know I have that tool somewhere, and I can dig it up if someone's interested. The script's probably lost, but is easy to rewrite though.