hello everyone, longtime lurker here… but i’ve done something that may be useful to someone so thought i’d do my first post:
it is a gen patch for doing midi to cv (eg with an expert sleepers IO). what (i think) is novel about it is that it works whilst playing sequences or undergoing deep or fast FM. so, if you’re very clumsy like me and scared of knocking the tuning knob mid-song I hope this can reduce your stage anxiety!
patch is here:
http://jamesholden.org/downloads/selftuner_fm.zip
and a demo video here:
https://www.instagram.com/p/B2PaXMOA6hy/
it works by running a virtual oscillator off the same note/fm as its sending to the real one (having compensated for output/input latency) then treating it like a race between the two - if the real one ‘laps’ the fake one then it adjusts the output voltage. that’s about it! it filters both so that it can use basic zero crossing detection to keep track of them (so as a result works best with simple waveforms, and will break with really wacky waves)
i think i’ve got this to the point where it’s sufficient for my own use, so i’m handing it over to the world now! if you want to adapt this to other platforms go ahead feel free (as long as it’s non commercial) there’s certainly room to make the code more efficient too (but it’s pretty light tbh)
there are some notes in the patch and i tried to document the gen code to explain what goes on as best i can, will follow this thread if people have questions. the most important thing is it needs an absolutely spot on round trip latency value for your particular driver/interface setup or it becomes chaotic.
if anyone with a better grasp of engineering than me can help: in terms of this being a PI closed loop control scheme, is the adjustment to ‘offset’ the integral term? could it be more stable if it did that bit slower? would smoothing the ‘errorvalue’ make it more stable? would that even allow introduction of a ‘D’ term?
thanks to leafcutter john for helpful chat and testing
(and since i’m writing, my sincere thanks to the people on this forum for creating such a pleasant and inspiring space to think about music making)
james