Closed tresf closed 6 years ago
Changed bug to running-list of built-in presets. ufo2
and Arpeggio9
are two that immediately kill LMMS sound playback on MacOS.
Edit: Got a backtrace, I think.
I think the relevant part in the backtrace is... LocalZynAddSubFx::processAudio(float (*) [2]) + 99 (LocalZynAddSubFx.cpp:270)
I can confirm that putting a nan
guard will prevent the cut-out but then the offending presets won't play, so there's an underlying bug...
Some unit tests:
Code to circumvent the audio cut-out:
plugins/zynaddsubfx/LocalZynAddSubFx.cpp
void LocalZynAddSubFx::processAudio( sampleFrame * _out )
{
float outputl[synth->buffersize];
float outputr[synth->buffersize];
m_master->GetAudioOutSamples( synth->buffersize, synth->samplerate, outputl, outputr );
+ for (int i = 0; i < synth->buffersize; ++i ) {
+ if (nan(outputl[i])) outputl[i] = 0;
+ if (nan(outputr[i])) outputr[i] = 0;
+ }
// TODO: move to MixHelpers
for( int f = 0; f < synth->buffersize; ++f )
{
_out[f][0] = outputl[f];
_out[f][1] = outputr[f];
}
}
But it gets stranger... turns out Arpeggio 9.xiz
has HARMONIC "mag" value=".." less than 64. If it's 64, it plays. If it's 63, it throws nans.
This isn't true for all presets either.
I guess it is related to undefined behavior of std::polar
for negative absolute value.
Related: https://github.com/zynaddsubfx/zynaddsubfx/commit/417d49b90514b263339fca723882c58e0942cc7a
Note that Zyn >= 2.5
doesn't have such issues, if my guess is correct.
Detailed explanation... mag < 64
means negative amplitude.
https://github.com/LMMS/lmms/blob/b4e78065e7fe043b2e423f81340d2b3b5fbc7e5a/plugins/zynaddsubfx/zynaddsubfx/src/Synth/OscilGen.cpp#L607-L608
In such cases, Zyn passes negative number for the first parameter of std::polar
. It will lead to undefined behavior.
https://github.com/LMMS/lmms/blob/b4e78065e7fe043b2e423f81340d2b3b5fbc7e5a/plugins/zynaddsubfx/zynaddsubfx/src/Synth/OscilGen.cpp#L632-L634
So I guess this is a issue with runtime library rather than Qt.
Edit: This is a running list of built-in presets that cause audio-cut out on MacOS and eventually find out why it happens.
presets/ZynAddSubFX/the_mysterious_bank_2/0037-ufo2.xiz
presets/ZynAddSubFX/Arpeggios/0009-Arpeggio9.xiz