zyn-fusion-issues
zyn-fusion-issues copied to clipboard
Presets using pad can load incorrectly
I'm on Linux Librazik 2 (derived from Debian 9) and using the zynnaddsub 3.0.5 from Librazik repository.
Sometimes, a preset using PAD sound different across it load, it's like if some parameters are randomized. This phenomenon is also noticeable visually, the full oscillator waveform in the PAD view can look different different across the preset load. Change and restore an oscillator parameter seems to restore waveform to what it should be.
Instructions to highlight the issue: first method (earing):
- step 1 : load the preset "MALLETS" (bank OLIVIERS-100)
- step 2 : play a note repeat several time step 1 and step 2, you should sometime ear a different sound.
second method (seeing):
- step 1: load the preset "MALLETS" (bank OLIVIERS-100)
- step 2: go to the PAD view, if you get this, the preset is correctly loaded, restart to step 1.
otherwise, the preset isn't correctly loaded.Then, if you disable and enable again "PRE/POST", you should see same image above (click on "APPLY" button on the top right to ear the change)
Confirmed data race in the parallel padsynth wavetable generation routine.
General backtrace when the problem is replicated:
- https://github.com/zynaddsubfx/zynaddsubfx/blob/master/src/Params/PADnoteParameters.cpp#L983
- https://github.com/zynaddsubfx/zynaddsubfx/blob/master/src/Params/PADnoteParameters.cpp#L923
- https://github.com/zynaddsubfx/zynaddsubfx/blob/master/src/Params/PADnoteParameters.cpp#L714
- https://github.com/zynaddsubfx/zynaddsubfx/blob/master/src/Synth/OscilGen.cpp#L1044
- https://github.com/zynaddsubfx/zynaddsubfx/blob/master/src/Synth/OscilGen.cpp#L825
Notably two threads reach OscilGen.cpp:825 at the same time which causes all sorts of minor conflicts due to buffer reuse. I don't think that the code can crash in this way, but it certainly can get numerically wrong results.
To resolve this issue a call to the PadSynthParameter's OscillGen prepare method should likely be added to https://github.com/zynaddsubfx/zynaddsubfx/blob/master/src/Params/PADnoteParameters.cpp#L973 (perhaps an if(oscil.needPrepar()) oscil.prepare()). Then all calls to get() will fail the needPrepare test resulting in the expected spectrum.
Good catch identifying this bug.
Since this issue has a documented fix (which ought to work) I'll mark it as something that a newcomer can commit and verify if someone is interested. Otherwise when it comes to the next release it should be integrated.