Lately Tuned - short looped DPCM sample tuning experiment

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

Moderator: Moderators

Post Reply
User avatar
rainwarrior
Posts: 7804
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Lately Tuned - short looped DPCM sample tuning experiment

Post by rainwarrior » Tue Jun 12, 2018 1:18 pm

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: 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
Attachments
lately_tuned.py.zip
(688 Bytes) Downloaded 266 times
lately_tuned.ftm
(3.88 KiB) Downloaded 281 times
lately_tuned.nsf
(5.97 KiB) Downloaded 283 times

User avatar
Jarhmander
Formerly ~J-@D!~
Posts: 495
Joined: Sun Mar 12, 2006 12:36 am
Location: Rive nord de Montréal

Re: Lately Tuned - short looped DPCM sample tuning experimen

Post by Jarhmander » Tue Jun 12, 2018 9:47 pm

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.
((λ (x) (x x)) (λ (x) (x x)))

Post Reply