The long-awaited update for libllsm is finally ready. libllsm2, successor to the speech processing library powering Moresampler and Synthesizer V (WIP) is now available on Github.

While there isn't much change to the model and algorithm, the new version is more of a clean-up and rewriting with a focus on the usability in host applications. In particular, I have been long aware that the separated storage of layer 0 and layer 1 parameters in libllsm is an extremely clumsy design when access to both layers is desired. This problem is addressed in libllsm2 by storing all frame-level parameters in a dynamic array structure named llsm_container, which can hold an arbitrary number of arbitrary objects. llsm_container frames are further wrapped in a llsm_chunk, the equivalent of a llsm_model in the legacy version.

The libllsm test (analysis -> layer 0 -> layer 1 -> layer 0 -> synthesis) now looks like this in libllsm2,

llsm_aoptions* opt_a = llsm_create_aoptions();
opt_a -> thop = (FP_TYPE)nhop / fs;
llsm_soptions* opt_s = llsm_create_soptions(fs);
llsm_chunk* chunk = llsm_analyze(opt_a, x, nx, fs, f0, nfrm, NULL);

llsm_output* out0 = llsm_synthesize(opt_s, chunk);

llsm_chunk_tolayer1(chunk, 2048);

llsm_output* out1 = llsm_synthesize(opt_s, chunk);

A major addition to the library is the capability of real-time synthesis, defined separately in llsmrt.h. The minimalist API design is inspired by Dr. Masanori Morise's World vocoder. The results from real-time synthesis are identical to the non real-time version but at a slight performance disadvantage (about 15% slower).

Another useful feature is Chrip-Z Transform (CZT) based harmonic analysis and synthesis. CZT is an extension of DFT that allows sampling at non-integer time/frequency indices. The use of CZT in harmonic analysis can be thought of as taking the exact phasor from the DTFT of windowed signals, instead of approximately interpolating the magnitude and phase across the nearest-neighboring bins as in the peak-picking method. Compared to peak-picking, CZT achieves a higher accuracy close to that of least-squares estimation (Stylianou, 1993). In fact, it can be shown that CZT at integer multiples of the fundamental frequency is a main-lobe-only approximation of a least-squares estimation of complex harmonic coefficients.

For the synthesis of harmonic signals, CZT reduces the time-complexity from quadratic to log-linear, making it even faster than Ciglet's recurrent sinusoid generator when there are more than ~30 harmonics. On my i7-7500U equipped laptop, libllsm2 compiled with gcc's -Ofast option achieves a synthesis speed of 60x real-time.