nukeykt / Nuked-OPM

Cycle accurate Yamaha YM2151 emulator
GNU Lesser General Public License v2.1
73 stars 5 forks source link

Detune 1 is wrong #10

Open jotego opened 3 years ago

jotego commented 3 years ago

After implementing the DT1 circuit following your code, I got several complaints about music being off-pitch. I have run your code to extract the same detune table as present in the YM2151 application notes:

Nuked-OPM:
Oct  Note        | DT1=0 | DT1=1 | DT1=2 | DT1=3
-----------------|-------|-------|-------|------
0    0 (  17 Hz) | 0.000 | 0.000 | 0.053 | 0.107 
0    1 (  18 Hz) | 0.000 | 0.000 | 0.053 | 0.107 
0    2 (  19 Hz) | 0.000 | 0.000 | 0.053 | 0.107 
0    3 (  21 Hz) | 0.000 | 0.000 | 0.053 | 0.107 
1    0 (  35 Hz) | 0.000 | 0.053 | 0.107 | 0.107 
1    1 (  37 Hz) | 0.000 | 0.053 | 0.107 | 0.107 
1    2 (  39 Hz) | 0.000 | 0.053 | 0.107 | 0.107 
1    3 (  41 Hz) | 0.000 | 0.053 | 0.107 | 0.160 
2    0 (  69 Hz) | 0.000 | 0.053 | 0.107 | 0.213 
2    1 (  73 Hz) | 0.000 | 0.053 | 0.107 | 0.213 
2    2 (  78 Hz) | 0.000 | 0.053 | 0.107 | 0.213 
2    3 (  82 Hz) | 0.000 | 0.053 | 0.160 | 0.213 
3    0 ( 139 Hz) | 0.000 | 0.107 | 0.213 | 0.267 
3    1 ( 147 Hz) | 0.000 | 0.107 | 0.213 | 0.267 
3    2 ( 156 Hz) | 0.000 | 0.107 | 0.213 | 0.267 
3    3 ( 165 Hz) | 0.000 | 0.107 | 0.213 | 0.320 
4    0 ( 277 Hz) | 0.000 | 0.107 | 0.267 | 0.427 
4    1 ( 294 Hz) | 0.000 | 0.107 | 0.267 | 0.427 
4    2 ( 311 Hz) | 0.000 | 0.107 | 0.267 | 0.427 
4    3 ( 330 Hz) | 0.000 | 0.160 | 0.320 | 0.427 
5    0 ( 554 Hz) | 0.000 | 0.213 | 0.427 | 0.587 
5    1 ( 587 Hz) | 0.000 | 0.213 | 0.427 | 0.587 
5    2 ( 622 Hz) | 0.000 | 0.213 | 0.427 | 0.587 
5    3 ( 659 Hz) | 0.000 | 0.213 | 0.427 | 0.640 
6    0 (1109 Hz) | 0.000 | 0.267 | 0.587 | 0.853 
6    1 (1174 Hz) | 0.000 | 0.267 | 0.587 | 0.853 
6    2 (1244 Hz) | 0.000 | 0.267 | 0.587 | 0.853 
6    3 (1319 Hz) | 0.000 | 0.320 | 0.640 | 0.907 
7    0 (2217 Hz) | 0.000 | 0.427 | 0.854 | 1.174 
7    1 (2349 Hz) | 0.000 | 0.427 | 0.854 | 1.174 
7    2 (2489 Hz) | 0.000 | 0.427 | 0.853 | 1.173 
7    3 (2637 Hz) | 0.000 | 0.427 | 0.853 | 1.173 

The values for DT1=0/3 seem fine. The values for DT1=1 and DT1=2 are wrong. Could you please review your notes?

imagen

nukeykt commented 3 years ago

can you provide vgm files for problematic songs?

nukeykt commented 3 years ago

also preferrably recordings of your core and real hardware so I could compare with my core output

jotego commented 3 years ago

People are complaining about Blanka's theme and also about Double Dragon music. I did measure all combinations of this on real hardware but I couldn't find the measurements the last time I looked for them. I will look harder for the files. I think rather than a VGM file, it is better to directly call the functions involved and get the raw phase increment values. It is much faster. I am doing that in this test bench https://github.com/jotego/jt51/tree/master/ver/jt51_pg

You would need to setup Verilator on a Linux machine to run the test, so maybe you can skip that and just inspect the code of https://github.com/jotego/jt51/blob/master/ver/jt51_pg/test.cc to figure out what I am doing.

I checked my original code output for DT1 and it was different from the App notes too (and different from yours). I think the code did match the measurements when I wrote it, but it is too long ago. I do need to find the measurements.

jotego commented 3 years ago

I found the measurements. Here they are:

https://drive.google.com/drive/folders/17Ra-kuqCgjCHayBnr8CpZbzzJb1GIXy7?usp=sharing

If you untar the file freq.tar.gz you will find binary files with 16-bit signed values of output waveforms for the different parameter settings.

I think that data is summarized in this spread sheet:

incr_fase.ods.zip

The spread sheet has some words in Spanish, as I wasn't sharing my work back then. But it isn't a big deal, fase means phase, etc.