gtaylormb / opl3_fpga

Reverse engineered SystemVerilog RTL version of the Yamaha OPL3 (YMF262) FM Synthesizer
GNU Lesser General Public License v3.0
359 stars 43 forks source link

Fix monkey island door open sound #50

Closed gtaylormb closed 2 weeks ago

gtaylormb commented 2 weeks ago

A lot of red herrings debugging this fix. Spent most of the time thinking this was an envelope issue, as discussed here: https://github.com/gtaylormb/opl3_fpga/issues/47

Turns out the OPL3 is generating a ~22-24KHz sine wave after ~0.02s, which gets filtered out post DAC by the LPF (and obviously you cannot hear it). I was truncating an extra fractional bit in the phase generator. This may or may not have an audible effect on "normal" music but it is a positive fix either way.

stohrendorf commented 2 weeks ago

Is this a possible bug in PPPlay too maybe? I tried to follow your changes, but I don't understand any of the code.

gtaylormb commented 2 weeks ago

Is this a possible bug in PPPlay too maybe? I tried to follow your changes, but I don't understand any of the code.

No, ppplay appears correct. The issue was I was missing a shift in the phase increment (the right shift by 1 after the block shift), and I was dropping off the bottom 10 bits of the phase accumulator instead of the bottom 9 bits for the final phase. This bug has existed in my code for the last decade or so.

stohrendorf commented 2 weeks ago

Good thing you found it.