<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">Post some code. :)</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">In both [line~] and [vline~] I believe the increment is calculated, set, and unset set once per event, since all the info you need for the ramp is given by the event definition. Unsetting it is the fun part -- it doesn't unset once it's reached its target, but rather once the number of blocks or samples has passed. Check out these lines of code, though:</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">from [line~]:</div><div class="gmail_default" style="font-family:verdana,sans-serif"><div class="gmail_default">    if (x->x_ticksleft)</div><div class="gmail_default">    {</div><div class="gmail_default">        t_sample f = x->x_value;</div><div class="gmail_default">        while (n--) *out++ = f, f += x->x_inc;</div><div class="gmail_default">        x->x_value += x->x_biginc;</div><div class="gmail_default">        x->x_ticksleft--;</div><div class="gmail_default">    }</div><div class="gmail_default">    else</div><div class="gmail_default">    {</div><div class="gmail_default">        t_sample g = x->x_value = x->x_target;</div><div class="gmail_default">        while (n--)</div><div class="gmail_default">            *out++ = g;</div><div class="gmail_default">    }</div></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">from [vline~]:</div><div class="gmail_default" style="font-family:verdana,sans-serif"><div class="gmail_default">        if (x->x_targettime <= timenext)</div><div class="gmail_default">            f = x->x_target, inc = x->x_inc = 0, x->x_targettime = 1e20;</div><div class="gmail_default">        *out++ = f;</div><div class="gmail_default">        f = f + inc;</div><div class="gmail_default"><br></div><div class="gmail_default"><br></div><div class="gmail_default">In [line~]: if there are still blocks to ramp over, get the value set from the last block, increment all the samples in the new block by the increment, store what will be the value for the next block, and decrement the number of blocks left. If there are no blocks left, then manually set a variable and the next block value to the target, and write that to all the points in the block.</div><div class="gmail_default"><br></div><div class="gmail_default">In [vline~]: if the target time has elapsed, set the variable f to the target, the increment to zero, and put the next target time WAY off in the future. Then continue to increment successive values in the block by 0. Since it's checking every sample here instead of every block, a conditional here would be more expensive than just adding 0 every time.</div><div class="gmail_default"><br></div><div class="gmail_default">Anyway, manually setting the output value to the target at the end of the ramp ensures that you'll make your target. That way you don't have to worry about trying to time exactly when to unset the increment right when it's finally incremented to the target, which is a great way to get an off-by-one error.</div><div class="gmail_default"><br></div><div class="gmail_default">Matt</div></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 2, 2015 at 11:36 AM, i go bananas <span dir="ltr"><<a href="mailto:hard.off@gmail.com" target="_blank">hard.off@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, me again.  <div><br></div><div>Thanks for the discussion.  It has really opened my eyes.  </div><div><br></div><div>So, i got my naive c++ implementation of line~ basically working.  </div><div><br></div><div>And of course, just running a for loop incrementing by ticks, i run into the exact precision error that this block quantizing seems to avoid.  My line from 0 to 100 over 44100 samples only gets to 99.93   </div><div><br></div><div>So, i also need to add something like pd's block quantization to make sure my line goes all the way to the specified value.  </div><div><br></div><div>My questions then are 2:  </div><div><br></div><div>Is pd's method the way i should do it?  Or is there a better alternative?  </div><div><br></div><div>And, if i do it the pd way, how does that work?  Does the increment get updated every block?   Or is it just the last block that is stretched?  </div>
<br>_______________________________________________<br>
<a href="mailto:Pd-list@lists.iem.at">Pd-list@lists.iem.at</a> mailing list<br>
UNSUBSCRIBE and account-management -> <a href="http://lists.puredata.info/listinfo/pd-list" rel="noreferrer" target="_blank">http://lists.puredata.info/listinfo/pd-list</a><br>
<br></blockquote></div><br></div></div>