Great. I'm seeing a little simplification ktr_filtered = ktr_accum instead of ktr_filtered = (ktr_accum > 0 ? 1 : 0) My head was around an unitary trigger. There are some variations of the prior solution but I don't see differences in the performance. Feel free to use what you want ... itr_delay = 0.015 ; 15 msec icycles_limit = itr_delay * kr kcycles init 0 k_have_trigger init 0 ktr_filtered init 0 if (kcycles > icycles_limit) then ktr_filtered = k_have_trigger k_have_trigger = 0 kcycles = 0 else if (k_have_trigger == 0 && ktr != 0) then k_have_trigger = 1 endif /* * another possibility is * * k_have_trigger = k_have_trigger | ktr * * however there are only details */ kcycles = kcycles + 1 endif ... tito On Fri, Aug 03, 2012 at 01:20:23AM -0400, William Wignall wrote: > Tito- > > This works beautifully. I can't thank you enough! This issue had been > bothering me for quite some time and I'm sure that I would not have been > able to come up with it on my own for a few weeks or months. > > Trev > > On Thu, Aug 2, 2012 at 6:17 AM, Tito Latini wrote: > > > In the follow change I use an accumulator for the triggers (ktr). > > If the value of the accumulator is positive after ~ 15 msec (quantized > > with kr), the trigger for midion2 (ktr_filtered) is 1 otherwise it is 0. > > It avoids multiple triggers within 15 msec (you can change this limit). > > > > The `reinit/rireturn' code is useless in this case and it is to remove. > > > > ... > > itr_delay = 0.015 > > icycles_limit = itr_delay * kr > > kcycles init 0 > > ktr_accum init 0 > > ktr_filtered init 0 > > > > if (kcycles > icycles_limit) then > > ktr_filtered = (ktr_accum > 0 ? 1 : 0) > > ktr_accum = 0 > > kcycles = 0 > > else > > ktr_accum = ktr_accum + ktr > > kcycles = kcycles + 1 > > endif > > > > /* MIDI Out */ > > > > kchn = 1 > > > > ;; knum is -35 when kpch is zero > > if knum > 0 then > > midion2 kchn, knum, kvel1, ktr_filtered > > ktr_filtered = 0 > > endif > > ... > > > > tito