Commit e3fc87c
Use a length-adaptive linear crossfade to hide Slip corrections
Replace the fixed 8-frame smootherstep crossfade with a linear ramp
whose length adapts to the chunk size, up to 128 frames.
Listening tests on sustained pure tones (the worst case) showed the slip
artefact is governed by the peak retiming rate of the crossfade: its
spectral spread scales with 1/length, so a longer fade keeps the
disturbance narrow and masked by the signal. Any velocity shaping that
peaks (smootherstep is 1.875x steeper in the middle than its average) or
concentrates the retiming (end-loaded curves, a hard cut) only widens
it. A linear ramp is the minimum-peak and minimum-energy monotonic fade,
so the old 8-frame smootherstep was in practice barely better than a
hard cut.
- Drop the FADE compile-time table; compute the linear weight inline.
- Replace the CROSSFADE_LEN constant with MAX_CROSSFADE_LEN (128) plus
crossfade_len_for(chunk), stored per instance and recomputed on
resize/reset. Large chunks get the full 128-frame fade; small chunks
shrink it instead of being rejected, lowering the minimum chunk size
from 18 to 4.
- Update the docs to match, and adjust tests for the narrower sustainable
ratio range at the longer fade.
Also add examples/gen_test_tones.py, the stepped-tone generator used to
audition the crossfade.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent e912257 commit e3fc87c
2 files changed
Lines changed: 186 additions & 69 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
0 commit comments