digital-sound-antiques / vgm-conv

Chip-type and clock converter for VGM
ISC License
45 stars 3 forks source link

Pitch calculation error #42

Closed denjhang closed 3 years ago

denjhang commented 3 years ago

截图未命名0817193238 截图未命名0817193308 The lowest note of NGP should be G2 or lower, but after conversion to AY8910, the lowest note is only A2

okaxaki commented 3 years ago

I have two questions.

okaxaki commented 3 years ago

If your vgm's NGP clock is 307200Hz, please make sure pitch on the MDPlayer keyboard is correct. If MDPlayer assumes 3579545Hz clock, MDPlayer shows 2 lower semi-tones for a 307200Hz vgm.

denjhang commented 3 years ago

I can make sure that the pitch displayed by MDPlayer is correct. Because I have reported a problem in the pitch calculation of SN76489 with a frequency other than 3,575,545 hz a long time ago https://github.com/kuma4649/MDPlayer/issues/124. This problem was fixed soon, which means that currently MDPlayer considers the difference of the clock when calculating the pitch.

denjhang commented 3 years ago

Currently AY8910 sound is detuned. In NGP, all sounds lower than A2 become A2 of AY8910.

denjhang commented 3 years ago

ngp-sonic.zip

denjhang commented 3 years ago

I found that not only the NGP, but also the pitch conversion error for the SN76489 that does not use the 3579545hz clock.

denjhang commented 3 years ago

lickspat.zip

okaxaki commented 3 years ago

Okay I got the point. Current vgm-conv internally convert SN76489's clock to 3579545Hz. At this clock, the note's lower limit is A2. I'll fix this problem but it will take some time.

Workaround: it is possible to get a correct conversion result with -c option that specifes the destination clock as the following.

vgm-conv -f sn76489 -t ay8910 -c 1536000 -o 1536000.vgm input.vgm
vgm-conv -c 1789773 -o output.vgm 1536000.vgm
okaxaki commented 3 years ago

Fixed at 0.8.21