<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Thanks. Do you have any resources to point to that I could look up about software PLLs? All the stuff I've seen seems to assume it's a hardware solution. While some of that is clearly transferable, something that had software in mind would help a lot.<div class=""><br class=""></div><div class="">Tom</div><div class=""><br class=""><div class="">
<div>==================<br class="">       Electric Druid<br class="">Synth & Stompbox DIY<br class="">==================</div><div class=""><br class=""></div><br class="Apple-interchange-newline">

</div>
<div><br class=""><blockquote type="cite" class=""><div class="">On 8 Mar 2024, at 16:52, DIY DSP <<a href="mailto:diydsp@yahoo.com" class="">diydsp@yahoo.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><div class="ydpbad9314cyahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><div class=""><div class=""><br class=""></div><div dir="ltr" data-setdir="false" class="">I've done this the "easy" way with a software PLL, and the hard way with a Kalman filter.  </div><div dir="ltr" data-setdir="false" class="">Technically what you need depends on the noise/error profile of the source clock.</div><div dir="ltr" data-setdir="false" class="">But start with the software PLL.. On every 4th input clock, use the error to update the phase and period of the output clock.</div><div dir="ltr" data-setdir="false" class="">For this application, since the signals will converge very quickly relative to how often they chance, I recommend using only the P term from the PID to compute the error and reset the phase of the output clock on the spot to the input clock.<br class=""></div><div dir="ltr" data-setdir="false" class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="ydpbad9314csignature"><div dir="ltr" style="font-family:Helvetica, Arial, sans-serif;font-size:16px;" class="">Noah Vawter's futuristic electronic music instrument lab: <a href="https://youtube.com/diydsp" rel="nofollow" target="_blank" class="">youtube.com/diydsp</a></div></div></div>
        <div class=""><br class=""></div><div class=""><br class=""></div>
        
        </div><div id="yahoo_quoted_0121750334" class="yahoo_quoted">
            <div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;" class="">
                
                <div class="">
                    On Friday, March 8, 2024 at 10:20:30 AM EST, Tom Wiltshire <<a href="mailto:tom@electricdruid.net" class="">tom@electricdruid.net</a>> wrote:
                </div>
                <div class=""><br class=""></div>
                <div class=""><br class=""></div>
                <div class=""><div dir="ltr" class="">Hi All,<br class=""></div><div dir="ltr" class=""><br class=""></div><div dir="ltr" class="">Has anyone got any experience dealing with writing software to sync to MIDI clock that they can share?<br class=""></div><div dir="ltr" class=""><br class=""></div><div dir="ltr" class="">I'm working on a drum sequencer which will run at 96PPQN, and it'd be nice if it could sync to incoming 24PPQN MIDI Clock messages.<br class=""></div><div dir="ltr" class=""><br class=""></div><div dir="ltr" class="">I can see a couple of ways to do this:<br class=""></div><div dir="ltr" class=""><br class=""></div><div dir="ltr" class="">1) Some sort of PID controller, where we compare the internal timing and the incoming clock timing and derive some error signals.<br class=""></div><div dir="ltr" class="">2) IIR filtering. We measure the time between incoming clocks and then use an IIR filter to provide some averaging and smoothing. We then set the internal clock based on the filter's output.<br class=""></div><div dir="ltr" class=""><br class=""></div><div dir="ltr" class="">(2) seems like the simpler approach. Clearly it will introduce some lag when changing tempo, but I'm not sure I see this as a fault - smooth tempo changes could be a feature. And depending on how much filtering is required, that lag might actually be quite short. What's a reasonable time constant for such a thing?<br class=""></div><div dir="ltr" class=""><br class=""></div><div dir="ltr" class="">How has this been approached in the past? I know that I'm not the first person to do this, so I'm just trying to avoid re-inventing the stone-age MIDI wheel!<br class=""></div><div dir="ltr" class=""><br class=""></div><div dir="ltr" class="">Many thanks for any ideas/pointers offered,<br class=""></div><div dir="ltr" class="">Tom<br class=""></div><div dir="ltr" class=""><br class=""></div><div dir="ltr" class="">==================<br class=""></div><div dir="ltr" class="">       Electric Druid<br class=""></div><div dir="ltr" class="">Synth & Stompbox DIY<br class=""></div><div dir="ltr" class="">==================<br class=""></div><div dir="ltr" class=""><br class=""></div><div dir="ltr" class=""><br class=""></div><div dir="ltr" class=""><br class=""></div><div dir="ltr" class=""><br class=""></div><div dir="ltr" class="">________________________________________________________<br class=""></div><div dir="ltr" class="">This is the Synth-diy mailing list<br class=""></div><div dir="ltr" class="">Submit email to: <a ymailto="mailto:Synth-diy@synth-diy.org" href="mailto:Synth-diy@synth-diy.org" class="">Synth-diy@synth-diy.org</a><br class=""></div><div dir="ltr" class="">View archive at: <a href="https://synth-diy.org/pipermail/synth-diy/" target="_blank" class="">https://synth-diy.org/pipermail/synth-diy/</a><br class=""></div><div dir="ltr" class="">Check your settings at: <a href="https://synth-diy.org/mailman/listinfo/synth-diy" target="_blank" class="">https://synth-diy.org/mailman/listinfo/synth-diy</a><br class=""></div><div dir="ltr" class="">Selling or trading? Use <a ymailto="mailto:marketplace@synth-diy.org" href="mailto:marketplace@synth-diy.org" class="">marketplace@synth-diy.org</a><br class=""></div></div>
            </div>
        </div></div></div></blockquote></div><br class=""></div></body></html>