<?xml version="1.0" encoding="UTF-8"?>
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"

			>

	<channel>
		<title>Cycling 74  &#187;  Topic: ITM and time objects</title>
		<atom:link href="http://cycling74.com/forums/topic/itm-and-time-objects/feed" rel="self" type="application/rss+xml" />
		<link>http://cycling74.com/forums/topic/itm-and-time-objects/feed</link>
		<description></description>
		<pubDate>Tue, 18 Jun 2013 18:11:04 +0000</pubDate>
		<generator>http://bbpress.org/?v=2.2.4</generator>
		<language></language>

		
														
					
				<item>
					<guid>http://cycling74.com/forums/topic/itm-and-time-objects/#post-54917</guid>
					<title><![CDATA[ITM and time objects]]></title>
					<link>http://cycling74.com/forums/topic/itm-and-time-objects/#post-54917</link>
					<pubDate>Sat, 12 Feb 2011 13:05:09 +0000</pubDate>
					<dc:creator>Luigi Castelli</dc:creator>

					<description>
						<![CDATA[
						<p>Hi there,</p>
<p>I would like to implement some ITM functionality in one of my objects.<br />
To start off, I&#8217;d like to implement some basic features similar to what speedlim does.</p>
<p>So, I would like to have 3 attributes:<br />
1 &#8211; &#8216;threshold&#8217;: to set a time threshold between which messages can be passed.<br />
2 &#8211; &#8216;quantize&#8217;: to be able to quantize incoming messages to a transport<br />
3 &#8211; &#8216;defer&#8217;: to put messages in the low-priority queue.</p>
<p>So far I have something like:</p>
<p>In main:</p>
<pre><code>//...
class_time_addattr(c,      "threshold",   "Time Threshold", TIME_FLAGS_USECLOCK | TIME_FLAGS_POSITIVE);
CLASS_ATTR_DEFAULT_SAVE(c, "threshold",   ATTR_FLAGS_NONE, "0.0");

class_time_addattr(c,      "quantize",     "Time Quantization", TIME_FLAGS_TICKSONLY | TIME_FLAGS_POSITIVE);
CLASS_ATTR_DEFAULT_SAVE(c, "quantize",    ATTR_FLAGS_NONE, "0.0");

CLASS_ATTR_CHAR(c,         "defer",       ATTR_FLAGS_NONE, t_myobj, defer);
CLASS_ATTR_STYLE_LABEL(c,  "defer",       ATTR_FLAGS_NONE, "onoff", "Defer Output To Low-Priority Queue");
CLASS_ATTR_DEFAULT_SAVE(c, "defer",       ATTR_FLAGS_NONE, "0");
//...</code></pre><p>In myobject_new():</p>
<pre><code>// ...
x->threshold = (t_timeobject *)time_new((t_object *)x, gensym("threshold"), (method)myobj_timefn, TIME_FLAGS_USECLOCK | TIME_FLAGS_POSITIVE);
x->quantize = (t_timeobject *)time_new((t_object *)x, gensym("quantize"), NULL, TIME_FLAGS_TICKSONLY | TIME_FLAGS_POSITIVE);
// ...</code></pre><p>then:</p>
<pre><code>void myobj_timefn(t_myobj *x)
{
    // ...
    if (x->something) {
        myobj_output(x);
    }
}</code></pre><p>and finally:</p>
<pre><code>void myobj_free(t_myobj *x)
{
    object_free(x->threshold);
    object_free(x->quantize);
}</code></pre><p>The above code works well.</p>
<p>My doubts come when implementing the option to defer messages to low-priority.<br />
I see that the ITM API does have a TIME_FLAGS_USEQELEM flag to do just that.</p>
<p>What&#8217;s the right strategy to go about it?<br />
1 &#8211; Should I create two different timeobject, one with the TIME_FLAGS_USEQELEM flag already set and the other without it, then switch between the two?<br />
2 &#8211; If there is a way to toggle the flag after the timeobject has been created, could I just do that? (it seems that would be the best option)<br />
3 &#8211; Or should I just call defer_low() in my time function in the usual way ?</p>
<p>For example:</p>
<pre><code>void myobj_timefn(t_myobj *x)
{
// ...
    if (x->something) {
        if (x->defer) {
            defer_low(x, (method)myobj_output, NULL, 0, NULL);
        } else {
            myobj_output(x);
        }
    }
}</code></pre><p>How is it done in speelim ?</p>
<p>Waiting for enlightment&#8230;</p>
<p>Thank you.</p>
<p>- Luigi</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

