nukeykt / Nuked-SC55

Roland SC-55 series emulation
Other
383 stars 40 forks source link

Possible DC offset issue with reverse play #53

Closed giulioz closed 4 months ago

giulioz commented 5 months ago

This is present in the JV-880 as it supports waveform reverse playback, dunno if the SC55 does that as well. When playing those tones, some DC offset accumulates which eventually leads to clipping. You can notice it in the second demo song.

image

To repro it it's enough to initialize a default patch (from the utility menu) and select a reverse tone like this one:

image
PythonBlue commented 5 months ago

I can reproduce this issue, myself, and while I don't know enough about assembly to have a fix, I can say that I've also had similar experiences early on during my attempts of creating custom SR-JV80 ROM images. While this obviously isn't supposed to happen for the official waveroms's, I think I can say that judging from those past experiences, it could be either or both of two things being the cause:

1) the exponent tables for the ADPCM audio might be starting on the wrong delta samples. This same cause plagued my early commits for the SRJV repo.

2) it appears that reversing the direction of playback isn't the only thing that happens when either a sample is reversed or pingpong looping is enabled: the amplitude for the source audio data is also inverted in these ROMplers. My guess is that this is because of the nature of ADPCM and their wanting to minimize DC offset risks while also making their samples seem like they loop longer than they actually do for pingpong looping specifically.

mmontag commented 4 months ago

@PythonBlue point 2 at least is correct. While implementing the looping logic for https://github.com/skjelten/emusc, I found that the ping pong loops are sliced at zero-crossing. In order to yield a smooth signal at the boundary, the polarity has to be inverted on the reverse pass.

PythonBlue commented 4 months ago

@PythonBlue point 2 at least is correct. While implementing the looping logic for https://github.com/skjelten/emusc, I found that the ping pong loops are sliced at zero-crossing. In order to yield a smooth signal at the boundary, the polarity has to be inverted on the reverse pass.

Yes, I did notice that aspect to the pingpong looping specifically, myself, during my ROM creation experiments. That said, so far, I only noticed the problem with one-shot reversed samples, including but not limited to the preset @giulioz displayed in his second image (another being a reversed tone from "Blade Runner" from SR-JV80-01), though as much as I hate to say it, it might be there for some pingpong samples as well.

kode54 commented 4 months ago

Since samples are deltas, and added when going forward, shouldn’t they be instead subtracted when going backwards?