Repository navigation
Bug fixes and performance improvements - #135
Merged
Merged
Conversation
…SmoothValue helper Fixes found during a LibSource review, each with regression tests. All changes are backward compatible: no well-behaved existing patch changes output. - TapTempo::clock(): cap trig at max_limit, not min_limit. The min/max refactor (67339bd) left the single-sample clock() capping at min_limit, so trig could never reach the (min_limit, max_limit) window trigger() requires -- per-sample tap tempo never updated. Patches using clock(steps) or the setters were unaffected. Regression test: TapTempoTestPatch 'single sample clock'. - WavetableOscillator / AntialiasedWavetableOscillator: restore the table index clamp. phase == 1.0 (e.g. setPhase(2*pi)) or negative phase from negative FM produced an out-of-bounds read; clamp to [0, size-1]. No-op for in-range phase, so identical output for normal use. Regression test: WavetableOscillatorTestPatch. - OscillatorTemplate::generate(fm): wrap phase at the lower bound too, so negative FM keeps phase in [begin, end). Bit-identical for fm >= 0 (branch never taken) and latency-free (sample read before the phase update, single else-if). - CircularBuffer::moveReadHead(): fix the inverted underflow assertion (getReadCapacity() >= samples), matching moveWriteHead. FLOW_ASSERT is a no-op unless defined, so no runtime change in shipped patches. - SmoothValue::normalForSampleRate(): new, purely additive helper to rescale a smoothing coefficient between sample rates (lambda^(from/to)); the existing normal(lambda, blocksize) is unchanged. Covered in SmoothValueTestPatch.
… order - WavetableOscillator.h: include InterpolatingCircularBuffer.h directly. It uses InterpolationMethod and InterpolatingCircularFloatBuffer but previously relied on include order (via OpenWareLibrary.h). Now it compiles standalone, so the test no longer needs a workaround include. - DcBlockingFilter: reorder the constructor init list to x1, y1, R to match the member declaration order, silencing -Wreorder. No behavioural change (the members are independent).
The web build's setSystemTables did nothing, so fast_powf, fast_expf, fast_logf and the rest of basicmaths.c read a null table of precision 0. The Faust architecture maps pow, exp and log to them (faustmath.h), so every Faust web build computed them wrongly (ufo's LFO phase came out in quarter steps, owl-gen-patches issue 524a5a0e). Filled at the firmware's precisions (OpenWare FastPowTable.h 11, FastLogTable.h 14), so the web build computes as the device does. Loop-Session: cycle8-worker1-l2u90mzn
…ltin_* where the FPU has directed rounding Patches are compiled with -fno-builtin, so Faust's fast_floorf() etc. stayed newlib calls (20..30 instructions plus the call) where the Cortex-M7 (FPv5, OWL3) has single instructions (vrintm, vrintp, vrintr, vrinta, vsqrt). Measured on a Genius (v22.4.0, block 128): aether-particle 51..59% to 44..53%, volt-drama 25% to 23%, pulsar-synth 6..7% to 5..6%. Guarded by __ARM_FEATURE_DIRECTED_ROUNDING or a double-precision FPU (__ARM_FP & 8, FPv5): the Cortex-M4 (FPv4, OWL1/OWL2) keeps the library calls. Only Faust patches change. Loop-Session: cycle19-worker2-vitacbci
-fno-builtin stopped GCC expanding fminf, fmaxf, floorf, sqrtf and similar to single FPU instructions (vminnm, vmaxnm, vrintm, vsqrt on the Cortex-M7), leaving calls into newlib, and -mtune=cortex-m4 overrode the tuning that -mcpu already selects for each platform. Measured on the Genius (OWL3): Heavy patches use 25-70 % less CPU (Granular_Delay 15 -> 5 %, Wavefolder 12 -> 3 %, Lich_Margot_Chorus 15 -> 7 %), some C++ and Faust patches a little less, the rest are unchanged. 120 C++, Faust, Gen, Heavy, DaisySP and Maximilian patches build the same for OWL2 and OWL3 with and without the change, and the recorded output of the 25 patches run on the Genius is unchanged.
…r AdsrEnvelope Members copied to locals for the loop and written back after it: the output stores could otherwise alias the float members, which were then loaded and stored every sample. StateVariableFilter, SmoothingFilter, DcBlockingFilter, EnvelopeFollower, Sine / AntialiasedRamp / AntialiasedSquareWave / Vosim oscillators, InterpolatingSignalGenerator. AdsrEnvelope gets generate(FloatArray) and process(FloatArray, FloatArray) overrides on a locals copy of the state machine, instead of the base classes' virtual generate() per sample. The per-sample generate() is unchanged. Outputs bit-identical to before (host test). Genius, cycles per block, 16 instances: ADSR -32 / -33%, SVF -23%, smoothing -20%, DC blocker -18%, envelope follower -11%, oscillators -8%. Patches: DualASR -17%, Vosim -9%, SuperSawPad -7%, PolySub / WitchySub -2.5%, others within +-1%.
Without it CMSIS takes its one-sample-per-iteration loops on Cortex-M. Genius, cycles per block: ZoelzerMultiFilter -31%, PolySub -15%, CMSIS benchmark (biquads, vector ops, FFT) -9%, LorenzFM -5%, DubDelay -4%; FFT / spectral patches +0.3 to +3.9% (FFTShift, ChannelVocoder, SpectralFreeze).
Stores through int32_t* may alias the size_t members, so with CMSIS-Core 6 (__SSAT as the __ssat builtin) GCC reloaded channels every sample. Inner loop back to 9 instructions with no load.
Both are 4; no behaviour change.
pingdynasty
force-pushed
the
feature/fixes-performance
branch
from
November 28, 2026 01:34
54d4cb4 to
82b3598
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug fixes and performance improvements held back from #134.
Fixes
clock()capped atmin_limitinstead ofmax_limit, so per-sample tap tempo never updatedsamplesize, notptrsize(both 4, no behaviour change)Performance
-fno-builtinand the fixed-mtune=cortex-m4: fminf, fmaxf, fabsf, sqrtf and friends compile to FPU instructions. Genius (OWL3): Heavy patches 25-70% less CPU.ARM_MATH_LOOPUNROLL: ZoelzerMultiFilter -31%, PolySub -15%, CMSIS benchmark -9% cycles per block; FFT/spectral patches +0.3 to +3.9%.generate()/process(), up to 33% faster than per-sample.channelsevery sample (stores throughint32_t*may alias it); inner loop back to 9 instructions, no load.Verification
make checkpasses (unit tests, including the new TapTempo and WavetableOscillator tests; ARM, web + webtest and native for each test patch)HISTORY.md has an entry for each change, newest first.