Closed qiemem closed 2 years ago
A quick overview of the code looks good, and I trust you know what you're doing more than I do for this kind of thing! Also sounds like it's been fairly battle tested, so I've changed this PR to merge into the 1.3 branch for further testing.
The braids_quantizer works by precomputing an
int16_t[128]
codebook to quickly perform quantized note lookups via binary search. The modified quantizer in this PR removes the codebook, instead computing the quantizer values on the fly. This works by determining which "octave" the note should be at (er... pitch moduloscale.span
, which is usually an octave, but not always), doing the relative lookup innotes_
, and then transposing by the "octave". This is nearly as fast as the original braids quantizer (around 5% slower IIRC when benchmarked on my laptop; I've never had any problems with it in practice, even at audio rate), but uses much less memory. On the production branch, this reduces overall statically allocated dynamic memory to 84%, and on BSS1.3, to 87%, removing the warning about memory usage.Another advantage of this is that it can be reconfigured on the fly, whereas the original braids quantizer was a bit too slow (at least, on o_C). This opens up some new applications and is actually why I originally wrote it.
I've used it in my personal Hemisphere fork for about 6 months, and it fully supports the extra functionality required by TB-3PO, etc.
I also use this quantizer in my Stages firmware, and you can find unit tests there ensuring identical behavior with the original quantizer, including with respect to hysteresis: https://github.com/qiemem/eurorack/blob/4a073be8069c0cf54b2d6f58da00d192a5f3ffe0/stages/test/stages_test.cc#L308-L340