I rewrote the main loop of this a few years ago to be re-entrant, so you can render N samples at a time. Synth projects wanting to use SAM should start somewhere like that probably.
https://github.com/boourns/SAM
I then ported it to Mutable Instruments Braids, a eurorack module: